:root {
    --bg: #f6f4ef;
    --paper: #fffdf9;
    --ink: #2c2825;
    --muted: #857f76;
    --line: #e3ddd2;
    --brand: #8a4b2f;
    --brand-soft: #f3e6dd;
    --ok: #2f6b4f;
    --danger: #a33a2f;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.65 "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- 顶栏 ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 700;
    font-size: 17px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--muted); font-size: 12px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user { color: var(--muted); font-size: 13px; }

/* ---------- 布局 ---------- */
.shell {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 20px;
    max-width: 1240px;
    margin: 0 auto;
    padding: 20px;
    align-items: start;
}

.side {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    position: sticky;
    top: 76px;
}
.nav { padding: 9px 12px; border-radius: 8px; color: var(--ink); font-size: 14px; }
.nav:hover { background: #faf5ee; text-decoration: none; }
.nav.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav.off { padding: 8px 12px; color: #b6afa4; font-size: 13px; cursor: default; }
.nav-sep { margin: 12px 4px 4px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 11px; color: var(--muted); letter-spacing: .08em; }

.page { min-width: 0; }
.page-title { font-size: 20px; margin: 0 0 16px; }

.solo { max-width: 420px; margin: 8vh auto 0; padding: 0 20px; }

/* ---------- 卡片 ---------- */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--ink);
    transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--brand); text-decoration: none; transform: translateY(-1px); }
