/* =============================================================================
   AI 腦健康平台 — dashboard identity (aligned to the platform UI mockups)
   Deep-navy ground, neon cyan-blue accent, gold key numbers. Desktop gets the
   dashboard shell (sidebar + flow + live-metrics rail); mobile keeps the
   focused single-column flow (elderly-first, Spec §17: large type, AA contrast,
   one instruction per screen, visible focus, reduced-motion + high-contrast).
   All id/class hooks used by app.js / ui.js are preserved.
   ============================================================================= */

:root {
  color-scheme: dark;

  /* brand */
  --blue: #38bdf8;            /* accent / links / active */
  --blue-dark: #a9d4ff;       /* readable "deep blue" text on dark */
  --blue-soft: rgba(56, 189, 248, .12);
  --btn-a: #1d6fe0;           /* button gradient start */
  --btn-b: #2fa3f0;           /* button gradient end */
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, .12);
  --gold: #ffd44d;            /* key numbers (scores, KPI) */

  /* ink */
  --ink: #e9f0fc;
  --ink-2: #c3d0e8;
  --muted: #9aacd0;
  --line: rgba(96, 140, 236, .20);
  --line-strong: rgba(96, 158, 255, .42);

  /* ground */
  --bg-a: #0a1530;
  --bg-b: #070e20;
  --bg-c: #0a1826;
  --card: #0d1730;
  --surface: #122045;
  --surface-2: #16264f;
  --stage: #060b1a;

  /* status */
  --good: #2fd08a;  --good-soft: rgba(47, 208, 138, .10);
  --warn: #f5b93e;  --warn-soft: rgba(245, 185, 62, .10);
  --alert: #f76a6a; --alert-soft: rgba(247, 106, 106, .12);

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .35);
  --shadow: 0 12px 34px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  --glow: 0 0 18px rgba(56, 189, 248, .35);
  --ring: 0 0 0 4px rgba(56, 189, 248, .30);
  --focus: #38bdf8;

  --r-lg: 20px; --r-md: 14px; --r-sm: 11px;
  --tap: 56px;
  --appbar-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", -apple-system, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 540px at 88% -10%, rgba(29, 111, 224, .18) 0%, transparent 60%),
    radial-gradient(860px 480px at -12% 108%, rgba(56, 189, 248, .09) 0%, transparent 55%),
    linear-gradient(170deg, var(--bg-a) 0%, var(--bg-b) 48%, var(--bg-c) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* -------- a11y primitives --------------------------------------------------- */
.skip-link {
  position: fixed; left: 12px; top: -70px; z-index: 300;
  background: linear-gradient(135deg, var(--btn-a), var(--btn-b)); color: #fff;
  padding: 12px 18px;
  border-radius: 0 0 12px 12px; font-weight: 700; text-decoration: none;
  transition: top .2s ease;
}
.skip-link:focus { top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
.btn:focus:not(:focus-visible), .iconbtn:focus:not(:focus-visible) { outline: none; }

/* ============================================================================
   Topbar
   ============================================================================ */
.appbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10, 20, 42, .82);
  backdrop-filter: saturate(1.3) blur(14px);
  -webkit-backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.appbar-inner {
  max-width: 1360px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--appbar-h); padding: 6px 18px;
}
.logo {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--btn-a), var(--blue));
  display: grid; place-items: center; color: #fff; font-size: 21px;
  box-shadow: var(--glow);
}
.brand { font-weight: 800; font-size: 16px; line-height: 1.15; letter-spacing: .01em; margin-right: auto; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; margin-top: 2px; letter-spacing: .08em; }

/* user chip (mockup: 王媽媽 · 72歲/女性 · 線上) */
.user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line-strong);
  padding: 6px 14px 6px 8px; border-radius: 99px;
}
.user-chip .avatar {
  width: 32px; height: 32px; border-radius: 99px; flex: none;
  background: var(--surface-2); display: grid; place-items: center; font-size: 17px;
  border: 1px solid var(--line);
}
.user-chip .uc-txt b { display: block; font-size: 14px; line-height: 1.2; }
.user-chip .uc-txt small { color: var(--teal); font-size: 11.5px; font-weight: 700; }

