/* =========================================================
   脈搏測試 · 樣式（沿用網站的宣紙、濃墨、朱紅配色）
   ========================================================= */
:root {
  --paper: #f6f2e9;
  --paper-deep: #ede6d6;
  --card: #fbf8f2;
  --ink: #1f1d1a;
  --ink-soft: #5a554d;
  --ink-faint: #a49c8e;
  --line: rgba(31, 29, 26, .12);
  --seal: #b8282e;
  --seal-soft: rgba(184, 40, 46, .1);
  --good: #2f7d4f;
  --fair: #b07a12;
  --poor: #b8282e;
  --brush: "LXGW WenKai TC", "Kaiti TC", "BiauKai", "DFKai-SB", "標楷體", serif;
  --body: "Noto Serif TC", "Songti TC", "PMingLiU", "新細明體", serif;
  --sans: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  line-height: 1.6;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }

/* ---------- 頂部 ---------- */
.top { display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 0 auto; padding: 12px 16px 6px; }
.back { color: var(--ink-soft); text-decoration: none; font-size: 28px; line-height: 1; padding: 0 4px; }
.seal {
  display: grid; place-items: center; width: 38px; height: 38px; flex: none;
  background: var(--seal); color: #fff4ea; border-radius: 6px;
  font: 700 22px var(--brush);
}
.title { flex: 1; min-width: 0; }
.title h1 { margin: 0; font: 400 22px var(--brush); letter-spacing: .12em; }
.title p { margin: 0; color: var(--ink-soft); font-size: 12.5px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; font-size: 13px; }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 28px; display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 16px; box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 8px 24px rgba(60, 40, 10, .05); }
.card h2 { margin: 0; font: 400 19px var(--brush); letter-spacing: .08em; }

/* ---------- 量測錶盤 ---------- */
.measure { text-align: center; }
.dial { position: relative; width: min(240px, 66vw); aspect-ratio: 1; margin: 4px auto 8px; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--paper-deep); }
.ring .progress { stroke: var(--seal); stroke-linecap: round; stroke-dasharray: 339.3; stroke-dashoffset: 339.3; transition: stroke-dashoffset .3s linear; }
.lens { position: absolute; inset: 13%; border-radius: 50%; overflow: hidden; background: #2a1414; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); }
.lens video { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .9; }
.lens-shade { position: absolute; inset: 0; background: radial-gradient(circle, rgba(0, 0, 0, .15), rgba(0, 0, 0, .55)); }
.readout { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.readout strong { font: 600 54px/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.readout small { font-size: 13px; opacity: .85; margin-top: 2px; }
.heart { font-size: 18px; color: #ff8a8a; opacity: .35; transition: transform .12s ease-out, opacity .12s; }
.heart.beat { transform: scale(1.45); opacity: 1; }

.status { margin: 4px 0 8px; min-height: 26px; font-size: 15px; color: var(--ink); }
.pills { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-soft); font-family: var(--sans); }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.pill.good i { background: var(--good); }
.pill.fair i { background: var(--fair); }
.pill.poor i { background: var(--poor); }

.wave { width: 100%; height: 96px; display: block; background: linear-gradient(var(--paper), #f3eee2); border-radius: 10px; border: 1px solid var(--line); }
.wave.small { height: 70px; margin-top: 12px; }
.wave-label { margin: 4px 0 12px; font-size: 11.5px; color: var(--ink-faint); font-family: var(--sans); }

.options { display: grid; gap: 10px; margin-bottom: 12px; }
.options.locked { opacity: .45; pointer-events: none; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label, .chips label { position: relative; }
.seg input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; flex-direction: column; align-items: center; padding: 8px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-size: 15px; cursor: pointer; }
.seg small { font-size: 11px; color: var(--ink-faint); font-family: var(--sans); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chips span { display: inline-block; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: 13px; cursor: pointer; }
.seg input:checked + span, .chips input:checked + span { border-color: var(--seal); background: var(--seal-soft); color: var(--seal); }
.seg input:checked + span small { color: var(--seal); }
.seg input:focus-visible + span, .chips input:focus-visible + span { outline: 2px solid var(--seal); outline-offset: 2px; }

.actions { display: grid; gap: 8px; }
.actions.two { grid-template-columns: 1fr 1fr; }
.btn { min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-size: 16px; letter-spacing: .1em; }
.btn.primary { background: var(--seal); border-color: var(--seal); color: #fff6ee; }
.btn.primary:active { background: #9c2026; }
.btn.ghost { background: transparent; color: var(--ink-soft); }
.btn:disabled { opacity: .45; }
.link { margin-top: 10px; background: none; border: 0; color: var(--ink-soft); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 結果 ---------- */
.result-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grade { font-size: 12.5px; padding: 2px 10px; border-radius: 999px; font-family: var(--sans); }
.grade.good { background: rgba(47, 125, 79, .12); color: var(--good); }
.grade.fair { background: rgba(176, 122, 18, .14); color: var(--fair); }
.grade.poor { background: var(--seal-soft); color: var(--poor); }
.big { text-align: center; margin: 10px 0 6px; }
.big strong { font: 600 64px/1 var(--sans); font-variant-numeric: tabular-nums; }
.big span { margin-left: 6px; color: var(--ink-soft); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 0; }
.facts div { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.facts dt { font-size: 12px; color: var(--ink-soft); }
.facts dd { margin: 0; font: 600 18px var(--sans); }
.facts dd small { font-weight: 400; font-size: 11.5px; color: var(--ink-faint); }
.notes { margin: 12px 0; font-size: 13.5px; color: var(--ink-soft); }
.notes p { margin: 6px 0; }

/* ---------- 紀錄 ---------- */
.muted { color: var(--ink-soft); font-size: 13px; }
.small-note { font-size: 12px; color: var(--ink-faint); margin: 8px 0 10px; }
.trend { width: 100%; height: 70px; display: block; margin: 8px 0 4px; }
.trend:empty { display: none; }
.records { list-style: none; margin: 0; padding: 0; }
.records li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.records li:last-child { border-bottom: 0; }
.records .when { font-size: 13px; color: var(--ink-soft); }
.records .hr { grid-row: span 2; align-self: center; font: 600 22px var(--sans); }
.records .hr small { font-size: 11px; font-weight: 400; color: var(--ink-faint); margin-left: 2px; }
.records .meta { font-size: 12px; color: var(--ink-faint); font-family: var(--sans); }
.records .empty { display: block; color: var(--ink-faint); font-size: 13px; text-align: center; padding: 14px 0; }

/* ---------- 說明 ---------- */
.howto details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.howto details:last-child { border-bottom: 0; }
.howto summary { font: 400 17px var(--brush); cursor: pointer; letter-spacing: .06em; }
.howto ol { padding-left: 1.3em; margin: 8px 0; font-size: 14px; }
.howto p { font-size: 14px; margin: 8px 0; }
.field { display: block; font-size: 14px; margin-top: 8px; }
.field select { display: block; width: 100%; margin-top: 6px; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); font: inherit; }

.fine-print { margin: 4px 4px 0; font-size: 12px; color: var(--ink-faint); line-height: 1.7; }
.fine-print strong { color: var(--ink-soft); }

.demo-badge { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--paper-deep); color: var(--ink-soft); font-size: 11px; font-family: var(--sans); vertical-align: 2px; }


@media (prefers-reduced-motion: reduce) {
  .heart, .ring .progress { transition: none; }
}
