/* 啡药 · 咖啡与精神科用药记录
 * 默认「冷静」配色；[data-theme="warm"] 切回咖啡志暖调，方便对比。
 */
:root {
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif SC", "Songti SC", STSong, "Source Han Serif SC", SimSun, serif;

  --bg: #edf1f3;
  --bg-glow: #e2eaec;
  --surface: #f8fafb;
  --surface-2: #eff4f6;
  --ink: #22323a;
  --ink-2: #3b4f59;
  --muted: #647982;
  --line: rgba(34, 50, 58, 0.11);
  --accent: #3f6f7e;
  --accent-2: #2f5866;
  --accent-soft: #e0ebee;
  --sage: #6f8f7c;
  --gold: #a98a4b;
  --green: #4d7c68;
  --amber: #a3762b;
  --red: #a24b40;
  --blue: #4a6f9e;
  --shadow: 0 1px 2px rgba(23, 42, 50, 0.04), 0 14px 34px -20px rgba(23, 42, 50, 0.28);
  --radius: 18px;
  --radius-sm: 12px;
}

[data-theme="warm"] {
  --bg: #f5eee3;
  --bg-glow: #efe4d3;
  --surface: #fffaf3;
  --surface-2: #f7efe4;
  --ink: #3d2f24;
  --ink-2: #55443a;
  --muted: #7a6a59;
  --line: rgba(61, 47, 36, 0.12);
  --accent: #b26a3c;
  --accent-2: #8f5230;
  --accent-soft: #f3e4d7;
  --sage: #8a9563;
  --gold: #c99a3f;
  --green: #5d7c4f;
  --amber: #b07c2a;
  --red: #a4473a;
  --blue: #6a6f9e;
  --shadow: 0 1px 2px rgba(61, 47, 36, 0.04), 0 14px 34px -20px rgba(61, 47, 36, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161e23;
    --bg-glow: #1b252b;
    --surface: #1e292f;
    --surface-2: #243138;
    --ink: #e8eff2;
    --ink-2: #c4d2d8;
    --muted: #91a4ac;
    --line: rgba(232, 239, 242, 0.12);
    --accent: #82b1c0;
    --accent-2: #a6ccd8;
    --accent-soft: #26373f;
    --sage: #97b3a1;
    --gold: #d3b26c;
    --green: #8ab99f;
    --amber: #d3a45c;
    --red: #d18a7e;
    --blue: #9db4d8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 34px -20px rgba(0, 0, 0, 0.6);
  }
  [data-theme="warm"] {
    --bg: #1d1813;
    --bg-glow: #241d16;
    --surface: #262019;
    --surface-2: #2f271e;
    --ink: #f2e9dc;
    --ink-2: #d8c9b7;
    --muted: #a89681;
    --line: rgba(242, 233, 220, 0.12);
    --accent: #d9a06c;
    --accent-2: #e7bb8e;
    --accent-soft: #3a2d20;
    --sage: #a9b58a;
    --gold: #dfb968;
    --green: #a3bd8b;
    --amber: #d9a95f;
    --red: #d98d7e;
    --blue: #a8addd;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.55;
  background:
    radial-gradient(1200px 700px at 88% -8%, var(--bg-glow), transparent 60%),
    radial-gradient(900px 600px at -10% 8%, var(--accent-soft), transparent 55%),
    var(--bg);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; font-family: var(--sans); color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }

.app { max-width: 940px; margin: 0 auto; padding: 0 16px 120px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 2px 12px;
  background: linear-gradient(var(--bg) 70%, transparent);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .mark {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 18px;
}
.brand h1 { font-size: 21px; letter-spacing: 0.04em; }
.brand .sub { font-size: 12px; color: var(--muted); font-family: var(--sans); }
.spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 16px;
  box-shadow: var(--shadow);
}
.icon-btn:active { transform: scale(0.96); }
.btn {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); border-radius: 999px;
  padding: 9px 16px; font-size: 13px; letter-spacing: 0.02em;
  box-shadow: var(--shadow);
}
.btn.calm { background: var(--accent); border-color: var(--accent); color: #f7fbfc; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.sm { padding: 6px 12px; font-size: 12px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-top: 14px;
}
.card h2 { font-size: 17px; letter-spacing: 0.02em; }
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card-head .hint { margin-left: auto; font-size: 12px; color: var(--muted); font-family: var(--sans); }
.subtle { color: var(--muted); font-size: 12.5px; font-family: var(--sans); }
.eyebrow { font-family: var(--sans); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- 视图切换 ---------- */
.view { display: none; }
.view.active { display: block; }

/* ---------- 表单 ---------- */
.seg {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 14px;
}
.seg button {
  flex: 1 0 auto; border: 0; background: transparent; color: var(--ink-2);
  padding: 8px 12px; border-radius: 10px; font-size: 13px; white-space: nowrap;
}
.seg button.on { background: var(--surface); color: var(--accent-2); box-shadow: var(--shadow); font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.grid .wide { grid-column: 1 / -1; }
.grid > .field:only-child { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-family: var(--sans); font-size: 11.5px; color: var(--muted); letter-spacing: 0.02em; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 10px 11px;
  font-size: 16px; color: var(--ink); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 64px; font-size: 16px; }
.live {
  margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--accent-soft); border: 1px solid var(--line);
  font-size: 13px; color: var(--accent-2);
}
.live b { font-family: var(--serif); font-size: 15px; }
.stars { display: flex; gap: 6px; padding: 4px 0 2px; }
.stars button {
  border: 0; background: none; padding: 0; font-size: 27px; line-height: 1;
  color: var(--line); filter: grayscale(1);
}
.stars button.on { color: var(--gold); filter: none; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  border-radius: 999px; padding: 6px 11px; font-size: 12.5px; font-family: var(--sans);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #f7fbfc; }
details.more { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
details.more summary { cursor: pointer; font-size: 13px; color: var(--muted); font-family: var(--sans); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+ "; }
details.more[open] summary::before { content: "− "; }
.save-row { margin-top: 16px; display: flex; gap: 10px; }
.save-row .btn { flex: 1; padding: 13px 16px; font-size: 15px; border-radius: 14px; }

/* ---------- 今日 ---------- */
.hero { text-align: left; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; background: var(--surface-2);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-pill[data-status="green"] .dot { background: var(--green); }
.status-pill[data-status="amber"] .dot { background: var(--amber); }
.status-pill[data-status="red"] .dot { background: var(--red); }
.big-num {
  font-family: var(--serif); font-size: 50px; line-height: 1.05; letter-spacing: -0.01em;
  margin: 8px 0 2px; font-variant-numeric: lining-nums tabular-nums;
}
.big-num small { font-size: 18px; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 14px; box-shadow: var(--shadow); }
.kpi .v { font-family: var(--serif); font-size: 27px; line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; }
.kpi .v small { font-size: 13px; color: var(--muted); margin-left: 2px; }
.kpi .l { font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.kpi .s { font-family: var(--sans); font-size: 11px; color: var(--muted); opacity: 0.85; }
.track { height: 9px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); margin-top: 10px; }
.track > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.track.green > i { background: var(--green); }
.track.amber > i { background: var(--amber); }
.track.red > i { background: var(--red); }
.advice-line { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 12.5px; color: var(--muted); font-family: var(--sans); }
.chart { width: 100%; height: auto; overflow: visible; display: block; }
.chart text { font-family: var(--sans); }
.chart-card { padding-bottom: 14px; }
.chart-note { margin-top: 8px; font-size: 12px; color: var(--muted); font-family: var(--sans); }
.med-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; color: var(--muted); font-family: var(--sans); }
.med-legend span { display: inline-flex; align-items: center; white-space: nowrap; }
.med-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.mc-wrap { position: relative; }
.mc-tip { position: absolute; top: 2px; left: 0; z-index: 6; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; font-size: 11px; line-height: 1.5; color: var(--ink); font-family: var(--sans); box-shadow: 0 6px 18px rgba(30, 45, 55, 0.12); pointer-events: none; white-space: nowrap; }
.mc-tip b { display: block; font-size: 10px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.mc-tip span { display: flex; align-items: center; }
.mc-tip i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.mc-tip em { font-style: normal; color: var(--muted); font-size: 10px; margin-left: 5px; }
.ch-wrap { position: relative; }
.ch-cursor { display: none; pointer-events: none; }
.ch-cursor .ch-vline { stroke: var(--ink); opacity: 0.45; }
.ch-cursor .ch-dot { stroke: var(--surface); stroke-width: 1; }

/* 今日时间线 */
.today-list { display: flex; flex-direction: column; gap: 8px; }
.today-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.today-item:last-child { border-bottom: 0; }
.today-item .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; flex: none; }
.today-item .t { font-family: var(--sans); font-size: 12px; color: var(--muted); width: 44px; flex: none; }
.today-item .m { min-width: 0; flex: 1; }
.today-item .m b { font-weight: 600; font-size: 14px; }
.today-item .m span { display: block; font-family: var(--sans); font-size: 11.5px; color: var(--muted); }
.today-item .r { font-family: var(--sans); font-size: 12px; color: var(--muted); text-align: right; }

/* ---------- 时间轴 ---------- */
.filter-row { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.day-group { margin-top: 16px; }
.day-head { display: flex; align-items: baseline; gap: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.day-head strong { font-family: var(--serif); font-size: 15px; }
.day-head span { font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-left: auto; }
.entry { display: flex; gap: 10px; padding: 11px 2px; border-bottom: 1px dashed var(--line); align-items: flex-start; }
.entry:last-child { border-bottom: 0; }
.entry .time { font-family: var(--sans); font-size: 12px; color: var(--muted); width: 44px; flex: none; padding-top: 2px; }
.entry .main { flex: 1; min-width: 0; }
.entry .title { font-size: 14.5px; font-weight: 600; }
.entry .meta { font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.entry .right { text-align: right; flex: none; }
.entry .right .score { font-family: var(--sans); font-size: 12px; color: var(--gold); }
.entry .right .acts { margin-top: 4px; display: flex; gap: 6px; justify-content: flex-end; }
.badge { display: inline-block; font-family: var(--sans); font-size: 10.5px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); margin-right: 6px; vertical-align: 1px; }
.badge.coffee { color: var(--accent-2); background: var(--accent-soft); border-color: transparent; }
.badge.med { color: var(--sage); background: color-mix(in srgb, var(--sage) 14%, transparent); border-color: transparent; }
.badge.checkin { color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, transparent); border-color: transparent; }
.badge.plan { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); border-color: transparent; }
.link { border: 0; background: none; color: var(--accent); font-family: var(--sans); font-size: 12px; padding: 7px 6px; margin: -5px -2px; }
.link.danger { color: var(--red); }
.empty { padding: 26px 8px; text-align: center; color: var(--muted); font-family: var(--sans); font-size: 13px; }

/* ---------- 药品库 ---------- */
.search-row { display: flex; gap: 8px; margin-top: 10px; }
.search-row input { flex: 1; }
.search-row input, .settings-group input, .settings-group select {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 16px; outline: none;
}
.search-row input:focus, .settings-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.drug-card { padding: 14px 2px; border-bottom: 1px dashed var(--line); }
.drug-card:last-child { border-bottom: 0; }
.drug-card .top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.drug-card .nm { font-size: 16px; font-weight: 600; }
.drug-card .alias { font-family: var(--sans); font-size: 11.5px; color: var(--muted); }
.drug-card .hl { margin-left: auto; font-family: var(--sans); font-size: 12px; color: var(--accent-2); background: var(--accent-soft); padding: 3px 8px; border-radius: 999px; }
.drug-card ul { margin: 7px 0 0; padding-left: 18px; font-family: var(--sans); font-size: 12px; color: var(--ink-2); line-height: 1.65; }
.drug-card li b { color: var(--ink); font-weight: 600; }
.drug-card .warn { font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.drug-card .add { margin-top: 8px; display: flex; gap: 8px; }
.mine-card { padding: 13px 2px; border-bottom: 1px dashed var(--line); }
.mine-card:last-child { border-bottom: 0; }
.mine-card .top { display: flex; align-items: center; gap: 8px; }
.mine-card .nm { font-weight: 600; font-size: 15px; }
.mine-card .dose { font-family: var(--sans); font-size: 12px; color: var(--muted); }
.mine-card .acts { margin-left: auto; display: flex; gap: 4px; }
.mine-card .sub { font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-top: 4px; }

/* 药品详情弹层 */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.detail-grid .kv { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.detail-grid .kv .k { font-family: var(--sans); font-size: 11px; color: var(--muted); }
.detail-grid .kv .v { font-size: 15px; font-weight: 600; margin-top: 2px; }
.warn-box { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--amber) 10%, transparent); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent); font-family: var(--sans); font-size: 12px; color: var(--ink-2); }

/* ---------- 打卡 ---------- */
.checkin-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.dot-scale { display: flex; gap: 6px; }
.dot-scale button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface-2); font-family: var(--sans); font-size: 13px; color: var(--ink-2);
}
.dot-scale button.on { background: var(--accent); border-color: var(--accent); color: #f7fbfc; }

/* ---------- 今天要不要喝 / 服药后回访 / 5 秒打卡 ---------- */
.drink-card .drink-verdict { font-family: var(--serif); font-size: 22px; line-height: 1.3; margin: 6px 0 12px; }
.drink-card[data-status="green"] .drink-verdict { color: var(--sage); }
.drink-card[data-status="amber"] .drink-verdict { color: var(--gold); }
.drink-card[data-status="red"] .drink-verdict { color: var(--red); }
.drink-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.drink-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.drink-row span { font-family: var(--sans); font-size: 11px; color: var(--muted); }
.drink-row b { font-family: var(--serif); font-size: 14px; font-weight: 600; }
.drink-why { margin-top: 10px; font-family: var(--sans); font-size: 12px; line-height: 1.5; color: var(--ink-2); background: color-mix(in srgb, var(--amber) 8%, transparent); border-radius: 10px; padding: 8px 10px; }
.follow-card { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.follow-line { font-family: var(--sans); font-size: 13.5px; line-height: 1.55; margin: 4px 0 10px; }
.quick-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dot-scale.lg button { width: 40px; height: 40px; font-size: 15px; }
.quick-word { flex: 1; min-width: 140px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); font-family: var(--sans); font-size: 16px; color: var(--ink); }
.quick-note { margin-top: 8px; font-family: var(--sans); font-size: 11.5px; color: var(--muted); }

/* ---------- 弹层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 27, 32, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; overflow-y: auto;
  animation: fade 0.16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 20px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.5);
  margin: auto 0 0;
  max-height: calc(100vh - 32px); overflow-y: auto;
}
.modal h2 { font-size: 19px; }
.modal .modal-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.modal .modal-head .x { margin-left: auto; }
.settings-group { margin-top: 16px; }
.settings-group h3 { font-size: 14px; margin-bottom: 8px; }
.settings-group .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 9px; }
.settings-group .row .field label { font-size: 11px; }
.settings-group .hint { font-family: var(--sans); font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.share-preview { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); margin-top: 12px; }
.share-preview img { display: block; width: 100%; height: auto; }
#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-family: var(--sans); font-size: 12.5px; z-index: 80; opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.demo-banner {
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  color: var(--ink-2); border-radius: 12px; padding: 8px 12px;
  font-family: var(--sans); font-size: 12px; margin-top: 10px;
}
.demo-banner .btn { margin-left: auto; padding: 4px 10px; font-size: 11.5px; }
.demo-banner.warn { background: color-mix(in srgb, var(--red) 12%, transparent); border-color: color-mix(in srgb, var(--red) 35%, transparent); }

/* 锁屏 */
.lock {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.lock .box { text-align: center; max-width: 300px; width: 100%; }
.lock .box .mark { width: 64px; height: 64px; margin: 0 auto 14px; font-size: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.lock input {
  width: 100%; text-align: center; letter-spacing: 0.6em; font-family: var(--sans);
  font-size: 22px; padding: 12px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); outline: none; margin-top: 8px;
}
.lock .err { font-family: var(--sans); font-size: 12px; color: var(--red); margin-top: 8px; min-height: 18px; }

/* ---------- 底栏 ---------- */
.tabbar {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: min(560px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--line); border-radius: 22px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px -18px rgba(20, 35, 42, 0.45);
  padding: 6px;
}
.tabbar button {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 4px; border-radius: 16px; font-family: var(--sans); font-size: 10.5px;
}
.tabbar button svg { width: 20px; height: 20px; }
.tabbar button.on { color: var(--accent-2); background: var(--accent-soft); }

/* ---------- 报告 ---------- */
.report-preview { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-top: 12px; background: var(--surface-2); }
.report-preview img { display: block; width: 100%; height: auto; }

/* ---------- 响应式 ---------- */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid .wide { grid-column: span 2; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .overlay { align-items: center; }
  .modal { margin: auto; }
  .app { padding-bottom: 96px; }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .big-num { font-size: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
.noscript { padding: 20px; text-align: center; font-family: var(--sans); }

/* ---------- 悬停提示 ---------- */
.tip {
  position: fixed;
  z-index: 60;
  max-width: min(280px, calc(100vw - 24px));
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(24, 34, 40, .93);
  color: #fff;
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: .01em;
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .12s ease, transform .12s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.tip.on { opacity: 1; transform: translateY(0); }
.tip b { font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .tip { background: rgba(238, 244, 246, .96); color: #14202a; }
  /* 深色模式下主按钮文字改用深色，保证对比度 */
  .btn.calm { color: #0f2a33; }
}