/* KPI chips (完成度 ring + 最近檢測時間) */
.kpi-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 14px;
}
.kpi-chip .kpi-lab { font-size: 11px; font-weight: 700; color: var(--muted); line-height: 1.35; letter-spacing: .02em; }
.kpi-chip .kpi-lab b { color: var(--ink); font-size: 12px; }
.kpi-chip .kpi-i { font-size: 18px; }
.ring {
  --p: 0; width: 42px; height: 42px; border-radius: 99px; flex: none;
  background:
    radial-gradient(closest-side, var(--surface) 71%, transparent 72%),
    conic-gradient(var(--teal) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 800; color: var(--teal);
  font-variant-numeric: tabular-nums;
  transition: background .4s;
}

.iconbtn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 700; text-decoration: none;
  padding: 8px 12px; border-radius: 99px; cursor: pointer; min-height: 40px;
  transition: background .15s, border-color .15s, transform .08s;
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn:active { transform: scale(.96); }
.iconbtn.ghosted { border-color: transparent; background: transparent; color: var(--muted); }
.iconbtn.ghosted:hover { background: var(--surface); color: var(--ink); }
.iconbtn-t { line-height: 1; }

/* Step rail (mobile; built by ui.js) */
.steprail {
  max-width: 640px; margin: 0 auto; padding: 12px 16px 14px;
  display: flex; align-items: flex-start; gap: 0;
}
.steprail .step { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.steprail .step::before {
  content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 3px;
  background: var(--line-strong); border-radius: 99px; z-index: 0;
}
.steprail .step:first-child::before { display: none; }
.steprail .step .bead {
  width: 28px; height: 28px; border-radius: 99px; z-index: 1;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
  background: var(--surface); color: var(--muted); border: 2px solid var(--line-strong);
  transition: background .3s, color .3s, border-color .3s, transform .3s;
}
.steprail .step .slab { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .01em; }
.steprail .step.done .bead { background: var(--teal); border-color: var(--teal); color: #04251f; }
.steprail .step.done::before { background: var(--teal); }
.steprail .step.active .bead { background: linear-gradient(135deg, var(--btn-a), var(--btn-b)); border-color: var(--blue); color: #fff; transform: scale(1.12); box-shadow: 0 0 0 5px rgba(56, 189, 248, .22); }
.steprail .step.active .slab { color: var(--blue); }
.steprail .step.active ~ .step::before { background: var(--line-strong); }

/* ============================================================================
   Layout: sidebar | flow | live rail (dashboard on desktop, column on mobile)
   ============================================================================ */
.layout { max-width: 640px; margin: 0 auto; }
.sidebar { display: none; }
.rail { display: none; }

.wrap { padding: 22px 18px calc(64px + env(safe-area-inset-bottom)); }

@media (min-width: 1120px) {
  .layout {
    display: grid;
    grid-template-columns: 236px minmax(540px, 680px) 316px;
    gap: 22px; max-width: 1360px; margin: 0 auto;
    padding: 22px 18px calc(64px + env(safe-area-inset-bottom));
    align-items: start;
  }
  .sidebar, .rail {
    display: block; position: sticky;
    top: calc(var(--appbar-h) + 18px);
    max-height: calc(100vh - var(--appbar-h) - 36px);
    overflow-y: auto;
  }
  .wrap { padding: 0; }
  .steprail { display: none; } /* desktop shows the flow in the sidebar instead */
  .user-chip.hidden ~ .kpi-chip { margin-left: 0; }
}

/* -------- Sidebar ------------------------------------------------------------ */
.sidebar {
  background: linear-gradient(180deg, rgba(24, 44, 92, .30), rgba(13, 23, 48, .90)), var(--card);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 14px 16px;
}
.side-head {
  font-size: 11.5px; font-weight: 800; color: var(--muted);
  letter-spacing: .18em; text-transform: uppercase;
  padding: 4px 10px 8px;
}
.side-head + .side-head, #side-steps + .side-head { margin-top: 16px; }

#side-steps .snav {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 12px; margin: 2px 0; border-radius: 12px;
  font-size: 15px; font-weight: 700; color: var(--muted);
  border: 1px solid transparent; position: relative;
}
#side-steps .snav .s-i { font-size: 17px; width: 24px; text-align: center; flex: none; }
#side-steps .snav .s-check { margin-left: auto; font-size: 13px; font-weight: 800; color: var(--teal); }
#side-steps .snav.active {
  background: var(--blue-soft); color: var(--ink);
  border-color: rgba(56, 189, 248, .35);
  box-shadow: inset 3px 0 0 var(--blue);
}
#side-steps .snav.done { color: var(--ink-2); }

.side-links { padding: 0 2px; }
.snav-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 12px; margin: 2px 0; border-radius: 12px;
  font-size: 15px; font-weight: 700; color: var(--ink-2);
  background: transparent; border: 1px solid transparent;
  text-decoration: none; cursor: pointer; font-family: inherit; text-align: left;
  transition: background .15s, color .15s;
}
.snav-link:hover { background: var(--surface); color: var(--ink); }
.snav-link[disabled] { opacity: .45; cursor: not-allowed; }
.snav-link span { font-size: 17px; width: 24px; text-align: center; flex: none; }

.privacy-badge {
  margin-top: 20px; padding: 14px;
  background: var(--good-soft); border: 1px solid rgba(47, 208, 138, .35);
  border-radius: var(--r-md);
}
.privacy-badge .pb-head { font-weight: 800; color: var(--good); font-size: 14px; margin-bottom: 8px; }
.privacy-badge ul { list-style: none; margin: 0; padding: 0; }
.privacy-badge li {
  position: relative; padding-left: 16px; margin: 5px 0;
  font-size: 12.5px; color: var(--ink-2); line-height: 1.45;
}
.privacy-badge li::before { content: "•"; position: absolute; left: 2px; color: var(--good); font-weight: 800; }

/* -------- Right rail: 即時檢測數據 ------------------------------------------ */
.rail-head {
  font-size: 15px; font-weight: 800; letter-spacing: .04em;
  padding: 2px 4px 12px; color: var(--ink);
}
.rail-head::before { content: "📈 "; }
.rail-card {
  background: linear-gradient(180deg, rgba(24, 44, 92, .30), rgba(13, 23, 48, .90)), var(--card);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px; margin-bottom: 12px;
}
.rc-top { display: flex; align-items: center; gap: 8px; }
.rc-i { font-size: 16px; }
.rc-k { font-size: 13px; font-weight: 800; color: var(--ink-2); letter-spacing: .02em; }
.rc-num { margin: 6px 0 2px; }
.rc-num b {
  font-size: 32px; font-weight: 800; color: var(--gold);
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
  text-shadow: 0 0 18px rgba(255, 212, 77, .22);
}
.rc-num b.good  { color: var(--good);  text-shadow: 0 0 18px rgba(47, 208, 138, .25); }
.rc-num b.warn  { color: var(--warn);  text-shadow: 0 0 18px rgba(245, 185, 62, .25); }
.rc-num b.alert { color: var(--alert); text-shadow: 0 0 18px rgba(247, 106, 106, .25); }
.rc-num small { color: var(--muted); font-size: 13px; font-weight: 700; margin-left: 4px; }

.spark { margin-left: auto; width: 92px; height: 28px; opacity: .9; }
.spark polyline { stroke: var(--blue); stroke-width: 2; }

/* tri-color measurement scale (良好 → 輕微延遲 → 明顯延遲) */
.scale {
  position: relative; height: 8px; border-radius: 99px; margin: 10px 0 6px;
  background: linear-gradient(90deg, #2fd08a 0 38%, #f5b93e 38% 72%, #f76a6a 72% 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25);
}
.scale i {
  position: absolute; top: 50%; left: 0%;
  width: 15px; height: 15px; border-radius: 99px;
  background: #fff; border: 3px solid var(--card);
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .55);
  transition: left .35s cubic-bezier(.22,.61,.36,1);
}
.scale-labs { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--muted); }

