/* Kuji — big type, big buttons, cute but quiet. Palette carried over from the 錦囊 prototype. */
:root {
  --bg: #F3F7F5; --card: #FFFFFF; --ink: #1B2826; --muted: #56645F; --line: #D3E0DA;
  --jade: #1F6F5C; --jade-soft: #DCEFE7; --mustard: #E3A92B; --mustard-ink: #3B2A05; --mustard-soft: #FCF0D2;
  --red: #B93A2B; --red-soft: #FBE3DF; --shade: rgba(18, 24, 22, .5);
  --sans: "PingFang HK", "Noto Sans HK", "Noto Sans CJK TC", "Microsoft JhengHei", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121816; --card: #1C2422; --ink: #ECF2EF; --muted: #A9B6B2; --line: #2F3D39;
    --jade: #66C6A8; --jade-soft: #1D332D; --mustard: #EDB94F; --mustard-ink: #2A1E03; --mustard-soft: #3A311F;
    --red: #F0897C; --red-soft: #3E2623; --shade: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121816; --card: #1C2422; --ink: #ECF2EF; --muted: #A9B6B2; --line: #2F3D39;
  --jade: #66C6A8; --jade-soft: #1D332D; --mustard: #EDB94F; --mustard-ink: #2A1E03; --mustard-soft: #3A311F;
  --red: #F0897C; --red-soft: #3E2623; --shade: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 18px; line-height: 1.6; overflow-x: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid var(--mustard); outline-offset: 3px; }
[hidden] { display: none !important; }
svg { display: block; width: 100%; height: 100%; }
.mascot, .av, .hint-icon, .sheet-icon { display: block; }

.screen { min-height: 100dvh; padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px); }

