/* CharterDrill v4.9 — rem-based so the text-size setting scales everything. */
:root {
  --bg: #0b1220; --bg-elevated: #111827; --card: #1e293b; --card-hover: #273449;
  --text: #f8fafc; --text-secondary: #cbd5e1; --muted: #94a3b8;
  --accent: #3b82f6; --accent-hover: #2563eb; --accent-soft: rgba(59,130,246,.15); --accent-text: #93c5fd;
  --success: #22c55e; --success-soft: rgba(34,197,94,.15); --success-text: #86efac;
  --danger: #ef4444; --danger-soft: rgba(239,68,68,.15); --danger-text: #fca5a5;
  --warning: #f59e0b; --warning-soft: rgba(245,158,11,.15); --warning-text: #fcd34d;
  --border: #334155; --radius: 14px; --shadow: 0 4px 20px rgba(0,0,0,.25);
  --kbd-bg: #0f172a; --kbd-border: #475569;
}
[data-theme="light"] {
  --bg: #f8fafc; --bg-elevated: #ffffff; --card: #ffffff; --card-hover: #f1f5f9;
  --text: #0f172a; --text-secondary: #334155; --muted: #5b6b80;
  --accent: #2563eb; --accent-hover: #1d4ed8; --accent-soft: rgba(37,99,235,.1); --accent-text: #1d4ed8;
  --success: #16a34a; --success-soft: rgba(22,163,74,.1); --success-text: #166534;
  --danger: #dc2626; --danger-soft: rgba(220,38,38,.08); --danger-text: #991b1b;
  --warning: #d97706; --warning-soft: rgba(217,119,6,.1); --warning-text: #92400e;
  --border: #e2e8f0; --shadow: 0 2px 12px rgba(0,0,0,.06);
  --kbd-bg: #f1f5f9; --kbd-border: #cbd5e1;
}
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html[data-textsize="s"] { font-size: 14.5px; }
html[data-textsize="m"] { font-size: 16px; }
html[data-textsize="l"] { font-size: 18px; }
html[data-textsize="xl"] { font-size: 20px; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.55; min-height: 100vh;
  -webkit-font-smoothing: antialiased; overflow-wrap: anywhere;
}
button { font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: .5rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .8rem; } .center { text-align: center; margin: .5rem 0; }
.ok-text { color: var(--success); }

header {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .8rem 1rem; padding-top: max(.8rem, env(safe-area-inset-top));
  background: var(--bg-elevated); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.logo { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.logo span { color: var(--accent); }
.header-stats { font-size: .78rem; color: var(--muted); font-weight: 500; text-align: right; }

.banner { padding: .6rem 1rem; font-size: .85rem; text-align: center; }
.banner.warn { background: var(--warning-soft); color: var(--warning-text); border-bottom: 1px solid var(--warning); }
.banner.info { background: var(--accent-soft); color: var(--accent-text); border-bottom: 1px solid var(--accent); }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; padding: .2rem; }

main { max-width: 680px; margin: 0 auto; padding: 1.1rem 1rem 2.5rem; padding-bottom: max(2.5rem, env(safe-area-inset-bottom)); }
.screen { display: none; }
.screen.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen.active { animation: none; } * { scroll-behavior: auto !important; } }

h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: .2rem; line-height: 1.25; }
h2 { font-size: 1.35rem; font-weight: 650; margin-bottom: 1rem; }
.subtitle { color: var(--muted); font-size: .92rem; margin-bottom: 1.1rem; }
.section-title { font-size: 1rem; margin: 1rem 0 .5rem; }

.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; margin-bottom: 1rem; }
.stat-card { background: var(--card); padding: 1rem .7rem; border-radius: var(--radius); text-align: center; border: 1px solid var(--border); box-shadow: var(--shadow); }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--accent); letter-spacing: -.02em; }
.stat-label { font-size: .75rem; color: var(--muted); margin-top: .15rem; font-weight: 500; }
.result-card { margin: 1rem auto; max-width: 280px; }
.band-ready { color: var(--success) !important; } .band-track { color: var(--accent) !important; }
.band-build { color: var(--warning) !important; } .band-start { color: var(--danger) !important; }

