/* ===================================================
   家族族谱 · 用户端样式
   设计语言:取"宗谱布面"的墨绿与"印章朱红"为主色,
   纸白背景、加大字号与按钮,照顾中老年用户的可读性与可点击性
   =================================================== */

:root {
    --ink: #1a1a18;
    --ink-secondary: #5c5a52;
    --ink-faint: #8a8779;
    --paper: #ffffff;
    --paper-soft: #faf8f4;
    --brand: #1c3d3a;
    --brand-light: #e8efee;
    --seal: #b23a2e;
    --seal-dark: #8e2e24;
    --seal-light: #f7e9e6;
    --border: #e4e0d6;
    --success: #3b7a3f;
    --success-light: #e7f1e8;
    --danger: #a3342b;
    --danger-light: #f7e9e6;
    --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper-soft);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    font-size: 17px;
    line-height: 1.7;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); text-decoration: none; }

.app {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--paper-soft);
    display: flex;
    flex-direction: column;
}

/* ---------- 顶部栏 ---------- */
.topbar {
    background: var(--brand);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 3px solid var(--seal);
}
.topbar a.back {
    color: #fff;
    font-size: 22px;
    line-height: 1;
    padding: 4px 8px 4px 0;
}
.topbar h1 {
    font-size: 18px;
    font-weight: 500;
    margin: 0;
    flex: 1;
}
.topbar .topbar-action {
    color: #fff;
    font-size: 14px;
    padding: 6px 10px;
    border: 1px solid rgba(255,255,255,.5);
    border-radius: 8px;
}

/* ---------- 主体内容 ---------- */
.content {
    flex: 1;
    padding: 16px 16px 90px;
}

/* ---------- 底部导航 ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: var(--paper);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 6px 0 10px;
    z-index: 20;
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--ink-faint);
    font-size: 12px;
    padding: 6px 0;
    min-height: 48px;
}
.bottom-nav a.active { color: var(--seal); font-weight: 500; }
.bottom-nav .nav-icon { font-size: 22px; line-height: 1; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 14px;
}
.card-accent {
    border-top: 3px solid var(--brand);
    border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- 首页大按钮入口 ---------- */
.entry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}
.entry-btn {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    min-height: 100px;
    justify-content: center;
}
.entry-btn .entry-icon { font-size: 30px; color: var(--brand); }
.entry-btn .entry-label { font-size: 16px; font-weight: 500; }
.entry-btn.help { border-color: var(--seal); }
.entry-btn.help .entry-icon { color: var(--seal); }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 0 20px;
    border-radius: var(--radius);
    font-size: 17px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    width: 100%;
    text-align: center;
}
.btn-primary { background: var(--seal); color: #fff; }
.btn-primary:active { background: var(--seal-dark); }
.btn-outline { background: var(--paper); color: var(--brand); border-color: var(--brand); }
.btn-outline:active { background: var(--brand-light); }
.btn-danger { background: var(--paper); color: var(--danger); border-color: var(--danger); }
.btn-block { display: block; width: 100%; margin-bottom: 10px; }
.btn-sm { min-height: 44px; font-size: 15px; padding: 0 16px; width: auto; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    font-size: 16px;
    color: var(--ink-secondary);
    margin-bottom: 8px;
}
.form-control {
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    font-size: 17px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink);
    font-family: inherit;
}
textarea.form-control { min-height: 100px; resize: vertical; }
.form-hint { font-size: 13px; color: var(--ink-faint); margin-top: 6px; }

.choice-group { display: flex; gap: 10px; flex-wrap: wrap; }
.choice-group label {
    flex: 1;
    min-width: 90px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 8px;
    font-size: 15px;
    color: var(--ink);
    background: var(--paper);
}
.choice-group input[type=radio],
.choice-group input[type=checkbox] { display: none; }
.choice-group input:checked + span,
.choice-group label:has(input:checked) {
    color: var(--seal);
}
.choice-group label:has(input:checked) {
    border-color: var(--seal);
    background: var(--seal-light);
    font-weight: 500;
}

.check-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 6px;
}
.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 8px;
    font-size: 16px;
    border-radius: 8px;
}
.check-row:active { background: var(--paper-soft); }
.check-row input[type=checkbox] {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    accent-color: var(--seal);
}
.relation-note {
    font-size: 13px;
    color: var(--ink-faint);
    background: var(--paper-soft);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    line-height: 1.6;
}

/* ---------- 列表项:成员 / 大事记 ---------- */
.member-item, .timeline-item {
    display: flex;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}
.member-item:last-child, .timeline-item:last-child { border-bottom: none; }

.avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 500;
    flex-shrink: 0;
    overflow: hidden;
    object-fit: cover;
}

.member-name { font-size: 17px; font-weight: 500; }
.member-meta { font-size: 14px; color: var(--ink-secondary); margin-top: 2px; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}
.status-dot.has-account { background: var(--success); }
.status-dot.no-account { background: transparent; border: 1.5px solid var(--ink-faint); }

