/* ═══════════════════════════════════════════════════════
   Study Companion — calm, offline-first, hers.
   Theme system: CSS custom properties on body[data-theme].
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 24px rgba(30, 24, 70, 0.08), 0 1px 3px rgba(30, 24, 70, 0.06);
  --space: clamp(14px, 3.5vw, 22px);
  --tscale: 1;
  --fs-base: calc(clamp(15px, 2.2vw, 17px) * var(--tscale));
  --fs-h2: calc(clamp(18px, 3vw, 21px) * var(--tscale));
  --fs-card: calc(clamp(19px, 3.4vw, 24px) * var(--tscale));
}
body[data-textsize="s"] { --tscale: 0.92; }
body[data-textsize="l"] { --tscale: 1.14; }

/* Easy-read mode — roomier spacing + a highly legible font */
body.easyread {
  font-family: Verdana, "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  letter-spacing: 0.02em; word-spacing: 0.06em; line-height: 1.72;
}
body.easyread .flashcard, body.easyread .bub, body.easyread .reveal-box, body.easyread p { line-height: 1.72; }

/* ── Themes ─────────────────────────────────────────── */
body[data-theme="sky"] {
  --bg: #eaf5fc; --card: #ffffff; --ink: #14304a; --muted: #436781;
  --accent: #0b4f8a; --accent-ink: #ffffff; --soft: #d8ebf8;
  --edge: #b0cfe6; --good: #17694a; --bad: #a13333;
  --sky1: rgba(126, 187, 233, 0.55); --sky2: rgba(183, 219, 248, 0.65);
  --shadow: 0 6px 24px rgba(24, 62, 96, 0.10), 0 1px 3px rgba(24, 62, 96, 0.08);
  background: linear-gradient(180deg, #eaf5fc 0%, #cfe6f6 48%, #b7d9f0 100%);
  background-attachment: fixed;
}
/* glossy highlight sheen — Sky only */
.gloss { display: none; }
body[data-theme="sky"] .gloss {
  display: block; position: absolute; inset: 0;
  background:
    radial-gradient(120% 55% at 50% -8%, rgba(255, 255, 255, 0.85) 0%, rgba(255, 255, 255, 0.28) 42%, rgba(255, 255, 255, 0) 68%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.30) 0%, rgba(255, 255, 255, 0) 38%);
}
body[data-theme="sky"] .b1 { background: var(--sky1); }
body[data-theme="sky"] .b2 { background: var(--sky2); }
/* contrasting deep-blue "banner" treatment on section headers */
body[data-theme="sky"] .card > h2 {
  display: block; background: var(--accent); color: var(--accent-ink);
  margin: calc(-1 * var(--space)) calc(-1 * var(--space)) 12px;
  padding: 11px var(--space);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: var(--fs-h2);
}
body[data-theme="sky"] .chip { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
body[data-theme="sky"] .banner { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

body[data-theme="dusk"] {
  --bg: #f6f4fb; --card: #ffffff; --ink: #262040; --muted: #5b5477;
  --accent: #5b49c4; --accent-ink: #ffffff; --soft: #ece8f8;
  --edge: #dcd6ee; --good: #1e6e46; --bad: #a13333;
  --sky1: rgba(167, 152, 235, 0.35); --sky2: rgba(247, 195, 216, 0.35);
}
body[data-theme="ocean"] {
  --bg: #f1f7f9; --card: #ffffff; --ink: #123540; --muted: #45646e;
  --accent: #0d6a86; --accent-ink: #ffffff; --soft: #e2eff3;
  --edge: #d2e4ea; --good: #1e6e46; --bad: #a13333;
  --sky1: rgba(126, 200, 227, 0.35); --sky2: rgba(178, 235, 214, 0.4);
}
body[data-theme="meadow"] {
  --bg: #f4f8f2; --card: #ffffff; --ink: #21351f; --muted: #566853;
  --accent: #3c7448; --accent-ink: #ffffff; --soft: #e6f0e3;
  --edge: #d6e4d1; --good: #1e6e46; --bad: #a13333;
  --sky1: rgba(173, 220, 155, 0.4); --sky2: rgba(246, 224, 158, 0.4);
}
body[data-theme="midnight"] {
  --bg: #141221; --card: #201d31; --ink: #edeaf8; --muted: #a9a3c4;
  --accent: #b3a6f5; --accent-ink: #17142a; --soft: #2a2640;
  --edge: #363152; --good: #7fd8a8; --bad: #f0a0a0;
  --sky1: rgba(97, 78, 189, 0.28); --sky2: rgba(196, 108, 155, 0.18);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  transition: background 0.4s ease, color 0.4s ease;
}

/* ── Dawn-sky background ────────────────────────────── */
.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blob { position: absolute; width: 65vmax; height: 65vmax; border-radius: 50%; filter: blur(60px); }
.b1 { background: var(--sky1); top: -25vmax; right: -20vmax; animation: drift1 48s ease-in-out infinite alternate; }
.b2 { background: var(--sky2); bottom: -30vmax; left: -22vmax; animation: drift2 56s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate(-6vmax, 7vmax); } }
@keyframes drift2 { to { transform: translate(7vmax, -6vmax); } }

/* ── Header ─────────────────────────────────────────── */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 18px) var(--space) 4px;
  max-width: 640px; margin: 0 auto;
}
h1 { font-size: clamp(21px, 4.5vw, 26px); margin: 0; letter-spacing: -0.02em; }
.tagline { margin: 0; color: var(--muted); font-size: 0.85em; }
.chip {
  background: var(--soft); color: var(--ink); border: 1px solid var(--edge);
  border-radius: 999px; padding: 6px 14px; font-size: 0.85em; font-weight: 600;
  white-space: nowrap;
}

