:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f9f8f4;
  --ink: #1d2621;
  --ink-2: #44504a;
  --muted: #747d78;
  --line: #e5e1d7;
  --line-2: #d3cec2;
  --accent: #2f6b4f;
  --accent-hover: #285c44;
  --accent-ink: #ffffff;
  --accent-soft: #e4eee7;
  --accent-line: #b8d2c2;
  --danger: #b03a29;
  --danger-soft: #f8e5e1;
  --warn: #8f6210;
  --warn-soft: #f6edd7;
  --shadow: 0 1px 2px rgba(29, 38, 33, .05), 0 4px 14px rgba(29, 38, 33, .05);
  --radius: 14px;
  --topbar-h: 58px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131715;
    --surface: #1b201d;
    --surface-2: #212724;
    --ink: #e7ece9;
    --ink-2: #c1c9c4;
    --muted: #8d9792;
    --line: #2c3430;
    --line-2: #3b4440;
    --accent: #7fc29e;
    --accent-hover: #93cfae;
    --accent-ink: #0d1912;
    --accent-soft: #1e3227;
    --accent-line: #2f5641;
    --danger: #f08b79;
    --danger-soft: #3a211c;
    --warn: #e2b660;
    --warn-soft: #342913;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 56px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
ul, ol { margin: 0; padding-left: 1.3em; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.page-pad { padding-top: 16px; padding-bottom: 32px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- 按钮、标签 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-size: 15px; font-weight: 500; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .chip:focus-visible, .btn-icon:focus-visible, .link-btn:focus-visible, .seg button:focus-visible, .save-state:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-outline { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line-2)); }
.btn-sm { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn-block { display: flex; width: 100%; }
.btn-add { width: 100%; margin-top: 12px; border-style: dashed; color: var(--accent); background: transparent; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font-size: 20px; line-height: 1; text-decoration: none; cursor: pointer; list-style: none;
}
.btn-icon::-webkit-details-marker { display: none; }
.link-btn { background: none; border: 0; padding: 4px 2px; color: var(--accent); font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn.danger { color: var(--danger); text-decoration: none; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }

.badge { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.7; white-space: nowrap; }
.b-pri { background: var(--danger-soft); color: var(--danger); }
.b-watch { background: var(--warn-soft); color: var(--warn); }
.b-normal { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.b-none { color: var(--muted); border: 1px dashed var(--line-2); }
.b-done { background: var(--accent-soft); color: var(--accent); }
.b-draft { color: var(--ink-2); border: 1px solid var(--line-2); }
.tag { display: inline-block; padding: 0 7px; border-radius: 6px; font-size: 12px; font-weight: 500; line-height: 1.8; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag-new { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.tag-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty { padding: 32px 20px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.banner-warn { background: var(--warn-soft); color: var(--warn); }

.bar { position: relative; height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* ---------- 顶栏 ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.tb-inner { display: flex; align-items: center; gap: 10px; min-height: var(--topbar-h); }
.tb-title { flex: 1; min-width: 0; }
.tb-main { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-actions { display: flex; align-items: center; gap: 8px; }
.back { font-size: 26px; border: 0; background: transparent; width: 36px; margin-left: -8px; }

.save-state { background: none; border: 0; padding: 0; font-size: 13px; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.save-state::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); flex: none; }
.save-state.s-ok::before { background: var(--accent); }
.save-state.s-busy::before { background: var(--warn); }
.save-state.s-err { color: var(--danger); }
.save-state.s-err::before { background: var(--danger); }

/* ---------- 菜单 ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
}
.menu-pop a, .menu-pop button { display: flex; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none; color: var(--ink); text-align: left; text-decoration: none; font-size: 15px; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); }
.menu-pop .danger { color: var(--danger); }

/* ---------- 首页 ---------- */
.hero { background: var(--surface); border-bottom: 1px solid var(--line); }
.hero-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding-top: 18px; padding-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo { width: 44px; height: 44px; flex: none; }
.brand h1 { font-size: 20px; line-height: 1.3; }
.brand p { font-size: 13px; color: var(--muted); }
.hero-actions { display: flex; gap: 8px; align-items: center; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 16px 0 12px; }
.stat { display: grid; gap: 0; text-align: left; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.stat:not([data-stat]) { cursor: default; }
.stat b { font-size: 24px; font-weight: 650; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat-pri b { color: var(--danger); }
.stat-watch b { color: var(--warn); }

.toolbar { display: grid; gap: 10px; margin-bottom: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; max-width: 100%; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; font-size: 14px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }
.seg-sm button { padding: 3px 9px; font-size: 13px; }
.in.in-sm { width: auto; min-height: 38px; padding: 6px 10px; font-size: 14px; }

.list-count { font-size: 13px; color: var(--muted); margin: 6px 2px 10px; }
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; padding-bottom: 40px; }
.rec { display: grid; gap: 6px; padding: 14px 16px; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.rec:hover { border-color: var(--accent-line); }
.rec:active { transform: scale(.995); }
.rec-top { display: flex; align-items: center; gap: 6px; }
.rec-date { margin-left: auto; font-size: 13px; color: var(--muted); }
.rec-title { font-size: 17px; font-weight: 600; line-height: 1.4; }
.rec-meta { font-size: 13.5px; color: var(--muted); }
.rec-kids { font-size: 14px; color: var(--ink-2); }
.rec-foot { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.rec-foot .bar { flex: 1; max-width: 120px; }

.trash-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; margin-bottom: 10px; }

/* ---------- 输入项 ---------- */
.in {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px; line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
.in::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.in:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea.in { resize: vertical; line-height: 1.75; min-height: 88px; }
input[type="date"].in, input[type="month"].in { min-width: 0; appearance: none; -webkit-appearance: none; }
.search { min-height: 46px; padding-left: 14px; }

/* ---------- 填写页 ---------- */
.page-edit { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.edit-layout { display: block; }
.secnav {
  position: sticky; top: var(--topbar-h); z-index: 15; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 8px 16px; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.secnav::-webkit-scrollbar { display: none; }
.secnav button {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 14px; color: var(--ink-2); cursor: pointer;
}
.secnav button.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.nav-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-count:empty { display: none; }
.nav-count.done { color: var(--accent); }

.edit-main { display: grid; gap: 14px; padding-top: 14px; min-width: 0; }
.sec { padding: 16px; scroll-margin-top: calc(var(--topbar-h) + 60px); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.sec-head h2 { font-size: 18px; font-weight: 650; }
.sec-count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sec-count.done { color: var(--accent); }

.row { padding: 14px 0; border-top: 1px dashed var(--line); }
.sec > .row:first-of-type, .item > .row:first-of-type { border-top: 0; }
.row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.row-head h3 { font-size: 15px; font-weight: 600; color: var(--ink-2); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.grid-basic { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 10px; }
.f { min-width: 0; }
.f-wide, .f-choice, .f-textarea, .f-list, .f-photos, .f-check { grid-column: 1 / -1; }
.f-label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); margin-bottom: 5px; }
.f-note { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.in-wrap { display: flex; align-items: center; gap: 6px; }
.in-wrap .in { flex: 1; min-width: 0; }
.affix { flex: none; color: var(--muted); font-size: 14px; }
.f-sum .sum-val { min-height: 44px; display: flex; align-items: center; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink-2); font-size: 15px; line-height: 1.3; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s; -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--accent-line); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips[data-multi] .chip[aria-pressed="true"]::before { content: '✓ '; }
.detail { margin-top: 8px; }

.check { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.guide { margin-bottom: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; color: var(--ink-2); }
.guide summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.guide ol { margin: 8px 0 4px; display: grid; gap: 2px; }
.f-textarea .hint { margin-bottom: 8px; }

.repeat .item:first-child { margin-top: 10px; }
.item { margin-top: 12px; padding: 4px 14px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.item-sm { padding: 10px 12px 12px; margin-top: 0; margin-bottom: 10px; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; }
.item-title { font-weight: 600; color: var(--accent); }
.item-name { margin-left: 8px; font-weight: 500; color: var(--ink-2); }
.item .in, .item .chip:not([aria-pressed="true"]) { background: var(--surface); }
.f-list .btn-add { margin-top: 0; }

.photos-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.photos-head .f-label { margin: 0; }
.photos-head .count { font-size: 13px; color: var(--warn); white-space: nowrap; }
.photos-head .count.ok { color: var(--accent); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ph { position: relative; margin: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.ph-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-del { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.ph-up { display: grid; place-items: center; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ph-add {
  position: relative; display: grid; place-content: center; justify-items: center; gap: 2px; aspect-ratio: 1; border-radius: 10px;
  border: 1.5px dashed var(--accent-line); color: var(--accent); font-size: 13px; cursor: pointer; background: transparent;
}
.ph-add .plus { font-size: 26px; line-height: 1; }
.ph-add:hover { background: var(--accent-soft); }

.form { display: grid; gap: 14px; }
.form-end { padding: 4px 4px 12px; font-size: 14px; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: color-mix(in srgb, var(--surface) 95%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bb-inner { display: flex; align-items: center; gap: 10px; min-height: 64px; }
.bb-progress { flex: 1; min-width: 0; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.bb-progress .bar { max-width: 220px; }

/* 录音卡片 */
.audio-card .hint { margin-bottom: 8px; }
.consent { font-size: 14.5px; border-radius: 8px; }
.audio-list { list-style: none; padding: 0; margin: 8px 0 4px; display: grid; gap: 8px; }
.audio-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.a-pick { padding-top: 2px; }
.a-pick input { width: 20px; height: 20px; accent-color: var(--accent); }
.a-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.a-name { font-weight: 500; word-break: break-all; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.a-sub { font-size: 12.5px; color: var(--muted); }
.a-main audio { width: 100%; height: 36px; margin-top: 4px; }
.audio-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.audio-actions .btn { position: relative; }
.ai-state { margin-top: 8px; font-size: 13px; color: var(--accent); }
.ai-state.off { color: var(--muted); }
.audio-view .btn { margin-top: 10px; }
.ai-runs { margin-top: 10px; font-size: 14px; }
.ai-runs summary { cursor: pointer; color: var(--accent); }
.ai-run { margin-top: 8px; display: grid; gap: 4px; }

@keyframes flash { 0%, 100% { box-shadow: var(--shadow); } 30% { box-shadow: 0 0 0 3px var(--accent-line); } }
.flash { animation: flash 1.2s ease 2; }
.consent.flash { animation: flash .6s ease 3; }

/* ---------- AI 草稿确认 ---------- */
.ai-review { display: grid; gap: 10px; }
.ai-review .banner { margin: 0; }
.ai-notes { font-size: 14px; padding: 8px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); }
.ai-tools { display: flex; gap: 12px; }
.ai-list { list-style: none; padding: 0; display: grid; gap: 8px; }
.ai-sec { font-size: 13px; font-weight: 600; color: var(--accent); margin-top: 6px; }
.ai-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.ai-check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 15px; }
.ai-check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.ai-val { grid-column: 1 / -1; display: grid; grid-template-columns: 2.6em 1fr; gap: 8px; font-size: 14px; }
.ai-val span { color: var(--muted); font-size: 12.5px; padding-top: 1px; }
.ai-val div { white-space: pre-wrap; word-break: break-word; }
.ai-cur div { color: var(--muted); }
.ai-new div { color: var(--ink); }
.ai-transcript summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.ai-transcript .d-para { margin-top: 6px; max-height: 260px; overflow: auto; }

/* ---------- 首页录音入口 ---------- */
.pick { display: grid; gap: 10px; }
.pick [data-step] { display: grid; gap: 10px; }
.pick-item { display: grid; gap: 2px; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.pick-item:hover { border-color: var(--accent-line); background: var(--surface-2); }
.pick-item span { font-size: 13px; color: var(--muted); }
.pick-new { border-color: var(--accent-line); background: var(--accent-soft); }
.pick-new b { color: var(--accent); }
.pick-or { font-size: 13px; color: var(--muted); }
.pick-list { display: grid; gap: 6px; max-height: 42vh; overflow: auto; }
.pick-target { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.pick-progress { font-size: 14px; color: var(--muted); min-height: 1.4em; }

/* ---------- 弹窗、提示 ---------- */
dialog.modal {
  border: 0; padding: 0; border-radius: 16px; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog.modal-wide { width: min(860px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(16, 22, 19, .5); }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); margin: 0; }
.modal-title { font-size: 18px; font-weight: 650; padding: 18px 20px 4px; }
.modal-body { padding: 10px 20px 4px; overflow: auto; display: grid; gap: 10px; font-size: 15px; }
.modal-body ul { display: grid; gap: 4px; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }
.lightbox-img { display: block; max-width: 100%; max-height: calc(100dvh - 140px); margin: 0 auto; border-radius: 8px; }
.miss { color: var(--warn); }

#toasts { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 10px; background: #26302b; color: #fff; font-size: 14.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); transition: opacity .3s, transform .3s; }
.toast-ok { background: #2f6b4f; }
.toast-error { background: #9c3324; }
.toast.out { opacity: 0; transform: translateY(6px); }

.busy { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(16, 22, 19, .45); }
.busy-box { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-radius: 14px; background: var(--surface); box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.rec-ui { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 18px 0 6px; }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
.rec-time { font-size: 34px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- 登录 ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 28px 24px; display: grid; gap: 14px; text-align: center; justify-items: center; }
.login-card .logo { width: 56px; height: 56px; }
.login-card h1 { font-size: 20px; }
.login-card .err { color: var(--danger); font-size: 14px; }

/* ---------- 查看页（纸质表样式） ---------- */
.wrap-doc { max-width: 960px; }
.view-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 14px; }
.audio-view { margin-top: 14px; }
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px 16px; box-shadow: var(--shadow); }
.doc-title { text-align: center; font-size: 21px; font-weight: 700; letter-spacing: .04em; margin-bottom: 14px; }
.doc-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 15px; }
.doc-table .c-label { width: 8.5em; }
.doc-table th, .doc-table td { border: 1px solid var(--line-2); padding: 8px 10px; vertical-align: top; text-align: left; }
.doc-table th { background: var(--surface-2); font-weight: 600; color: var(--ink-2); }
.doc-table th small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.d-sec th { background: var(--accent-soft); color: var(--accent); font-size: 16px; letter-spacing: .02em; }
.d-headcell { padding: 10px 12px !important; }
.d-head { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.d-head-wide { grid-column: 1 / -1; }
.d-f { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin: 0 16px 4px 0; }
.d-wide { display: flex; }
.d-l { color: var(--muted); }
.d-u { color: var(--muted); font-size: .92em; }
.v { font-weight: 600; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.blank::before { content: '—'; color: var(--line-2); font-weight: 400; }
.opt { display: inline-flex; align-items: baseline; gap: 2px; margin-right: 8px; }
.opt i { font-style: normal; color: var(--accent); }
.opt .v, .opt .blank { margin-left: 4px; }
.doc:not(.all-opts) .opt.off { display: none; }
.doc:not(.all-opts) .d-choice.none:not(.d-cond)::after { content: '未填'; color: var(--muted); font-size: .92em; }
.doc:not(.all-opts) .d-choice.none.d-cond { display: none; }
.doc.all-opts .opt.off { color: var(--muted); }
.doc.all-opts .opt.off i { color: var(--muted); }
.d-line { padding: 3px 0; }
.d-line + .d-line { border-top: 1px dashed var(--line); }
.d-who { display: inline-block; margin-right: 10px; color: var(--accent); font-weight: 600; }
.d-block { display: block; margin: 2px 0 6px; }
.d-sub { font-weight: 600; color: var(--ink-2); font-size: 14px; }
.d-hint { color: var(--muted); font-size: 13px; }
.d-para { white-space: pre-wrap; word-break: break-word; line-height: 1.75; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); margin-top: 4px; }
.d-para-empty::before { content: '未填写'; color: var(--muted); }
.d-empty { color: var(--muted); font-size: 14px; }
.d-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 6px; }
.d-ph { padding: 0; border: 0; background: none; border-radius: 8px; overflow: hidden; aspect-ratio: 4 / 3; cursor: zoom-in; }
.d-ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }

/* ---------- 宽屏 ---------- */
@media (min-width: 760px) {
  .row { display: grid; grid-template-columns: 9.5em minmax(0, 1fr); gap: 16px; }
  .row-head { flex-direction: column; align-items: flex-start; gap: 4px; margin: 10px 0 0; }
  .item > .row { grid-template-columns: 8.5em minmax(0, 1fr); }
  .sec { padding: 20px 22px; }
}
@media (min-width: 1000px) {
  .edit-layout { display: grid; grid-template-columns: 180px minmax(0, 840px); gap: 28px; justify-content: center; }
  .secnav {
    position: sticky; top: calc(var(--topbar-h) + 16px); align-self: start; flex-direction: column; margin: 14px 0 0; padding: 0;
    background: none; backdrop-filter: none; border: 0;
  }
  .secnav button { justify-content: space-between; border-radius: 10px; padding: 9px 12px; }
  .bb-inner { max-width: 1048px; }
}
@media (max-width: 759px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat { padding: 10px 12px; }
  .stat b { font-size: 21px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn-primary { flex: 1; }
  .rec-grid { grid-template-columns: 1fr; }
  .doc { padding: 16px 12px; border-radius: 12px; }
  .doc-table, .doc-table tbody, .doc-table tr, .doc-table th, .doc-table td { display: block; width: 100%; }
  .doc-table { border-top: 1px solid var(--line-2); }
  .doc-table th, .doc-table td { border-top: 0; }
  .doc-table tr:not(.d-sec) th { border-bottom: 0; padding-bottom: 2px; background: none; color: var(--accent); font-size: 14px; }
  .d-sec th { margin-top: 0; }
  .d-head { grid-template-columns: 1fr; }
  .bb-progress .bar { display: none; }
  .tb-actions .btn { padding: 8px 12px; }
}
@media (max-width: 380px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- 打印 ---------- */
@media print {
  @page { size: A4; margin: 12mm 12mm 14mm; }
  :root { --ink: #000; --ink-2: #000; --muted: #333; --line: #000; --line-2: #000; --surface: #fff; --surface-2: #fff; --accent: #000; --accent-soft: #eee; color-scheme: light; }
  html, body { background: #fff; color: #000; }
  body { font-family: "Songti SC", "STSong", "SimSun", serif; font-size: 10.5pt; line-height: 1.55; }
  .no-print, .topbar, .bottombar, .secnav, #toasts, .busy, dialog { display: none !important; }
  .wrap, .wrap-doc { max-width: none; padding: 0; }
  .page-pad { padding: 0; }
  .doc { border: 0; border-radius: 0; padding: 0; box-shadow: none; }
  .doc-title { font-size: 16pt; margin-bottom: 8pt; }
  .doc-table { font-size: 10.5pt; }
  .doc-table .c-label { width: 7em; }
  .doc-table, .doc-table tbody { display: table; }
  .doc-table tbody { display: table-row-group; }
  .doc-table tr { display: table-row; break-inside: avoid; }
  .doc-table th, .doc-table td { display: table-cell; border: .6pt solid #000; padding: 3pt 5pt; color: #000; }
  .doc-table th { background: #fff; text-align: center; vertical-align: middle; }
  .d-sec th { background: #e8e8e8 !important; text-align: left; font-size: 11pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc .opt.off { display: inline-flex !important; color: #000; }
  .doc .opt i { color: #000; }
  .doc .d-choice.none::after { content: none !important; }
  .doc .d-choice.d-cond { display: inline-flex !important; }
  .v { font-weight: 400; text-decoration: underline; text-underline-offset: 2pt; }
  .blank { display: inline-block; min-width: 3.5em; border-bottom: .6pt solid #000; height: 1em; }
  .blank::before { content: none; }
  .d-who { color: #000; }
  .d-line + .d-line { border-top: 0; }
  .d-para { background: none; padding: 2pt 0; }
  .d-para-empty { min-height: 28mm; }
  .d-para-empty::before { content: none; }
  .d-head { grid-template-columns: 1fr 1fr; }
  .d-photos { grid-template-columns: repeat(3, 1fr); }
  .d-ph { aspect-ratio: auto; height: 45mm; }
  .doc-meta { color: #333; font-size: 8.5pt; }
}