/* ---------- start & done ---------- */
.start-inner { max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; text-align: center; }
.mascot { width: 96px; height: 96px; }
h1 { font-size: clamp(30px, 6vw, 42px); font-weight: 900; margin: 6px 0 2px; line-height: 1.2; }
.sub { color: var(--muted); margin: 0 0 22px; }
.label { font-size: 19px; font-weight: 800; margin: 14px 0 10px; }
.who { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 480px; }
.who button { background: var(--card); border: 3px solid var(--line); border-radius: 20px; padding: 10px 6px 8px; font-weight: 800; font-size: 17px; }
.who button .av { width: 72px; height: 72px; margin: 0 auto 2px; }
.who button[aria-checked="true"] { border-color: var(--jade); background: var(--jade-soft); }
.asked-note { font-size: 15px; color: var(--muted); margin: 10px 0 0; }
.link { background: none; border: 0; color: var(--jade); font-weight: 700; text-decoration: underline; padding: 0 4px; }
.mins { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.mins button { background: var(--card); border: 3px solid var(--line); border-radius: 999px; padding: 8px 20px; font-weight: 800; }
.mins button[aria-checked="true"] { border-color: var(--jade); background: var(--jade); color: #fff; }
.consent { display: flex; gap: 12px; align-items: flex-start; text-align: left; margin: 26px 0 16px; background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; font-size: 16px; max-width: 520px; }
.consent input { width: 26px; height: 26px; flex: none; margin: 2px 0 0; accent-color: var(--jade); }
.go { background: var(--jade); color: #fff; border: 0; border-radius: 999px; padding: 16px 52px; font-size: 22px; font-weight: 900; }
.fine { font-size: 14px; color: var(--muted); max-width: 520px; text-align: left; margin: 18px 0 0; padding-left: 20px; }
.fine li { margin-bottom: 4px; }

/* ---------- interview: child's side + test panel ---------- */
.session { height: 100dvh; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 40%); overflow: hidden; }
.session.no-panel { grid-template-columns: minmax(0, 1fr); }
.kid { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: calc(env(safe-area-inset-top, 0px) + 16px) 0 calc(env(safe-area-inset-bottom, 0px) + 16px); }
.bar { display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.time { flex: 1; min-width: 0; max-width: 360px; }
.track { height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--jade); border-radius: 99px; transition: width 1s linear, background .6s; }
.fill.late { background: var(--mustard); }
.fill.over { background: var(--red); }
.time-text { font-size: 14px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }
.rec { color: var(--red); font-weight: 700; }
.chip { background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 15px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.chip.danger { color: var(--red); border-color: var(--red-soft); }

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; padding: 0 16px; }
.orb-wrap { width: min(58vw, 42dvh, 320px); aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.orb { --level: 0; width: 100%; height: 100%; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #9FE0C8 0, transparent 55%), radial-gradient(circle at 70% 35%, #FFD27A 0, transparent 50%),
              radial-gradient(circle at 60% 75%, #FFA3B5 0, transparent 52%), radial-gradient(circle at 30% 72%, #9CC9F0 0, transparent 55%), #CDEBDD;
  transform: scale(calc(1 + var(--level) * .28)); animation: spin 18s linear infinite, breathe 4.5s ease-in-out infinite; }
@keyframes spin { to { rotate: 360deg; } }
@keyframes breathe { 50% { scale: 1.05; } }
.status { margin: 24px 0 0; color: var(--muted); font-size: 17px; text-align: center; max-width: 30em; min-height: 3.4em; }
.status b { color: var(--ink); }
.hint-btn { align-self: center; margin: 0 16px 6px; background: var(--mustard); color: var(--mustard-ink); border: 0; border-radius: 999px; font-size: 24px; font-weight: 900; padding: 16px 44px 16px 28px; display: flex; align-items: center; gap: 12px; box-shadow: 0 4px 0 rgba(0, 0, 0, .12); }
.hint-icon { width: 44px; height: 44px; flex: none; }

/* hint sheet */
.overlay { position: absolute; inset: 0; background: var(--shade); display: flex; align-items: flex-end; justify-content: center; z-index: 10; padding: 16px 16px calc(env(safe-area-inset-bottom, 0px) + 16px); }
.sheet { background: var(--card); border-radius: 26px; padding: 18px; width: 100%; max-width: 600px; max-height: 100%; overflow-y: auto; animation: up .22s ease; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-icon { width: 52px; height: 52px; flex: none; }
.sheet h2 { margin: 0; font-size: 20px; }
.card { display: grid; grid-template-columns: 88px minmax(0, 1fr); width: 100%; text-align: left; border: 3px solid var(--line); border-radius: 18px; background: var(--bg); padding: 0; margin-bottom: 10px; overflow: hidden; }
.card:hover { border-color: var(--jade); }
.card .pg { background: var(--jade); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 4px; text-align: center; }
.card .pg b { font-size: 28px; font-weight: 900; line-height: 1; }
.card .pg span { font-size: 13px; margin-top: 4px; line-height: 1.3; }
.card .q { padding: 12px 14px; font-size: 20px; font-weight: 800; line-height: 1.45; }
.card .q small { display: block; font-weight: 500; color: var(--muted); font-size: 14px; margin-top: 4px; }
.card.gentle { border-color: var(--red-soft); background: var(--red-soft); }
.card.gentle .pg { background: var(--red); }
.thinking { padding: 22px 6px; color: var(--muted); text-align: center; }
.skip { display: block; margin: 4px auto 0; background: none; border: 0; color: var(--muted); font-size: 17px; padding: 8px 14px; }

/* transcript drawer */
.lines { overflow-y: auto; flex: 1; min-height: 80px; }
.ln { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px; padding: 6px 0; font-size: 16px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.ln time { color: var(--muted); font-size: 13px; padding-top: 3px; }
.ln.wake span { background: var(--mustard-soft); border-radius: 6px; padding: 0 4px; }
.ln.hint span { color: var(--jade); font-weight: 700; }
.ln.live span { color: var(--muted); font-style: italic; }
.empty { color: var(--muted); font-size: 15px; padding: 10px 0; }
.health { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; font-size: 14px; margin: 10px 0 0; padding-top: 10px; border-top: 2px dashed var(--line); color: var(--muted); }
.health dt { font-weight: 700; }
.health dd { margin: 0; }
.row { display: flex; gap: 6px; margin-bottom: 6px; }
.row input { flex: 1; min-width: 0; border: 2px solid var(--line); border-radius: 999px; padding: 7px 14px; background: var(--bg); }

/* done */
.nums { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; margin: 6px 0 8px; }
.nums b { display: block; font-size: 36px; font-weight: 900; line-height: 1.1; }
.nums span { font-size: 14px; color: var(--muted); }
.asked-list { text-align: left; max-width: 520px; margin: 0 0 18px; padding-left: 26px; font-size: 17px; }
.asked-list li { margin-bottom: 4px; }
.asked-list small { color: var(--muted); }
.premium { max-width: 520px; border: 3px dashed var(--mustard); border-radius: 18px; padding: 14px 16px; text-align: left; margin: 0 0 18px; background: var(--mustard-soft); }
.premium p { margin: 2px 0 0; font-size: 15px; color: var(--muted); }
.done-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 20px; }

.toast { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 70px); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 16px; font-size: 16px; z-index: 30; max-width: calc(100% - 32px); text-align: center; }

.code-box { margin: 18px 0 0; background: var(--mustard-soft); border-radius: 14px; padding: 10px 14px; max-width: 520px; text-align: left; font-size: 15px; }
.code-box input { flex: 1; min-width: 0; border: 2px solid var(--line); border-radius: 999px; padding: 6px 12px; background: var(--card); }
.settings select { border: 2px solid var(--line); border-radius: 8px; padding: 3px 6px; background: var(--bg); max-width: 100%; }

/* chapter choice (start) and chapter box (interview) */
.chapters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 560px; }
.chapters button { background: var(--card); border: 3px solid var(--line); border-radius: 18px; padding: 10px 12px; text-align: left; }
.chapters button b { display: block; font-size: 18px; }
.chapters button span { display: block; font-size: 14px; color: var(--muted); line-height: 1.4; }
.chapters button[aria-checked="true"] { border-color: var(--jade); background: var(--jade-soft); }
.chapter-box { margin: 10px 16px 0; background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 10px 14px; }
.chapter-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chapter-box h2 { margin: 0; font-size: 20px; }
.photo-step { display: flex; align-items: center; gap: 8px; }
.photo-step b { font-size: 17px; }
.openers-title { margin: 4px 0; color: var(--muted); font-size: 15px; }
.openers { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.openers button { width: 100%; display: flex; gap: 10px; align-items: center; text-align: left; background: var(--bg); border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; font-size: 19px; font-weight: 700; }
.openers button .tick { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); display: grid; place-items: center; font-size: 16px; color: #fff; }
.openers button[aria-pressed="true"] { color: var(--muted); }
.openers button[aria-pressed="true"] .tick { background: var(--jade); border-color: var(--jade); }
.chapter-box + .stage .orb-wrap { width: min(40vw, 26dvh, 240px); }
.card .pg b.topic { font-size: 18px; }

/* test panel */
.panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--card); border-left: 2px solid var(--line); font-size: 14px; line-height: 1.5; }
.panel-head { padding: 12px 14px 6px; }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-sum { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; padding: 0 10px; border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 10px; font-weight: 700; color: var(--muted); font-size: 14px; margin-bottom: -2px; }
.tabs button[aria-selected="true"] { color: var(--jade); border-bottom-color: var(--jade); }
.tab { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 14px 20px; }
#tab-live:not([hidden]) { display: flex; flex-direction: column; }
#tab-live .lines { flex: 1; min-height: 160px; }
.tab h3 { font-size: 14px; margin: 12px 0 6px; color: var(--ink); }
.tab h3 small { color: var(--muted); font-weight: 400; }
.lines { overflow-y: auto; }
.ln { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.ln time { color: var(--muted); font-size: 12px; padding-top: 2px; }
.ln.wake span { background: var(--mustard-soft); border-radius: 4px; padding: 0 3px; }
.ln.wakerow span { color: #8a5a00; font-weight: 700; }
.ln.hintrow span { color: var(--jade); font-weight: 700; }
.ln.live span { color: var(--muted); font-style: italic; }
.tag { font-style: normal; font-size: 12px; margin-left: 6px; padding: 0 6px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--jade-soft); color: var(--jade); }
.empty { color: var(--muted); padding: 6px 0; margin: 0; }
.dec { border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; background: var(--bg); }
.dec header { font-weight: 700; margin-bottom: 2px; }
.dec p { margin: 2px 0; }
.dec details { margin: 2px 0; }
.dec .seg { background: var(--card); border-radius: 8px; padding: 6px 8px; white-space: pre-wrap; }
.dec .warn { color: var(--red); font-weight: 700; }
.cards-shown { margin: 4px 0; padding-left: 20px; }
.cards-shown li.gentle { color: var(--red); }
.cards-shown small { color: var(--muted); margin-left: 4px; }
.outcome { font-weight: 700; }
.rank { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
.rank th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 2px 4px; }
.rank td { border-bottom: 1px solid var(--line); padding: 3px 4px; vertical-align: top; }
.rank td.q small { display: block; color: var(--muted); }
.rank td.num { white-space: nowrap; text-align: right; }
.rank tr.shown td { background: var(--mustard-soft); }
.rank .badge { font-weight: 700; color: var(--jade); white-space: nowrap; }
.pbar { display: inline-block; width: 48px; height: 6px; background: var(--line); border-radius: 99px; margin-right: 4px; vertical-align: middle; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--jade); }
.more { font-size: 13px; margin-top: 4px; }
.bank-sum { margin: 0 0 8px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.filters button { background: var(--bg); border: 2px solid var(--line); border-radius: 99px; padding: 2px 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.filters button[aria-pressed="true"] { border-color: var(--jade); color: var(--jade); }
.filters input { flex: 1; min-width: 120px; border: 2px solid var(--line); border-radius: 99px; padding: 2px 10px; background: var(--bg); font-size: 13px; }
.chapter h4 { margin: 12px 0 4px; font-size: 14px; }
.chapter h4 small { color: var(--muted); font-weight: 400; }
.qrow { display: grid; grid-template-columns: 74px 44px 40px minmax(0, 1fr) 56px; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line); align-items: start; }
.qrow.follow .q { padding-left: 12px; }
.qrow.shown { background: var(--mustard-soft); }
.qrow .q small { display: block; color: var(--muted); font-size: 12px; }
.qrow .num { text-align: right; font-size: 12px; }
.qrow .num small, .qrow .num b { display: block; }
.qrow .id, .qrow .pg { color: var(--muted); font-size: 12px; }
.st { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 0 4px; }
.st-cand { color: var(--jade); }
.st-asked { color: #fff; background: var(--jade); }
.st-off { color: var(--muted); }
.st-wait { color: #8a5a00; }
.st-open { color: var(--mustard-ink); background: var(--mustard-soft); }
.settings { display: grid; gap: 8px; }
.settings label { display: grid; gap: 2px; font-weight: 600; }
.settings label:has(input[type="checkbox"]) { display: flex; gap: 8px; align-items: center; }
.settings input[type="number"] { width: 120px; border: 2px solid var(--line); border-radius: 8px; padding: 3px 8px; background: var(--bg); }
.settings small { color: var(--muted); font-weight: 400; }
.hint-text { color: var(--muted); margin: 0 0 6px; }
.lines.small { max-height: 260px; }
.share { background: var(--mustard-soft); border-radius: 10px; padding: 6px 8px; }
.test-badge { font-size: 13px; color: var(--muted); background: var(--mustard-soft); border-radius: 10px; padding: 6px 10px; max-width: 520px; margin-top: 10px; }

@media (max-width: 900px) {
  .session { height: auto; display: block; overflow: visible; }
  /* phones: the child's side may scroll; the hint button stays reachable and the sheet sits on the screen's bottom */
  .kid { height: auto; min-height: 100dvh; }
  .stage { flex: none; padding: 10px 16px; }
  .hint-btn { position: sticky; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); z-index: 5; }
  .overlay { position: fixed; }
  .panel { border-left: 0; border-top: 2px solid var(--line); max-height: none; }
  .tab { overflow: visible; }
}

@media (max-width: 600px) {
  /* test panel on a phone: bigger type, rows that wrap instead of narrow columns */
  .panel { font-size: 15px; }
  .panel-sum, .tag, .ln time, .qrow .q small, .rank td.q small { font-size: 13px; }
  .tabs button { font-size: 15px; padding: 10px 10px; }
  .rank th:nth-child(2), .rank td:nth-child(2) { display: none; }
  .rank td, .rank th { padding: 4px 3px; }
  .pbar { width: 32px; }
  .qrow { grid-template-columns: auto auto 1fr auto; grid-template-areas: "st id pg num" "q q q q"; row-gap: 2px; }
  .qrow .st { grid-area: st; } .qrow .id { grid-area: id; } .qrow .pg { grid-area: pg; } .qrow .num { grid-area: num; }
  .qrow .q { grid-area: q; font-size: 16px; }
  .qrow.follow .q { padding-left: 14px; }
  .settings input[type="number"], .settings select { font-size: 16px; }
  .settings label:has(input[type="checkbox"]) input { width: 22px; height: 22px; }
  .openers button { font-size: 16px; padding: 6px 10px; }
  .openers button .tick { width: 22px; height: 22px; }
  .chapter-box { margin: 8px 12px 0; padding: 8px 10px; }
  .chapter-box h2 { font-size: 18px; }
  .chapter-box + .stage .orb-wrap { width: min(30vw, 120px); }
  .status { font-size: 15px; margin-top: 8px; min-height: 0; }
  .chapters { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 420px) {
  .who { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .who button { font-size: 15px; padding: 8px 2px 6px; }
  .who button .av { width: 60px; height: 60px; }
  .hint-btn { font-size: 21px; padding: 14px 32px 14px 22px; }
  .card { grid-template-columns: 74px minmax(0, 1fr); }
  .card .q { font-size: 18px; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .status { margin-top: 10px; min-height: 0; }
  .hint-btn { padding: 10px 34px 10px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; transform: none; filter: brightness(calc(1 + var(--level) * .35)); }
  .sheet { animation: none; }
  .fill { transition: none; }
}
