@font-face { font-family: 'OpenDyslexic'; src: url('../fonts/opendyslexic-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'OpenDyslexic'; src: url('../fonts/opendyslexic-700.woff2') format('woff2'); font-weight: 500 700; font-display: swap; }
/* SOC Storybook: calm pop-up paper aesthetic, accessibility first */
:root {
  --text-xs: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  --text-sm: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --text-base: clamp(1.0625rem, 1rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem; --space-5: 1.25rem;
  --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem; --space-16: 4rem;
  --radius-sm: 10px; --radius: 16px; --radius-lg: 24px; --radius-full: 999px;
  --font-body: 'Lexend', 'Atkinson Hyperlegible', system-ui, sans-serif;
  --font-display: 'Chillax', 'Lexend', system-ui, sans-serif;
  --lh: 1.65; --ls: 0.01em; --ws: 0.04em;
  --ease: cubic-bezier(.2,.8,.2,1);
  --tap: 52px;
  --fs-scale: 1;
  --water: #2F7F8C; --water-soft: #DDEFF0;
  --earth: #5E7D3F; --earth-soft: #E5EDD9;
  --fire: #B85E2E; --fire-soft: #F7E3D5;
  --air: #7A69AE; --air-soft: #ECE7F6;
}
:root, [data-theme="light"] {
  --bg: #F7F0E3; --surface: #FFFBF3; --surface-2: #F2E9D8; --surface-3: #EAE0CC;
  --ink: #2C2838; --muted: #625C6E; --faint: #8E8798; --border: #E2D6C0; --border-strong: #CDBFA5;
  --primary: #2B6A6E; --primary-hover: #215559; --primary-ink: #FFFFFF; --primary-soft: #D9ECEA;
  --good: #3D7A4F; --good-soft: #E1F0E2; --gentle: #9A6B12; --gentle-soft: #F8ECCF;
  --shadow-paper: 0 1px 0 rgba(120,95,60,.10), 0 6px 14px -6px rgba(90,70,40,.22);
  --shadow-lift: 0 2px 0 rgba(120,95,60,.12), 0 14px 28px -12px rgba(90,70,40,.32);
  --tint: transparent;
}
[data-theme="dark"] {
  --bg: #1C1A23; --surface: #262330; --surface-2: #2F2B3A; --surface-3: #383344;
  --ink: #EFE8DA; --muted: #B9B1C2; --faint: #8F879B; --border: #3B3647; --border-strong: #4C465A;
  --primary: #7CC4C3; --primary-hover: #95D3D2; --primary-ink: #13272A; --primary-soft: #23383B;
  --good: #8ACB98; --good-soft: #233629; --gentle: #E7C27A; --gentle-soft: #3A3122;
  --water: #7BC3CD; --water-soft: #20343A; --earth: #A9C68A; --earth-soft: #283224;
  --fire: #EBA27A; --fire-soft: #3B2A22; --air: #BBAEE6; --air-soft: #2D2840;
  --shadow-paper: 0 1px 0 rgba(0,0,0,.3), 0 6px 14px -6px rgba(0,0,0,.5);
  --shadow-lift: 0 2px 0 rgba(0,0,0,.35), 0 14px 28px -12px rgba(0,0,0,.6);
}
[data-tint="peach"] { --bg: #F9E7DA; --surface: #FFF5EE; }
[data-tint="mint"]  { --bg: #E4F0E2; --surface: #F6FBF4; }
[data-tint="blue"]  { --bg: #E2ECF5; --surface: #F5F9FD; }
[data-tint="grey"]  { --bg: #E9E8E6; --surface: #F8F7F5; }
[data-font="atkinson"] { --font-body: 'Atkinson Hyperlegible', 'Lexend', system-ui, sans-serif; --font-display: 'Atkinson Hyperlegible', system-ui, sans-serif; }
[data-font="dyslexic"] { --ls: 0; --ws: 0.02em; --font-body: 'OpenDyslexic', 'Lexend', system-ui, sans-serif; --font-display: 'OpenDyslexic', 'Lexend', system-ui, sans-serif; }
[data-font="dyslexic"] body { font-size: calc(var(--text-base) * .92); }
[data-font="dyslexic"] .topbar-title, [data-font="dyslexic"] .h-display { font-weight: 400; }
[data-spacing="wide"] { --lh: 1.9; --ls: 0.04em; --ws: 0.12em; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: calc(100% * var(--fs-scale)); }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: var(--text-base); line-height: var(--lh);
  letter-spacing: var(--ls); word-spacing: var(--ws);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  background-image: radial-gradient(rgba(140,110,60,.05) 1px, transparent 1px);
  background-size: 6px 6px;
}
[data-theme="dark"] body { background-image: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 8px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: var(--space-2) var(--space-4); z-index: 99; }
.skip:focus { left: var(--space-2); top: var(--space-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
@media (min-width: 700px) {
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); background: color-mix(in oklab, var(--bg) 70%, var(--surface)); }
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--space-2);
  padding: calc(env(safe-area-inset-top) + var(--space-3)) var(--space-4) var(--space-3);
  background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-title { flex: 1; margin: 0; font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); letter-spacing: 0; line-height: 1.2; }
.icon-btn {
  width: var(--tap); height: var(--tap); min-width: var(--tap); display: grid; place-items: center;
  border-radius: var(--radius-full); border: 1.5px solid var(--border); background: var(--surface); color: var(--ink);
  transition: background .2s var(--ease), transform .15s var(--ease);
}
.icon-btn:active { transform: scale(.94); }
.voice-toggle .vo-on { display: none; }
.voice-toggle[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.voice-toggle[aria-pressed="true"] .vo-on { display: block; }
.voice-toggle[aria-pressed="true"] .vo-off { display: none; }

.main { flex: 1; padding: var(--space-2) var(--space-4) calc(110px + env(safe-area-inset-bottom)); outline: none; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 520px; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr);
  padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px -16px rgba(60,40,20,.25);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 58px; justify-content: center;
  border: 0; background: transparent; color: var(--muted); border-radius: var(--radius); font-size: var(--text-xs); font-weight: 500;
}
.tab svg { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }
.app.focus-mode .tabbar { display: none; }
.app.focus-mode .main { padding-bottom: calc(var(--space-8) + env(safe-area-inset-bottom)); }

/* Typography helpers */
h2, h3 { margin: 0; line-height: 1.25; letter-spacing: 0; }
.h-display { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); }
.h-section { font-weight: 600; font-size: var(--text-lg); }
.eyebrow { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
p { margin: 0 0 var(--space-3); max-width: 62ch; }
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.section { margin-top: var(--space-8); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--space-3); gap: var(--space-3); }

/* Paper cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-5); box-shadow: var(--shadow-paper); position: relative;
}
.card.tight { padding: var(--space-4); }
.card.flat { box-shadow: none; }
.card-btn { width: 100%; text-align: left; display: block; color: inherit; transition: transform .18s var(--ease), box-shadow .18s var(--ease); }
.card-btn:active { transform: translateY(1px) scale(.995); }
@media (hover:hover) { .card-btn:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); } }
.paper-layer { position: relative; }
.paper-layer::after {
  content: ""; position: absolute; inset: 6px -5px -6px 5px; border-radius: var(--radius-lg);
  background: var(--surface-2); border: 1px solid var(--border); z-index: -1;
}

/* Buttons */
.btn {
  min-height: var(--tap); padding: 0 var(--space-6); border-radius: var(--radius-full); border: 1.5px solid transparent;
  font-weight: 600; font-size: var(--text-sm); display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  transition: background .2s var(--ease), transform .15s var(--ease), border-color .2s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
@media (hover:hover) { .btn-primary:hover { background: var(--primary-hover); } }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-block { width: 100%; }
.btn-lg { min-height: 60px; font-size: var(--text-base); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; }

/* Chips and pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600; background: var(--surface-2); color: var(--muted); letter-spacing: .02em; }
.pill.water { background: var(--water-soft); color: var(--water); }
.pill.earth { background: var(--earth-soft); color: var(--earth); }
.pill.fire  { background: var(--fire-soft);  color: var(--fire); }
.pill.air   { background: var(--air-soft);   color: var(--air); }
.pill.build { background: var(--gentle-soft); color: var(--gentle); }
.pill.good  { background: var(--good-soft); color: var(--good); }

/* Hero / Today */
.hero { border-radius: var(--radius-lg); overflow: hidden; position: relative; border: 1px solid var(--border); box-shadow: var(--shadow-paper); background: var(--surface); }
.hero img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; object-position: center 60%; }
.hero-body { padding: var(--space-4) var(--space-5) var(--space-5); display: flex; gap: var(--space-4); align-items: center; }
.countdown { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 84px; padding: var(--space-2) var(--space-3); border-radius: var(--radius); background: var(--primary-soft); color: var(--primary); }
.countdown b { font-family: var(--font-display); font-size: var(--text-xl); line-height: 1; }
.countdown span { font-size: var(--text-xs); font-weight: 600; text-align: center; line-height: 1.25; }

.task { display: flex; align-items: center; gap: var(--space-4); }
.task-num { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.task.done .task-num { background: var(--good-soft); color: var(--good); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; line-height: 1.35; }
.task-meta { font-size: var(--text-sm); color: var(--muted); }
.chev { color: var(--faint); flex-shrink: 0; }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day-dot { aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; font-size: var(--text-xs); font-weight: 600; background: var(--surface-2); color: var(--muted); }
.day-dot.on { background: var(--primary); color: var(--primary-ink); }
.day-dot.today { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Realm cards */
.realm-card { overflow: hidden; padding: 0; }
.realm-card img { width: 100%; aspect-ratio: 16/8; object-fit: cover; }
.realm-card .realm-body { padding: var(--space-4) var(--space-5) var(--space-5); }
.progress { height: 10px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .6s var(--ease); }
.progress.water > i { background: var(--water); } .progress.earth > i { background: var(--earth); }
.progress.fire > i { background: var(--fire); } .progress.air > i { background: var(--air); }

.list { display: flex; flex-direction: column; gap: var(--space-3); }
.list-item { display: flex; align-items: center; gap: var(--space-3); min-height: 64px; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); text-align: left; width: 100%; color: inherit; }
.check-badge { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border-strong); flex-shrink: 0; display: grid; place-items: center; }
.check-badge.on { background: var(--good); border-color: var(--good); color: #fff; }
[data-theme="dark"] .check-badge.on { color: #13271a; }

/* Player (lesson / lab) */
.player { display: flex; flex-direction: column; min-height: calc(100dvh - 140px); }
.steps-dots { display: flex; gap: 6px; margin: var(--space-2) 0 var(--space-4); }
.steps-dots i { flex: 1; height: 6px; border-radius: 6px; background: var(--surface-3); transition: background .3s; }
.steps-dots i.on { background: var(--primary); }
.player-card { flex: 1; }
.player-nav { position: sticky; bottom: 0; display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-3); padding: var(--space-4) 0 calc(var(--space-2) + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.card-kind { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-3); }
.card-kind .ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; }
.big-text { font-size: var(--text-lg); line-height: 1.55; font-weight: 400; }
.real-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.real-list li { padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface-2); border-left: 5px solid var(--primary); }
.real-list li b { font-weight: 600; }
.trap { background: var(--gentle-soft); border-color: color-mix(in oklab, var(--gentle) 30%, var(--border)); }
.life { background: var(--primary-soft); border-color: color-mix(in oklab, var(--primary) 25%, var(--border)); }
.read-btn { margin-top: var(--space-4); }

.audio-box { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius); background: var(--surface-2); margin-top: var(--space-4); }
.play-btn { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; flex-shrink: 0; }
.play-btn svg { width: 24px; height: 24px; }
.speed-btn { min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-full); border: 1.5px solid var(--border-strong); background: var(--surface); font-size: var(--text-xs); font-weight: 600; }
.transcript { margin-top: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-sm); }
.transcript p { margin: 0; }
.transcript .who { font-weight: 700; }
.who.pip { color: var(--fire); } .who.juno { color: var(--water); }

/* Questions */
.q-text { font-size: var(--text-lg); font-weight: 500; line-height: 1.45; margin-bottom: var(--space-4); }
.artifact { font-family: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, monospace; font-size: var(--text-xs); line-height: 1.6; letter-spacing: 0; word-spacing: 0; white-space: pre-wrap; word-break: break-word; background: #26232F; color: #EDE6D6; padding: var(--space-4); border-radius: var(--radius); margin: 0 0 var(--space-4); overflow-x: auto; }
.options { display: flex; flex-direction: column; gap: var(--space-3); }
.opt {
  min-height: 60px; padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 2px solid var(--border);
  background: var(--surface); text-align: left; display: flex; align-items: center; gap: var(--space-3); line-height: 1.4; transition: border-color .2s, background .2s;
}
.opt .mark { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border-strong); flex-shrink: 0; display: grid; place-items: center; font-weight: 700; font-size: var(--text-xs); }
.opt.multi .mark { border-radius: 8px; }
.opt[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.opt[aria-pressed="true"] .mark { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .mark { background: var(--good); border-color: var(--good); color: #fff; }
.opt.missed { border-color: var(--gentle); background: var(--gentle-soft); }
.opt[disabled] { cursor: default; }
.feedback { margin-top: var(--space-4); padding: var(--space-4); border-radius: var(--radius); }
.feedback.good { background: var(--good-soft); }
.feedback.gentle { background: var(--gentle-soft); }
.feedback h3 { font-size: var(--text-base); font-weight: 700; margin-bottom: var(--space-1); }
.order-row { display: flex; gap: var(--space-2); margin-top: var(--space-3); }

/* Flashcards */
.flash { min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--space-3); padding: var(--space-8) var(--space-5); width: 100%; border: 1px solid var(--border); }
.flash .front { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); line-height: 1.25; }
.flash .back { font-size: var(--text-lg); line-height: 1.5; }
.flash-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }

/* Songs */
.lyrics { display: flex; flex-direction: column; gap: var(--space-3); }
.lyric { font-size: var(--text-lg); line-height: 1.5; color: var(--faint); transition: color .25s; padding: var(--space-2) var(--space-3); border-radius: var(--radius); }
.lyric.now { color: var(--ink); background: var(--surface-2); }
.lyric .w { display: inline-block; transition: transform .15s var(--ease), color .15s; }
.lyric .w.hit { color: var(--primary); transform: translateY(-3px) scale(1.06); font-weight: 600; }
.beat-ball { width: 18px; height: 18px; border-radius: 50%; background: var(--fire); }

/* Blueprint */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: var(--radius-full); background: var(--surface-2); border: 1px solid var(--border); }
.seg button { min-height: 44px; border: 0; border-radius: var(--radius-full); background: transparent; font-weight: 600; font-size: var(--text-xs); color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-paper); }
.layer-stack { display: flex; flex-direction: column; gap: 0; }
.layer { position: relative; }
.layer + .layer::before { content: ""; display: block; width: 4px; height: 18px; margin: 0 auto; background: repeating-linear-gradient(to bottom, var(--border-strong) 0 4px, transparent 4px 8px); }
.layer-btn { width: 100%; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border-radius: var(--radius); border: 1.5px solid var(--border); background: var(--surface); text-align: left; box-shadow: var(--shadow-paper); }
.layer-btn[aria-expanded="true"] { border-color: var(--primary); }
.layer-ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex-shrink: 0; font-weight: 700; }
.layer-detail { padding: var(--space-4); margin-top: var(--space-2); border-radius: var(--radius); background: var(--surface-2); }
.tool-row { display: flex; flex-direction: column; padding: var(--space-2) 0; border-bottom: 1px dashed var(--border-strong); }
.tool-row:last-child { border-bottom: 0; }
.tool-row b { font-weight: 600; }
.kv { display: grid; grid-template-columns: 1fr; gap: var(--space-1); }
.xlate { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--space-2) var(--space-3); align-items: center; font-size: var(--text-sm); }
.xlate .from { color: var(--muted); }
.xlate .arrow { color: var(--faint); }
.xlate .to { font-weight: 600; }
.nest { border: 2px solid var(--primary); border-radius: var(--radius); padding: var(--space-3); }
.nest .nest { border-color: var(--water); margin-top: var(--space-3); }
.nest .nest .nest { border-color: var(--fire); }
.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label { font-weight: 600; font-size: var(--text-sm); }
.input { min-height: var(--tap); padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1.5px solid var(--border-strong); background: var(--surface); width: 100%; }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { min-height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-full); border: 1.5px solid var(--border-strong); background: var(--surface); font-size: var(--text-sm); font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.pitch-out { white-space: pre-wrap; font-size: var(--text-sm); line-height: 1.6; background: var(--surface-2); border-radius: var(--radius); padding: var(--space-4); }