/* 綜合狀態 card */
.rail-card.assess { border-color: rgba(47, 208, 138, .30); }
.assess-row { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; }
.assess-face {
  width: 44px; height: 44px; border-radius: 99px; flex: none;
  background: var(--good-soft); border: 1px solid rgba(47, 208, 138, .4);
  display: grid; place-items: center; font-size: 24px;
}
#assess-label { font-size: 20px; font-weight: 800; color: var(--good); }
#assess-text { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.55; }

/* 趨勢變化 chart */
#trend-svg { width: 100%; height: auto; margin-top: 6px; }
#trend-svg polyline { stroke: var(--blue); stroke-width: 2.5; }
#trend-svg .dots circle { fill: var(--blue); stroke: var(--card); stroke-width: 2; }
#trend-svg .dots text { fill: var(--blue-dark); font-size: 10px; font-weight: 700; text-anchor: middle; }
#trend-svg .labs text { fill: var(--muted); font-size: 9px; text-anchor: middle; }
.rail-foot { margin: 8px 0 0; font-size: 11px; color: var(--muted); line-height: 1.4; }

/* Mobile: the rail stays hidden during tasks (focused flow) and appears with
   the result screen (綜合狀態 + 趨勢, without the live cards). */
@media (max-width: 1119.98px) {
  body[data-screen="s-result"] .rail { display: block; max-width: 640px; margin: 0 auto; padding: 0 18px 40px; }
  body[data-screen="s-result"] .rail #live-cards, body[data-screen="s-result"] .rail-head { display: none; }
}