.banner {
  max-width: 640px; margin: 10px auto 0; padding: 10px 14px;
  background: var(--soft); border: 1px solid var(--edge); border-radius: var(--radius-sm);
  font-size: 0.85em; color: var(--muted);
}
.banner, main { margin-inline: var(--space); }
@media (min-width: 700px) { .banner, main { margin-inline: auto; } }

/* ── Layout ─────────────────────────────────────────── */
main { max-width: 640px; padding-top: 10px; }
.view { display: grid; gap: 14px; animation: rise 0.35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: var(--space); border: 1px solid var(--edge);
}
h2 { font-size: var(--fs-h2); margin: 0 0 10px; letter-spacing: -0.01em; }
.note {
  background: var(--soft); border-radius: var(--radius-sm); padding: 12px 16px;
  margin: 0; border: 1px solid var(--edge);
}
.mini { color: var(--muted); font-size: 0.85em; margin: 8px 0 0; }
.center { text-align: center; }
.about { margin-top: 4px; }

/* ── Buttons & fields ───────────────────────────────── */
.btn {
  font: inherit; font-weight: 650; cursor: pointer; border-radius: var(--radius-sm);
  padding: 12px 18px; border: 1px solid var(--edge); background: var(--card); color: var(--ink);
  transition: transform 0.12s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; width: 100%; margin-top: 12px; }