/* Settings */
.setting { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4) 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting-label { font-weight: 600; }
.setting-help { font-size: var(--text-sm); color: var(--muted); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--tap); }
.switch { position: relative; width: 60px; height: 36px; border-radius: var(--radius-full); background: var(--surface-3); border: 1.5px solid var(--border-strong); flex-shrink: 0; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 27px; height: 27px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch[aria-checked="true"] { background: var(--primary); border-color: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(24px); }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: var(--space-2); }
.choice { overflow-wrap: anywhere; min-height: var(--tap); border-radius: var(--radius); border: 1.5px solid var(--border-strong); background: var(--surface); font-size: var(--text-sm); font-weight: 500; padding: var(--space-2); }
.choice[aria-checked="true"] { border: 2.5px solid var(--primary); background: var(--primary-soft); font-weight: 700; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 50%; vertical-align: -3px; margin-right: 6px; border: 1px solid var(--border-strong); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
.stat { padding: var(--space-4); border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat b { display: block; font-family: var(--font-display); font-size: var(--text-xl); line-height: 1.1; }
.stat span { font-size: var(--text-sm); color: var(--muted); }
.plan-week { display: grid; grid-template-columns: 76px 1fr; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px dashed var(--border); font-size: var(--text-sm); }
.plan-week.now { background: var(--primary-soft); border-radius: var(--radius-sm); padding-inline: var(--space-3); border-bottom-color: transparent; }
.plan-week b { font-weight: 600; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--bg); padding: var(--space-3) var(--space-5); border-radius: var(--radius-full); font-size: var(--text-sm); font-weight: 500; transition: opacity .25s, transform .25s var(--ease); z-index: 50; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Read-aloud word highlight */
.speaking-word { background: color-mix(in oklab, var(--primary) 28%, transparent); border-radius: 4px; box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary) 28%, transparent); }