.actions { display: flex; flex-direction: column; gap: .6rem; margin: 1rem 0; }
.action-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.btn {
  padding: .8rem 1rem; border: none; border-radius: 12px; font-size: .97rem; font-weight: 600; cursor: pointer;
  transition: background .15s ease, transform .15s ease; text-decoration: none; display: inline-block; text-align: center;
  min-height: 44px; line-height: 1.3;
}
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(59,130,246,.3); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--card-hover); }
.btn.text { background: transparent; color: var(--muted); font-size: .88rem; padding: .4rem; min-height: 36px; }
.btn.text.danger:hover, .btn.text.danger { color: var(--danger); }
.btn.danger-btn { background: var(--danger); color: #fff; }
.btn.back { margin-top: 1rem; width: 100%; }

.daily-length { display: flex; align-items: center; justify-content: center; gap: .4rem; margin: -.2rem 0 .4rem; font-size: .82rem; color: var(--muted); }
.len-btn { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: .35rem .75rem; border-radius: 8px; font-size: .85rem; cursor: pointer; min-height: 36px; min-width: 44px; }
.len-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.daily-banner { padding: .7rem 1rem; border-radius: 12px; text-align: center; margin-bottom: 1rem; font-size: .88rem; font-weight: 500; }
.daily-banner.pending { background: var(--accent-soft); color: var(--accent-text); border: 1px solid rgba(59,130,246,.35); }
.daily-banner.done { background: var(--success-soft); color: var(--success-text); border: 1px solid rgba(34,197,94,.35); }

.topic-breakdown, .analytics-card, .settings-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; margin: .85rem 0; box-shadow: var(--shadow);
}
.topic-breakdown h3, .analytics-card h3 { font-size: .9rem; color: var(--muted); margin-bottom: .6rem; font-weight: 600; }
.topic-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name score" "meta score"; align-items: center; column-gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.topic-row .topic-name { grid-area: name; } .topic-row .topic-meta { grid-area: meta; } .topic-row .topic-score { grid-area: score; }
.topic-row:last-child { border-bottom: none; }
.topic-name { font-weight: 500; }
.topic-meta { color: var(--muted); font-size: .74rem; }
.topic-score { font-weight: 650; min-width: 2.8rem; text-align: right; }
.topic-grid { display: flex; flex-direction: column; gap: .5rem; }
.topic-btn { display: flex; justify-content: space-between; gap: .5rem; text-align: left; background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: .85rem 1rem; cursor: pointer; min-height: 44px; }
.topic-btn:hover { border-color: var(--accent); }

.disclaimer { font-size: .74rem; color: var(--muted); text-align: center; margin-top: 1.5rem; line-height: 1.45; }