.btn.subtle { background: var(--soft); }
.btn.danger { background: none; color: var(--bad); border-color: currentColor; width: 100%; margin-top: 12px; }
.file-btn { display: inline-flex; align-items: center; justify-content: center; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .flashcard:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

.field { display: block; margin: 10px 0; }
.field span { display: block; font-size: 0.85em; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
input[type="text"], input[type="number"], select, textarea {
  font: inherit; width: 100%; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--edge); background: var(--bg); color: var(--ink);
}
textarea { resize: vertical; }
.check { display: flex; gap: 9px; align-items: center; margin: 12px 0 2px; font-size: 0.95em; }
.check input { width: 19px; height: 19px; accent-color: var(--accent); }

/* ── Today: energy orbs ─────────────────────────────── */
.orbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.orb {
  font: inherit; cursor: pointer; display: grid; justify-items: center; gap: 3px;
  padding: 16px 6px 12px; border-radius: var(--radius); border: 1.5px solid var(--edge);
  background: var(--bg); color: var(--ink); transition: transform 0.15s ease, border-color 0.2s, background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.orb:active { transform: scale(0.96); }
.orb.selected { border-color: var(--accent); background: var(--soft); }
.orb small { color: var(--muted); }
.orb-dot { border-radius: 50%; background: var(--accent); opacity: 0.9; margin-bottom: 4px; }
.d1 { width: 12px; height: 12px; }
.d2 { width: 19px; height: 19px; }
.d3 { width: 27px; height: 27px; }

/* ── Today: plan ────────────────────────────────────── */
.plan { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plan button {
  font: inherit; width: 100%; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--edge); background: var(--bg); color: var(--ink);
}
.plan .tick {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  border: 2px solid var(--edge); display: grid; place-items: center;
  font-size: 14px; color: var(--accent-ink); background: transparent;
}
.plan .done .tick { background: var(--accent); border-color: var(--accent); }
.plan .done { opacity: 0.75; }
.plan .plan-label { flex: 1; }
.plan .plan-count { color: var(--muted); font-size: 0.85em; }

/* ── Flashcards ─────────────────────────────────────── */
.deck-tag { margin: 2px 4px 8px; color: var(--muted); font-weight: 650; font-size: 0.9em; }
.badge {
  background: var(--accent); color: var(--accent-ink); font-size: 0.75em;
  padding: 2px 10px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  font: inherit; font-size: 0.88em; font-weight: 600; cursor: pointer;
  padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--edge);
  background: var(--bg); color: var(--ink);
}
.chips button.selected { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

.flashcard {
  font: inherit; width: 100%; min-height: 250px; cursor: pointer;
  display: grid; place-items: center; gap: 10px; padding: 26px 20px;
  background: var(--card); color: var(--ink);
  border-radius: var(--radius); border: 1px solid var(--edge); box-shadow: var(--shadow);
  font-size: var(--fs-card); line-height: 1.45; text-align: center;
  transition: transform 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.flashcard.flipping { transform: rotateY(90deg); }
.flashcard small { color: var(--muted); font-size: 0.55em; }
#card-face { white-space: pre-line; }

.grade-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.btn.grade { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.r { background: #c4554d; }
.dot.g { background: #3e8e5f; }
.dot.b { background: #4776c9; }
#end-review { margin: 10px auto 0; display: block; }

/* ── Math ───────────────────────────────────────────── */
.problem-box { background: var(--bg); border: 1px solid var(--edge); border-radius: var(--radius-sm); padding: 16px; margin: 10px 0; }
.problem { font-size: var(--fs-card); margin: 0; text-align: center; letter-spacing: 0.01em; }
.hint-line { color: var(--muted); font-size: 0.88em; margin: 10px 0 0; text-align: center; }
.math-row { display: flex; gap: 10px; margin-top: 10px; }
.math-row input { flex: 1; min-width: 0; }
.math-row .btn { flex: 1; }
.math-row .btn.primary { width: auto; margin-top: 0; flex: 0 0 auto; padding-inline: 22px; }
.feedback { min-height: 1.4em; font-weight: 650; margin: 10px 0 0; }
.feedback.ok { color: var(--good); }
.feedback.no { color: var(--bad); }

/* ── Reading ────────────────────────────────────────── */
.read-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.plain-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 7px; }
.plain-list li {
  background: var(--bg); border: 1px solid var(--edge); border-radius: var(--radius-sm);
  padding: 10px 13px; font-size: 0.92em; display: flex; justify-content: space-between; gap: 10px;
}
.plain-list .sub { color: var(--muted); }

/* ── Me / progress ──────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--bg); border: 1px solid var(--edge); border-radius: var(--radius-sm);
  padding: 12px 8px; text-align: center;
}
.stat strong { display: block; font-size: 1.5em; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 0.78em; }
.pbar { flex: none; width: 86px; height: 8px; border-radius: 99px; background: var(--soft); overflow: hidden; align-self: center; }
.pbar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ── Big Map ────────────────────────────────────────── */
#map-domains details {
  border: 1px solid var(--edge); border-radius: var(--radius-sm);
  margin-top: 8px; background: var(--bg); overflow: hidden;
}
#map-domains summary {
  cursor: pointer; padding: 11px 13px; font-weight: 650; font-size: 0.93em;
  display: flex; justify-content: space-between; gap: 8px; list-style: none;
}
#map-domains summary::-webkit-details-marker { display: none; }
#map-domains summary .sub { color: var(--muted); font-weight: 500; font-size: 0.9em; }
.map-items { padding: 2px 13px 11px; display: grid; gap: 6px; }
.map-items label { display: flex; gap: 9px; align-items: flex-start; font-size: 0.9em; cursor: pointer; }
.map-items input { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.map-items .done-item { color: var(--muted); text-decoration: line-through; }

/* ── Tab bar ────────────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(6, 1fr);
  max-width: 640px; margin: 0 auto;
  background: var(--card); border-top: 1px solid var(--edge);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  font: inherit; font-size: 0.72em; font-weight: 600; cursor: pointer;
  display: grid; justify-items: center; gap: 2px; padding: 7px 2px;
  background: none; border: none; color: var(--muted); border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }
body[data-theme="midnight"] .tab.active { color: var(--accent); }

/* ── Planner ────────────────────────────────────────── */
.stack { display: grid; gap: 9px; margin-top: 10px; }
.btn.full { width: 100%; }
summary.btn { display: block; text-align: center; list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
.a-group-label { font-size: 0.8em; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 12px 0 6px; }
.a-item { display: flex; align-items: center; gap: 9px; background: var(--bg); border: 1px solid var(--edge); border-radius: var(--radius-sm); padding: 9px 11px; margin-top: 6px; }
.a-item.overdue { border-color: var(--bad); }
.a-item .a-main { flex: 1; min-width: 0; }
.a-item .a-title { font-weight: 600; font-size: 0.94em; }
.a-item .a-sub { color: var(--muted); font-size: 0.8em; }
.a-item.done-a .a-title { text-decoration: line-through; color: var(--muted); }
.a-btn { font: inherit; cursor: pointer; border: 1px solid var(--edge); background: var(--card); color: var(--ink); border-radius: 9px; padding: 5px 9px; font-size: 0.82em; font-weight: 650; }
.a-btn.ok { color: var(--good); }
.a-btn.miss { color: var(--bad); }
.score-row { display: flex; gap: 7px; margin-top: 7px; }
.score-row input { width: 70px; padding: 7px 9px; }
#roadmap-box details, #writing-box details { border: 1px solid var(--edge); border-radius: var(--radius-sm); margin-top: 8px; background: var(--bg); }
#roadmap-box summary, #writing-box summary { cursor: pointer; padding: 10px 13px; font-weight: 650; font-size: 0.92em; display: flex; justify-content: space-between; list-style: none; }
#roadmap-box summary::-webkit-details-marker, #writing-box summary::-webkit-details-marker { display: none; }
#roadmap-box .map-items, #writing-box .map-items { padding: 2px 13px 11px; display: grid; gap: 6px; }
textarea#tpl-out, textarea#share-out { font-size: 0.9em; }

/* ── Tutor chat ─────────────────────────────────────── */
#tutor-overlay, #game-overlay { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; }
#game-overlay[hidden] { display: none; }
.tutor-panel {
  display: flex; flex-direction: column; width: 100%; max-width: 640px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 12px);
  gap: 8px;
}
.tutor-head { display: flex; gap: 7px; align-items: center; }
.tutor-head strong { flex: 1; font-size: 1.15em; }
#tutor-msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.bub {
  max-width: 86%; padding: 10px 14px; border-radius: 16px;
  font-size: 0.95em; line-height: 1.45; white-space: pre-wrap; overflow-wrap: break-word;
}
.bub.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.bub.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--edge); border-bottom-left-radius: 6px; }
.bub.sys { align-self: center; background: var(--soft); color: var(--muted); font-size: 0.85em; text-align: center; }
#tutor-inrow { display: flex; gap: 8px; align-items: flex-end; }
#tutor-inrow textarea { flex: 1; resize: none; }
#tutor-inrow .btn { margin: 0; width: auto; padding-inline: 18px; }

/* ── Focus overlay ──────────────────────────────────── */
#focus-overlay {
  position: fixed; inset: 0; z-index: 30; background: var(--bg);
  display: grid; place-items: center; padding: 20px;
}
.focus-inner { width: min(340px, 92vw); display: grid; gap: 12px; text-align: center; }
#focus-clock { font-size: clamp(64px, 22vw, 96px); font-weight: 700; letter-spacing: -0.03em; margin: 0; font-variant-numeric: tabular-nums; }

/* ── Toast ──────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 999px;
  font-size: 0.9em; font-weight: 600; box-shadow: var(--shadow); max-width: 88vw; text-align: center;
}

/* ── Games ──────────────────────────────────────────── */
#game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
#game-grid .btn { margin: 0; }
#game-board { flex: 1; overflow-y: auto; padding: 4px 2px; }
.game-q { font-size: 1.05em; line-height: 1.4; margin: 6px 0 14px; white-space: pre-line; }
.game-opts { display: grid; gap: 9px; }
.opt-btn {
  font: inherit; text-align: left; cursor: pointer; padding: 12px 15px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--edge);
  background: var(--card); color: var(--ink); font-size: 0.95em;
}
.opt-btn.right { border-color: var(--good); color: var(--good); }
.opt-btn.wrong { border-color: var(--bad); color: var(--bad); }
.opt-btn:disabled { opacity: 0.9; }
.sort-cats { display: grid; gap: 8px; margin-bottom: 12px; }
.sort-cat {
  border: 1.5px solid var(--edge); border-radius: var(--radius-sm); padding: 8px 10px; min-height: 46px;
  background: var(--card);
}
.sort-cat.active { border-color: var(--accent); background: var(--soft); }
.sort-cat b { font-size: 0.8em; color: var(--muted); display: block; margin-bottom: 4px; }
.sort-cat .chiplet { display: inline-block; background: var(--soft); border: 1px solid var(--edge); border-radius: 999px; padding: 3px 9px; margin: 2px; font-size: 0.8em; }
.sort-item {
  font: inherit; cursor: pointer; padding: 9px 13px; margin: 5px 0; width: 100%;
  border-radius: var(--radius-sm); border: 1.5px solid var(--edge); background: var(--soft); color: var(--ink); font-size: 0.92em;
}
/* Word Bloom — colors contrast-verified ≥5:1 against white text */
.wb-grid { display: grid; gap: 6px; justify-content: center; margin: 10px 0 14px; }
.wb-row { display: grid; gap: 6px; }
.wb-tile {
  width: clamp(34px, 11.5vw, 46px); height: clamp(34px, 11.5vw, 46px);
  display: grid; place-items: center; font-weight: 700; font-size: clamp(1.05em, 5vw, 1.35em);
  border: 2px solid var(--edge); border-radius: 8px; background: var(--card); color: var(--ink); text-transform: uppercase;
}
.wb-tile.filled { border-color: var(--muted); }
.wb-tile.correct { background: #2e7d4f; border-color: #2e7d4f; color: #fff; }
.wb-tile.present { background: #8a6410; border-color: #8a6410; color: #fff; }
.wb-tile.absent  { background: #566677; border-color: #566677; color: #fff; }
.wb-keys { display: grid; gap: 6px; margin-top: 6px; }
.wb-krow { display: flex; gap: 5px; justify-content: center; }
.wb-key {
  font: inherit; font-weight: 650; cursor: pointer; min-width: 27px; height: 46px; padding: 0 7px;
  border-radius: 7px; border: 1px solid var(--edge); background: var(--soft); color: var(--ink);
  font-size: 0.95em; -webkit-tap-highlight-color: transparent;
}
.wb-key.wide { font-size: 0.72em; padding: 0 9px; }
.wb-key.correct { background: #2e7d4f; border-color: #2e7d4f; color: #fff; }
.wb-key.present { background: #8a6410; border-color: #8a6410; color: #fff; }
.wb-key.absent  { background: #566677; border-color: #566677; color: #fff; }
/* Geo Quiz */
.geo-choose { display: grid; gap: 10px; margin-top: 12px; }
.geo-map { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 54px; gap: 6px; background: #7ebbe9; padding: 8px; border-radius: 12px; margin: 12px 0; }
.geo-tile { display: grid; place-items: center; text-align: center; font-size: 0.68em; font-weight: 700; line-height: 1.1; border-radius: 8px; cursor: pointer; padding: 2px; border: 1.5px solid rgba(11,79,138,0.25); color: #14304a; -webkit-tap-highlight-color: transparent; }
.geo-tile.land { background: #a7e0c0; }
.geo-tile.ocean { background: #9ccdf0; }
.geo-tile.hit { outline: 3px solid #2e7d4f; outline-offset: -1px; }
.geo-tile.miss { outline: 3px solid #a13333; outline-offset: -1px; }

/* Label It */
.label-wrap { position: relative; max-width: 300px; margin: 12px auto; }
.label-wrap svg { width: 100%; display: block; border-radius: 10px; }
.label-pt { position: absolute; transform: translate(-50%, -50%); width: 27px; height: 27px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 0.82em; cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.25); -webkit-tap-highlight-color: transparent; }
.label-pt.sel { outline: 3px solid var(--ink); }
.label-pt.done { background: #2e7d4f; }
.label-opts { display: grid; gap: 8px; margin-top: 12px; }

/* Card search */
#card-search { width: 100%; }
#search-results li { display: block; cursor: pointer; }
#search-results .sr-q { font-weight: 600; font-size: 0.92em; }
#search-results .sr-a { color: var(--muted); font-size: 0.86em; margin-top: 4px; white-space: pre-line; }

/* Activity chart */
#activity-chart svg { width: 100%; height: auto; display: block; }

/* Study garden */
#garden svg { width: 100%; height: auto; display: block; }
#garden-card { overflow: hidden; }

/* Dictation mic active state */
.btn.rec { background: var(--bad); color: #fff; border-color: transparent; }

.teach-txt { width: 100%; margin-top: 10px; }
.reveal-box { background: var(--soft); border: 1px solid var(--edge); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 12px; white-space: pre-line; font-size: 0.92em; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
  font: inherit; cursor: pointer; min-height: 76px; padding: 8px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--edge);
  background: var(--card); color: var(--ink); font-size: 0.82em; line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
}
.tile.sel { border-color: var(--accent); background: var(--soft); }
.tile.hit { border-color: var(--good); color: var(--good); background: var(--card); opacity: 0.65; pointer-events: none; }
.tile.shake { border-color: var(--bad); }
.seq-slot {
  display: flex; gap: 9px; align-items: center; margin-top: 7px;
  background: var(--card); border: 1.5px dashed var(--edge); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 44px; font-size: 0.92em; cursor: pointer;
}
.seq-slot.filled { border-style: solid; }
.seq-slot.rightpos { border-color: var(--good); }
.seq-slot.wrongpos { border-color: var(--bad); }
.seq-slot .num { font-weight: 700; color: var(--muted); width: 20px; flex: none; }
.pool { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pool button {
  font: inherit; font-size: 0.88em; cursor: pointer; padding: 9px 13px;
  border-radius: 999px; border: 1.5px solid var(--edge); background: var(--soft); color: var(--ink);
}
#game-check { margin-top: 12px; }

/* ── Confetti ───────────────────────────────────────── */
.confetti-bit {
  position: fixed; top: -12px; width: 9px; height: 14px; z-index: 60;
  border-radius: 2px; pointer-events: none;
  animation: confall 2.3s ease-in forwards;
}
@keyframes confall {
  to { transform: translateY(105vh) rotate(540deg); opacity: 0.7; }
}

/* ── Print sheets & certificates ────────────────────── */
#print-sheet { display: none; }
@media print {
  body.print-mode > *:not(#print-sheet) { display: none !important; }
  body.print-mode #print-sheet { display: block !important; color: #000; background: #fff; font-size: 12px; }
  .ps-title { font-size: 20px; margin: 0 0 4px; }
  .ps-sub { color: #444; margin: 0 0 14px; }
  .ps-pack { font-size: 14px; font-weight: 700; margin: 14px 0 6px; border-bottom: 2px solid #000; padding-bottom: 3px; }
  .ps-row { padding: 5px 0; border-bottom: 1px solid #ccc; page-break-inside: avoid; }
  .ps-q { font-weight: 700; }
  .ps-a { margin-top: 2px; white-space: pre-line; }
  .cert { border: 8px double #223; padding: 60px 40px; text-align: center; margin-top: 40px; }
  .cert h1 { font-size: 30px; margin: 0 0 8px; }
  .cert .cert-name { font-size: 26px; margin: 18px 0 6px; }
  .cert .cert-what { font-size: 16px; }
  .cert .cert-date { margin-top: 26px; color: #444; }
}

/* ── Low-stim mode & reduced motion ─────────────────── */
body.lowstim .blob { animation: none; opacity: 0.4; }
body.lowstim .view { animation: none; }
body.lowstim .flashcard, body.lowstim .btn, body.lowstim .orb { transition: none; }
body.lowstim .flashcard.flipping { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .blob, .view { animation: none !important; }
  .flashcard, .btn, .orb { transition: none !important; }
  .flashcard.flipping { transform: none !important; }
}

@media (max-width: 360px) {
  .orbs, .grade-row, .read-btns, .stat-row { grid-template-columns: 1fr 1fr; }
}