/* Mascot: squash and stretch */
.bit { width: 96px; height: 96px; flex-shrink: 0; overflow: visible; }
.bit.sm { width: 64px; height: 64px; }
.bit.lg { width: 140px; height: 140px; }
.bit .body { transform-origin: 50% 92%; animation: breathe 3.2s ease-in-out infinite; }
.bit .eyes { transform-origin: 50% 46%; animation: blink 5s infinite; }
.bit.happy .body { animation: hop .9s var(--ease) 2; }
.bit.happy .eyes-open { display: none; } .bit .eyes-happy { display: none; } .bit.happy .eyes-happy { display: inline; }
.bit.think .body { animation: tilt 1.6s ease-in-out 1; }
.bit .shadow { transform-origin: 50% 50%; animation: shadow 3.2s ease-in-out infinite; }
.bit.happy .shadow { animation: shadowhop .9s var(--ease) 2; }
@keyframes breathe { 0%,100% { transform: scale(1,1); } 50% { transform: scale(1.04,.96); } }
@keyframes blink { 0%,92%,100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes hop { 0% { transform: scale(1,1); } 18% { transform: scale(1.18,.8); } 40% { transform: translateY(-26%) scale(.88,1.14); } 62% { transform: translateY(0) scale(1.14,.86); } 80% { transform: scale(.97,1.03); } 100% { transform: scale(1,1); } }
@keyframes shadow { 0%,100% { transform: scaleX(1); } 50% { transform: scaleX(1.05); } }
@keyframes shadowhop { 0%,100% { transform: scaleX(1); opacity: 1; } 40% { transform: scaleX(.6); opacity: .5; } }
@keyframes tilt { 0%,100% { transform: rotate(0); } 30% { transform: rotate(-8deg) scale(1.02,.98); } 65% { transform: rotate(6deg); } }

/* Page transitions: gentle pop-up fold */
.view-enter { animation: popin .38s var(--ease) both; }
@keyframes popin { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
@media (prefers-reduced-motion: reduce) {
  html:not(.allow-motion) *, html:not(.allow-motion) *::before, html:not(.allow-motion) *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.center { text-align: center; }
.mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
hr.soft { border: 0; border-top: 1px dashed var(--border-strong); margin: var(--space-5) 0; }
details.card summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; list-style: none; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: "+"; margin-left: auto; font-size: 1.4em; color: var(--muted); }
details.card[open] summary::after { content: "–"; }
[hidden] { display: none !important; }
.hero img, .realm-card img { height: auto; }

/* ---------- Bedtime stories: pop-up storybook player ---------- */
.story-card { display: flex; gap: var(--space-4); align-items: center; padding: var(--space-3); }
.story-card img { width: 112px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); flex: none; box-shadow: var(--shadow-paper); }
.story-card-body { flex: 1; min-width: 0; }
.ep-item { align-items: center; }
.ep-thumb { width: 72px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; flex: none; }
.hero img[src*="story/"] { aspect-ratio: 16 / 9; }

.sb { display: flex; flex-direction: column; gap: var(--space-3); }
.sb-stage { perspective: 1600px; padding: 4px 8px 12px 4px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sb-book { position: relative; aspect-ratio: 4 / 3; transform-style: preserve-3d; }
.sb-page, .sb-turn-fwd, .sb-turn-back {
  position: absolute; inset: 0; border-radius: 6px 16px 16px 6px; overflow: hidden; background: #F3E8D2;
  box-shadow: 3px 3px 0 #EEE2CA, 6px 6px 0 #E3D4B8, 9px 9px 0 #D8C7A7, 0 18px 30px -14px rgba(70,50,20,.45);
}
.sb-page::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 22px; z-index: 6; pointer-events: none;
  background: linear-gradient(90deg, rgba(80,55,25,.32), rgba(80,55,25,.08) 55%, transparent); }
.sb-scene { position: absolute; inset: 0; transform-origin: 50% 100%; animation: sbRise .9s cubic-bezier(.2,.9,.25,1.1) both; }
@keyframes sbRise { from { transform: rotateX(78deg); filter: brightness(.7); } to { transform: none; filter: none; } }
.sb-bgwrap { position: absolute; inset: 0; overflow: hidden; }
.sb-bg { width: 100%; height: 100%; object-fit: cover; animation: sbKen 22s ease-in-out infinite alternate; transform-origin: 50% 60%; }
@keyframes sbKen { from { transform: scale(1.03) translate(0,0); } to { transform: scale(1.12) translate(-2%, -1.5%); } }
.sb-fold { position: absolute; inset: auto 0 0 0; height: 30%; pointer-events: none; background: linear-gradient(0deg, rgba(60,40,20,.18), transparent); }

.sb-hang { position: absolute; inset: 0 0 auto 0; height: 50%; pointer-events: none; z-index: 3; }
.sb-hang .str { position: absolute; top: 0; width: 34px; transform-origin: 50% 0; animation: sbDrop .9s cubic-bezier(.3,1.5,.5,1) var(--d) both, sbSwing var(--sw) ease-in-out calc(var(--d) + .9s) infinite alternate; }
.sb-hang .str::before { content: ""; display: block; width: 1.5px; height: var(--len); margin: 0 auto; background: rgba(90,70,40,.55); }
.sb-hang .str svg { display: block; width: 34px; height: auto; filter: drop-shadow(0 3px 2px rgba(60,40,20,.25)); }
@keyframes sbDrop { from { transform: translateY(-120%); } to { transform: none; } }
@keyframes sbSwing { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }

.sb-pops { position: absolute; top: 9%; left: 5%; right: 30%; display: flex; flex-wrap: wrap; gap: 6px; z-index: 4; pointer-events: none; perspective: 500px; }
.sb-tag { background: #FFFBF3; color: #2C2838; border: 1px solid #D9CBB1; border-radius: 6px; padding: 3px 10px; font-size: var(--text-xs); font-weight: 600; line-height: 1.5;
  box-shadow: 0 3px 0 #E3D4B8, 0 6px 10px -6px rgba(60,40,20,.5); transform-origin: 50% 100%; transform: rotate(var(--tilt)); animation: sbTag .6s cubic-bezier(.3,1.6,.5,1) var(--d) both; }
@keyframes sbTag { from { transform: rotateX(-90deg); opacity: 0; } to { transform: rotate(var(--tilt)); opacity: 1; } }

.sb-bit { position: absolute; bottom: 5%; width: 30%; z-index: 5; transform: translateX(-50%); }
.sb-bit.pos-left { left: 24%; } .sb-bit.pos-mid { left: 50%; } .sb-bit.pos-right { left: 74%; }
.sb-bit img { display: block; width: 100%; height: auto; transform-origin: 50% 100%; filter: drop-shadow(0 4px 3px rgba(60,40,20,.25)); }
.sb-bit-shadow { position: absolute; left: 18%; right: 18%; bottom: -2%; height: 9%; border-radius: 50%; background: rgba(60,40,20,.22); filter: blur(2px); }
.sb-bit.enter-pop { animation: sbPop .8s cubic-bezier(.3,1.6,.5,1) .5s both; }
@keyframes sbPop { from { transform: translateX(-50%) translateY(30%) scale(.2); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
.sb-bit.enter-walk { animation: sbWalk 1.8s cubic-bezier(.3,.7,.4,1) .3s both; }
@keyframes sbWalk { from { transform: translateX(-260%); } to { transform: translateX(-50%); } }
@keyframes sbStep { 0%,100% { transform: translateY(0) rotate(-3deg) scale(1,1); } 50% { transform: translateY(-7%) rotate(3deg) scale(.97,1.03); } }
.sb-bit img.anim-breathe { animation: sbBreathe 3.2s ease-in-out 1.4s infinite; }
.sb-bit img.anim-wave { animation: sbWave 1.6s ease-in-out 1.2s infinite; }
.sb-bit img.anim-type { animation: sbType .45s ease-in-out 1.3s infinite; }
.sb-bit img.anim-sway { animation: sbSway 2.6s ease-in-out 1.3s infinite; }
.sb-bit img.anim-brace { animation: sbBrace 2s ease-in-out 1.3s infinite; }
.sb-bit img.anim-shiver { animation: sbShiver .5s linear 1.3s infinite; }
.sb-bit img.anim-jump { animation: sbJump 1.1s cubic-bezier(.3,.7,.4,1) 1.2s infinite; }
.sb-bit img.anim-ponder { animation: sbPonder 3s ease-in-out 1.3s infinite; }
.sb-bit img.anim-nod { animation: sbNod 1.4s ease-in-out 1.3s infinite; }
.sb-bit img.anim-snooze { animation: sbBreathe 4.5s ease-in-out .9s infinite; }
.sb-bit.enter-walk img.anim-breathe, .sb-bit.enter-walk img.anim-sway, .sb-bit.enter-walk img.anim-ponder, .sb-bit.enter-walk img.anim-nod, .sb-bit.enter-walk img.anim-type, .sb-bit.enter-walk img.anim-brace, .sb-bit.enter-walk img.anim-shiver, .sb-bit.enter-walk img.anim-jump, .sb-bit.enter-walk img.anim-wave { animation: sbStep .3s ease-in-out .3s 6, sbBreathe 3.2s ease-in-out 2.2s infinite; }
@keyframes sbBreathe { 0%,100% { transform: scale(1,1); } 50% { transform: scale(1.035,.965); } }
@keyframes sbWave { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes sbType { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2.5%) scale(1.01,.99); } }
@keyframes sbSway { 0%,100% { transform: translateX(0) rotate(0); } 50% { transform: translateX(6%) rotate(4deg); } }
@keyframes sbBrace { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05,.97); } }
@keyframes sbShiver { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-1.5%); } 75% { transform: translateX(1.5%); } }
@keyframes sbJump { 0%,100% { transform: translateY(0) scale(1,1); } 15% { transform: scale(1.12,.88); } 45% { transform: translateY(-22%) scale(.92,1.08); } 75% { transform: translateY(0) scale(1.08,.92); } }
@keyframes sbPonder { 0%,100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
@keyframes sbNod { 0%,100% { transform: rotate(0); } 40% { transform: rotate(5deg) translateY(-2%); } }

.sb-fx { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.sb-fx i { position: absolute; top: -8%; display: block; animation-name: sbFall; animation-timing-function: linear; animation-iteration-count: infinite; }
.fx-rain i { width: 1.5px; height: 14px; background: rgba(160,190,220,.85); border-radius: 2px; transform: rotate(12deg); }
.fx-snow i { width: 7px; height: 7px; border-radius: 50%; background: #fff; opacity: .9; animation-name: sbSnow; }
.fx-leaves i { width: 10px; height: 7px; border-radius: 0 70% 0 70%; background: hsl(calc(18 + var(--h) * 8), 65%, 52%); animation-name: sbLeaf; }
.fx-sparks i { width: 5px; height: 5px; border-radius: 50%; background: #F2C76B; box-shadow: 0 0 6px #F2C76B; top: auto; bottom: 10%; animation-name: sbSpark; }
.fx-confetti i { width: 7px; height: 10px; border-radius: 2px; background: hsl(calc(var(--h) * 70), 60%, 64%); animation-name: sbLeaf; }
.fx-stars i { width: 4px; height: 4px; border-radius: 50%; background: #FFF6D6; top: calc(var(--h) * 8% + 4%); animation-name: sbTwinkle; }
@keyframes sbFall { to { transform: translateY(130vh) rotate(12deg); } }
@keyframes sbSnow { 0% { transform: translate(0,0); } 50% { transform: translate(12px, 50vh); } 100% { transform: translate(-6px, 110vh); } }
@keyframes sbLeaf { 0% { transform: translate(0,0) rotate(var(--r)); } 50% { transform: translate(18px, 45vh) rotate(calc(var(--r) + 180deg)); } 100% { transform: translate(-10px, 100vh) rotate(calc(var(--r) + 360deg)); } }
@keyframes sbSpark { 0% { transform: translateY(0) scale(1); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(-40vh) scale(.3); opacity: 0; } }
@keyframes sbTwinkle { 0%,100% { opacity: .2; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.3); } }

.sb-cover { position: absolute; inset: 0; z-index: 10; border-radius: 6px 16px 16px 6px; transform-origin: 0 50%; transform-style: preserve-3d; backface-visibility: hidden;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.14), transparent 60%), repeating-linear-gradient(45deg, rgba(255,255,255,.03) 0 2px, transparent 2px 5px), #2B6A6E;
  box-shadow: inset 10px 0 14px -6px rgba(0,0,0,.35), 3px 3px 0 #EEE2CA, 6px 6px 0 #E3D4B8, 0 18px 30px -14px rgba(40,30,10,.5); color: #FFF6E2; }
.sb-cover.opening { animation: sbOpen 1.3s cubic-bezier(.45,.05,.3,1) forwards; }
@keyframes sbOpen { 0% { transform: rotateY(0); } 100% { transform: rotateY(-165deg); opacity: .0; } }
.sb-cover-in { position: absolute; inset: 7%; border: 2px solid rgba(242,199,107,.75); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--space-3); gap: 4px; }
.sb-cover-in .eyebrow { color: #F2D9A0; font-size: .72rem; }
.sb-cover-title { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.15rem, 4.6vw, 1.7rem); line-height: 1.2; }
.sb-cover-in img { width: 30%; height: auto; animation: sbBreathe 3.2s ease-in-out infinite; }
.sb-once { margin: 0; font-style: normal; font-family: var(--font-display); color: #F2D9A0; }

.sb-turn-fwd { z-index: 8; transform-origin: 0 50%; animation: sbFlip .95s cubic-bezier(.45,.05,.3,1) forwards; pointer-events: none; }
.sb-turn-fwd::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(60,40,20,.35)); animation: sbShade .95s linear forwards; }
@keyframes sbFlip { 0% { transform: rotateY(0); } 100% { transform: rotateY(-178deg); } }
@keyframes sbShade { from { opacity: 0; } to { opacity: 1; } }
.sb-turn-back { z-index: 8; transform-origin: 100% 50%; animation: sbFlipB .8s cubic-bezier(.45,.05,.3,1) forwards; pointer-events: none; }
@keyframes sbFlipB { 0% { transform: rotateY(0); opacity: 1; } 100% { transform: rotateY(120deg); opacity: 0; } }
.sb-turn-fwd, .sb-turn-back { backface-visibility: hidden; }
.sb-fade { animation: sbFadeIn .5s ease both; }
@keyframes sbFadeIn { from { opacity: 0; } to { opacity: 1; } }

.sb-ctrl { display: flex; align-items: center; justify-content: center; gap: var(--space-3); }
.sb-play { flex: 1; max-width: 300px; gap: var(--space-2); }
.sb-play svg { width: 22px; height: 22px; }
.sb-nav { width: 52px; height: 52px; border: 1px solid var(--border); background: var(--surface); border-radius: 50%; }
.sb-nav:disabled { opacity: .4; }
.sb-opts { justify-content: center; }
.sb-cap { padding: var(--space-4) var(--space-5); }
.sb-lines p { margin: 0 0 var(--space-2); color: var(--muted); transition: color .3s; }
.sb-lines p.now { color: var(--ink); }
.sb-lines p.now .who { text-decoration: underline; text-underline-offset: 3px; }
.sb-lines.caps-off p { display: none; }
.sb-lines.caps-off::before { content: "Captions are off. Tap Captions to show the words."; color: var(--muted); font-size: var(--text-sm); }
.sb-learned { margin-bottom: var(--space-4); }
.sb-learned ol { margin: var(--space-2) 0 var(--space-3); padding-left: 1.3em; display: flex; flex-direction: column; gap: var(--space-2); }
.sb-learned li { background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-weight: 600; animation: popin .5s var(--ease) var(--d) both; }
.sb-learned a { color: var(--primary); }
.sb-after { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-4); }
.reduce-motion .sb-fx, .reduce-motion .sb-hang .str { display: none; }
@media (prefers-reduced-motion: reduce) { html:not(.allow-motion) .sb-fx { display: none; } }
.story-card img, .ep-thumb, .sb-cover-in img, .sb-bg { height: auto; }
.sb-bg { height: 100%; }
.sb-turn-fwd *, .sb-turn-back * { animation: none !important; }
.sb-turn-fwd .sb-fx, .sb-turn-back .sb-fx { display: none; }
.reduce-motion .sb-page *, .reduce-motion .sb-learned li { animation-delay: 0s !important; }
@media (prefers-reduced-motion: reduce) { html:not(.allow-motion) .sb-page *, html:not(.allow-motion) .sb-learned li { animation-delay: 0s !important; } html:not(.allow-motion) .sb-hang .str { display: none; } }