/* ============================================================================
   Flow content
   ============================================================================ */
.card {
  background: linear-gradient(180deg, rgba(24, 44, 92, .35), rgba(13, 23, 48, .92)), var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 30px 26px; border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--btn-a), var(--blue), var(--teal));
  opacity: .9;
}
.screen { animation: rise .4s cubic-bezier(.22,.61,.36,1); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }

.eyebrow {
  display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .16em;
  text-transform: uppercase; color: var(--blue);
  background: var(--blue-soft); border: 1px solid rgba(56, 189, 248, .28);
  padding: 6px 13px; border-radius: 99px; margin-bottom: 14px;
}
.eyebrow.tasknum { color: var(--teal); background: var(--teal-soft); border-color: rgba(45, 212, 191, .3); }

h1 { font-size: 30px; margin: 0 0 10px; letter-spacing: .01em; line-height: 1.18; }
h2 { font-size: 24px; margin: 0 0 10px; letter-spacing: .01em; line-height: 1.22; }
h3 { font-size: 18px; margin: 0 0 8px; }
p.lead { font-size: 18px; color: var(--ink-2); margin: 0 0 24px; line-height: 1.6; }
p.lead.sm { font-size: 15px; margin-bottom: 14px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* footer tip (mockup: 小提醒) */
.task-tip {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 18px 0 0; padding: 12px 14px;
  background: var(--surface); border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--muted); line-height: 1.5;
}

/* -------- Welcome extras ---------------------------------------------------- */
.featurelist { list-style: none; padding: 0; margin: 0 0 22px; display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.featurelist li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 10px; text-align: center; }
.featurelist .fi { font-size: 26px; display: block; margin-bottom: 6px; }
.featurelist b { display: block; font-size: 15px; }
.featurelist small { color: var(--muted); font-size: 12px; }

/* -------- Callouts ---------------------------------------------------------- */
.note, .privacy, .suggest {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 16px; padding: 15px 17px; border-radius: var(--r-md);
  font-size: 14.5px; line-height: 1.55;
}
.callout-i { flex: none; font-size: 20px; line-height: 1.3; }
.note    { background: var(--warn-soft);  border: 1px solid rgba(245, 185, 62, .35);  color: var(--warn); }
.privacy { background: var(--good-soft);  border: 1px solid rgba(47, 208, 138, .35);  color: var(--good); }
.suggest { background: var(--blue-soft);  border: 1px solid rgba(56, 189, 248, .30);  color: var(--blue-dark); margin-top: 20px; }
.note b, .privacy b, .suggest b { color: inherit; }