.tag {
    display: inline-block;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--brand-light);
    color: var(--brand);
    margin-right: 4px;
}
.tag.seal { background: var(--seal-light); color: var(--seal-dark); }

.generation-label {
    font-size: 14px;
    color: var(--ink-faint);
    margin: 22px 0 6px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
}

/* ---------- 提示信息 ---------- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 15px;
}
.flash.success { background: var(--success-light); color: var(--success); }
.flash.error { background: var(--danger-light); color: var(--danger); }

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    color: var(--ink-faint);
    padding: 50px 20px;
    font-size: 15px;
}

/* ---------- 登录/注册页(无底部导航,居中卡片) ---------- */
.auth-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    padding: 30px 24px;
}
.auth-logo {
    text-align: center;
    margin-bottom: 28px;
}
.auth-logo .seal-mark {
    display: inline-flex;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--seal);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 10px;
}
.auth-logo h1 { font-size: 20px; margin: 0; font-weight: 500; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.auth-tabs a {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    color: var(--ink-secondary);
    font-size: 16px;
}
.auth-tabs a.active { color: var(--seal); border-bottom: 2px solid var(--seal); font-weight: 500; }

.section-title {
    font-size: 19px;
    font-weight: 600;
    color: var(--brand);
    margin: 0 0 14px;
    padding-left: 12px;
    border-left: 4px solid var(--seal);
    display: flex;
    align-items: center;
    justify-content: space-between;
    line-height: 1.4;
}

/* 用于把页面划分成几个大区域的标题,比如"本家庭关系"和"关联本家族其他家庭",
   比 .section-title 更高一级,中老年用户能一眼看出这是两块不一样的内容 */
.region-divider {
    font-size: 17px;
    font-weight: 600;
    color: var(--ink);
    background: var(--paper-soft);
    padding: 10px 14px;
    border-radius: var(--radius);
    margin: 20px 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.region-divider:first-child { margin-top: 0; }
.region-divider .region-hint {
    font-size: 13px;
    font-weight: 400;
    color: var(--ink-faint);
}

/* 比 .region-divider 更明显的"点击展开"按钮,带边框和强调色,一看就知道能点 */
.expand-toggle {
    font-size: 16px;
    font-weight: 500;
    color: var(--seal-dark);
    background: var(--seal-light);
    border: 1.5px solid var(--seal);
    padding: 14px 16px;
    border-radius: var(--radius);
    margin: 20px 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
}
.expand-toggle .expand-icon {
    font-size: 20px;
    font-weight: 700;
    color: var(--seal);
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--paper);
}
.section-title a { font-size: 14px; color: var(--seal); font-weight: 400; }

.muted { color: var(--ink-secondary); }
.center { text-align: center; }
.mb-0 { margin-bottom: 0; }

/* ---------- 族谱关系图 ---------- */
.chart-toolbar {
    font-size: 13px;
    color: var(--ink-faint);
    margin-bottom: 8px;
}
.chart-scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--paper);
    margin-bottom: 14px;
}
.chart-canvas {
    position: relative;
    transform-origin: top left;
    transition: transform .2s ease;
}
.chart-canvas.zoomed-out { transform: scale(0.62); }
.chart-svg-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}
.chart-card {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
}
.chart-name {
    font-size: 12px;
    font-weight: 500;
    margin-top: 5px;
    white-space: nowrap;
    max-width: 78px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ink);
}
.chart-relation {
    font-size: 11px;
    color: var(--seal-dark);
    margin-top: 1px;
    white-space: nowrap;
}

/* ============ 日历选择器 ============ */
.ft-dp { position: relative; }
.ft-dp-trigger {
    text-align: left;
    cursor: pointer;
    background: var(--paper);
}
.ft-dp-popup {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    padding: 14px;
    z-index: 50;
    width: 300px;
}
.ft-dp-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}
.ft-dp-head select {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 4px;
    font-size: 14px;
    background: var(--paper-soft);
    color: var(--ink);
}
.ft-dp-arrow {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--paper-soft);
    font-size: 16px;
    color: var(--ink-secondary);
    cursor: pointer;
}
.ft-dp-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 12px;
    color: var(--ink-faint);
    margin-bottom: 4px;
}
.ft-dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.ft-dp-day {
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 4px 0 6px;
    cursor: pointer;
    text-align: center;
    line-height: 1.2;
}
.ft-dp-day:hover { background: var(--paper-soft); }
.ft-dp-num { font-size: 14px; color: var(--ink); }
.ft-dp-lunar { font-size: 10px; color: var(--ink-faint); margin-top: 1px; }
.ft-dp-day.is-today .ft-dp-num { color: var(--seal); font-weight: 600; }
.ft-dp-day.is-selected { background: var(--seal); }
.ft-dp-day.is-selected .ft-dp-num,
.ft-dp-day.is-selected .ft-dp-lunar { color: #fff; }
.ft-dp-footer {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}
.ft-dp-footer a { color: var(--seal); text-decoration: none; }
@media (max-width: 380px) {
    .ft-dp-popup { width: 92vw; left: 50%; transform: translateX(-50%); }
}