/* ---------- Practice exam (Category Quiz layout) ---------- */
:root, [data-theme="light"] { --bad: #B4473A; --bad-soft: #FBE6E3; --pink: #F6D9DC; --pink-ink: #7A2E3A; }
[data-theme="dark"] { --bad: #F0A196; --bad-soft: #3B2526; --pink: #46282E; --pink-ink: #F4C7CD; }
.app.exam-mode .topbar { display: none; }
.app.exam-mode .main { padding-top: calc(env(safe-area-inset-top) + var(--space-2)); }
.xwrap { display: flex; flex-direction: column; min-height: calc(100dvh - 40px); }
.xhead { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.xtitle { margin: 0; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); letter-spacing: 0; }
.xhead .icon-btn, .icon-btn.sm { width: 44px; height: 44px; min-width: 44px; border: 0; background: transparent; }
.icon-btn svg { width: 24px; height: 24px; }
.xmeta { display: flex; justify-content: space-between; align-items: center; margin-top: var(--space-2); font-size: var(--text-sm); font-weight: 500; }
.xtimer { background: var(--pink); color: var(--pink-ink); padding: 4px 12px; border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; font-weight: 600; font-size: var(--text-sm); }
.xprog { height: 8px; border-radius: 99px; background: var(--surface-3); margin-top: var(--space-2); overflow: hidden; }
.xprog i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .4s var(--ease); }
.xq { flex: 1; padding-top: var(--space-5); }
.xstem { font-size: var(--text-lg); line-height: 1.45; font-weight: 400; }
.xstem b, .xfb b { font-weight: 700; }
.xopts { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-6); }
.xopt { display: flex; align-items: center; gap: 0; width: 100%; text-align: left; min-height: 56px; padding: 0; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; box-shadow: var(--shadow-paper); }
.xopt[hidden] { display: none; }
.xopt .xl { width: 46px; align-self: stretch; display: grid; place-items: center; font-weight: 700; position: relative; }
.xopt .xl::after { content: ''; position: absolute; right: 0; top: 14px; bottom: 14px; width: 1.5px; background: var(--border-strong); }
.xopt .xt { flex: 1; padding: 14px 16px; }
.xopt:active { transform: scale(.99); }
.xopt.sel { border-color: var(--primary); background: var(--primary-soft); }
.xopt.right { border-color: var(--good); background: var(--good-soft); }
.xopt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.xopt[disabled] { cursor: default; opacity: 1; }
.xfb { margin-top: var(--space-5); padding: var(--space-4); border-radius: var(--radius); border: 1px solid var(--border); }
.xfb.good { background: linear-gradient(160deg, var(--surface), var(--good-soft)); }
.xfb.bad { background: linear-gradient(160deg, var(--surface), var(--bad-soft)); }
.xfb-h { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: var(--space-2); }
.xfb.good .xfb-h { color: var(--good); } .xfb.bad .xfb-h { color: var(--bad); }
.xfb-h svg { width: 22px; height: 22px; }
.xfb p { margin: 0 0 var(--space-2); font-size: var(--text-sm); line-height: 1.6; }
.xrate { display: flex; justify-content: center; gap: var(--space-4); margin-top: var(--space-3); }
.xrate .icon-btn { border: 0; background: transparent; width: 44px; height: 44px; min-width: 44px; color: var(--muted); }
.xrate .icon-btn[data-rate="flag"] { color: var(--bad); }
.xrate .icon-btn[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.xrate .flip svg { transform: rotate(180deg) scaleX(-1); }
.xtools { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.xtools .read-btn { margin: 0; }
.xhint { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px 6px 6px; border-radius: 99px; border: 1.5px solid var(--border); background: var(--air-soft); color: var(--ink); font: inherit; font-weight: 600; font-size: var(--text-sm); }
.xhint[hidden] { display: none; }
.bit.xs { width: 34px; height: 34px; }
.xbar { position: sticky; bottom: 0; display: grid; grid-template-columns: 56px 1fr 56px; gap: var(--space-3); padding: var(--space-4) 0 calc(var(--space-2) + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 75%, transparent); margin-top: var(--space-4); }
.icon-btn.lg { width: 56px; height: 56px; border-radius: var(--radius); border-color: var(--border-strong); color: var(--primary); }
.icon-btn[disabled] { opacity: .45; }
#xbm[aria-pressed="true"] { --bmfill: currentColor; background: var(--primary-soft); }
.list-item[disabled] { opacity: .55; }
.pill.gentle { background: var(--bad-soft); color: var(--bad); }

/* ---------- SOC Lab ---------- */
.tab span { white-space: nowrap; }
.mono { font-family: ui-monospace, 'JetBrains Mono', 'Cascadia Mono', Menlo, Consolas, monospace; letter-spacing: 0; word-spacing: 0; }
.seg.scroll { display: flex; overflow-x: auto; scrollbar-width: none; border-radius: var(--radius); scroll-snap-type: x proximity; }
.seg.scroll::-webkit-scrollbar { display: none; }
.seg.scroll button { flex: 0 0 auto; padding: 0 16px; white-space: nowrap; scroll-snap-align: center; }
.soc-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(68px, 1fr)); gap: 8px; }
.soc-stats > div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; }
.soc-stats b { font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.soc-stats span { font-size: var(--text-xs); color: var(--muted); }
.pill.sev-crit { background: var(--bad); color: #fff; }
.pill.sev-high { background: var(--bad-soft); color: var(--bad); }
.pill.sev-med { background: var(--gentle-soft); color: var(--gentle); }
.pill.sev-low { background: var(--water-soft); color: var(--water); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.medal { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 6px; border-radius: 99px; font-size: var(--text-xs); font-weight: 700; color: var(--ink); background: color-mix(in oklab, var(--m) 28%, var(--surface)); border: 1.5px solid var(--m); }
.medal::before { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--m); }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: var(--text-sm); }
.ent { display: inline-block; padding: 3px 10px; border-radius: 8px; background: var(--surface-2); font-size: var(--text-xs); word-break: break-all; }
.kv-row { display: grid; grid-template-columns: 88px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); align-items: start; }
.kv-row:last-child { border-bottom: 0; }
.kv-row .chips { gap: 6px; }
.trail-step { display: grid; grid-template-columns: 40px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.trail-step:last-child { border-bottom: 0; }
.trail-step .tier { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: var(--text-xs); }
.chip.sm { min-height: 40px; padding: 0 12px; font-size: var(--text-xs); }
.chip.right { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.chip.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.chip[disabled] { opacity: 1; }
.chip.right[disabled], .chip.wrong[disabled] { opacity: 1; }
.chip[disabled]:not(.right):not(.wrong) { opacity: .55; }
#closeForm .chip { text-align: left; min-height: 44px; height: auto; padding: 8px 14px; }
select.input { appearance: auto; }
.score-rows > div { display: grid; grid-template-columns: 1fr 90px 52px; gap: 10px; align-items: center; font-size: var(--text-sm); padding: 4px 0; }
.score-rows .bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.score-rows .bar i { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.score-rows b { text-align: right; font-variant-numeric: tabular-nums; }
.note-pre, .kq-pre { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); margin: 6px 0 0; letter-spacing: 0; word-spacing: 0; }
textarea.kq { font-size: 14px; line-height: 1.5; min-height: 140px; letter-spacing: 0; word-spacing: 0; tab-size: 2; }
.err-card { background: var(--bad-soft); border-color: var(--bad); }
.kt-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); -webkit-overflow-scrolling: touch; }
.kt { border-collapse: collapse; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; letter-spacing: 0; word-spacing: 0; min-width: 100%; }
.kt th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 8px 10px; font-weight: 700; white-space: nowrap; border-bottom: 1px solid var(--border-strong); }
.kt td { padding: 8px 10px; white-space: nowrap; border-bottom: 1px solid var(--border); max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.kt tbody tr[data-row] { cursor: pointer; }
.kt tbody tr[data-row]:hover, .kt tbody tr[data-row]:focus { background: var(--primary-soft); outline: none; }
.kt tr.kd td { white-space: normal; max-width: none; background: var(--surface-2); }
.kd-grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; max-width: 86vw; position: sticky; left: 10px; }
.kd-grid .mono { word-break: break-all; }
.agent-row { width: 100%; background: transparent; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; min-height: 48px; }
.list-item.fix-right { border-color: var(--good); background: var(--good-soft); }
.list-item.fix-wrong { border-color: var(--bad); background: var(--bad-soft); }
.list-item[disabled] { opacity: 1; }
.cmp { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 6px 10px; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.board > div { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); font-size: var(--text-sm); }
.board > div:nth-child(odd) { background: var(--surface-2); }
.board > div.me { background: var(--primary-soft); font-weight: 700; }
.board .pos { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); font-weight: 700; font-size: var(--text-xs); }
details.tbl > summary { cursor: pointer; padding: 6px 0; }
#closeForm .chip, .chip[data-ans] { border-radius: 14px; text-align: left; }
.chip[data-ans] { min-height: 44px; height: auto; padding: 8px 14px; }
.has-cmd { word-break: break-word; }