/* Quiz */
.quiz-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; color: var(--muted); font-size: .84rem; font-weight: 500; }
#quiz-topic { text-align: center; flex: 1; }
#timer.low { color: var(--danger); font-weight: 700; }
.progress-bar { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: .8rem; }
#progress-fill { height: 100%; background: var(--accent); width: 0; transition: width .25s ease; }
.question-card { background: var(--card); padding: 1.2rem; border-radius: var(--radius); margin-bottom: .85rem; border: 1px solid var(--border); box-shadow: var(--shadow); }
#question-text { font-size: 1.04rem; margin-bottom: 1rem; line-height: 1.6; }
.options { display: flex; flex-direction: column; gap: .55rem; }
.option {
  display: flex; align-items: flex-start; gap: .7rem; width: 100%;
  background: var(--bg); border: 2px solid var(--border); padding: .75rem .85rem; border-radius: 12px;
  cursor: pointer; text-align: left; color: var(--text); font-size: .96rem; min-height: 48px; transition: border-color .12s, background .12s;
}
.option:hover { border-color: var(--accent); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.correct { border-color: var(--success); background: var(--success-soft); }
.option.incorrect { border-color: var(--danger); background: var(--danger-soft); }
.option.disabled { cursor: default; }
.option:disabled { color: var(--text); opacity: 1; }
.opt-letter {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 1.7rem; height: 1.7rem;
  border-radius: 50%; border: 1.5px solid var(--border); font-weight: 700; font-size: .82rem; color: var(--muted);
}
.opt-letter.small { width: 1.5rem; height: 1.5rem; font-size: .75rem; }
.option.selected .opt-letter { background: var(--accent); border-color: var(--accent); color: #fff; }
.option.correct .opt-letter { background: var(--success); border-color: var(--success); color: #fff; }
.option.incorrect .opt-letter { background: var(--danger); border-color: var(--danger); color: #fff; }
.opt-text { flex: 1; padding-top: .1rem; }
.confirm { width: 100%; margin-top: .9rem; }
.hint { font-size: .78rem; color: var(--muted); text-align: center; margin-top: .45rem; }
.quiz-actions { display: flex; gap: .6rem; }
.quiz-actions .btn { flex: 1; }

/* Explanation */
.explanation { background: var(--card); padding: 1rem 1.1rem; border-radius: var(--radius); margin-bottom: .85rem; border: 1px solid var(--border); border-left: 4px solid var(--accent); font-size: .93rem; }
.verdict { font-weight: 700; font-size: 1.02rem; margin-bottom: .6rem; }
.verdict.ok { color: var(--success); } .verdict.bad { color: var(--danger); }
.exp-section { margin: .85rem 0; }
.exp-section h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .4rem; }
.steps { padding-left: 1.3rem; } .steps li { margin: .3rem 0; padding-left: .2rem; }
.keystrokes { list-style: none; counter-reset: ks; display: flex; flex-direction: column; gap: .35rem; }
.keystrokes li { counter-increment: ks; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; font-size: .88rem; }
.keystrokes li::before { content: counter(ks); color: var(--muted); font-size: .72rem; min-width: 1.1rem; }
kbd {
  display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; font-weight: 600;
  background: var(--kbd-bg); border: 1px solid var(--kbd-border); border-bottom-width: 3px; border-radius: 6px; padding: .05rem .4rem; white-space: nowrap;
}
.ks-result { color: var(--success); font-weight: 600; margin-left: .2rem; }
.distractors { list-style: none; display: flex; flex-direction: column; gap: .55rem; }
.distractors li { display: flex; gap: .6rem; align-items: flex-start; }
.distractors li > div { flex: 1; }
.distractors li.is-key { background: var(--warning-soft); border-radius: 8px; padding: .4rem; }
.dis-opt { font-weight: 600; }
.distractors p { color: var(--text-secondary); font-size: .88rem; margin-top: .1rem; }
.key-tag { font-size: .72rem; color: var(--warning-text); font-style: normal; }
.takeaway { background: var(--success-soft); border: 1px solid rgba(34,197,94,.35); border-radius: 10px; padding: .65rem .8rem; margin: .85rem 0 .5rem; }
.takeaway strong { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--success-text); }
.review-flag { background: var(--warning-soft); border: 1px solid var(--warning); color: var(--text); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .6rem; font-size: .86rem; }
.review-flag strong { color: var(--warning-text); }
.formula-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.formula-tag { background: var(--accent-soft); color: var(--accent-text); border: 1px solid rgba(59,130,246,.4); padding: .3rem .65rem; border-radius: 999px; font-size: .78rem; cursor: pointer; min-height: 32px; }
.formula-tag:hover { background: var(--accent); color: #fff; }
.rate-block { border-top: 1px solid var(--border); margin-top: .8rem; padding-top: .7rem; }
.rate-label { font-size: .82rem; color: var(--muted); }
.quality-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-top: .45rem; }
.qbtn { padding: .55rem .2rem; border: none; border-radius: 8px; font-size: .84rem; font-weight: 600; cursor: pointer; color: #fff; min-height: 44px; }
.qbtn.again { background: #b91c1c; } .qbtn.hard { background: #b45309; } .qbtn.good { background: #15803d; } .qbtn.easy { background: #1d4ed8; }
.qbtn:disabled { opacity: .4; cursor: default; } .qbtn.chosen { opacity: 1; outline: 2px solid var(--text); }
.next-review { margin-top: .5rem; font-size: .83rem; color: var(--muted); }

/* Visuals */
.visual figure { margin: 0; }
figcaption { font-size: .75rem; color: var(--muted); margin-top: .3rem; text-align: center; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .84rem; }
th, td { border-bottom: 1px solid var(--border); padding: .35rem .5rem; text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: .76rem; }
tr.hl td { background: var(--accent-soft); font-weight: 600; }
.vis-bars { display: flex; flex-direction: column; gap: .3rem; }
.bar-row { display: grid; grid-template-columns: minmax(4.5rem, 32%) 1fr auto; gap: .5rem; align-items: center; font-size: .8rem; }
.bar-track { background: var(--border); border-radius: 4px; height: .6rem; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--muted); border-radius: 4px; }
.bar-fill.neg { background: var(--danger); }
.bar-row.hl .bar-fill { background: var(--accent); } .bar-row.hl { font-weight: 700; }
.bar-row.hl .bar-fill.neg { background: var(--danger); }
.vis-bars.diverging .bar-track { position: relative; overflow: visible; }
.vis-bars.diverging .bar-row { grid-template-columns: minmax(4.5rem, 32%) 1fr 4.2rem; } .vis-bars.diverging .bar-val { text-align: right; }
.vis-bars.diverging .bar-track::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.vis-bars.diverging .bar-fill.neg { border-radius: 4px 0 0 4px; } .vis-bars.diverging .bar-fill:not(.neg) { border-radius: 0 4px 4px 0; }
.bar-val { font-variant-numeric: tabular-nums; }
.vis-flow { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; font-size: .8rem; }
.flow-node { background: var(--accent-soft); border: 1px solid rgba(59,130,246,.35); border-radius: 8px; padding: .25rem .5rem; }
.flow-arrow { color: var(--muted); }
.vis-timeline { padding: 0 1.2rem; }
.tl-line { position: relative; height: 4.2rem; margin: 0 .2rem; }
.tl-line::before { content: ""; position: absolute; left: 0; right: 0; top: 2.1rem; height: 2px; background: var(--muted); }
.tl-pt { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; font-size: .72rem; width: 4rem; }
.tl-cf { height: 1.6rem; display: flex; align-items: flex-end; font-weight: 600; text-align: center; line-height: 1.1; }
.tl-dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--accent); margin: .2rem 0; }
.tl-t { color: var(--muted); }
.vis-svg svg { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.vis-svg .ax { stroke: var(--muted); stroke-width: 1; }
.vis-svg .zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.vis-svg .guide { stroke: var(--warning); stroke-width: 1; stroke-dasharray: 4 3; fill: none; }
.vis-svg .line { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-linejoin: round; }
.vis-svg .line.dim { stroke: var(--muted); stroke-dasharray: 5 4; }
.vis-svg .dot { fill: var(--accent); } .vis-svg .dot.good { fill: var(--success); }
.vis-svg .lbl { fill: var(--text-secondary); font-size: 9px; }
.vis-svg .band1 { fill: var(--accent); opacity: .18; } .vis-svg .band2 { fill: var(--accent); opacity: .08; }

/* Formula reference */
.formula-index { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .8rem; }
.formula-index a { font-size: .76rem; color: var(--accent); background: var(--accent-soft); padding: .25rem .55rem; border-radius: 999px; text-decoration: none; }
.formula-section { background: var(--card); padding: 1rem 1.1rem; border-radius: var(--radius); margin-bottom: .75rem; border: 1px solid var(--border); scroll-margin-top: 4.5rem; }
.formula-section h3 { color: var(--accent); margin-bottom: .5rem; font-size: 1.04rem; }
.formula-item { padding: .55rem 0; border-bottom: 1px solid var(--border); scroll-margin-top: 5rem; transition: background .4s; }
.formula-item:last-child { border-bottom: none; }
.formula-item.flash { background: var(--warning-soft); border-radius: 8px; padding-left: .5rem; padding-right: .5rem; }
.formula-name { font-weight: 600; font-size: .9rem; }
.formula-expr { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .55rem; margin: .3rem 0; }
.formula-note { font-size: .78rem; color: var(--muted); }
.formula-topic { font-size: .78rem; color: var(--muted); margin-bottom: .3rem; }
.related-btn { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--border); color: var(--text); padding: .6rem .75rem; border-radius: 10px; margin-bottom: .4rem; font-size: .86rem; cursor: pointer; min-height: 44px; }
.related-btn:hover { border-color: var(--accent); }

/* Settings */
.settings-card { text-align: center; }
.settings-card p { margin-bottom: .6rem; }
.settings-note { font-size: .78rem; color: var(--muted); margin-top: .4rem; }
.settings-label { font-size: .85rem; margin-top: .9rem; }
.seg { display: inline-grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; width: 100%; max-width: 320px; }
.seg button { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: .45rem 0; cursor: pointer; font-weight: 700; min-height: 44px; }
.seg button[data-ts="s"] { font-size: .85rem; } .seg button[data-ts="l"] { font-size: 1.1rem; } .seg button[data-ts="xl"] { font-size: 1.25rem; }
.seg button small { font-size: .62rem; font-weight: 500; margin-left: .1rem; color: var(--muted); }
.seg button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg button.active small { color: #dbeafe; }
.toggle { display: flex; align-items: center; justify-content: center; gap: .5rem; font-size: .9rem; cursor: pointer; min-height: 44px; }
.toggle input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
#account-status { font-size: .88rem; margin-bottom: .6rem; font-weight: 500; }
.danger-zone { box-shadow: none; }
.search-box { width: 100%; padding: .75rem 1rem; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 1rem; margin-bottom: .75rem; min-height: 44px; }
.search-box:focus { outline: none; border-color: var(--accent); }

/* Analytics */
.analytics-row { display: flex; justify-content: space-between; gap: .5rem; padding: .38rem 0; font-size: .88rem; border-bottom: 1px solid var(--border); }
.analytics-row:last-child { border-bottom: none; }
.analytics-row.three { flex-wrap: wrap; } .analytics-row.three > span:first-child { flex: 1 1 9rem; }
table.weights tr.w-under td:nth-child(2) { color: var(--danger); font-weight: 600; }
table.weights tr.w-over td:nth-child(2) { color: var(--warning); font-weight: 600; }

/* Streak */
.streak-tracker { margin-bottom: .75rem; }
.streak-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .4rem .75rem; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .6rem 1rem; }
.streak-box.active { border-color: var(--success); background: var(--success-soft); }
.streak-num { font-size: 1.55rem; font-weight: 700; color: var(--warning); }
.streak-label { font-weight: 600; font-size: .95rem; }
.streak-mult { background: var(--warning); color: #1c1917; font-size: .75rem; font-weight: 700; padding: .15rem .4rem; border-radius: 6px; }
.streak-best { font-size: .78rem; color: var(--muted); }

/* Results review */
.review-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin: .5rem 0; padding: .6rem .8rem; }
.review-item.bad { border-left: 4px solid var(--danger); } .review-item.ok { border-left: 4px solid var(--success); }
.review-item summary { cursor: pointer; font-weight: 600; font-size: .9rem; min-height: 32px; display: flex; align-items: center; }
.review-item .rq { margin: .5rem 0; } .review-item .ra { font-size: .88rem; margin-bottom: .4rem; }

/* Modal & toast */
.modal { position: fixed; inset: 0; background: rgba(2,6,23,.6); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal-card { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 1.2rem; width: 100%; max-width: 420px; box-shadow: var(--shadow); max-height: 90vh; overflow: auto; }
.modal-card h3 { font-size: 1.1rem; margin-bottom: .5rem; }
#modal-body p { margin-bottom: .5rem; font-size: .92rem; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: .8rem; }
.modal-actions .btn { flex: 1 1 auto; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); margin: .5rem 0; }
.field input { padding: .6rem .7rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 1rem; min-height: 44px; }
.toast { position: fixed; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-size: .88rem; z-index: 60; max-width: calc(100% - 2rem); text-align: center; box-shadow: var(--shadow); }
.load-error { text-align: center; padding: 2rem 1rem; } .load-error p { color: var(--muted); margin: .5rem 0 1rem; }

@media (max-width: 400px) {
  main { padding: .9rem .75rem 2rem; }
  h1 { font-size: 1.4rem; }
  .question-card, .explanation { padding: .95rem; }
  .stats-grid { gap: .55rem; }
  .stat-value { font-size: 1.35rem; }
  .header-stats { font-size: .72rem; }
  .quality-buttons { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- v4.10: report, time, mock trend ---------- */
.report-btn { display: block; margin: .6rem auto 0; font-size: .85rem; font-weight: 500; color: var(--muted); min-height: 44px; }
.report-btn:hover, .report-btn:focus-visible { color: var(--accent); }
.report-q { font-size: .9rem; color: var(--text-secondary); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: .5rem .7rem; margin: .5rem 0; }
.report-reasons { border: none; padding: 0; margin: .4rem 0; }
.report-reasons legend { font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.radio-row { display: flex; align-items: center; gap: .55rem; min-height: 44px; font-size: .95rem; cursor: pointer; }
.radio-row input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); flex: none; }
.field textarea { padding: .6rem .7rem; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 1rem; resize: vertical; min-height: 4.5rem; }
.report-list { list-style: none; padding: 0; margin: .4rem 0 0; max-height: 50vh; overflow-y: auto; }
.report-item { border-top: 1px solid var(--border); padding: .55rem 0; font-size: .9rem; overflow-wrap: anywhere; }
.report-note { margin-top: .25rem; font-size: .88rem; color: var(--text-secondary); white-space: pre-wrap; }
.verdict-time { font-weight: 500; opacity: .8; font-size: .9em; }
.sub-h { font-size: .82rem; color: var(--muted); font-weight: 600; margin: .8rem 0 .3rem; text-transform: uppercase; letter-spacing: .03em; }
.time-table td:nth-child(2), .time-table td:nth-child(3), .time-table th:nth-child(2), .time-table th:nth-child(3) { text-align: right; white-space: nowrap; }
.mock-trend { margin: .2rem 0 .6rem; }
.mock-trend .dot { stroke: var(--card); stroke-width: 1.5; }
#results .analytics-card { margin-top: 1rem; text-align: left; }
.slow-q { font-size: .85rem; }

/* ---------- v4.12: case sets (shared vignette) ---------- */
.vignette { margin-bottom: .9rem; }
.vignette-tag { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); margin-bottom: .35rem; }
.vignette-box { background: var(--bg); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: .65rem .8rem; font-size: .9rem; line-height: 1.55; }
.vignette-box summary { font-weight: 700; cursor: pointer; margin-bottom: .2rem; }
.vignette-box p { margin: .45rem 0 0; overflow-wrap: anywhere; }
.vignette-box .table-wrap { margin-top: .5rem; }
/* v4.13: case tables keep words and numbers whole; only the first (label) column wraps */
.vignette-box th, .vignette-box td { overflow-wrap: normal; word-break: normal; padding: .35rem .4rem; }
.vignette-box td:not(:first-child), .vignette-box th:not(:first-child) { white-space: nowrap; }
.case-btn { border-style: dashed; }

/* ---------- v4.12: paywall (native app; web preview via ?paywall=preview) ---------- */
.pw-sale { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 10px; padding: .55rem .75rem; margin-bottom: .8rem; font-size: .9rem; }
.pw-sale #pw-countdown { font-variant-numeric: tabular-nums; }
.pw-features { margin: 0 0 .9rem 1.1rem; padding: 0; font-size: .9rem; line-height: 1.6; }
.pw-plans { display: flex; flex-direction: column; gap: .6rem; margin-bottom: .9rem; }
.pw-plan { display: flex; flex-direction: column; align-items: stretch; gap: .25rem; text-align: left; width: 100%; background: var(--card); color: var(--text); border: 2px solid var(--border); border-radius: 12px; padding: .75rem .85rem; cursor: pointer; font: inherit; }
.pw-plan.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pw-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.pw-title { font-weight: 700; }
.pw-badge { background: #15803d; color: #fff; font-size: .75rem; font-weight: 800; border-radius: 999px; padding: .15rem .55rem; white-space: nowrap; }
.pw-price { font-size: 1.05rem; }
.pw-was { color: var(--muted); margin-right: .2rem; }
.pw-now { font-size: 1.35rem; font-weight: 800; }
.pw-per { color: var(--muted); font-size: .85rem; }
.pw-terms { color: var(--muted); font-size: .76rem; line-height: 1.4; }
.pw-legal { color: var(--muted); font-size: .72rem; line-height: 1.45; margin-top: .6rem; }
#pw-restore { display: block; margin: .6rem auto 0; }

.pw-legal a { color: var(--accent, #60a5fa); }

/* ======================= v4.14 polish ======================= */
:root { --accent-strong: #2563eb; --accent-strong-hover: #1d4ed8; --gold: #f59e0b; --silver: #94a3b8; --bronze: #c2773b; --platinum: #67e8f9; }
[data-theme="light"] { --accent-strong: #2563eb; --accent-strong-hover: #1e40af; --gold: #b45309; --silver: #64748b; --bronze: #9a5527; --platinum: #0e7490; }
/* iOS feel: no grey tap flash, no double-tap zoom delay, no rubber-band bleed behind the app, no text-selection callouts on controls */
html { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; background: var(--bg); }
body { overscroll-behavior-y: none; }
button, .btn, .option, .choice, .tool-btn, .seg button, .len-btn, .qbtn, .topic-btn, summary, label.toggle, label.check {
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
a { color: var(--accent-text); }
a:not(.btn):not(.skip-link) { text-decoration-thickness: 1px; text-underline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
/* safe areas on all edges (landscape notch) */
header { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
main { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); padding-bottom: calc(2.5rem + env(safe-area-inset-bottom)); }
.modal { padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); overscroll-behavior: contain; }
.modal-card { overscroll-behavior: contain; }
.toast { bottom: calc(1.2rem + env(safe-area-inset-bottom)); }
/* contrast (WCAG AA): filled buttons use a darker blue; text-coloured accents use the -text tokens */
.btn.primary, .len-btn.active, .seg button.active, .skip-link { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary { box-shadow: 0 2px 8px rgba(37,99,235,.3); }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong-hover); }
.seg button.active small { color: #fff; }
.link-btn { color: var(--accent-text); }
.btn.text { color: var(--text-secondary); min-height: 44px; }
.btn.text.danger, .btn.text.danger:hover { color: var(--danger-text); }
.band-start { color: var(--danger-text) !important; } .band-build { color: var(--warning-text) !important; }
.verdict.ok, .ks-result { color: var(--success-text); } .verdict.bad { color: var(--danger-text); }
.formula-index a, .formula-section h3 { color: var(--accent-text); }
.option.selected .opt-letter { background: var(--accent-strong); border-color: var(--accent-strong); }
#progress-fill { background: var(--accent-strong); }
/* tap targets ≥ 44 pt */
.skip-link { min-height: 44px; display: inline-flex; align-items: center; }
.len-btn { min-height: 44px; }
.formula-tag { min-height: 44px; }
.link-btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.formula-index a { min-height: 44px; display: inline-flex; align-items: center; padding: .25rem .7rem; }
.practice-f { padding: .2rem 0; }
/* reduced motion: no transitions or animations anywhere */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.actions-title { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .6rem 0 0; font-weight: 600; }
.wide { width: 100%; display: block; }
.btn.wide + .btn.wide { margin-top: .55rem; }
.left { text-align: left; }
.select, textarea, input[type="text"], input[type="date"] {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: .6rem .7rem; min-height: 44px; margin: .3rem 0 .6rem;
}
textarea { resize: vertical; min-height: 7rem; }
input[type="date"] { -webkit-appearance: none; appearance: none; }
.field { display: block; text-align: left; font-size: .85rem; color: var(--text-secondary); margin-top: .4rem; }
.text-link { color: var(--accent-text); font-weight: 600; overflow-wrap: anywhere; }

/* quiz tools: bookmark / note / report */
.quiz-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-top: .7rem; }
.tool-btn { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); border-radius: 10px; min-height: 44px; padding: .35rem .4rem; font-size: .82rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .3rem; }
.tool-btn:hover { border-color: var(--accent); color: var(--text); }
.tool-btn[aria-pressed="true"] { border-color: var(--gold); color: var(--warning-text); background: var(--warning-soft); }
.tool-btn:disabled { opacity: .5; cursor: default; }
.quiz-note { margin-top: .6rem; font-size: .85rem; background: var(--warning-soft); border-radius: 10px; padding: .5rem .7rem; color: var(--text); white-space: pre-wrap; }
.report-btn { display: inline-flex; margin: 0; }

/* dashboard plan card */
.plan-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem; margin-bottom: .9rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .6rem; }
.plan-card:empty { display: none; }
.countdown { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.cd-num { font-size: 1.7rem; font-weight: 750; color: var(--accent-text); letter-spacing: -.02em; line-height: 1.1; }
.cd-label { font-size: .88rem; color: var(--text-secondary); }
.countdown .link-btn { min-height: 44px; padding: 0 .2rem; }
.goal-head { display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-secondary); margin-bottom: .25rem; font-weight: 600; }
.mini-bar { height: .5rem; background: var(--border); border-radius: 999px; overflow: hidden; flex: 1; min-width: 3rem; }
.mini-bar > i { display: block; height: 100%; background: var(--accent-strong); border-radius: 999px; transition: width .4s ease; }
.mini-bar.goal > i { background: var(--warning); } .mini-bar.goal.done > i { background: var(--success); }
.level-line { display: flex; align-items: center; gap: .6rem; font-size: .85rem; font-weight: 650; }
.level-btn { background: none; border: none; color: var(--text); font: inherit; font-weight: 650; font-size: .85rem; width: 100%; min-height: 44px; padding: 0; cursor: pointer; text-align: left; }
.results-progress { max-width: 360px; margin: .8rem auto; display: flex; flex-direction: column; gap: .6rem; }

/* onboarding */
#onboarding { padding-top: .5rem; }
.onb-dots { display: flex; gap: .4rem; justify-content: center; margin: .3rem 0 1rem; }
.onb-dots i { width: .5rem; height: .5rem; border-radius: 50%; background: var(--border); }
.onb-dots i.on { background: var(--accent-strong); width: 1.4rem; border-radius: 999px; }
.onb-step { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .2rem; font-weight: 600; }
.disclaimer-box { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--warning); border-radius: 12px; padding: .75rem .9rem; font-size: .82rem; color: var(--text-secondary); margin: 0 0 1.1rem; }
.choice-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.choice { display: flex; justify-content: space-between; align-items: center; gap: .5rem; text-align: left; width: 100%; min-height: 52px; padding: .7rem 1rem; background: var(--card); color: var(--text); border: 2px solid var(--border); border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer; }
.choice[aria-checked="true"] { border-color: var(--accent-strong); background: var(--accent-soft); }
.choice[aria-checked="true"]::after { content: "✓"; color: var(--accent-text); font-weight: 800; }
.onb-nav { display: grid; grid-template-columns: 1fr 2fr; gap: .6rem; }

/* builder */
.bl-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.check-list { display: flex; flex-direction: column; }
.check { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; min-height: 44px; border-bottom: 1px solid var(--border); font-size: .9rem; cursor: pointer; }
.check:last-child { border-bottom: none; }
.check input, .toggle input { width: 1.25rem; height: 1.25rem; accent-color: var(--accent-strong); }
.seg.seg-5 { grid-template-columns: repeat(3, 1fr); max-width: none; }
.seg.seg-4 { max-width: none; }
.seg.seg-5 button, .seg.seg-4 button { font-weight: 600; font-size: .85rem; }
.toggle.left { justify-content: flex-start; margin-top: .6rem; }
#bl-match { font-size: .88rem; color: var(--text-secondary); min-height: 1.4em; }

/* flashcards */
.fc-stats { grid-template-columns: repeat(4, 1fr); gap: .45rem; margin: .8rem 0; }
.fc-stats .stat-card { padding: .6rem .3rem; } .fc-stats .stat-value { font-size: 1.2rem; color: var(--accent-text); }
.fc-fill { height: 100%; background: var(--accent-strong); }
.flashcard { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem 1.1rem; min-height: 11rem; display: flex; flex-direction: column; justify-content: center; gap: .5rem; text-align: center; box-shadow: var(--shadow); margin-bottom: .8rem; }
.flashcard .formula-expr { text-align: left; }
.fc-name { font-size: 1.15rem; font-weight: 700; }
.qbtn small { display: block; font-size: .7rem; font-weight: 500; opacity: .9; }

/* notebook */
.nb-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; margin-top: .9rem; }
.nb-item { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .75rem .9rem; }
.nb-meta { font-size: .76rem; color: var(--muted); margin-bottom: .25rem; }
.nb-star { color: var(--warning-text); font-weight: 600; }
.nb-q { font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.nb-note { font-size: .85rem; background: var(--warning-soft); border-radius: 8px; padding: .4rem .6rem; margin-top: .4rem; white-space: pre-wrap; }
.nb-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.nb-actions .tool-btn { flex: 1 1 auto; }
.empty-state { text-align: center; padding: 1.6rem 1rem; background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state p { margin-top: .35rem; }
.empty-icon { font-size: 2rem; }

/* achievements */
.level-card { display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.level-badge { width: 3.2rem; height: 3.2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.25rem; color: #fff; background: linear-gradient(135deg, var(--accent-strong), #7c3aed); }
.level-info { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.level-count { text-align: center; display: flex; flex-direction: column; }
.level-count strong { font-size: 1.3rem; }
.xp-help { margin: .6rem 0; font-size: .85rem; } .xp-help summary { cursor: pointer; color: var(--accent-text); min-height: 44px; display: flex; align-items: center; font-weight: 600; }
.badge-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.badge { display: grid; grid-template-columns: auto 1fr; gap: .75rem; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: .75rem .85rem; }
.badge-icon { width: 2.6rem; height: 2.6rem; border-radius: 50%; display: grid; place-items: center; font-size: 1.3rem; background: var(--bg); border: 2px solid var(--border); }
.badge.locked .badge-icon { filter: grayscale(1); opacity: .55; }
.badge.tier-0 .badge-icon { border-color: var(--bronze); } .badge.tier-1 .badge-icon { border-color: var(--silver); }
.badge.tier-2 .badge-icon { border-color: var(--gold); } .badge.tier-3 .badge-icon { border-color: var(--platinum); }
.badge-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.badge-tier { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.badge.tier-0 .badge-tier { color: var(--bronze); } .badge.tier-1 .badge-tier { color: var(--text-secondary); } .badge.tier-2 .badge-tier { color: var(--gold); } .badge.tier-3 .badge-tier { color: var(--platinum); }
.badge-goal { font-size: .84rem; color: var(--text-secondary); margin: .15rem 0 .35rem; }
.badge-prog { margin-top: .2rem; }
.tier-pips { display: flex; gap: .25rem; margin-top: .35rem; }
.tier-pips i { width: .55rem; height: .55rem; border-radius: 50%; background: var(--border); }
.tier-pips i.on.t0 { background: var(--bronze); } .tier-pips i.on.t1 { background: var(--silver); } .tier-pips i.on.t2 { background: var(--gold); } .tier-pips i.on.t3 { background: var(--platinum); }
.pro-tag { display: inline-block; font-size: .66rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: .05rem .4rem; border-radius: 6px; background: var(--accent-soft); color: var(--accent-text); border: 1px solid var(--accent); }
.diag-list { list-style: none; display: grid; grid-template-columns: 1fr; gap: .2rem; margin-bottom: .5rem; font-size: .86rem; }
.diag-list li.ok span:first-child { color: var(--success-text); font-weight: 700; } .diag-list li.bad span:first-child { color: var(--danger-text); font-weight: 700; }
.faq { border-bottom: 1px solid var(--border); } .faq:last-child { border-bottom: none; }
.faq summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; font-size: .9rem; }
.faq p { padding-bottom: .6rem; color: var(--text-secondary); }

/* unlock toast + confetti */
.ach-toast { position: fixed; left: 50%; top: calc(.8rem + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 70; width: min(92vw, 400px);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .7rem; background: var(--bg-elevated); color: var(--text);
  border: 2px solid var(--gold); border-radius: 16px; padding: .65rem .8rem; box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: achIn .35s ease; overflow: visible; }
.ach-toast.tier-0 { border-color: var(--bronze); } .ach-toast.tier-1 { border-color: var(--silver); } .ach-toast.tier-3 { border-color: var(--platinum); }
.ach-toast-icon { font-size: 1.7rem; }
.ach-toast-text { display: flex; flex-direction: column; font-size: .86rem; min-width: 0; }
.ach-toast-btn { background: var(--accent-strong); color: #fff; border: none; border-radius: 10px; min-height: 44px; min-width: 44px; padding: 0 .8rem; font: inherit; font-weight: 700; cursor: pointer; }
@keyframes achIn { from { opacity: 0; transform: translate(-50%, -12px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.confetti i { position: absolute; top: 50%; left: var(--x); width: 6px; height: 10px; border-radius: 2px; background: var(--gold); opacity: 0;
  animation: confetti 1.1s ease-out var(--d) forwards; transform: rotate(var(--r)); }
.confetti i:nth-child(3n) { background: var(--accent-strong); } .confetti i:nth-child(3n+1) { background: var(--success); }
@keyframes confetti { 0% { opacity: 1; transform: translateY(0) rotate(var(--r)); } 100% { opacity: 0; transform: translateY(70px) rotate(calc(var(--r) + 260deg)); } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } .ach-toast { animation: none; } }
.link-btn { min-width: 44px; padding: .2rem .4rem; }
.toast { pointer-events: none; }

/* ---------------- v4.15 ---------------- */
/* Daily Drill card: first thing under the title, so the main daily action is above the fold on a 375×667 iPhone SE */
.daily-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem .8rem .55rem; margin: .7rem 0 .85rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .55rem; }
.daily-card .daily-banner { margin: 0; padding: .5rem .75rem; }
.daily-card #btn-daily { width: 100%; font-size: 1.02rem; }
.daily-card .daily-length { margin: 0; }
#dashboard > .subtitle { margin-bottom: .3rem; }
/* Paywall: compact plan rows + sticky purchase footer */
.pw-features { margin-bottom: .35rem; line-height: 1.45; }
.pw-more { margin: 0 0 .7rem; font-size: .86rem; }
.pw-more summary { color: var(--accent-text); cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.pw-more-list { margin: .2rem 0 0 1.1rem; padding: 0; line-height: 1.5; }
.pw-plans { gap: .45rem; margin-bottom: .6rem; }
.pw-plan { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .05rem .6rem; padding: .5rem .8rem; min-height: 56px; }
.pw-plan .pw-head { grid-column: 1; grid-row: 1 / span 2; justify-content: flex-start; flex-wrap: wrap; gap: .3rem .5rem; }
.pw-plan .pw-price { grid-column: 2; grid-row: 1; text-align: right; white-space: nowrap; font-size: .95rem; }
.pw-plan .pw-now { font-size: 1.15rem; }
.pw-plan .pw-eq { grid-column: 2; grid-row: 2; text-align: right; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.pw-plan .pw-terms { grid-column: 1 / -1; grid-row: 3; margin-top: .25rem; }
.pw-plan:not(.selected) .pw-terms { display: none; }
.pw-footer { position: sticky; bottom: 0; z-index: 6; background: var(--bg); border-top: 1px solid var(--border);
  margin: .6rem -1rem 0; padding: .55rem 1rem calc(.45rem + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: .35rem; box-shadow: 0 -6px 16px rgba(0,0,0,.18); }
.pw-footer #pw-continue { width: 100%; }
.pw-footer #pw-restore { margin: 0 auto; }
.pw-sel { margin: 0; font-size: .82rem; text-align: center; line-height: 1.35; }
.pw-legal { margin-top: .2rem; }
/* Flashcards: prose cards (Standards, lists) read better in the body font than in monospace */
.formula-expr.prose { font-family: inherit; font-size: .95rem; line-height: 1.5; white-space: normal; }
/* v4.15: large text sizes let the plan price wrap instead of pushing the page sideways */
.pw-plan { grid-template-columns: minmax(0, 1fr) auto; }
.pw-plan .pw-head { min-width: 0; }
html[data-textsize="l"] .pw-plan .pw-price, html[data-textsize="xl"] .pw-plan .pw-price { white-space: normal; max-width: 9.5rem; }
html[data-textsize="l"] .pw-plan .pw-per, html[data-textsize="xl"] .pw-plan .pw-per { display: block; }
html[data-textsize="l"] .pw-plan .pw-eq, html[data-textsize="xl"] .pw-plan .pw-eq { white-space: normal; }

/* v4.17: Full Exam */
.fe-note { background: var(--accent-soft); border: 1px solid var(--border); border-radius: 10px; padding: .55rem .75rem; font-size: .85rem; line-height: 1.45; }
.fe-alloc { margin: .35rem 0; line-height: 1.45; }
.fe-break .btn { margin-top: .4rem; }
#fe-break-clock { font-variant-numeric: tabular-nums; font-size: 1.1rem; }
#btn-full-exam.in-progress { border-color: var(--accent); }
.fe-session .fe-used { display: block; font-weight: 400; }