/* -------- Consent + check tiles --------------------------------------------- */
.consent-row {
  display: flex; align-items: flex-start; gap: 12px; margin: 22px 0 18px;
  padding: 16px; border: 2px solid var(--line-strong); border-radius: var(--r-md);
  font-weight: 600; color: var(--ink); cursor: pointer; transition: border-color .15s, background .15s;
  background: var(--surface);
}
.consent-row:has(:checked) { border-color: var(--blue); background: var(--blue-soft); }
.consent-row input { width: 26px; height: 26px; margin-top: 1px; accent-color: var(--blue); flex: none; }
.check-tile {
  display: flex; align-items: center; gap: 12px; margin: 4px 0 20px;
  padding: 15px 16px; border: 2px solid var(--line-strong); border-radius: var(--r-md); cursor: pointer;
  transition: border-color .15s, background .15s;
  background: var(--surface);
}
.check-tile:has(:checked) { border-color: var(--blue); background: var(--blue-soft); }
.check-tile input { width: 24px; height: 24px; accent-color: var(--blue); flex: none; }
.check-tile b { display: block; font-size: 15.5px; }
.check-tile small { color: var(--muted); font-size: 13px; }

/* -------- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap); padding: 18px 22px; margin-top: 8px;
  font-size: 19px; font-weight: 800; font-family: inherit; color: #fff;
  background: linear-gradient(135deg, var(--btn-a), var(--btn-b));
  border: 0; border-radius: 14px; cursor: pointer;
  transition: transform .08s, filter .2s, box-shadow .2s;
  box-shadow: 0 8px 24px rgba(29, 111, 224, .40);
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; filter: grayscale(.35); }
.btn.secondary { background: var(--surface-2); color: var(--ink); box-shadow: none; border: 1px solid var(--line-strong); }
.btn.secondary:hover { filter: brightness(1.15); background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; font-weight: 700; }
.btn.ghost:hover { filter: none; color: var(--ink); background: var(--surface); }
.btn.lg { padding: 21px; font-size: 21px; }
.btn-row { display: flex; gap: 12px; }
.btn-row .btn { flex: 1; }

/* -------- Forms ------------------------------------------------------------- */
label.field { display: block; margin: 0 0 18px; font-weight: 700; font-size: 15px; color: var(--ink); }
input[type=text], input[type=password], select {
  width: 100%; margin-top: 8px; padding: 16px; font-size: 18px; color: var(--ink);
  font-family: inherit; min-height: var(--tap);
  border: 2px solid var(--line-strong); border-radius: 12px; background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]::placeholder, input[type=password]::placeholder { color: var(--muted); opacity: .75; }
input:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
input[type=checkbox] { accent-color: var(--blue); }

/* -------- Progress bar ------------------------------------------------------ */
.progress { height: 12px; background: var(--surface-2); border-radius: 99px; margin: 0 0 14px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--btn-a), var(--blue)); transition: width .4s ease; box-shadow: 0 0 10px rgba(56, 189, 248, .5); }

/* -------- Pills ------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 99px; font-size: 15px; font-weight: 800; border: 1px solid transparent; }
.pill::before { content: "●"; font-size: 10px; }
.pill.good  { background: var(--good-soft);  color: var(--good);      border-color: rgba(47, 208, 138, .40); }
.pill.warn  { background: var(--warn-soft);  color: var(--warn);      border-color: rgba(245, 185, 62, .40); }
.pill.alert { background: var(--alert-soft); color: var(--alert);     border-color: rgba(247, 106, 106, .40); }
.pill.info  { background: var(--blue-soft);  color: var(--blue-dark); border-color: rgba(56, 189, 248, .35); }

/* -------- Checklist --------------------------------------------------------- */
ul.checklist { list-style: none; padding: 0; margin: 20px 0; }
ul.checklist li { display: flex; align-items: center; gap: 12px; padding: 15px 4px; border-bottom: 1px dashed var(--line); font-size: 17px; }
ul.checklist li:last-child { border-bottom: 0; }
ul.checklist li .dot { width: 30px; height: 30px; border-radius: 99px; display: grid; place-items: center; font-size: 16px; background: var(--surface-2); color: var(--muted); flex: none; font-weight: 800; }
ul.checklist li .dot.ok  { background: var(--good-soft);  color: var(--good); }
ul.checklist li .dot.bad { background: var(--alert-soft); color: var(--alert); }
ul.checklist li .dot.run { background: var(--blue-soft);  color: var(--blue); }

