/* ==========================================================
   百族谱 H5 · 设计系统
   主色沿用小程序：棕 #8B4513 ／ 纸底 #f6f2ec
   ========================================================== */

:root {
  --brand: #8B4513;
  --brand-dark: #6B3410;
  --brand-soft: #f0e6d6;
  --bg: #f6f2ec;
  --card: #ffffff;
  --text: #33291f;
  --text-2: #6b6157;
  --muted: #9c948a;
  --border: #ece5da;
  --r: 12px;
  --r-lg: 16px;
  --shadow: 0 2px 10px rgba(90, 60, 30, .06);
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; }
body.no-tab { padding-bottom: 16px; }

/* ---------- 顶部 ---------- */
.hero {
  background: transparent; /* 棕色底已废弃：标题直接浮在页面背景上 */
  color: #fff;
  padding: 26px 20px 30px;
  text-align: center;
}
.hero .title { font-size: 26px; font-weight: 500; letter-spacing: 6px; margin: 0 0 8px; }
.hero .poem { font-size: 14px; letter-spacing: 3px; opacity: .82; margin: 0; }
.hero .stats { display: flex; justify-content: center; gap: 34px; margin-top: 20px; }
.hero .stats b { display: block; font-size: 22px; font-weight: 500; line-height: 1.2; }
.hero .stats span { font-size: 12px; opacity: .78; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .back {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
}
.topbar h1 { font-size: 17px; font-weight: 500; margin: 0; }
.topbar .spacer { flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 4px 16px; }
.card h2 { font-size: 15px; font-weight: 500; margin: 0 0 12px; }

.section-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 500; color: var(--text-2);
  margin: 18px 4px 10px;
}
.section-title::before {
  content: ""; width: 3px; height: 13px; border-radius: 2px; background: var(--brand);
}
.section-title .count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12px; }

/* ---------- 按钮 ---------- */
.btn {
  display: block; width: 100%;
  padding: 13px 16px;
  border: none; border-radius: var(--r);
  font-size: 16px; text-align: center;
  background: var(--brand); color: #fff;
  transition: background .15s;
}
.btn:active { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.plain { background: var(--brand-soft); color: var(--brand); }
.btn[disabled] { opacity: .55; }
.btn.sm { width: auto; display: inline-block; padding: 8px 18px; font-size: 14px; }

/* ---------- 输入 ---------- */
.field {
  display: block; width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 15px; color: var(--text);
  background: #fff; outline: none;
}
.field:focus { border-color: var(--brand); }
.searchbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 999px;
}
.searchbar input { flex: 1; border: none; outline: none; font-size: 15px; background: transparent; }
.searchbar svg { flex: 0 0 auto; color: var(--muted); }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 2px 9px;
  border-radius: 6px; font-size: 12px;
  background: var(--brand-soft); color: var(--brand);
}
.tag.gray { background: #f1efea; color: var(--text-2); }
.tag.line { background: transparent; border: 1px solid var(--border); color: var(--muted); }

/* ---------- 头像 ---------- */
.avatar {
  width: 46px; height: 46px; flex: 0 0 auto;
  border-radius: 50%; overflow: hidden;
  background: var(--brand-soft); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 500;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: 14px; }
.avatar.lg { width: 84px; height: 84px; font-size: 32px; }
.avatar.dead { filter: grayscale(1); opacity: .72; }

/* ---------- 列表行 ---------- */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-size: 15px; font-weight: 500; }
.row .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.row .chev { color: #cfc7ba; flex: 0 0 auto; }
.row .trail { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }

.kv { display: flex; gap: 12px; padding: 9px 0; font-size: 14px; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); flex: 0 0 68px; }
.kv .v { flex: 1; word-break: break-all; }

/* ---------- 筛选 ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 14px;
  border-radius: 999px; font-size: 13.5px;
  background: #fff; color: var(--text-2);
  border: 1px solid var(--border);
}
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- 字辈分组 ---------- */
.gen-card { display: flex; align-items: center; gap: 14px; }
.gen-seal {
  width: 46px; height: 46px; flex: 0 0 auto;
  border-radius: 10px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.gen-seal.pale { background: var(--brand-soft); color: var(--brand); }

/* ---------- 相册网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.grid a, .grid figure { margin: 0; }
.grid img, .grid .ph {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 8px; background: var(--brand-soft);
}
.grid .ph { display: flex; align-items: center; justify-content: center; color: var(--brand); font-size: 22px; }
.grid .cap {
  font-size: 11.5px; color: var(--muted);
  margin-top: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

/* ---------- 时间线 ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute; left: -21px; top: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #fff; border: 2px solid var(--brand);
}
.tl-item .date { font-size: 12.5px; color: var(--brand); margin-bottom: 3px; }
.tl-item .ttl { font-size: 15px; font-weight: 500; }
.tl-item .txt { font-size: 14px; color: var(--text-2); margin-top: 3px; white-space: pre-wrap; }

/* ---------- 状态 ---------- */
.empty { text-align: center; padding: 56px 0; color: var(--muted); font-size: 14px; }
.empty .big { font-size: 34px; color: #ded5c6; margin-bottom: 8px; }
.loading { text-align: center; padding: 40px 0; color: var(--muted); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 8px);
  background: rgba(40, 30, 20, .92); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 200; max-width: 78vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255, 255, 255, .97);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; color: var(--muted);
}
.tabbar a.on { color: var(--brand); }
.tabbar svg { width: 21px; height: 21px; display: block; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh; display: flex; flex-direction: column;
  justify-content: center; padding: 32px 24px;
  background: var(--brand);
}
.login-box { background: #fff; border-radius: 20px; padding: 30px 24px; max-width: 400px; width: 100%; margin: 0 auto; }
.login-box .brand-mark {
  width: 62px; height: 62px; margin: 0 auto 14px;
  border-radius: 16px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; letter-spacing: 0;
}
.login-box h1 { font-size: 21px; font-weight: 500; text-align: center; margin: 0 0 4px; letter-spacing: 3px; }
.login-box .poem { text-align: center; font-size: 13px; color: var(--muted); letter-spacing: 2px; margin: 0 0 24px; }
.login-box .hint { font-size: 12.5px; color: var(--muted); margin-top: 12px; text-align: center; line-height: 1.7; }

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}