.card.static:hover { border-color: var(--line); transform: none; }
.card small { color: var(--muted); font-size: 12px; }
.card strong { font-size: 26px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.card .muted { font-size: 12px; }

/* ---------- 面板与表格 ---------- */
.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.panel.flush { padding: 0; overflow: hidden; }
.panel-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; margin-bottom: 10px;
}
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 600; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
    text-align: left; font-weight: 500; color: var(--muted);
    font-size: 12px; padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: #fbf8f3;
    white-space: nowrap;
}
.table tbody td { padding: 10px 12px; border-bottom: 1px solid #f0ebe2; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .right { text-align: right; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 18px 4px; margin: 0; text-align: center; }
.total { margin-left: auto; font-size: 13px; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; background: #efeae1; color: #6d665c; }
.tag.live { background: #e6f1ea; color: var(--ok); }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form.inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea {
    font: inherit; color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 11px;
    width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(138, 75, 47, .1);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-size: 14px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: #cfc7ba; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #753f27; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #e5c9c4; }
.btn.danger:hover { background: #fbf0ee; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }

.rowform { display: flex; align-items: center; gap: 8px; }
.rowform input.mini { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; }
.rowform input.num { width: 64px; }

.actions { display: flex; align-items: center; gap: 12px; padding-top: 4px; }

.filter {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 10px 12px; margin-bottom: 12px;
}
.filter input, .filter select {
    font: inherit; font-size: 14px; padding: 8px 10px;
    border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.filter input[type=text] { width: 180px; }

/* ---------- 详情 ---------- */
.profile { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.profile-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.profile-head h2 { margin: 0; font-size: 22px; }
.profile-head h2 small { font-size: 13px; color: var(--muted); font-weight: 400; }
.profile-head p { margin: 4px 0 0; font-size: 13px; }
.profile-actions { display: flex; gap: 8px; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 6px 14px; margin: 16px 0 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.bio { margin-top: 14px; padding: 12px 14px; background: #faf6ef; border-radius: 8px; font-size: 14px; color: #4a443c; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    display: flex; flex-direction: column;
    padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; color: var(--ink); min-width: 96px;
}
.chip:hover { border-color: var(--brand); text-decoration: none; }
.chip small { color: var(--muted); font-size: 11px; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.timeline li { padding-left: 12px; border-left: 2px solid var(--line); }

/* ---------- 其他 ---------- */
.notice { background: #fbf6ef; border: 1px solid #eadfd0; border-radius: 8px; padding: 12px 14px; font-size: 13px; color: #6b5c4a; }
.notice b { display: block; margin-bottom: 4px; }
.notice p { margin: 0; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash.ok { background: #e9f2ec; color: var(--ok); border: 1px solid #cfe2d7; }
.flash.error { background: #fbf0ee; color: var(--danger); border: 1px solid #ecd2cd; }

.pager { display: flex; gap: 6px; justify-content: center; margin: 8px 0 24px; }
.pg { padding: 5px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font-size: 13px; }
.pg.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pg.dots { border: 0; background: transparent; color: var(--muted); }

.login-wrap { display: grid; place-items: center; }
.login-card {
    width: 100%; background: var(--paper); border: 1px solid var(--line);
    border-radius: 14px; padding: 26px 24px;
    box-shadow: 0 10px 30px rgba(70, 50, 30, .06);
}
.login-card h1 { font-size: 20px; margin: 0; }
.login-card .muted { margin: 4px 0 20px; font-size: 13px; }
.login-card .field { margin-bottom: 12px; }
.login-card .foot { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ---------- 通用小件 ---------- */
.badge {
    display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--brand); color: #fff;
    font-size: 11px; line-height: 18px; text-align: center;
}
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; word-break: break-all; color: #6b6358; }
.inline-form { display: inline; }
.inline-form button { margin: 0; }
.link-cell { display: flex; align-items: center; gap: 8px; max-width: 420px; }
.link-cell .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.notice.warn { background: #fdf3ef; border-color: #eed6cd; color: #7c4630; }
.hp { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* ---------- 族人填报端（H5） ---------- */
body.h5 { background: #f4f1ea; }

.h5-top {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 14px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.h5-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.h5-brand .brand-mark { width: 32px; height: 32px; font-size: 15px; }
.h5-brand .brand-text strong { font-size: 14px; }
.h5-brand .brand-text small { font-size: 11px; }
.h5-tag { font-size: 11px; color: var(--brand); background: var(--brand-soft); padding: 3px 9px; border-radius: 20px; white-space: nowrap; }

.h5-main { max-width: 620px; margin: 0 auto; padding: 14px; }

.h5-intro {
    background: var(--brand-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
    color: #6d3c26;
}
.h5-intro p { margin: 0; font-size: 13px; line-height: 1.6; }
.h5-intro p + p { margin-top: 3px; color: #8a6a55; }

.h5-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px 14px;
    margin-bottom: 12px;
    display: flex; flex-direction: column; gap: 12px;
}
.h5-card h2 {
    margin: 0; font-size: 14px; font-weight: 600; color: #4a4038;
    padding-bottom: 8px; border-bottom: 1px solid #f0ebe2;
    letter-spacing: .02em;
}
.h5-card .grid2 { gap: 10px; }
.h5-card .field > span { font-size: 12px; }
.h5-card .field input, .h5-card .field select, .h5-card .field textarea {
    font-size: 16px;   /* 移动端 16px 防 iOS 缩放 */
    padding: 11px 12px;
}
.h5-hint { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.6; }
.h5-hint.center { text-align: center; margin-top: 8px; }

.h5-notice { background: #faf6ef; border: 1px solid #ece2d3; border-radius: 10px; padding: 12px; }
.h5-notice p { margin: 0; font-size: 13px; line-height: 1.75; color: #5c5247; }
.h5-notice p.muted { margin-top: 8px; font-size: 11px; }

.h5-agree {
    display: flex; align-items: flex-start; gap: 9px;
    font-size: 14px; line-height: 1.55; color: #3f3730;
    padding: 10px 12px;
    background: var(--brand-soft); border-radius: 10px;
}
.h5-agree input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--brand); }

.h5-card .btn.block { padding: 12px; font-size: 16px; }

.h5-center { text-align: center; padding: 26px 18px; }
.h5-ok {
    display: inline-block; margin-bottom: 10px;
    padding: 3px 12px; border-radius: 20px;
    background: #e6f1ea; color: var(--ok); font-size: 12px;
}
.h5-stop {
    display: inline-block; margin-bottom: 10px;
    padding: 3px 12px; border-radius: 20px;
    background: #fbf0ee; color: var(--danger); font-size: 12px;
}
.h5-center h2 { font-size: 17px; margin: 0 0 10px; border: 0; padding: 0; }
.h5-center .btn { margin-top: 6px; }

.h5-foot { text-align: center; font-size: 11px; color: #a49c90; padding: 6px 14px 26px; }

.h5-intro h1 { font-size: 19px; margin: 0 0 6px; }
.small { font-size: 11px; }
.h5-links { margin-top: 10px; }

/* ---------- 相册 ---------- */
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 12px; }
.album-item { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.album-item a { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #faf6ef; }
.album-item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #f6efe3; }
.album-item figcaption { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.album-item figcaption b { color: var(--ink); font-size: 13px; font-weight: 500; }
.album-item figcaption small { font-size: 11px; }
.pub-album { margin-top: 16px; }
@media (max-width: 760px) { .album { grid-template-columns: 1fr 1fr; gap: 10px; } }

.h5-sub { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.h5-sub-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.h5-sub h3, .h5-sub p { margin: 0; }

/* ---------- 公开谱站 ---------- */
body.pub { background: #f5f1e8; }

.pub-top {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 22px; background: var(--paper);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 10;
}
.pub-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.pub-brand .brand-mark { width: 42px; height: 42px; font-size: 19px; }
.pub-brand strong { font-size: 17px; }
.pub-brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }

.pub-nav { display: flex; gap: 4px; }
.pub-nav a {
    padding: 7px 13px; border-radius: 20px; font-size: 14px;
    color: var(--ink);
}
.pub-nav a:hover { background: #faf5ee; text-decoration: none; }
.pub-nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.pub-main { max-width: 980px; margin: 0 auto; padding: 24px 22px 10px; }

.pub-hero { padding: 18px 0 8px; }
.pub-hero h1 { font-size: 30px; margin: 0 0 10px; letter-spacing: .04em; }
.pub-lead { color: #5c5347; font-size: 15px; line-height: 1.85; margin: 0 0 18px; max-width: 720px; }

.pub-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pub-stats div {
    background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
    padding: 12px 14px; display: flex; flex-direction: column; gap: 2px;
}
.pub-stats strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.pub-stats span { font-size: 12px; color: var(--muted); }

.pub-notice {
    margin-top: 18px; padding: 14px 16px;
    background: #fbf6ef; border: 1px solid #ead9c4; border-radius: 12px;
    font-size: 14px; color: #6b5540;
}
.pub-notice b { display: block; margin-bottom: 4px; font-size: 13px; letter-spacing: .04em; }
.pub-notice p { margin: 0; line-height: 1.8; }

.pub-block { margin-top: 26px; }
.pub-block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.pub-block h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; }
.pub-block h2::after { content: ''; display: block; width: 26px; height: 2px; background: var(--brand); margin-top: 6px; }
.pub-block-head h2 { margin-bottom: 0; }
.pub-block-head a { font-size: 13px; }

.pub-branches { display: flex; flex-wrap: wrap; gap: 10px; }
.pub-branch {
    display: flex; flex-direction: column; gap: 2px;
    padding: 12px 18px; background: var(--paper);
    border: 1px solid var(--line); border-radius: 12px; color: var(--ink);
}
.pub-branch:hover { border-color: var(--brand); text-decoration: none; }
.pub-branch strong { font-size: 15px; }
.pub-branch small { color: var(--muted); font-size: 12px; }

.pub-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.pub-person {
    display: flex; flex-direction: column; gap: 3px;
    padding: 12px 14px; background: var(--paper);
    border: 1px solid var(--line); border-radius: 12px; color: var(--ink);
}
.pub-person:hover { border-color: var(--brand); text-decoration: none; }
.pub-person strong { font-size: 16px; }
.pub-person small { color: var(--muted); font-size: 12px; }

.pub-toolbar { margin-bottom: 10px; }
.pub-toolbar h1 { font-size: 22px; margin: 0 0 12px; }
.pub-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.pub-filter .chip { padding: 6px 13px; border-radius: 20px; border: 1px solid var(--line); background: var(--paper); font-size: 13px; color: var(--ink); }
.pub-filter .chip:hover { border-color: var(--brand); text-decoration: none; }
.pub-filter .chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.pub-gen { margin-bottom: 22px; }
.pub-gen-title { font-size: 15px; color: var(--brand); margin: 0 0 10px; letter-spacing: .08em; }

.pub-profile { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; }
.pub-profile-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pub-profile-head h1 { font-size: 26px; margin: 0; }
.pub-profile-head small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.pub-back { margin: 18px 0 0; font-size: 14px; }

.pub-join { padding: 16px 18px; background: var(--brand-soft); border-radius: 12px; }
.pub-join h2::after { background: #fff; }
.pub-join p { margin: 0; font-size: 14px; line-height: 1.8; color: #6d3c26; }

.pub-center { text-align: center; padding: 60px 20px; }
.pub-center h1 { font-size: 24px; margin: 0 0 10px; }

.pub-foot {
    max-width: 980px; margin: 30px auto 0; padding: 18px 22px 34px;
    border-top: 1px solid var(--line); text-align: center;
}
.pub-foot p { margin: 0; font-size: 12px; color: #85796a; }
.pub-foot .muted { margin-top: 4px; font-size: 11px; }

@media (max-width: 760px) {
    .pub-top { padding: 10px 14px; flex-direction: column; align-items: flex-start; gap: 8px; }
    .pub-main { padding: 16px 14px 8px; }
    .pub-hero h1 { font-size: 22px; }
    .pub-stats { grid-template-columns: 1fr 1fr; }
    .pub-people { grid-template-columns: 1fr 1fr; }
    .pub-profile { padding: 16px; }
}

@media (max-width: 760px) {
    .shell { grid-template-columns: 1fr; padding: 14px; gap: 14px; }
    .side { position: static; flex-direction: row; flex-wrap: wrap; padding: 8px; }
    .nav { padding: 7px 10px; font-size: 13px; }
    .nav-sep, .nav.off { display: none; }
    .table { font-size: 13px; }
    .table thead { display: none; }
    .table tbody td { display: block; border: 0; padding: 4px 12px; }
    .table tbody tr { display: block; padding: 10px 0; border-bottom: 1px solid #f0ebe2; }
    .table tbody td.right { text-align: left; }
    .grid2, .grid3 { grid-template-columns: 1fr; }
    .form.inline { flex-direction: column; align-items: stretch; }
    .cards { grid-template-columns: 1fr 1fr; }
    .kv { grid-template-columns: 76px 1fr; }
}

/* 谱牒文献正文 */
.pub-article {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 26px 30px;
    font-size: 15px;
    line-height: 2.05;
    letter-spacing: .02em;
    color: var(--ink);
}
.pub-article p { margin: 0 0 1em; }
@media (max-width: 640px) {
    .pub-article { padding: 18px 18px; font-size: 14px; line-height: 1.95; }
}
