/* ============ ScoreClimb — fun SAT prep ============ */
:root {
  --bg: #f6f4ff;
  --card: #ffffff;
  --raised: #ffffff;
  --ink: #2d2a45;
  --ink-soft: #3d3a58;
  --muted: #8a86a8;
  --primary: #6c4df6;
  --primary-dark: #5438d9;
  --accent: #ff9f1c;
  --green: #22c55e;
  --green-soft: #e8fbef;
  --green-ink: #15803d;
  --red: #ef4444;
  --red-soft: #fdeaea;
  --red-ink: #b91c1c;
  --gold: #fbbf24;
  --gold-soft: #fff8e6;
  --line: #e4dfff;
  --line-strong: #cfc6ff;
  --tint: #f1edff;
  --tint-soft: #faf9ff;
  --track: #ece8ff;
  --topbar: rgba(246, 244, 255, .92);
  --radius: 20px;
  --shadow: 0 4px 16px rgba(80, 60, 180, .10);
  color-scheme: light;
}

html.dark {
  --bg: #141227;
  --card: #1e1b38;
  --raised: #262347;
  --ink: #ecebf7;
  --ink-soft: #c9c5e2;
  --muted: #9b97bf;
  --primary: #8b74ff;
  --primary-dark: #6a4ff0;
  --green-soft: #12301f;
  --green-ink: #4ade80;
  --red-soft: #38181d;
  --red-ink: #f87171;
  --gold-soft: #332b10;
  --line: #37325e;
  --line-strong: #4a4380;
  --tint: #2b2750;
  --tint-soft: #232045;
  --track: #322d58;
  --topbar: rgba(20, 18, 39, .92);
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* pre-paint state from the early inline script in <head> — avoids a flash of the
   onboarding screen (or wrong theme) for returning users while app.js boots */
html.authed #screen-onboarding { display: none !important; }
html.authed #app-shell { display: block !important; }
body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-weight: 900; margin: .4em 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.5rem; }
h4 { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; margin-top: 1.2em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.accent { color: var(--primary); }
a { color: var(--primary); }

.screen { max-width: 760px; margin: 0 auto; padding: 20px 16px 90px; }

/* ---------- buttons, chips, inputs ---------- */
.btn {
  font-family: inherit; font-weight: 800; font-size: 1rem;
  border: none; border-radius: 16px; padding: 12px 22px; cursor: pointer;
  transition: transform .08s, box-shadow .15s; display: block; width: 100%; margin-top: 12px;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 4px 0 var(--primary-dark);
}
.btn-primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.btn-big { padding: 16px 24px; font-size: 1.1rem; margin-top: 24px; }
.btn-ghost { background: transparent; color: var(--primary); border: 2px dashed var(--line-strong); }
.btn-danger { background: var(--red-soft); color: var(--red); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  font-family: inherit; font-weight: 700; font-size: .92rem;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  background: var(--raised); border: 2px solid var(--line); color: var(--ink);
  transition: all .12s;
}
.chip:hover { border-color: var(--primary); }
.chip.selected { background: var(--primary); border-color: var(--primary); color: #fff; }

.text-input {
  font-family: inherit; font-size: 1.05rem; font-weight: 700;
  width: 100%; padding: 13px 16px; margin: 6px 0;
  border: 2px solid var(--line); border-radius: 14px; background: var(--raised); color: var(--ink);
}
.text-input:focus { outline: none; border-color: var(--primary); }
.field-label { display: block; margin-top: 18px; font-weight: 800; font-size: .95rem; }

.slider { width: 100%; accent-color: var(--primary); height: 34px; }

/* ---------- onboarding ---------- */
#screen-onboarding { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px 16px; }
.onboard-wrap { max-width: 460px; width: 100%; text-align: center; }
.onboard-progress { height: 10px; background: var(--line); border-radius: 999px; margin-bottom: 34px; overflow: hidden; }
#ob-bar { height: 100%; width: 10%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; transition: width .3s; }
.ob-mascot { font-size: 3.4rem; margin-bottom: 4px; }
.ob-sub { color: var(--muted); font-weight: 600; margin-top: 0; }
.brand { color: var(--primary); }
.target-display { font-size: 3.2rem; font-weight: 900; color: var(--primary); margin: 8px 0; }
.goal-cards { display: flex; gap: 10px; margin-top: 14px; }
.goal-card {
  flex: 1; font-family: inherit; background: var(--raised); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: center;
  font-weight: 700; color: var(--muted); transition: all .12s;
}
.goal-card strong { color: var(--ink); font-size: 1.05rem; }
.goal-card.selected { border-color: var(--primary); background: var(--tint); box-shadow: var(--shadow); }
.goal-emoji { font-size: 1.6rem; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; background: var(--topbar);
}
.brand-mini { font-weight: 900; font-size: 1.15rem; color: var(--primary); cursor: pointer; }
.topbar-stats { display: flex; gap: 8px; }
.stat-pill {
  font-weight: 800; font-size: .92rem; padding: 6px 13px; border-radius: 999px; background: var(--raised); box-shadow: var(--shadow);
}
.streak-pill { color: #e8590c; }
.xp-pill { color: var(--primary); }
.streak-pill.pop { animation: pop .4s; }
@keyframes pop { 40% { transform: scale(1.35); } }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around; padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--raised); box-shadow: 0 -4px 20px rgba(80,60,180,.12);
}
.tab {
  font-family: inherit; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 1.3rem; color: var(--muted); font-weight: 800; padding: 6px 10px; border-radius: 14px;
}
.tab span { font-size: .68rem; }
.tab.active { color: var(--primary); background: var(--tint); }

/* ---------- cards & dashboard ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hero-card, .badges-card, .streak-card, .ap-card { grid-column: 1 / -1; }
.hero-card { display: flex; gap: 20px; align-items: stretch; }
.hero-left { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.hero-right { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.test-track + .test-track { padding-top: 14px; border-top: 2px solid var(--tint); }
.track-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 900; margin-bottom: 6px; }
.countdown-line { font-weight: 800; color: var(--accent); font-size: .85rem; }
.pace-line { font-weight: 700; font-size: .9rem; color: var(--muted); margin: 6px 0 0; }
.pace-line.small { font-size: .8rem; }

.score-journey { margin: 8px 0 10px; }
.journey-labels { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); font-weight: 700; text-align: center; margin-bottom: 6px; }
.journey-labels strong { font-size: 1.05rem; color: var(--ink); }
.journey-labels strong.accent { color: var(--primary); }
.journey-track { position: relative; height: 14px; background: var(--track); border-radius: 999px; }
.journey-fill { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--accent)); transition: width .6s; }
.journey-dot { position: absolute; top: -13px; left: 0%; transform: translateX(-50%); font-size: 1.3rem; transition: left .6s; }

.goal-ring-wrap { position: relative; width: 120px; height: 120px; }
.goal-ring { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--track); stroke-width: 12; }
.ring-fg { fill: none; stroke: var(--green); stroke-width: 12; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset .6s; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; }
.ring-center small { color: var(--muted); font-weight: 700; }

.section-card { cursor: pointer; transition: box-shadow .12s; }
.section-card:hover { box-shadow: 0 8px 24px rgba(80, 60, 180, .18); }
.section-emoji { font-size: 2rem; }
.mini-bar { height: 10px; background: var(--track); border-radius: 999px; margin: 8px 0 6px; overflow: hidden; }
.mini-bar > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; transition: width .5s; }
.section-card p { margin: 0; font-size: .85rem; font-weight: 700; }

.badge-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.badge {
  display: flex; flex-direction: column; align-items: center; width: 86px; text-align: center;
  background: var(--tint-soft); border: 2px solid var(--track); border-radius: 16px; padding: 10px 4px; gap: 2px;
}
.badge .b-emoji { font-size: 1.7rem; }
.badge .b-name { font-size: .68rem; font-weight: 800; }
.badge.locked { filter: grayscale(1); opacity: .45; }

/* ---------- quiz ---------- */
.btn-exit { background: var(--raised); border: none; border-radius: 12px; width: 36px; height: 36px; font-size: 1rem; cursor: pointer; box-shadow: var(--shadow); color: var(--muted); font-weight: 900; }
.btn-exit.on { background: var(--accent); color: #fff; }
.quiz-meta { display: flex; gap: 8px; margin: 6px 0 10px; font-size: .75rem; font-weight: 800; }
.quiz-meta span { background: var(--raised); border-radius: 999px; padding: 4px 12px; box-shadow: var(--shadow); color: var(--muted); }
.quiz-meta .diff-E { color: var(--green); } .quiz-meta .diff-M { color: var(--accent); } .quiz-meta .diff-H { color: var(--red); }

.q-stimulus { border-left: 4px solid var(--track); padding-left: 14px; margin-bottom: 14px; color: var(--ink-soft); }
.q-stimulus:empty { display: none; }
.q-stem { font-weight: 700; }
/* College Board question content embeds numbers/expressions as MathML <math> tags,
   which browsers render with their own internal math font by default — this fixes
   the visual mismatch (thin, non-bold, mismatched size) against the surrounding text */
math { font-size: inherit; font-weight: inherit; font-style: inherit; }
/* some question content embeds math as tiny (often ~24x16px) raster images rather
   than MathML — scale them up relative to the surrounding text so they're legible
   instead of rendering as an illegible speck */
.math-img { height: 1.4em !important; width: auto !important; vertical-align: middle; display: inline-block; }
/* these images (small inline formulas, standalone graphs/charts, and inline SVG
   figures alike) are dark lines/text rendered for a white background -- invisible
   or illegible against our dark theme without inverting them */
html.dark .math-img,
html.dark .q-stimulus img, html.dark .q-stem img, html.dark #q-rationale img,
html.dark .q-stimulus svg, html.dark .q-stem svg, html.dark #q-rationale svg {
  filter: invert(1) hue-rotate(180deg);
}
.q-stimulus table, .q-stem table { border-collapse: collapse; margin: 10px auto; }
.q-stimulus td, .q-stimulus th, .q-stem td, .q-stem th { border: 1px solid var(--line); padding: 6px 12px; }
.q-stimulus img, .q-stem img, #q-rationale img { max-width: 100%; height: auto; }
.q-stimulus svg, .q-stem svg, #q-rationale svg { max-width: 100%; height: auto; }

/* College Board question HTML: hide screen-reader-only long descriptions, scale figures */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.q-stimulus svg, .q-stem svg, #q-rationale svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.q-stimulus figure, .q-stem figure { margin: 8px 0; text-align: center; }
.dap_copyright { font-size: .75rem; color: var(--muted); }

.q-options { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.sat-option-row { display: flex; align-items: center; gap: 14px; }
.opt {
  display: flex; gap: 14px; align-items: flex-start; text-align: left;
  font-family: inherit; font-size: 1rem; color: var(--ink);
  background: var(--tint-soft); border: 2px solid var(--line); border-radius: 16px; padding: 16px 18px; cursor: pointer;
  transition: all .12s; width: 100%; flex: 1; min-width: 0;
}
.opt:hover { border-color: var(--primary); }
.opt .opt-letter {
  flex: 0 0 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-weight: 900; background: var(--raised);
}
.opt.selected { border-color: var(--primary); background: var(--tint); }
.opt.selected .opt-letter { background: var(--primary); border-color: var(--primary); color: #fff; }
.opt.correct { border-color: var(--green); background: var(--green-soft); }
.opt.correct .opt-letter { background: var(--green); border-color: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.wrong .opt-letter { background: var(--red); border-color: var(--red); color: #fff; }
.opt:disabled { cursor: default; }
.opt > div { min-width: 0; }
.opt p { margin: 0; }

/* per-option cross-out toggle (sits to the right of each choice, real-SAT style —
   crossing out is a standalone per-choice action, not a separate "mode" you switch) */
.sat-crossout-toggle {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  background: var(--raised); border: 2px solid var(--line); color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: .8rem;
  position: relative; font-family: inherit;
}
.sat-crossout-toggle::after {
  content: ''; position: absolute; left: 3px; right: 3px; top: 50%; height: 2px;
  background: var(--muted); transform: rotate(-18deg); opacity: 0;
}
.sat-crossout-toggle.on { border-color: var(--ink); color: var(--ink); }
.sat-crossout-toggle.on::after { opacity: 1; background: var(--ink); }

.q-spr { margin-top: 14px; }

.prev-answer-btn { display: block; background: none; border: none; color: var(--accent); font-weight: 700; font-size: .85rem; text-decoration: underline; padding: 2px 0 8px; cursor: pointer; }
.q-feedback { margin-top: 4px; }
.feedback-banner { border-radius: 16px; padding: 12px 18px; font-weight: 900; font-size: 1.05rem; margin-bottom: 10px; }
.feedback-banner.good { background: var(--green-soft); color: var(--green-ink); }
.feedback-banner.bad { background: var(--red-soft); color: var(--red-ink); }
.rationale-card summary { font-weight: 900; cursor: pointer; }
#q-rationale { margin-top: 8px; color: var(--ink-soft); font-size: .95rem; }
.quiz-actions { margin-top: 8px; }

/* ---------- results ---------- */
.results-card { text-align: center; padding: 34px 24px; }
.results-emoji { font-size: 3.6rem; }
.results-stats { display: flex; justify-content: center; gap: 34px; margin: 18px 0; }
.results-stats div { display: flex; flex-direction: column; }
.results-stats strong { font-size: 1.7rem; font-weight: 900; }
.results-stats span { color: var(--muted); font-weight: 700; font-size: .82rem; }
#res-badges .badge-earned {
  background: var(--gold-soft); border: 2px solid var(--gold); border-radius: 14px; padding: 8px 14px;
  font-weight: 800; margin: 4px; display: inline-block;
}

/* ---------- stats ---------- */
.skill-list { display: flex; flex-direction: column; gap: 10px; }
.skill-row { display: grid; grid-template-columns: 1fr 110px 46px; gap: 10px; align-items: center; font-weight: 700; font-size: .9rem; }
.skill-row .sk-bar { height: 10px; background: var(--track); border-radius: 999px; overflow: hidden; }
.skill-row .sk-bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.skill-row .sk-pct { text-align: right; color: var(--muted); font-size: .8rem; }
.domain-tag {
  display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 999px;
  font-size: .72rem; font-weight: 800; vertical-align: middle;
}
.domain-tag-weak { background: var(--red-soft); color: var(--red-ink); }
.domain-tag-strong { background: var(--green-soft); color: var(--green-ink); }
.activity-grid { display: flex; gap: 5px; flex-wrap: wrap; }
.day-cell { width: 22px; height: 22px; border-radius: 6px; background: var(--track); }
.day-cell.lvl1 { background: #b9f0cd; } .day-cell.lvl2 { background: #62d992; } .day-cell.lvl3 { background: var(--green); }

.settings-card .btn { margin-top: 16px; }

/* ---------- toast & confetti ---------- */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); max-width: 92vw; text-align: center;
  background: var(--ink); color: var(--bg); font-weight: 800; padding: 12px 22px; border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); z-index: 60; animation: toast-in .25s;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }
/* hidden by default -- Confetti.burst() shows it only while particles are animating,
   so this full-viewport, highest-z-index canvas isn't a permanent compositor layer
   sitting over every screen */
#confetti-canvas { display: none; position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* ---------- practice exam ---------- */
body.exam-mode .tabbar { display: none; }

.exam-pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.exam-spec-table { width: 100%; font-size: .85rem; }
.resume-card { border: 3px solid var(--accent); }

.ex-module-label { font-weight: 900; font-size: .85rem; color: var(--muted); }
.ex-timer {
  font-weight: 900; font-size: 1.15rem; font-variant-numeric: tabular-nums;
  background: var(--raised); padding: 6px 14px; border-radius: 12px; box-shadow: var(--shadow); color: var(--ink);
}
.ex-timer.low { color: var(--red); animation: timer-pulse 1s infinite; }
@keyframes timer-pulse { 50% { background: var(--red-soft); } }
.ex-mod-label-row { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 10px; font-size: .8rem; }
.ex-qcount { font-weight: 900; color: var(--muted); }

.opt.crossed { opacity: .45; }
.opt.crossed > div { text-decoration: line-through; }

.exam-nav-row { display: flex; gap: 10px; }
.exam-nav-row .btn { margin-top: 8px; }

/* ---------- real-SAT-format test-taking screens (Practice quiz + Exam runner) ----------
   Always renders as a plain white/black exam interface (like the actual Bluebook
   testing app), regardless of the app's own light/dark theme setting -- test-day
   fidelity matters more here than matching the user's theme preference. */
body.sat-testing { background: #fff; }
body.sat-testing .topbar,
body.sat-testing .tabbar { display: none; }

.sat-mode { --sat-ink: #14171a; --sat-muted: #5b6470; --sat-line: #d7dbe0; --sat-bg: #fff; --sat-raised: #f4f5f7; }
.sat-mode {
  background: var(--sat-bg); color: var(--sat-ink); border-radius: 0; box-shadow: none;
  max-width: 1180px; width: 100%; padding-left: 40px; padding-right: 40px;
}

.sat-topbar { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.sat-qnum {
  flex: 0 0 34px; height: 34px; border-radius: 8px; background: var(--sat-ink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 1.05rem;
}
.sat-mark-btn {
  display: flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer;
  font-family: inherit; font-weight: 800; font-size: .85rem; color: var(--sat-muted); padding: 6px 4px;
}
.sat-mark-icon { font-size: 1rem; filter: grayscale(1); opacity: .6; }
.sat-mark-btn.on { color: var(--sat-ink); }
.sat-mark-btn.on .sat-mark-icon { filter: none; opacity: 1; }
.sat-topbar-spacer { flex: 1; }
.sat-icon-btn {
  background: var(--sat-raised); border: 1px solid var(--sat-line); border-radius: 10px;
  width: 34px; height: 34px; font-size: .95rem; cursor: pointer; color: var(--sat-ink);
}
.sat-progress { height: 6px; background: var(--sat-line); border-radius: 999px; overflow: hidden; margin: 4px 0 6px; }
.sat-progress > div { height: 100%; background: var(--sat-ink); border-radius: 999px; transition: width .3s; }

.sat-mode .quiz-meta span { background: var(--sat-raised); color: var(--sat-muted); box-shadow: none; border: 1px solid var(--sat-line); }

.sat-body { display: flex; gap: 48px; margin-top: 18px; align-items: stretch; }
.sat-panel-left {
  flex: 1 1 48%; min-width: 0; padding-right: 24px;
  border-right: 1px solid var(--sat-line); font-family: 'Georgia', 'Times New Roman', serif; font-size: 1.05rem; line-height: 1.6;
}
.sat-panel-left:empty,
.sat-body.single .sat-panel-left { display: none; }
.sat-body.single .sat-panel-right { flex: 1 1 100%; }
.sat-panel-right { flex: 1 1 54%; min-width: 0; }
.sat-mode .q-stimulus { border-left: none; padding-left: 0; margin-bottom: 0; color: var(--sat-ink); }
.sat-mode .q-stem { color: var(--sat-ink); }
.sat-mode .opt { background: #fff; border-color: var(--sat-line); color: var(--sat-ink); }
.sat-mode .opt .opt-letter { background: #fff; border-color: var(--sat-line); color: var(--sat-ink); }
.sat-mode .opt.selected { border-color: var(--sat-ink); background: var(--sat-raised); }
.sat-mode .opt.selected .opt-letter { background: var(--sat-ink); border-color: var(--sat-ink); }
.sat-mode .sat-crossout-toggle { background: #fff; }
/* the real digital SAT never inverts diagrams for a theme -- keep stimulus/stem
   media at their normal (non-dark-mode) colors even if the app itself is dark */
.sat-mode .q-stimulus img, .sat-mode .q-stem img,
.sat-mode .q-stimulus svg, .sat-mode .q-stem svg { filter: none !important; }

.sat-bottom-bar { display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--sat-line); padding-top: 12px; margin-top: 14px; }
.sat-count-label { font-weight: 800; color: var(--sat-muted); font-size: .9rem; white-space: nowrap; }
.sat-bottom-bar .btn { width: auto; display: inline-block; margin-top: 0; margin-left: auto; }
.exam-nav-row.sat-bottom-bar #ex-back { margin-left: 0; margin-right: auto; }
.exam-nav-row.sat-bottom-bar .btn-ghost:not(#ex-back) { margin-left: 0; }

@media (max-width: 720px) {
  .sat-mode { padding-left: 16px; padding-right: 16px; }
  .sat-body { flex-direction: column; gap: 0; }
  .sat-panel-left { padding-right: 0; padding-bottom: 16px; margin-bottom: 16px; border-right: none; border-bottom: 1px solid var(--sat-line); }
  .sat-mark-label { display: none; }
}
@media (min-width: 721px) and (max-width: 1000px) {
  .sat-mode { padding-left: 24px; padding-right: 24px; }
  .sat-body { gap: 32px; }
}

.overlay {
  position: fixed; inset: 0; z-index: 45; background: rgba(45, 42, 69, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.nav-card { max-width: 440px; width: 100%; max-height: 85vh; overflow-y: auto; }
.nav-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.nav-q {
  width: 46px; height: 40px; font-family: inherit; font-weight: 800; cursor: pointer;
  background: var(--tint-soft); border: 2px dashed var(--line-strong); border-radius: 10px; color: var(--muted);
}
.nav-q.answered { background: var(--tint); border-style: solid; border-color: var(--primary); color: var(--primary); }
.nav-q.current { outline: 3px solid var(--accent); }
.nav-q.flagged { border-color: var(--red); }

.break-timer { font-size: 3.4rem; font-weight: 900; color: var(--primary); font-variant-numeric: tabular-nums; margin: 10px 0; }

.exr-total { font-size: 4rem; font-weight: 900; color: var(--primary); line-height: 1.1; }
.exr-sections { display: flex; gap: 24px; justify-content: center; margin: 14px 0; }
.exr-sections > div { flex: 1; max-width: 220px; }
.exr-sections strong { font-size: 1.6rem; font-weight: 900; }
.exr-detail { margin: 14px 0 4px; text-align: left; }
.exam-hist-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 9px 4px; border-bottom: 2px solid var(--tint); font-weight: 700; font-size: .9rem;
}
.exam-hist-row:last-child { border-bottom: none; }
.missed-card summary { font-weight: 800; cursor: pointer; }
.missed-card .q-stimulus, .missed-card .q-stem { margin-top: 10px; }
.missed-rationale { color: var(--ink-soft); font-size: .92rem; margin-top: 6px; }

/* floating popup panels: Desmos calculator & reference sheet */
.float-panel {
  position: fixed; right: 14px; bottom: 14px; z-index: 48;
  width: min(460px, 94vw); height: min(540px, 78vh);
  min-width: 320px; min-height: 360px; max-width: 96vw; max-height: 90vh;
  background: var(--raised); border-radius: 16px; box-shadow: 0 12px 44px rgba(45,42,69,.35);
  display: flex; flex-direction: column; overflow: hidden; resize: both;
}
.ref-panel { height: auto; width: min(420px, 94vw); resize: none; }
.float-head {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--ink); color: var(--bg); font-weight: 800; font-size: .85rem; padding: 8px 14px;
  flex: 0 0 auto; cursor: grab; touch-action: none; user-select: none;
}
.float-head.dragging { cursor: grabbing; }
.float-head-actions { display: flex; gap: 4px; align-items: center; }
.float-head a { color: var(--bg); text-decoration: none; font-size: 1rem; padding: 2px 8px; }
.float-head button {
  background: none; border: none; color: var(--bg); font-size: 1rem; cursor: pointer;
  font-family: inherit; font-weight: 900; padding: 2px 6px;
}
#calc-frame { flex: 1; width: 100%; border: none; }
.ref-body { padding: 14px 18px; font-size: .9rem; overflow-y: auto; }
.ref-body p { margin: 6px 0; }

/* ---------- question bank browser ---------- */
.bank-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.bank-selpage-label { font-weight: 800; font-size: .85rem; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.bank-toolbar input[type="checkbox"], .bank-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.bank-row {
  display: grid; grid-template-columns: 28px 110px 76px 1fr 74px; gap: 8px; align-items: center;
  padding: 9px 4px; border-bottom: 2px solid var(--tint); font-weight: 700; font-size: .85rem; cursor: pointer;
}
.bank-row.bank-head { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; cursor: default; }
.bank-row.picked { background: var(--tint); }
.bank-row:not(.bank-head):hover { background: var(--tint-soft); }
.bank-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; color: var(--primary); font-weight: 700; }
.bank-seen { color: var(--green); font-family: 'Nunito', sans-serif; }
.bank-row .diff-E { color: var(--green); } .bank-row .diff-M { color: var(--accent); } .bank-row .diff-H { color: var(--red); }
.bank-pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 12px 0 4px; }
.bank-prev-head { display: flex; justify-content: space-between; align-items: center; }
.bank-prev-head strong { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--primary); }
.bp-opt { cursor: default; }
#bank-ids { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }

@media (max-width: 640px) {
  .bank-row { grid-template-columns: 24px 90px 1fr 60px; }
  .bank-row > span:nth-child(3) { display: none; } /* hide section column on small screens */
}

/* ---------- study guides ---------- */
.guide-nav { padding: 8px 0; }
.guide-nav .chip { font-size: .78rem; padding: 6px 12px; }
.guide-sec summary { font-weight: 900; font-size: 1.05rem; cursor: pointer; }
.guide-content { margin-top: 10px; font-size: .95rem; }
.guide-content ul { padding-left: 20px; margin: 8px 0; }
.guide-content li { margin: 6px 0; }
.g-table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: .9rem; }
.g-table th { background: var(--tint); color: var(--primary); text-align: left; }
.g-table th, .g-table td { border: 2px solid var(--track); padding: 7px 10px; }
.g-tip {
  background: var(--gold-soft); border: 2px solid var(--gold); border-radius: 14px;
  padding: 10px 14px; font-weight: 700; font-size: .9rem; margin: 10px 0;
}
.g-ex {
  display: block; background: var(--tint-soft); border-left: 4px solid var(--line-strong); border-radius: 0 10px 10px 0;
  padding: 8px 12px; margin: 8px 0; font-size: .88rem; color: var(--ink-soft);
}
.g-domain {
  display: inline-block; background: var(--tint); color: var(--primary); font-weight: 800;
  font-size: .78rem; border-radius: 999px; padding: 4px 12px; margin: 0 0 6px;
}

/* ---------- file:// protocol warning ---------- */
.file-warning {
  position: sticky; top: 0; z-index: 80; background: var(--red-soft); color: var(--red-ink);
  font-weight: 700; font-size: .85rem; padding: 10px 16px; text-align: center; line-height: 1.5;
}
.file-warning code {
  background: rgba(0,0,0,.08); border-radius: 6px; padding: 1px 6px; font-weight: 800;
}

/* ---------- loading overlay ---------- */
.loading-overlay { z-index: 70; background: rgba(20, 18, 39, .55); }
.loading-box {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 34px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  font-weight: 800; color: var(--ink);
}
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid var(--track); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- AP scores ---------- */
.ap-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-chip {
  font-weight: 800; font-size: .85rem; padding: 7px 14px; border-radius: 999px;
  background: var(--tint); color: var(--primary); border: 2px solid var(--line);
}
.ap-chip.ap-5, .ap-chip.ap-4 { background: var(--green-soft); color: var(--green-ink); border-color: var(--green); }
.ap-chip.ap-3 { background: var(--gold-soft); color: var(--ink); border-color: var(--gold); }
.ap-chip.ap-2, .ap-chip.ap-1 { background: var(--red-soft); color: var(--red-ink); border-color: var(--red); }
.ap-row {
  display: grid; grid-template-columns: 1fr 40px 32px; gap: 10px; align-items: center;
  padding: 8px 4px; border-bottom: 2px solid var(--tint); font-weight: 700;
}
.ap-score-pill {
  text-align: center; font-weight: 900; border-radius: 999px; padding: 2px 0;
  background: var(--tint); color: var(--primary);
}
.ap-score-pill.ap-5, .ap-score-pill.ap-4 { background: var(--green-soft); color: var(--green-ink); }
.ap-score-pill.ap-3 { background: var(--gold-soft); color: var(--ink); }
.ap-score-pill.ap-2, .ap-score-pill.ap-1 { background: var(--red-soft); color: var(--red-ink); }
.ap-add-row { display: grid; grid-template-columns: 1fr 84px; gap: 8px; margin-top: 10px; }
.ap-add-row #ap-other { grid-column: 1 / -1; margin: 0; }
.ap-score-select { text-align: center; font-weight: 900; }

/* ---------- streak card ---------- */
.streak-hero { display: flex; gap: 30px; margin: 6px 0 12px; }
.streak-hero > div { display: flex; flex-direction: column; }
.streak-hero strong { font-size: 2rem; font-weight: 900; line-height: 1.1; }
.streak-hero span { color: var(--muted); font-weight: 700; font-size: .8rem; }
.streak-week { display: flex; gap: 6px; }
.streak-day {
  flex: 1; text-align: center; background: var(--tint-soft); border: 2px solid var(--line);
  border-radius: 12px; padding: 7px 0 5px; font-weight: 800; font-size: .68rem; color: var(--muted);
}
.streak-day .sd-flame { display: block; font-size: 1.1rem; filter: grayscale(1); opacity: .35; }
.streak-day.lit { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.streak-day.lit .sd-flame { filter: none; opacity: 1; }
.streak-day.today { outline: 2px solid var(--primary); }
#streak-msg { margin: 10px 0 0; }

/* ---------- mobile polish ---------- */
* { -webkit-tap-highlight-color: transparent; }
body:not(.exam-mode) .float-panel { bottom: 84px; }

@media (max-width: 640px) {
  .dash-grid { grid-template-columns: 1fr; }
  .hero-card { flex-direction: column; }
  .goal-cards { flex-direction: column; }
  .exam-pick-grid { grid-template-columns: 1fr; }
  .exr-sections { flex-direction: column; align-items: center; }
  .tab { padding: 6px 6px; font-size: 1.2rem; }
  .screen { padding: 14px 10px 96px; }
  .topbar { padding: 10px 12px; }
  .card { padding: 16px 14px; }
  .exam-topbar { flex-wrap: wrap; }
  .ex-module-label { font-size: .72rem; }
  .ex-timer { font-size: 1.05rem; padding: 5px 10px; }
  .exam-tools { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .tool-btn { flex: 0 0 auto; }
  .exam-nav-row { gap: 6px; }
  .exam-nav-row .btn { padding: 12px 8px; font-size: .88rem; }
  .g-table { display: block; overflow-x: auto; }
  .results-stats { gap: 18px; }
  .quiz-meta { flex-wrap: wrap; }
  .float-panel {
    width: 100vw; right: 0; left: 0; height: min(480px, 62vh);
    border-radius: 16px 16px 0 0; bottom: 0 !important; resize: none;
  }
}

/* ---------- countdown, adaptive launcher, exam library, libraries ---------- */
.countdown-card { background: #3a4bc0; color: #fff; text-align: center; margin-bottom: 16px; }
.cd-title { font-weight: 900; font-size: 1.15rem; margin-bottom: 12px; }
.cd-boxes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.cd-boxes div { background: #fff; color: #3a4bc0; border-radius: 14px; padding: 10px 4px; display: flex; flex-direction: column; }
.cd-boxes strong { font-size: 1.8rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.cd-boxes span { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.adaptive-card { margin-bottom: 16px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.lib-exam {
  font-family: inherit; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
  background: var(--tint-soft); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; color: var(--ink);
}
.lib-exam:hover { border-color: var(--primary); }
.lib-exam span { font-size: .78rem; color: var(--muted); font-weight: 700; }
.lib-exam.done { border-color: var(--green); }
.lib-exam.inprog { border-color: var(--accent); }
.lib-credits { padding-left: 18px; margin: 8px 0 0; }
.lib-credits li { margin-bottom: 8px; font-size: .9rem; }
.help-list { padding-left: 18px; }
.help-list li { margin-bottom: 8px; }
.sat-text-btn {
  background: none; border: none; cursor: pointer; font-family: inherit; font-weight: 800;
  font-size: .85rem; color: var(--sat-ink); padding: 6px 8px; text-decoration: underline;
}
.cd-boxes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cd-boxes strong { font-size: clamp(1.2rem, 5vw, 1.8rem); }
.cd-boxes span { font-size: clamp(.55rem, 2vw, .68rem); }
.ex-qcount { white-space: nowrap; margin-left: 10px; }
@media (max-width: 720px) {
  .sat-topbar { flex-wrap: wrap; row-gap: 6px; }
  .sat-text-btn { padding: 6px 4px; }
  .ex-timer { font-size: 1rem; padding: 5px 10px; }
}
/* right panel with no stem text: don't leave a gap above the choices */
.sat-panel-right .q-stem:empty { display: none; }
.sat-panel-right .q-stem:empty + .q-options { margin-top: 0; }
/* ---------- flashcards ---------- */
.flash-card {
  position: relative; min-height: 220px; margin: 14px 0; border: 2px solid var(--line); border-radius: 18px;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 28px 20px; cursor: pointer; background: var(--tint-soft);
}
.flash-front { font-size: 2rem; font-weight: 900; }
.flash-back { display: none; font-size: 1.15rem; font-weight: 700; white-space: pre-line; }
.flash-card.flipped .flash-front { display: none; }
.flash-card.flipped .flash-back { display: block; }
.flash-hint { position: absolute; bottom: 8px; right: 12px; font-size: .7rem; color: var(--muted); font-weight: 700; }
.flash-btns { display: flex; gap: 10px; }
.flash-btns .btn { flex: 1; }
#flash-bar { height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width .3s; }
.pred-row { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pred-row strong { font-size: 1.6rem; color: var(--primary); }
.tab { padding: 6px 6px; }
.tabbar { gap: 0; padding-left: 2px; padding-right: 2px; }
.tab { flex: 1 1 0; min-width: 0; padding: 6px 2px; font-size: 1.2rem; }
.tab span { font-size: .6rem; }
/* ---------- study time + question of the day ---------- */
.study-card { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: center; margin-bottom: 16px; }
.study-card strong { display: block; font-size: 1.7rem; color: var(--primary); }
.study-card span { font-size: .78rem; font-weight: 700; color: var(--muted); }
.qotd-opts { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.qotd-result { margin-top: 10px; }

/* ---------- highlight + notes ---------- */
mark.hl { background: #ffe066; color: inherit; border-radius: 3px; padding: 0; cursor: pointer; }
mark.hl.has-note { border-bottom: 2px dotted #a16207; }
mark.hl.has-note::after { content: ' 📝'; font-size: .75em; }
.sat-panel-left, .sat-panel-right .q-stem { -webkit-user-select: text; user-select: text; }
.ann-bar, .ann-editor {
  position: fixed; z-index: 80; background: #14171a; color: #fff; border-radius: 12px; padding: 6px;
  box-shadow: 0 8px 28px rgba(0,0,0,.35); display: flex; gap: 6px; max-width: calc(100vw - 16px);
}
.ann-bar button, .ann-editor button {
  font-family: inherit; font-weight: 800; font-size: .85rem; cursor: pointer; color: #fff;
  background: rgba(255,255,255,.12); border: none; border-radius: 8px; padding: 9px 12px; min-height: 40px;
}
.ann-bar button:hover, .ann-editor button:hover { background: rgba(255,255,255,.22); }
.ann-editor { flex-direction: column; width: 280px; padding: 10px; }
.ann-editor textarea {
  width: 100%; min-height: 80px; resize: vertical; border-radius: 8px; border: none; padding: 8px;
  font-family: inherit; font-size: 1rem; background: #fff; color: #14171a;
}
.ann-row { display: flex; gap: 6px; }
.ann-row button { flex: 1; }
.ann-editor .danger { background: rgba(239,68,68,.35); }