/* -------- Task stage -------------------------------------------------------- */
.stage {
  position: relative; height: 330px; border-radius: 18px;
  background: radial-gradient(circle at 50% 38%, #14224a, var(--stage) 78%);
  display: grid; place-items: center; user-select: none; -webkit-user-select: none;
  cursor: pointer; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(96, 158, 255, .18), var(--shadow-sm);
}
.stage .hint { color: #c9d6ee; font-size: 18px; text-align: center; padding: 0 24px; line-height: 1.5; }
.target { width: 134px; height: 134px; border-radius: 99px; background: radial-gradient(circle at 35% 30%, #86efac, #16a34a); box-shadow: 0 0 60px rgba(74,222,128,.8); animation: pop .2s ease; }
@keyframes pop { from { transform: scale(.3); opacity: .2; } to { transform: scale(1); opacity: 1; } }
.imgcard { font-size: 116px; line-height: 1; animation: pop .2s ease; filter: drop-shadow(0 10px 20px rgba(0,0,0,.4)); }
.attn-target { position: absolute; width: 88px; height: 88px; border-radius: 99px; background: radial-gradient(circle at 35% 30%, #86efac, #16a34a); box-shadow: 0 0 40px rgba(74,222,128,.8); animation: pop .18s ease; transform: translate(-50%,-50%); cursor: pointer; }
.taskmeta { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; font-weight: 600; margin: 16px 2px 0; min-height: 38px; }
.chip-count { background: var(--surface-2); color: var(--ink-2); padding: 6px 14px; border-radius: 99px; font-weight: 800; font-size: 14px; border: 1px solid var(--line); font-variant-numeric: tabular-nums; flex: none; }
/* live measurement note — neutral pill; a successful measurement (is-hit,
   set by app.js) turns it into the green detection banner from the mockup */
.live-note:not(:empty) {
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line-strong);
  padding: 7px 14px; border-radius: 10px;
  font-weight: 800; font-size: 14.5px;
  font-variant-numeric: tabular-nums;
}
.live-note.is-hit:not(:empty) {
  background: var(--good-soft); color: var(--good);
  border-color: rgba(47, 208, 138, .35);
}
.live-note.is-hit:not(:empty)::before { content: "✓ "; }
.flash { position: absolute; inset: 0; background: #22c55e; opacity: 0; pointer-events: none; }
.flash.hit { animation: flash .3s ease; }
.flash.miss { background: #ef4444; animation: flash .3s ease; }
@keyframes flash { 0% { opacity: .4; } 100% { opacity: 0; } }

/* -------- Camera ------------------------------------------------------------ */
.camwrap { position: relative; border-radius: 18px; overflow: hidden; background: var(--stage); aspect-ratio: 4/3; box-shadow: inset 0 0 0 1px rgba(96, 158, 255, .18), var(--shadow-sm); }
video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camwrap .overlay { position: absolute; left: 12px; bottom: 12px; background: rgba(6,10,20,.78); border: 1px solid var(--line); color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.camwrap .rec { position: absolute; right: 12px; top: 12px; color: #fff; font-size: 12px; font-weight: 700; display: flex; gap: 6px; align-items: center; background: rgba(6,10,20,.6); border: 1px solid var(--line); padding: 5px 10px; border-radius: 99px; }
.camwrap .rec i { width: 9px; height: 9px; border-radius: 99px; background: var(--good); box-shadow: 0 0 6px var(--good); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* -------- Drawing ----------------------------------------------------------- */
.canvas-frame { display: grid; place-items: center; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
#draw-canvas { width: 100%; max-width: 300px; height: auto; aspect-ratio: 1; background: var(--stage); border: 2px dashed var(--line-strong); border-radius: 14px; touch-action: none; }

/* -------- Result: hero gauge ------------------------------------------------ */
.result-hero { display: flex; align-items: center; gap: 20px; margin: 8px 0 22px; }
.gauge {
  --val: 0; flex: none; width: 150px; height: 150px; border-radius: 99px; display: grid; place-items: center;
  background:
    radial-gradient(closest-side, var(--card) 76%, transparent 77%),
    conic-gradient(var(--gauge-c, var(--blue)) calc(var(--val) * 1%), var(--surface-2) 0);
  box-shadow: var(--shadow-sm), 0 0 24px rgba(56, 189, 248, .18);
  transition: background .1s;
}
.gauge.good  { --gauge-c: var(--good); }
.gauge.warn  { --gauge-c: var(--warn); }
.gauge.alert { --gauge-c: var(--alert); }
.gauge.info  { --gauge-c: var(--blue); }
.gauge-inner { text-align: center; }
.gauge .num { font-size: 46px; font-weight: 800; line-height: 1; color: var(--gold) !important; letter-spacing: .01em; font-variant-numeric: tabular-nums; text-shadow: 0 0 22px rgba(255, 212, 77, .30); }
.gauge .lab { font-size: 12.5px; font-weight: 700; color: var(--muted); margin-top: 3px; }
.result-verdict { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.result-verdict .muted { font-size: 14.5px; line-height: 1.5; margin: 0; }

/* -------- Result: metrics --------------------------------------------------- */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 20px 0; }
.metric { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.metric-i { position: absolute; top: 14px; right: 14px; font-size: 18px; opacity: .8; }
.metric .k { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric .v { font-size: 28px; font-weight: 800; color: var(--ink); margin-top: 2px; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.metric .v.sm { font-size: 19px; }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); margin-top: 10px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--btn-a), var(--blue)); transition: width .6s cubic-bezier(.22,.61,.36,1); }

/* -------- Result: PBM + disclaimer ------------------------------------------ */
.pbm-card { margin-top: 20px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.pbm-card h3 { margin-top: 0; }
.disclaimer { margin-top: 22px; font-size: 13px; color: var(--muted); line-height: 1.55; padding: 15px; background: var(--surface); border-radius: var(--r-sm); border: 1px solid var(--line); }
.model-line { margin-top: 8px; font-size: 12px; opacity: .85; }

.spinner { width: 50px; height: 50px; border: 5px solid var(--surface-2); border-top-color: var(--blue); border-radius: 99px; animation: spin 1s linear infinite; margin: 28px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* -------- Dialog ------------------------------------------------------------ */
.qr-dialog { border: 1px solid var(--line-strong); border-radius: 18px; padding: 24px; max-width: 360px; width: calc(100% - 32px); box-shadow: var(--shadow-lg); color: var(--ink); background: var(--card); }
.qr-dialog::backdrop { background: rgba(4, 8, 18, .7); backdrop-filter: blur(3px); }
.dlg-title { margin: 0 0 8px; font-size: 20px; }
.qr-img-wrap { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 12px; }
.qr-img-wrap img { width: 220px; height: 220px; image-rendering: pixelated; }
.qr-url { margin-top: 12px; text-align: center; font-size: 14px; word-break: break-all; color: var(--muted); background: var(--surface); border-radius: 8px; padding: 10px 12px; }

/* ============================================================================
   Responsive (narrow phones)
   ============================================================================ */
@media (max-width: 640px) {
  .kpi-chip .kpi-lab { display: none; }
  .kpi-chip { padding: 4px; border: 0; background: transparent; }
  #kpi-last { display: none !important; }
  .user-chip .uc-txt small { display: none; }
  .user-chip .uc-txt b { white-space: nowrap; }
  .brand small { display: none; }
}
@media (max-width: 400px) {
  .wrap { padding-left: 14px; padding-right: 14px; }
  .card { padding: 24px 18px; }
  h1 { font-size: 26px; }
  .result-hero { flex-direction: column; text-align: center; }
  .result-verdict { align-items: center; }
  .featurelist { gap: 8px; }
  .featurelist li { padding: 12px 6px; }
  .iconbtn-t { display: none; }
  .steprail .step .slab { font-size: 10.5px; }
  .user-chip { display: none; }
}
@media (min-width: 640px) { .card { padding: 36px 34px; } h1 { font-size: 34px; } }

/* -------- Preference layers ------------------------------------------------- */
@media (prefers-contrast: more) {
  :root {
    --muted: #c9d6ee; --ink-2: #dde7f7;
    --line: rgba(140, 176, 255, .45); --line-strong: rgba(160, 196, 255, .7);
  }
  .card, .metric, input[type=text], input[type=password], select { border-width: 2px; }
  .btn { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .camwrap .rec i { animation: none; opacity: 1; }
}
