/* ==========================================================================
   ASTRA — Accelerated Study Toward Real Achievement (IELTS study platform)
   Design: "Đêm đầy sao" — studying late under a painted night sky
   (homage to Van Gogh, The Starry Night, 1889, public domain; everything is drawn in code).
   Rule taken from the painting: the village is calm, the sky moves.
   Chrome (top bar, sidebar with its cypress, page-title strips, dashboard sky) is painted;
   everything people read or answer sits on solid, quiet surfaces.
   Type: Fraunces (soft variable serif) for titles, Be Vietnam Pro for reading and UI.
   ========================================================================== */

:root {
  /* the painting */
  --night: #0e1a2e;        /* Prussian night: top bar, sidebar */
  --night-2: #13254a;
  --ultra: #1e3f73;
  --cobalt: #3367a8;
  --swirl-pale: #a9c4d6;
  --star: #e8b931;
  --halo: #f2de7a;
  --emerald: #6fa58a;
  --cypress: #121a14;
  /* chrome text (always on night) */
  --chrome-text: #c9d6ec;
  --chrome-muted: #7f93b8;

  /* the village: calm reading surfaces */
  --bg: #e9edf5;
  --bg-panel: #f1f4fa;
  --card: #ffffff;
  --ink: #14213d;
  --text: #14213d;
  --muted: #5a6787;
  --line: #dde3ee;
  --border-ink: #d3dbe9;
  --shadow-ink: rgba(14, 26, 46, 0.1);
  --dot: transparent;

  --pri: #2a5aa0;
  --pri-solid: #2a5aa0;
  --pri-hover: #1e4683;
  --pri-soft: #e6eef9;
  --coral: #8a6412;          /* ochre: yellow that passes contrast on light */
  --coral-soft: #fbf1d3;
  --bad: #b3261e;
  --bad-solid: #b3261e;
  --bad-soft: #fbe9e7;
  --ok: #2f7d5b;
  --ok-solid: #2f7d5b;
  --ok-soft: #e3f2ea;
  --amber: #8a6412;
  --amber-soft: #fbf1d3;
  --mark: #f8e9a6;
  --uhl: #f2de7a;
  color-scheme: light;

  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-title: "Fraunces", Georgia, serif;
  --font-comic: var(--font-body);
  --font-hand: var(--font-body);

  --radius-panel: 14px;
  --radius-sm: 8px;
  --shadow-sm: none;
  --shadow: 0 1px 2px rgba(14, 26, 46, 0.05);
  --shadow-lg: 0 10px 28px rgba(14, 26, 46, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09111f; --bg-panel: #172540; --card: #14223a; --ink: #e6ecf7; --text: #e6ecf7; --muted: #95a6c6;
    --line: #22314e; --border-ink: #2a3b5c; --shadow-ink: rgba(0, 0, 0, 0.45);
    --pri: #8fb4e8; --pri-solid: #3367a8; --pri-hover: #4277bb; --pri-soft: #17284a;
    --coral: #f2de7a; --coral-soft: #2f2812; --bad: #ff8a80; --bad-solid: #b3261e; --bad-soft: #3a1714;
    --ok: #86c9a6; --ok-solid: #2f7d5b; --ok-soft: #11291f; --amber: #f2de7a; --amber-soft: #2f2812; --mark: #5c4d12; --uhl: #6b5a14;
    --shadow: none; --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09111f; --bg-panel: #172540; --card: #14223a; --ink: #e6ecf7; --text: #e6ecf7; --muted: #95a6c6;
  --line: #22314e; --border-ink: #2a3b5c; --shadow-ink: rgba(0, 0, 0, 0.45);
  --pri: #8fb4e8; --pri-solid: #3367a8; --pri-hover: #4277bb; --pri-soft: #17284a;
  --coral: #f2de7a; --coral-soft: #2f2812; --bad: #ff8a80; --bad-solid: #b3261e; --bad-soft: #3a1714;
  --ok: #86c9a6; --ok-solid: #2f7d5b; --ok-soft: #11291f; --amber: #f2de7a; --amber-soft: #2f2812; --mark: #5c4d12; --uhl: #6b5a14;
  --shadow: none; --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

/* ---------- Base & Sketchbook Typography ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 15px/1.68 var(--font-body);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--pri); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  font-family: var(--font-comic);
  letter-spacing: -0.01em;
  line-height: 1.3;
}
h1 {
  font-size: 1.78rem;
  font-weight: 700;
  margin: 0.1em 0 0.7em;
  display: inline-block;
  position: relative;
  padding-bottom: 4px;
}
h1::after {
  content: "";
  display: block;
  height: 2px;
  width: 48px;
  margin-top: 8px;
  border-radius: 2px;
  background: var(--pri);
  opacity: 0.5;
}
h1 small { font-family: var(--font-body); font-size: 0.82rem; font-weight: 500; }
h2 { font-size: 1.2rem; font-weight: 700; margin: 0.15em 0 0.6em; }
h2.sect { margin-top: 24px; }
h3 { font-size: 1.04rem; font-weight: 700; margin: 0.9em 0 0.4em; }
h4 { font-size: 0.96rem; font-weight: 700; margin: 0.8em 0 0.35em; }

code {
  background: var(--amber-soft);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.88em;
}

mark {
  background: var(--mark);
  color: inherit;
  padding: 0 3px;
  border-radius: 4px;
  cursor: help;
}
mark.uhl { background: var(--uhl); color: inherit; border-radius: 3px; padding: 0 2px; }

::selection { background: var(--mark); color: var(--ink); }

/* Custom subtle scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); border: 2px solid transparent; background-clip: content-box; }

/* ---------- App Shell: Masthead & Storybook Sidebar ---------- */
.top {
  position: fixed;
  inset: 0 0 auto 0;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  background: var(--card);
  border-bottom: 2.5px solid var(--border-ink);
  box-shadow: var(--shadow-sm);
  z-index: 30;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-comic);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.brand:hover { text-decoration: none; opacity: 0.7; }
.brand-sketch { display: inline-flex; align-items: center; justify-content: center; transition: transform 0.2s ease; }
.brand:hover .brand-sketch { transform: scale(1.1); }
.brand b {
  color: var(--pri);
  background: none;
  padding: 0;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

.spacer { flex: 1; }
#keystate {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1.5px solid var(--line);
  background: var(--bg-panel);
  white-space: nowrap;
}
#keystate.ok { color: var(--ok); background: var(--ok-soft); border-color: var(--ok); }
#keystate.bad { color: var(--bad); background: var(--bad-soft); border-color: var(--bad); }

.model {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.model select { max-width: 215px; padding: 5px 10px; font-size: 0.82rem; }

#burger { display: none; }

#nav {
  position: fixed;
  top: 60px;
  bottom: 0;
  left: 0;
  width: 228px;
  padding: 14px 12px 24px;
  background: var(--card);
  border-right: 2.5px solid var(--border-ink);
  overflow-y: auto;
  z-index: 25;
}
.nav-sec {
  font-family: var(--font-hand);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 10px 4px;
  margin-top: 4px;
}
.nav-sec:first-child { margin-top: 0; padding-top: 2px; }

#nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
  border: 1.8px solid transparent;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
#nav a span { font-size: 1.05rem; width: 22px; text-align: center; flex-shrink: 0; }
#nav a:hover {
  background: var(--pri-soft);
  border-color: transparent;
  text-decoration: none;
  transform: none;
}
#nav a.on {
  background: var(--pri-soft);
  color: var(--pri);
  font-weight: 600;
  border-color: transparent;
  border-left: 3px solid var(--pri);
  box-shadow: none;
}

.nav-backdrop { display: none; }

main {
  margin: 60px 0 0 228px;
  padding: 28px 30px 48px;
  max-width: 1180px;
  min-height: calc(100vh - 60px);
}
main > * { animation: panelIn 0.2s ease-out both; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Comic Panels (Cards) & Grid Layouts ---------- */
.card {
  background: var(--card);
  border: 2px solid var(--border-ink);
  border-radius: var(--radius-panel);
  padding: 18px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.card.hl {
  border-left: 6px solid var(--pri);
  background-image:
    radial-gradient(var(--dot) 1px, transparent 1px),
    linear-gradient(135deg, var(--pri-soft) 0%, var(--card) 58%);
  background-size: 14px 14px, 100% 100%;
}

.card.error {
  border-left: 6px solid var(--bad);
  background: var(--bad-soft);
}
.card.error pre {
  white-space: pre-wrap;
  font-size: 0.82rem;
  background: var(--card);
  padding: 10px 12px;
  border: 1.5px solid var(--border-ink);
  border-radius: 8px;
}

details.card > summary,
details > summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "▸";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--border-ink);
  background: var(--amber-soft);
  color: var(--text);
  font-size: 0.78rem;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}
details[open] > summary::before { transform: rotate(90deg); background: var(--pri-soft); }
details[open] > summary { margin-bottom: 10px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }

.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .big {
  font-family: var(--font-comic);
  font-size: 2.35rem;
  font-weight: 700;
  color: var(--pri);
  line-height: 1.05;
}
.stat .big small { font-size: 1rem; color: var(--muted); font-family: var(--font-body); }
.stat > .btn { margin-top: auto; align-self: flex-start; }

.muted { color: var(--muted); }
.small, small { font-size: 0.84rem; }
.center { text-align: center; justify-content: center; }
.mt { display: block; margin-top: 10px; }
.ok { color: var(--ok); font-weight: 600; }
.okc { color: var(--ok); }
.bad { color: var(--bad); font-weight: 600; }
.good { color: var(--ok); font-weight: 600; }
.warnc { color: var(--amber); font-weight: 600; }
.pre { white-space: pre-wrap; font-size: 0.82rem; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.row.between { justify-content: space-between; }
.row input:not([type="checkbox"]):not([type="radio"]) { flex: 1; min-width: 160px; }

/* ---------- Tactile Buttons & Form Controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-comic);
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.25;
  padding: 9px 17px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-ink);
  background: var(--pri-solid);
  color: #fff;
  box-shadow: 3px 3px 0 var(--shadow-ink);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}
.btn:hover:not(:disabled) {
  transform: translate(-1.5px, -1.5px);
  box-shadow: 4.5px 4.5px 0 var(--shadow-ink);
  text-decoration: none;
}
.btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--shadow-ink);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn.ghost {
  background: var(--card);
  color: var(--pri);
}
.btn.ghost:hover:not(:disabled) { background: var(--pri-soft); }
.btn.small { padding: 6px 12px; font-size: 0.85rem; box-shadow: var(--shadow-sm); }
.btn.green { background: var(--ok-solid); }
.btn.red { background: var(--bad-solid); }

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 2px solid var(--border-ink);
  border-radius: 9px;
  padding: 5px 10px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.12s ease;
}
.icon:hover { background: var(--amber-soft); transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow-ink); }
.icon:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--shadow-ink); }

.mini {
  margin-top: 8px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 99px;
  border: 1.8px solid var(--border-ink);
  background: var(--card);
  color: var(--text);
  box-shadow: 1.5px 1.5px 0 var(--shadow-ink);
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.12s ease;
}
.mini:hover { background: var(--amber-soft); transform: translateY(-1px); }
.mini.on { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-panel);
  border: 2px solid var(--border-ink);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { width: 100%; resize: vertical; line-height: 1.7; background: var(--card); }
input:focus, select:focus, textarea:focus {
  outline: none;
  background: var(--card);
  box-shadow: 0 0 0 3px var(--pri-soft), 3px 3px 0 var(--pri);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--pri); cursor: pointer; }
input.wide { width: 100%; }

.form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.84rem; font-weight: 600; color: var(--muted); }
.form fieldset {
  border: 2px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  width: 100%;
  background: var(--bg-panel);
}
.form legend { font-family: var(--font-comic); font-size: 0.88rem; font-weight: 700; color: var(--text); padding: 0 6px; }
label.inline {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
  margin-bottom: 4px;
  color: var(--text) !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  cursor: pointer;
}

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.filters > input:first-child { grid-column: 1 / -1; }
.filters input { flex: 1 1 100%; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }

/* ---------- Stamps, Tags, Chips & Progress Bars ---------- */
.tag {
  display: inline-block;
  font-family: var(--font-comic);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--pri-soft);
  color: var(--pri);
  border: 1.5px solid var(--border-ink);
  vertical-align: middle;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.hard { background: var(--coral-soft); color: var(--coral); }
.tag.p1 { background: var(--pri-soft); color: var(--pri); }
.tag.p2 { background: var(--amber-soft); color: var(--amber); }
.tag.p3 { background: var(--ok-soft); color: var(--ok); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 8px 0; }
.chip {
  background: var(--bg-panel);
  border: 1.5px solid var(--border-ink);
  border-radius: 10px;
  padding: 4px 11px;
  font-size: 0.88rem;
  color: var(--text);
  font-family: inherit;
  box-shadow: 1.5px 1.5px 0 var(--shadow-ink);
}
.chip small { color: var(--muted); }
.chip.small { font-size: 0.76rem; padding: 2px 8px; box-shadow: none; border-color: var(--line); }
.btnchip { cursor: pointer; background: var(--amber-soft); font-weight: 600; transition: transform 0.1s ease; }
.btnchip:hover { transform: translate(-1px, -1px); background: var(--pri-soft); }

.bar {
  height: 11px;
  background: var(--bg-panel);
  border: 1.8px solid var(--border-ink);
  border-radius: 99px;
  overflow: hidden;
  margin: 7px 0;
}
.bar span {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(
    -45deg,
    var(--ok),
    var(--ok) 8px,
    rgba(255, 255, 255, 0.16) 8px,
    rgba(255, 255, 255, 0.16) 14px
  );
  border-right: 1.5px solid var(--border-ink);
  transition: width 0.35s ease;
}
.bar.red span { background: var(--bad); }
.bar.amber span { background: var(--amber); }
.weak { margin: 10px 0; }

/* ---------- Roadmap, Tasks, Stages & Lesson Cards ---------- */
.tasks { list-style: none; padding: 0; margin: 6px 0; }
.tasks li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1.5px dashed var(--line); }
.tasks li:last-child { border-bottom: 0; }
.tasks label { flex: 1; display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.tasks input[type="checkbox"] { margin-top: 4px; }
.tasks input:checked + *, .tasks li:has(input:checked) label { color: var(--muted); text-decoration: line-through; }
.go {
  font-family: var(--font-comic);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 2px 9px;
  border-radius: 8px;
  border: 1.5px solid var(--border-ink);
  background: var(--pri-soft);
}
.go:hover { background: var(--pri); color: #fff; text-decoration: none; }
.day { border-bottom: 1.5px dashed var(--line); padding: 8px 0; }
.day:last-child { border-bottom: 0; }
.day.past summary { opacity: 0.6; }

.roadmap-strip { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.roadmap-strip h2 { margin: 2px 0 8px; font-size: 1.3rem; }
.rs-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  padding-left: 18px;
  border-left: 2px dashed var(--line);
}
.rs-side .big { font-family: var(--font-comic); font-size: 1.75rem; font-weight: 700; color: var(--coral); }
.comic-doodle { display: block; max-width: 100%; height: auto; margin-bottom: 2px; }
.tutor-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 2px dashed var(--line);
}
.tutor-avatar { flex-shrink: 0; }
.tutor-bubble {
  position: relative;
  background: var(--bg-panel);
  border: 2px solid var(--border-ink);
  border-radius: 14px;
  padding: 9px 14px;
  font-size: 0.92rem;
  box-shadow: var(--shadow-sm);
}
.tutor-bubble::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: var(--border-ink);
}
.tutor-bubble::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--bg-panel);
}
.stage-dots { display: flex; gap: 7px; margin-top: 12px; flex-wrap: wrap; }
.stage-dots a {
  font-family: var(--font-comic);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 11px;
  border-radius: 99px;
  border: 1.8px solid var(--border-ink);
  background: var(--card);
  color: var(--text);
}
.stage-dots a:hover { background: var(--amber-soft); text-decoration: none; }
.stage-dots a.on { background: var(--pri-solid); color: #fff; box-shadow: 2px 2px 0 var(--shadow-ink); }

.stages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 14px 0 18px; }
.stage {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
  margin: 0;
  padding: 13px;
}
.stage:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); text-decoration: none; border-color: var(--pri); }
.stage.on { border: 2.5px solid var(--border-ink); background: var(--amber-soft); box-shadow: var(--shadow-lg); }
.stage .sno { font-family: var(--font-comic); font-size: 0.85rem; font-weight: 700; color: var(--coral); }
.stage small { font-size: 0.79rem; }
.stage .bar span { background: var(--pri); }

.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(305px, 1fr)); gap: 16px; }
.lesson { display: flex; gap: 14px; color: var(--text); margin: 0; padding: 16px 18px; }
.lesson:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); text-decoration: none; }
.lesson.done { border-left: 6px solid var(--ok); }
.lesson .lcol { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lesson .lno {
  font-family: var(--font-comic);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--pri);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  border: 2px solid var(--border-ink);
  background: var(--amber-soft);
  box-shadow: 2px 2px 0 var(--shadow-ink);
}
.lesson .lno:hover { text-decoration: none; background: var(--pri-soft); }
.lesson .lbody { flex: 1; min-width: 0; }
.lesson .lbody > a { color: var(--text); }
.lesson .lbody > a:hover { text-decoration: none; }
.lesson .lbody > a:hover h3 { color: var(--pri); }
.lesson h3 { margin: 0 0 5px; }
.lesson .sel { width: 18px; height: 18px; }

.crumbs {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-family: var(--font-comic);
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.crumbs a {
  padding: 2px 10px;
  border-radius: 99px;
  border: 1.5px solid var(--border-ink);
  background: var(--card);
  color: var(--text);
  box-shadow: 1.5px 1.5px 0 var(--shadow-ink);
}
.crumbs a:hover { background: var(--amber-soft); text-decoration: none; }

/* Storybook File-Folder Tabs */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  border-bottom: 2.5px solid var(--border-ink);
  padding-bottom: 0;
}
.tabs a {
  font-family: var(--font-comic);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 8px 14px;
  border-radius: 10px 10px 0 0;
  border: 2px solid transparent;
  border-bottom: none;
  color: var(--muted);
  position: relative;
  top: 2px;
}
.tabs a:hover { color: var(--text); background: var(--bg-panel); text-decoration: none; }
.tabs a.on {
  background: var(--card);
  color: var(--pri);
  border-color: var(--border-ink);
  font-weight: 700;
  padding-bottom: 10px;
}

.banklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.bankitem { margin: 0; color: var(--text); display: flex; flex-direction: column; gap: 6px; padding: 15px 17px; }
.bankitem:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); text-decoration: none; }
.bankitem.done { border-left: 6px solid var(--ok); }
.bankcta { display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.bankcta:hover { text-decoration: none; transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); }

.levels { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
.lvl {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-ink);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.lvl:hover { transform: translate(-1px, -1px); box-shadow: 3.5px 3.5px 0 var(--shadow-ink); }
.lvl b { font-family: var(--font-comic); font-size: 1.25rem; color: var(--pri); }
.lvl small { font-size: 0.76rem; }
.lvl.on { background: var(--amber-soft); box-shadow: var(--shadow); }
tr.insrs { opacity: 0.6; }
.wprompt div:last-child { line-height: 1.55; }

/* ---------- Study Tables, Flashcards, Prompts & Essays ---------- */
.vtable { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.vtable th {
  font-family: var(--font-comic);
  background: var(--bg-panel);
  border-bottom: 2px solid var(--border-ink);
  padding: 8px 10px;
  text-align: left;
}
.vtable td { padding: 8px 10px; border-bottom: 1px dashed var(--line); text-align: left; vertical-align: top; }
.vtable tbody tr:hover { background: var(--pri-soft); }
.mdt { margin: 10px 0; font-size: 0.9rem; }

.ipa { font-family: "Lucida Sans Unicode", "Segoe UI", sans-serif; color: var(--muted); }
.formula {
  background: var(--pri-soft);
  border: 2px solid var(--border-ink);
  border-left: 6px solid var(--pri);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  font-weight: 600;
  margin: 10px 0;
}
.mist { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.mist td { padding: 7px 10px; border-bottom: 1px dashed var(--line); vertical-align: top; }
ul.warn li::marker { content: "⚠ "; }
ul.check { padding-left: 4px; }
ul.check li { list-style: none; position: relative; padding-left: 26px; }
ul.check li::before { content: ""; position: absolute; left: 0; top: .32em; width: 14px; height: 14px; border: 1.5px solid var(--emerald); border-radius: 4px; }

/* Comic Caption Box (.prompt) & Book Page (.essay) */
.prompt {
  background: var(--amber-soft);
  border: 2px solid var(--border-ink);
  border-left: 6px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  margin: 10px 0;
  box-shadow: var(--shadow-sm);
}
.prompt.big { font-size: 1.12rem; font-weight: 500; }
.essay {
  background: var(--bg-panel);
  border: 1.8px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 8px 0;
  line-height: 1.85;
}

/* Illustrated Flashcard */
.flash {
  min-height: 205px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2.5px solid var(--border-ink);
  border-radius: 18px;
  outline: 2px dashed var(--line);
  outline-offset: -10px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  padding: 28px 26px;
  text-align: center;
  margin: 14px auto;
  max-width: 580px;
  transition: transform 0.14s ease, background-color 0.18s ease;
}
.flash:hover { transform: translate(-2px, -2px); }
.flash.flip { background: var(--pri-soft); outline-color: var(--pri); }
.flash .word { font-family: var(--font-comic); font-size: 2.15rem; font-weight: 700; color: var(--pri); }
.flash .meaning { font-family: var(--font-comic); font-size: 1.38rem; font-weight: 700; }
.flash.big { min-height: 250px; cursor: default; }
.flash.big:hover { transform: none; }
.flash hr { width: 55%; border: 0; border-top: 2px dashed var(--line); }

.boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(38px, 1fr)); gap: 5px; margin: 10px 0; }
.boxes small { display: block; font-size: .72rem; line-height: 1.15; }
.boxes div {
  flex: 1;
  text-align: center;
  background: var(--bg-panel);
  border: 1.8px solid var(--border-ink);
  border-radius: 10px;
  padding: 7px 4px;
  box-shadow: 2px 2px 0 var(--shadow-ink);
}
.boxes span { display: block; font-family: var(--font-comic); font-weight: 700; font-size: 1.25rem; color: var(--pri); }

/* ---------- Quizzes, Split Reading, Audio Player & Answer Sheet ---------- */
.q {
  padding: 13px 15px;
  border: 2px solid var(--border-ink);
  border-radius: var(--radius-sm);
  background: var(--card);
  margin: 10px 0;
  box-shadow: 2.5px 2.5px 0 var(--shadow-ink);
}
.q.right { border-color: var(--ok); background: var(--ok-soft); }
.q.wrong { border-color: var(--bad); background: var(--bad-soft); }
.q.flagged { border-left: 6px solid var(--amber); }
.qtext { margin-bottom: 9px; font-weight: 500; }
.qno {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-comic);
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 50%;
  background: var(--amber-soft);
  color: var(--text);
  border: 2px solid var(--border-ink);
  box-shadow: 1.5px 1.5px 0 var(--shadow-ink);
  font-size: 0.82rem;
  font-weight: 700;
  margin-right: 7px;
}
.blank { border-bottom: 2.5px dashed var(--pri); padding: 0 12px; font-weight: 600; color: var(--pri); }
.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices.col { flex-direction: column; gap: 6px; }
.choices label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 11px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: var(--bg-panel);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.choices label:hover { border-color: var(--border-ink); background: var(--amber-soft); }
.choices label:has(input:checked) { border-color: var(--pri); background: var(--pri-soft); font-weight: 600; }

.qfb { font-size: 0.9rem; margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--line); }
.evidence { font-style: italic; color: var(--muted); border-left: 3px solid var(--pri); padding-left: 10px; margin: 5px 0; }
.qgroup { margin-bottom: 22px; }
.qhead .instr { font-weight: 600; margin: 6px 0 8px; }
.match-list { background: var(--bg-panel); border: 1.8px dashed var(--line); border-radius: var(--radius-sm); padding: 10px 14px; margin: 8px 0; font-size: 0.92rem; }
.summary-box { background: var(--pri-soft); border: 2px solid var(--border-ink); border-radius: var(--radius-sm); padding: 13px 16px; margin: 8px 0; line-height: 1.75; }
.gapno { color: var(--pri); font-family: var(--font-comic); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.passage { max-height: 78vh; overflow-y: auto; padding-right: 12px; position: sticky; top: 76px; }
.passage p { text-align: justify; }
.questions { max-height: none; }

.timer {
  font-family: var(--font-comic);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.2rem;
  padding: 3px 12px;
  border-radius: 10px;
  border: 2px solid var(--border-ink);
  background: var(--amber-soft);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.timer.danger { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }

.player {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-ink);
  background: var(--pri-soft);
}
.player.sticky { position: sticky; top: 68px; z-index: 10; box-shadow: var(--shadow); }
.player audio { flex: 1 1 300px; }

.transcript p { line-height: 1.95; }
.transcript p.li { margin: 3px 0; }
.gap {
  font: inherit;
  border: none !important;
  border-bottom: 2.5px solid var(--pri) !important;
  background: var(--pri-soft) !important;
  padding: 1px 6px !important;
  margin: 0 2px;
  border-radius: 6px 6px 0 0 !important;
  color: var(--text);
}
.gap.okg { border-color: var(--ok) !important; background: var(--ok-soft) !important; }
.gap.badg { border-color: var(--bad) !important; background: var(--bad-soft) !important; }
sup.badc { color: var(--ok); font-weight: 700; margin-right: 4px; }
.srcs { margin-top: 8px; font-size: 0.8rem; color: var(--muted); }
.srcs ol { margin: 4px 0 0 18px; padding: 0; }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 4px 0 10px; }
.flag { float: right; border: none; background: none; color: var(--muted); cursor: pointer; font-size: 1.05rem; }
.q.flagged .flag { color: var(--amber); }
.clip { display: flex; flex-direction: column; gap: 4px; }
.clip audio { max-width: 100%; }

.plabel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-comic);
  font-weight: 700;
  min-width: 1.75em;
  padding: 0 0.35em;
  margin-right: 0.35em;
  border-radius: 6px;
  border: 1.5px solid var(--border-ink);
  background: var(--amber-soft);
  color: var(--text);
  font-size: 0.85em;
}
.achead { margin-top: 1em; }

.anskeys { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 14px; margin: 12px 0; }
.anskeys label { display: flex; align-items: center; gap: 7px; }
.anskeys span { min-width: 26px; text-align: right; font-family: var(--font-comic); font-weight: 700; color: var(--pri); }
.anskeys input { flex: 1; min-width: 0; }
.anskeys input.okg { background: var(--ok-soft); border-color: var(--ok); }
.anskeys input.badg { background: var(--bad-soft); border-color: var(--bad); }

/* ---------- Writing Bands, Mock Steps & Comic Speech Bubbles ---------- */
.bands { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.bands > div {
  flex: 1;
  min-width: 110px;
  text-align: center;
  background: var(--card);
  border: 2px solid var(--border-ink);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
  box-shadow: var(--shadow-sm);
}
.bands span { display: block; font-family: var(--font-comic); font-size: 1.8rem; font-weight: 700; color: var(--pri); }
.bands .overall { background: var(--pri-solid); }
.bands .overall span, .bands .overall small { color: #fff; }

.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.steps .card { margin: 0; display: flex; flex-direction: column; }
.steps .card .btn { margin-top: auto; align-self: flex-start; }
.step.done { border-color: var(--ok); border-left: 6px solid var(--ok); }

/* Comic Speech Bubbles for AI Tutor & Lesson Q&A */
.chatlog {
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 12px 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1.8px dashed var(--line);
  background: var(--bg-panel);
}
.chatlog.tall { max-height: 62vh; min-height: 220px; }

.msg {
  position: relative;
  padding: 12px 16px;
  border-radius: 16px;
  border: 2px solid var(--border-ink);
  max-width: 82%;
  box-shadow: var(--shadow-sm);
}
.msg.me {
  align-self: flex-end;
  background: var(--pri-solid);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.me::before {
  content: "";
  position: absolute;
  right: -10px;
  bottom: 7px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-left-color: var(--border-ink);
  border-bottom-color: var(--border-ink);
}
.msg.me::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 9px;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-left-color: var(--pri-solid);
  border-bottom-color: var(--pri-solid);
}
form.row textarea { flex: 1 1 420px; width: auto; min-height: 54px; }
.msg.ai {
  align-self: flex-start;
  background: var(--card);
  color: var(--text);
  border-bottom-left-radius: 4px;
}
.msg.ai::before {
  content: "";
  position: absolute;
  left: -10px;
  bottom: 7px;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  border-right-color: var(--border-ink);
  border-bottom-color: var(--border-ink);
}
.msg.ai::after {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 9px;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-right-color: var(--card);
  border-bottom-color: var(--card);
}
.msg hr { border: none; border-top: 1.5px dashed var(--line); margin: 10px 0; }

.res li { margin: 8px 0; }

/* Floating Comic Dictionary Note */
.dictpop {
  position: fixed;
  z-index: 60;
  width: 320px;
  background: var(--card);
  color: var(--text);
  border: 2.5px solid var(--border-ink);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dictpop .dw { font-family: var(--font-comic); font-size: 1.18rem; font-weight: 700; color: var(--pri); }
.dictpop .row { margin: 4px 0 0; }

.loading { text-align: center; padding: 42px 16px; color: var(--muted); }
.spinner {
  width: 38px;
  height: 38px;
  border: 3.5px solid var(--line);
  border-top-color: var(--pri);
  border-right-color: var(--coral);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  font-family: var(--font-comic);
  font-weight: 700;
  background: var(--amber-soft);
  color: var(--ink);
  border: 2px solid var(--border-ink);
  box-shadow: var(--shadow);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  z-index: 70;
}

/* ---------- Task 1 Figures, Charts & Process Storyboards ---------- */
.chart { max-width: 720px; margin: 12px auto; }
.pie { display: inline-block; width: 48%; min-width: 240px; }
.datatable { border-collapse: collapse; margin: 10px auto; border: 2px solid var(--border-ink); }
.datatable th, .datatable td { border: 1.5px solid var(--line); padding: 7px 14px; text-align: center; }
.datatable th { background: var(--bg-panel); font-family: var(--font-comic); }
.datatable caption { font-family: var(--font-comic); font-weight: 700; margin-bottom: 6px; }

.t1fig {
  margin: 1.2em 0;
  padding: 14px;
  background: var(--bg-panel);
  border: 2px solid var(--border-ink);
  border-radius: var(--radius-sm);
}
.t1fig figcaption { font-family: var(--font-comic); margin-bottom: 0.6em; }
.fig { width: 100%; max-width: 680px; height: auto; display: block; font-family: inherit; fill: currentColor; }
.fig.pie { max-width: 240px; margin: auto; }
.fig.map { max-width: 380px; margin: auto; }
.figrow { display: flex; flex-wrap: wrap; gap: 1em; justify-content: center; }
.figrow > div { flex: 1 1 240px; max-width: 400px; }
.tscroll { overflow-x: auto; }

ol.process {
  counter-reset: st;
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em 1.5em;
  align-items: center;
}
ol.process li {
  border: 2px solid var(--border-ink);
  border-radius: var(--radius-sm);
  padding: 0.5em 0.8em;
  background: var(--card);
  box-shadow: 2px 2px 0 var(--shadow-ink);
  position: relative;
}
ol.process li::before {
  counter-increment: st;
  content: counter(st) ". ";
  font-family: var(--font-comic);
  font-weight: 700;
  color: var(--pri);
}
ol.process li:not(:last-child)::after {
  content: "➜";
  position: absolute;
  right: -1.15em;
  top: 50%;
  transform: translateY(-50%);
  color: var(--coral);
  font-weight: 700;
}

/* ==========================================================================
   Đêm đầy sao layer — overrides the older styling above (kept before the responsive section).
   ========================================================================== */
body { font: 15px/1.7 var(--font-body); background: var(--bg); font-variant-numeric: lining-nums; }
h1, h2, h3, h4 { font-family: var(--font-title); font-variation-settings: "SOFT" 100, "WONK" 0; font-variant-numeric: lining-nums; letter-spacing: -0.01em; }
h2 { font-size: 1.28rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.06rem; font-weight: 600; }
h4 { font-weight: 600; }
p, li { max-width: 74ch; }
:root { --focus: #1e3f73; }
:root[data-theme="dark"] { --focus: #f2de7a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --focus: #f2de7a; } }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; box-shadow: 0 0 0 4px var(--card); }
.top :focus-visible, #nav :focus-visible, .journey :focus-visible, h1.sky :focus-visible { outline-color: var(--halo); box-shadow: none; }
select { max-width: 100%; }
.form > label, .filters > label { min-width: 0; max-width: 100%; }
.form select, .filters select { width: 100%; }
::placeholder { color: var(--muted); opacity: 1; }
::selection { background: var(--halo); color: var(--night); }

/* --- chrome: the night (top bar + sidebar), same in both themes --- */
.top { background: var(--night); border-bottom: 1px solid #1d2c4a; box-shadow: none; color: var(--chrome-text); }
.brand { font-family: var(--font-title); font-size: 1.35rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: #f4efd9; font-variation-settings: "SOFT" 100, "WONK" 1; }
.brand:hover { opacity: 1; color: var(--halo); }
.brand:hover .brand-sketch { transform: none; }
.brand-sketch path { fill: var(--star); stroke: none; }
.brand .brand-text { letter-spacing: .08em; font-weight: 600; }
#keystate { background: transparent; border: 0; color: var(--chrome-muted); font-weight: 500; padding: 0; display: inline-flex; align-items: center; gap: 7px; }
#keystate::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.top select { max-width: 190px; text-overflow: ellipsis; }
#keystate.ok { color: #9fd4b8; background: transparent; }
#keystate.bad { color: #ffb4ab; background: transparent; }
.model { color: var(--chrome-muted); font-weight: 500; }
.top select { background: var(--night-2); color: var(--chrome-text); border-color: #2a3c60; }
.top .icon { background: transparent; color: var(--chrome-text); border-color: #2a3c60; }
.top .icon:hover { background: var(--night-2); color: var(--halo); }

#nav { background: var(--night); border-right: 1px solid #1d2c4a; padding: 18px 12px 0; display: flex; flex-direction: column; }
.nav-sec { font-family: var(--font-body); font-size: 0.76rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--chrome-muted); padding: 16px 12px 6px; }
#nav a { display: flex; align-items: center; gap: 11px; color: var(--chrome-text); border: 0; border-radius: var(--radius-sm); padding: 7px 12px; margin-bottom: 1px; font-weight: 400; font-size: 0.92rem; transition: background-color .15s ease, color .15s ease; }
#nav a .ic { flex-shrink: 0; opacity: .7; transition: opacity .15s ease, color .15s ease; }
#nav a:hover { background: rgba(169, 196, 214, 0.08); color: #fff; text-decoration: none; }
#nav a:hover .ic { opacity: 1; }
#nav a.on { background: rgba(232, 185, 49, 0.1); color: var(--halo); font-weight: 600; border-left: 0; box-shadow: inset 2px 0 0 var(--star); }
#nav a.on .ic { opacity: 1; color: var(--star); }
#nav a .nt { width: auto; font-size: inherit; text-align: left; flex: 1; }
#nav { scrollbar-color: #2a3c60 transparent; scrollbar-width: thin; padding-bottom: 24px; }
#nav::-webkit-scrollbar-thumb { background: #2a3c60; }

main { --gutter: max(30px, calc((100vw - 228px - 1140px) / 2)); max-width: none; padding-left: var(--gutter); padding-right: var(--gutter); }
#backdrop { position: fixed; top: 60px; left: 228px; width: calc(100% - 228px); height: calc(100vh - 60px); z-index: -1; pointer-events: none; display: block; }
main > * { animation: none; }

/* --- page title: a strip of painted sky (the canvas is painted by sky.js) --- */
main h1.sky {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; isolation: isolate; overflow: hidden;
  min-height: 132px; margin: 0 0 24px; padding: 22px 26px 18px; border-radius: var(--radius-panel);
  background: var(--ultra); color: #fbf6e2;
  font-family: var(--font-title); font-size: 2.15rem; font-weight: 600; line-height: 1.15; letter-spacing: -0.015em;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}
main h1.sky::after { content: none; }
main h1.sky .sky-cv { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
/* scrim: keeps the title above 4.5:1 whatever strokes sit behind it */
main h1.sky::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(100deg, rgba(10, 20, 44, .82) 0%, rgba(10, 20, 44, .55) 45%, rgba(10, 20, 44, 0) 78%); }
main h1.sky small { font-family: var(--font-body); font-size: 0.8rem; font-weight: 500; letter-spacing: 0; color: var(--swirl-pale); margin-bottom: 2px; font-variation-settings: normal; }
main .row.between:has(> h1.sky) { position: relative; margin: 0 0 24px; }
main .row.between > h1.sky { flex: 1 1 100%; margin: 0; }
main .row.between:has(> h1.sky + .mini) + .tabs { padding-right: 150px; }
main .row.between > h1.sky + .mini { position: absolute; right: 0; top: calc(100% + 30px); margin: 0; z-index: 2;
  background: var(--card); color: var(--text); border: 1px solid var(--border-ink); }
main .row.between > h1.sky + .mini:hover { background: var(--pri-soft); color: var(--pri); }
main .row.between > h1.sky + .mini.on { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }

/* --- surfaces (the calm village) --- */
.card { border: 1px solid var(--border-ink); box-shadow: var(--shadow); padding: 20px 24px; border-radius: var(--radius-panel); background: var(--card); transition: border-color .15s ease, box-shadow .15s ease; }
.card.hl { border: 1px solid color-mix(in srgb, var(--emerald) 40%, var(--border-ink)); background-image: none; background: color-mix(in srgb, var(--emerald) 7%, var(--card)); }
.card.error { border-left: 3px solid var(--bad); }
a.card:hover, .lesson:hover, .bankitem:hover, .bankcta:hover, .stage:hover { transform: none; border-color: var(--pri); box-shadow: var(--shadow-lg); }
.lesson.done, .bankitem.done { border-left: 3px solid var(--ok); }
details > summary::before { content: ""; width: 8px; height: 8px; border: 0; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); border-radius: 0; background: none; transform: rotate(-45deg); margin-right: 4px; box-shadow: none; }
details[open] > summary::before { transform: rotate(45deg); background: none; }

/* --- controls --- */
.btn { font-family: var(--font-body); font-weight: 600; font-size: 0.92rem; border: 1px solid var(--star); background: var(--star); color: var(--night); border-radius: 999px; box-shadow: none; padding: 9px 18px; transition: background-color .15s ease, border-color .15s ease; }
.btn:hover:not(:disabled) { transform: none; box-shadow: none; background: #f2c94c; border-color: #f2c94c; }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--pri); border-color: var(--border-ink); }
.btn.ghost:hover:not(:disabled) { background: var(--pri-soft); border-color: var(--pri); }
.btn.small { box-shadow: none; padding: 5px 13px; }
.btn.green { background: var(--ok-solid); border-color: var(--ok-solid); }
.btn.red { background: var(--bad-solid); border-color: var(--bad-solid); }
.icon, .mini { border: 1px solid var(--border-ink); box-shadow: none; border-radius: var(--radius-sm); background: var(--card); }
.icon:hover, .mini:hover { transform: none; box-shadow: none; background: var(--bg-panel); }
.icon:active { transform: translateY(1px); box-shadow: none; }
.mini.on { border-color: var(--ok); }
input:not([type="checkbox"]):not([type="radio"]), select, textarea { border: 1px solid var(--border-ink); border-radius: var(--radius-sm); box-shadow: none; font-family: var(--font-body); background: var(--card); color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: var(--cobalt); box-shadow: 0 0 0 3px var(--pri-soft); outline: none; }
.form legend { font-family: var(--font-body); font-weight: 600; }

.bankitem > .row.between { flex-wrap: nowrap; align-items: flex-start; margin: 0 0 4px; }
.bankitem > .row.between > b { font-family: var(--font-title); font-size: 1.04rem; font-weight: 600; line-height: 1.3; }
.bankitem .tag { flex-shrink: 0; }
.warnc { display: inline-block; font-weight: 500; color: var(--amber); background: rgba(232, 185, 49, .12); border: 1px solid rgba(232, 185, 49, .3); border-radius: 8px; padding: 4px 12px; max-width: 74ch; }
.warnc b { font-weight: 600; }
:root[data-theme="dark"] .tag.hard { color: #f2de7a; background: rgba(232, 185, 49, .18); }
.tag { font-family: var(--font-body); font-weight: 500; border: 0; border-radius: 999px; padding: 1px 8px; font-size: 0.74rem; }
.chip { border: 1px solid var(--line); background: var(--bg-panel); box-shadow: none; border-radius: var(--radius-sm); }
.btnchip { background: var(--card); border-color: var(--border-ink); }
.btnchip:hover { transform: none; border-color: var(--pri); background: var(--pri-soft); }
.bar { height: 6px; border: 0; background: var(--line); }
.bar span { background: var(--ok); border: 0; border-radius: 99px; }
.stage .bar span { background: var(--cobalt); }

.crumbs { font-family: var(--font-body); font-weight: 500; font-size: 0.86rem; gap: 6px; }
.crumbs a { border: 1px solid var(--border-ink); box-shadow: none; border-radius: 999px; padding: 3px 12px; background: var(--card); }
.crumbs a:hover { background: var(--pri-soft); border-color: var(--pri); }
.tabs { border-bottom: 1px solid var(--border-ink); gap: 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; scroll-behavior: smooth; }
.tabs.more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 48px), transparent); }
.tabs a { scroll-snap-align: center; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { white-space: nowrap; flex-shrink: 0; }
.tabs a { font-family: var(--font-body); font-weight: 500; border: 0; border-radius: 0; padding: 10px 12px; top: 1px; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs a:hover { background: none; color: var(--text); border-bottom-color: var(--border-ink); }
.tabs a.on { background: none; border: 0; border-bottom: 3px solid var(--star); color: var(--text); font-weight: 600; padding-bottom: 10px; }
.stage-dots a { font-family: var(--font-body); font-weight: 500; border: 1px solid var(--border-ink); }
.stage-dots a.on { background: var(--pri-solid); border-color: var(--pri-solid); box-shadow: none; }

.stage { display: flex; flex-direction: column; }
.stage .bar { margin-top: auto; }
.nw { white-space: nowrap; }
.stage.on { border: 1px solid var(--border-ink); border-top: 3px solid var(--star); background: var(--card); box-shadow: var(--shadow-lg); }
.stage .moon { color: var(--star); font-size: 1.05em; }
.stage .sno { font-family: var(--font-body); color: var(--pri); font-weight: 600; }
.lesson .lno { font-family: var(--font-title); font-weight: 600; font-size: 1.15rem; border: 1px solid var(--border-ink); background: var(--bg-panel); box-shadow: none; border-radius: 50%; width: 40px; height: 40px; }
.lvl { box-shadow: none !important; border-width: 1px !important; }
.lvl:hover { transform: none; border-color: var(--pri) !important; }
.lvl b, .flash .word, .flash .meaning, .boxes span, .gapno, .rs-side .big, .stat .big { font-family: var(--font-title); }
.stat .big { font-weight: 600; color: var(--pri); }
.q { box-shadow: none; border-width: 1px; }
.choices label { border-width: 1px; box-shadow: none; }
.choices label:hover { background: var(--pri-soft); border-color: var(--pri); }
.choices label.correct { border-color: var(--emerald); box-shadow: inset 0 0 0 1px var(--emerald); font-weight: 600; }
.choices label.correct::after { content: " ✓"; color: var(--ok); }
.choices label.chosen { border-color: #c0563f; text-decoration: line-through; text-decoration-color: rgba(192, 86, 63, .6); }
.flash { box-shadow: none; }
.flash:hover { transform: none; }
.prompt { border-left-color: var(--cobalt); }
.vtable th { font-weight: 600; }
.vtable tbody tr:hover { background: var(--bg-panel); }
.timer, .player { box-shadow: none; }
.comic-doodle { display: none; }

/* --- dashboard: the night sky of the 5-stage journey --- */
.journey { position: relative; border-radius: 18px; overflow: hidden; isolation: isolate; min-height: 360px; margin: 0 0 26px; background: var(--ultra); color: #fbf6e2; }
.journey > canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
.journey::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to top, rgba(14, 26, 46, .88) 0%, rgba(14, 26, 46, .55) 38%, rgba(14, 26, 46, 0) 62%); }
.journey .jtext { position: absolute; left: 30px; bottom: 26px; right: 30px; max-width: 560px; }
.journey .jtext p { margin: 0 0 4px; color: #d7deea; font-size: 0.9rem; }
.journey .jtitle { font-family: var(--font-title); font-variation-settings: "SOFT" 100, "WONK" 1; font-size: 2.3rem; font-weight: 600; line-height: 1.12; margin: 0 0 14px; color: #fbf6e2; }
.journey .jnext { display: inline-flex; align-items: center; gap: 10px; background: var(--halo); color: var(--night); font-weight: 600; padding: 10px 20px; border-radius: 999px; }
.journey .jnext:hover { background: #fff3b0; text-decoration: none; }
.journey .jsub { margin-left: 14px; color: #d7deea; font-size: 0.88rem; }
.journey .jsub a { color: #fbf6e2; }
.journey h1::after { content: none; }
.journey .jtitle { display: block; padding: 0; }
.journey .jcypress { position: absolute; left: 0; bottom: 0; width: 150px; height: 100%; z-index: -1; }
.journey .jtext { left: 150px; }
.jpath { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.jpath polyline { fill: none; stroke: var(--halo); stroke-opacity: .55; stroke-width: 1.5; stroke-dasharray: 2 7; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.jpath .m { display: none; }
.jstars { list-style: none; margin: 0; padding: 0; }
.jstars li { max-width: none; }
.jstar { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -14px); display: flex; flex-direction: column; align-items: center; gap: 8px; color: #fbf6e2; text-decoration: none; z-index: 1; }
.jstar .dot { width: 28px; height: 28px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 247, 214, .95) 0, rgba(242, 222, 122, 0) 70%); animation: twinkle 6s ease-in-out infinite; }
.jstars li:nth-child(2) .dot { animation-delay: -1.5s; } .jstars li:nth-child(3) .dot { animation-delay: -3s; } .jstars li:nth-child(4) .dot { animation-delay: -4.5s; } .jstars li:nth-child(5) .dot { animation-delay: -2.2s; }
.jstar.on .dot { width: 64px; height: 64px; margin: -18px 0 -18px; animation: none; background: none; }
.jstar .lb { font-size: 0.78rem; font-weight: 500; white-space: nowrap; padding: 2px 10px; border-radius: 999px; background: rgba(10, 20, 44, .7); }
.jstar:not(.on) .nm { display: none; }
.jstar:not(.on):hover .nm, .jstar:not(.on):focus-visible .nm { display: inline; }
.jstar.on .lb { background: var(--halo); color: var(--night); font-weight: 600; }
.jstar.done .lb::before { content: "✓ "; color: #a8e0c4; }
.jstar:hover { text-decoration: none; }
.jstar:hover .lb { background: rgba(10, 20, 44, .95); color: var(--halo); }
.jstar.on:hover .lb { background: #fff3b0; color: var(--night); }
.jstar:focus-visible { outline: none; }
.jstar:focus-visible .lb { outline: 2px solid var(--halo); outline-offset: 3px; }
@keyframes twinkle { 0%, 100% { opacity: .15; } 50% { opacity: .7; } }

.today-line { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 22px; padding: 16px 22px; margin: 0 0 28px; }
.today-line .ti { display: flex; gap: 12px; align-items: flex-start; line-height: 1.4; }
.today-line .ti > .ic { flex-shrink: 0; margin-top: 2px; color: var(--cobalt); }
.today-line .ti small { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 3px; text-wrap: balance; }
.today-line b { font-family: var(--font-title); font-size: 1.25rem; font-weight: 600; }
.today-line a { color: var(--text); text-decoration: none; }
.today-line a:hover { color: var(--pri); }
.today-line a.act { color: var(--pri); font-weight: 600; text-decoration: underline; text-decoration-color: var(--star); text-decoration-thickness: 2px; text-underline-offset: 4px; }
:root[data-theme="dark"] .today-line .ti > .ic { color: var(--pri); }
.t1fig { border: 0; margin: 14px 0; padding: 18px 20px; border-radius: 12px; background: var(--bg-panel); }
.t1fig .figrow > div { flex: 1 1 220px; }
.t1fig .chips { justify-content: center; }

/* custom audio player (player.js) */
audio[data-ap] { display: none; }
.aplayer { display: flex; align-items: center; gap: 12px; flex: 1 1 320px; min-width: 0; }
.ap-play { flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--star); color: var(--night); display: grid; place-items: center; cursor: pointer; }
.ap-play:hover { background: #f2c94c; }
.ap-t, .ap-d { font: 600 .9rem var(--font-title); font-variant-numeric: tabular-nums; color: var(--muted); min-width: 2.6em; }
.aplayer input.ap-bar { width: auto; background: linear-gradient(90deg, var(--cobalt) var(--p, 0%), var(--line) var(--p, 0%)) !important; }
.ap-bar { flex: 1; min-width: 60px; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 99px; border: 0 !important; padding: 0 !important; box-shadow: none !important;
  background: linear-gradient(90deg, var(--cobalt) var(--p, 0%), var(--line) var(--p, 0%)); cursor: pointer; }
.ap-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--cobalt); border: 2px solid var(--card); }
.ap-bar::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--cobalt); border: 2px solid var(--card); }
.player { align-items: center; gap: 10px 12px; }
.player { display: flex; flex-wrap: wrap; }
.player.sticky { position: sticky; top: 60px; z-index: 5; margin: 0 calc(-1 * var(--gutter)) 16px; padding: 10px var(--gutter); border: 0; border-bottom: 1px solid var(--border-ink); border-radius: 0; background: var(--card); box-shadow: 0 6px 14px -10px rgba(14, 26, 46, .35); }
html:has(.player.sticky), html:has(.testbar) { scroll-padding-top: 150px; }
.player > .muted { align-self: center; display: inline-flex; align-items: center; height: 32px; line-height: 1; }
.player [data-rate].on { background: rgba(232, 185, 49, .16); border-color: rgba(232, 185, 49, .6); color: var(--text); }
.transcript p:has(> .spk) { position: relative; padding-left: 8.5em; }
.transcript .spk.same { visibility: hidden; }
.transcript .spk { position: absolute; left: 0; top: 0; line-height: inherit; display: inline-block; min-width: 7.5em; font-family: var(--font-title); font-weight: 600; color: var(--cobalt); }
input.gap { height: 1.6em; vertical-align: baseline; padding: 0 .4em; line-height: 1.6em; }

/* writing feedback: the overall band is the moon; each criterion row carries its own comment */
.card.fb { border: 1px solid var(--border-ink); background: var(--card); }
.bands { display: grid; grid-template-columns: minmax(170px, 210px) 1fr; gap: 16px; margin: 0 0 20px; }
.bands > .overall { display: flex; flex-direction: column; gap: 2px; padding: 18px 20px; border-radius: 14px; background: var(--night); color: var(--chrome-text); }
.bands > .overall span { font: 600 3rem/1 var(--font-title); color: var(--halo); }
.bands > .overall small { color: var(--swirl-pale); font-size: .8rem; }
.bands > .overall .next { margin: 12px 0 0; font-size: .84rem; line-height: 1.45; color: #e6ecf7; }
.bands > div { text-align: left; }
.bands > .overall { border: 0; align-items: flex-start; }
.crit { display: grid; gap: 0; padding: 0 4px; align-content: start; }
.bands > .overall { align-self: start; }
.bands > .crit { border: 0; background: none; box-shadow: none; padding: 0 4px; }
.bars { align-self: stretch; width: 100%; position: relative; display: flex; gap: 10px; align-items: flex-end; height: 132px; margin: 18px 0 0; padding-bottom: 18px; }
.bars .bb { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bars .bb i { display: block; width: 100%; max-width: 22px; border-radius: 4px 4px 0 0; background: var(--cobalt); }
.bars .bb.lowest i { background: var(--star); }
.bars .bb small { position: absolute; bottom: -18px; font-size: .66rem; color: var(--swirl-pale); }
.bars .bb { padding-top: 18px; }
.bars .bb i { max-height: calc(100% - 18px); }
.bars .bb em { font: 600 .72rem var(--font-title); font-style: normal; color: #e6ecf7; margin-bottom: 2px; }
.bars .goal b { position: absolute; right: 0; top: -15px; font: 600 .66rem var(--font-body); color: var(--halo); }
.bars .goal { position: absolute; left: 0; right: 0; border-top: 1.5px dashed rgba(242, 222, 122, .7); }
.cr { display: grid; grid-template-columns: 3.2rem 1fr; gap: 12px; align-items: start; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.cr:last-child { border-bottom: 0; }
.cr .b { font: 600 1.45rem/1.2 var(--font-title); color: var(--text); }
.cr.lowest .b { color: var(--coral); }
.cr b { font-weight: 600; font-size: .92rem; }
.cr p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.55; }
.fixes { list-style: none; padding: 0; margin: 0 0 16px; }
.fixes li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); max-width: none; }
.fixes .fx { font-weight: 500; }
.fixes del { color: #b04a34; text-decoration: line-through 1.5px; text-decoration-color: currentColor; }
.fixes ins { color: var(--ok); text-decoration: underline 2px var(--emerald); text-underline-offset: 3px; font-weight: 600; }
.fixes .arr { margin: 0 6px; color: var(--muted); }
.fixes .why { flex-basis: 100%; color: var(--muted); font-size: .88rem; }
:root[data-theme="dark"] .fixes del { color: #f0a08c; }
.essay mark { background: rgba(232, 185, 49, .3); border-bottom: 2px solid var(--star); border-radius: 2px; padding: 0 1px; }
.essay { line-height: 1.85; }
@media (max-width: 640px) { .bands { grid-template-columns: 1fr; } }

/* reading & quiz surfaces: long night sessions */
.testbar { position: sticky; top: 60px; z-index: 6; display: flex; align-items: center; gap: 14px; margin: 0 calc(-1 * var(--gutter)) 16px; padding: 10px var(--gutter);
  background: var(--card); border-bottom: 1px solid var(--border-ink); box-shadow: 0 6px 14px -10px rgba(14, 26, 46, .35); }
.testbar #flags { padding: 2px 10px; border-radius: 999px; background: rgba(232, 185, 49, .16); color: var(--amber); font-weight: 500; }
.split > .passage, .split > .questions { scroll-padding-top: 16px; }
.only-wrong .questions .q.right { display: none; }
.seg { display: none; }
.testbar .tb-title { font-family: var(--font-title); font-weight: 600; font-size: 1.02rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.testbar .tb-count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tb-count.scored { color: var(--text); }
.tb-count .sc { font: 600 1.3rem var(--font-title); color: var(--coral); margin-right: 2px; }
.tb-count .sc.good { color: var(--ok); }
.split.graded > .passage, .split.graded > .questions { height: auto; max-height: none; overflow: visible; }
.testbar #flags:empty { display: none; }
.testbar .btn { padding: 7px 18px; }
main:has(.testbar) h1.sky { min-height: 76px; font-size: 1.55rem; padding: 14px 22px; }
.split { padding: 0; gap: 0; overflow: hidden; }
.split > .passage, .split > .questions { height: calc(100vh - 170px); min-height: 420px; overflow-y: auto; overscroll-behavior: contain; padding: 22px 26px; position: static; max-height: none;
  scrollbar-width: thin; scrollbar-color: var(--border-ink) transparent; }
.split > .passage { border-right: 1px solid var(--line); }
#ptext p { position: relative; padding-left: 2rem; border-radius: 6px; transition: background-color .6s ease; }
#ptext .plabel { position: absolute; left: 0; top: .25rem; font: 600 .78rem/1.3rem var(--font-title); color: var(--coral); background: var(--coral-soft); border: 0; border-radius: 6px; min-width: 1.35rem; text-align: center; padding: 0; }
#ptext p.pflash { animation: pflash 1.6s ease; }
@keyframes pflash { 0%, 35% { background: rgba(232, 185, 49, .16); } 100% { background: transparent; } }
.tools { gap: 10px; margin: 0 0 14px; }
.hltoggle { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 8px; border: 1px solid var(--border-ink); border-radius: 999px; cursor: pointer; font-weight: 500; }
.hltoggle { background: var(--card); color: var(--muted); font: 500 .84rem var(--font-body); }
.hltoggle[aria-pressed="true"] { background: rgba(232, 185, 49, .14); border-color: rgba(232, 185, 49, .55); color: var(--text); }
#hlclear { display: none; margin: 0; }
.passage:has(#ptext mark) #hlclear { display: inline-flex; }
.qhead .instr { font-weight: 400; margin: 6px 0 10px; }
.questions .qtext { font-weight: 500; }
.questions .qno { font-weight: 700; }
.qhead .instr b { font-weight: 600; }
.match-list { border-radius: 10px; padding: 10px 14px; background: var(--bg-panel); border: 0; }
.match-list b { display: inline-block; width: 1.4em; font-variant-numeric: tabular-nums; color: var(--cobalt); }
.questions .q { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; padding: 14px 4px 14px 0; margin: 0; }
.questions .q.right, .questions .q.wrong { padding-left: 14px; border-left: 3px solid; }
.questions .q.right { border-left-color: var(--emerald); background: rgba(111, 165, 138, .05); }
.questions .q.wrong { border-left-color: #c0563f; background: rgba(192, 86, 63, .04); }
.questions .q.flagged { border-left: 3px solid var(--star); padding-left: 14px; }
.qfb { border-top: 0; padding-top: 4px; }
.verdict b:first-child { font-family: var(--font-title); }
.q.right .verdict b:first-child { color: var(--ok); }
.q.wrong .verdict b:first-child { color: #b04a34; }
:root[data-theme="dark"] .q.wrong .verdict b:first-child { color: #f0a08c; }
.pchip { display: inline-flex; align-items: center; margin-top: 6px; font: 500 .8rem var(--font-body); color: var(--pri); background: var(--pri-soft); border: 0; border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.pchip:hover { background: var(--pri); color: #fff; }
.q select { min-width: 84px; padding: 6px 10px; }
.flag { float: right; margin: 2px 0 0 8px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; }
.flag { opacity: .45; }
.flag:hover { opacity: .8; }
.q.flagged .flag { color: var(--star); opacity: 1; }
.timer.done { font-family: var(--font-body); font-weight: 500; font-size: .84rem; color: var(--muted); }
main > p.muted, main > .muted, .card > p, .card p.small, .muted.small { text-wrap: pretty; }
.exam-card .helper { flex-basis: 100%; }
.card > p.small:first-child { max-width: none; }

.passage p { text-align: left; hyphens: auto; line-height: 1.78; font-size: 1rem; }
.timer { border: 1px solid var(--border-ink); background: var(--card); color: var(--text); font-family: var(--font-title); font-weight: 600; box-shadow: none; border-radius: 999px; padding: 4px 14px; }
.timer.danger { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.qno { border: 0; background: var(--pri-soft); color: var(--pri); box-shadow: none; font-family: var(--font-title); }
.q { border-radius: 12px; }
.q.right { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.q.wrong { border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.match-list { border: 1px solid var(--line); border-style: solid; }
.evidence { border-left-color: var(--star); }

/* skip link, nav badge, onboarding */
.skip { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--star); color: var(--night); padding: 8px 14px; border-radius: 8px; font-weight: 600; }
.skip:focus { top: 10px; }
main:focus { outline: none; }
#nav .badge { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--star); color: var(--night); font: 600 .72rem/20px var(--font-body); text-align: center; }
.onboard { border: 1px solid color-mix(in srgb, var(--star) 55%, var(--border-ink)); }
.obsteps { counter-reset: ob; list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 14px; }
.obsteps > li { counter-increment: ob; position: relative; padding-left: 44px; max-width: none; }
.obsteps > li::before { content: counter(ob); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--night); color: var(--halo); display: grid; place-items: center; font: 600 .95rem var(--font-title); }
.obsteps p { margin: 2px 0 8px; color: var(--muted); }
.obsteps .row { margin: 6px 0 0; }
.obsteps .row input[type="date"] { flex: 0 0 auto; width: 200px; min-width: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Responsive Breakpoints ---------- */
@media (min-width: 641px) and (max-width: 1100px) { .today-line { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .journey { min-height: 460px; }
  .journey .jcypress { width: 96px; height: 72%; top: auto; bottom: 0; }
  .journey .jtext { left: 22px; right: 22px; bottom: 22px; }
  .jpath .d { display: none; } .jpath .m { display: inline; }
  .jstar { left: var(--mx); top: var(--my); }
  .jstar .lb { font-size: 0.7rem; padding: 1px 7px; }

}

@media (max-width: 900px) {
  #burger { display: inline-flex; }
  .model, #keystate { display: none; }
  #nav {
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: none;
  }
  body.menu #nav {
    transform: none;
    box-shadow: 12px 0 30px rgba(0, 0, 0, 0.18);
  }
  body.menu .nav-backdrop {
    display: block;
    position: fixed;
    inset: 60px 0 0 0;
    background: rgba(18, 14, 34, 0.4);
    z-index: 20;
  }
  main { margin-left: 0; padding: 18px 16px 36px; --gutter: 16px; }
  #backdrop { left: 0; width: 100%; }
  #nav { visibility: hidden; transition: transform .22s ease, visibility 0s .22s; }
  body.menu #nav { visibility: visible; transition: transform .22s ease; }
  .grid2, .grid3, .split, .steps, .roadmap-strip { grid-template-columns: 1fr; }
  .rs-side { padding-left: 0; border-left: 0; padding-top: 12px; border-top: 2px dashed var(--line); }
  .passage { position: static; max-height: none; padding-right: 0; }
  .stages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .levels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .vtable { display: block; overflow-x: auto; }
}

@media (max-width: 520px) {
  .stages { grid-template-columns: 1fr; }
  .levels { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .msg { max-width: 92%; }
  main .row.between:has(> h1.sky + .mini) { flex-direction: column; align-items: flex-end; }
  .split > .passage, .split > .questions { height: auto; min-height: 0; overflow: visible; }
  .testbar { margin: 0 -16px 12px; padding: 8px 16px; flex-wrap: nowrap; }
  .testbar .tb-title { flex-basis: auto; }
  .testbar .tb-count, .testbar #flags { display: none; }
  .seg { display: flex; position: sticky; top: 112px; z-index: 5; margin: 0 -16px 12px; background: var(--card); border-bottom: 1px solid var(--border-ink); border-radius: 0; padding: 6px 16px; }
  .player.sticky { margin: 0 -16px 12px; padding: 8px 16px; flex-wrap: nowrap; gap: 8px; }
  .player .muted { display: none; }
  .player [data-rate]:not(.on) { display: none; }
  .player .lbl { display: none; }
  .player .mini, .ap-play { min-width: 44px; min-height: 44px; }
  .split .passage .tools { display: none; }
  .aplayer { flex: 1 1 auto; gap: 8px; }
  .ap-d { display: none; }
  .transcript p:has(> .spk) { padding-left: 0; }
  .transcript .spk { position: static; display: block; min-width: 0; font-size: .8rem; margin-bottom: 2px; }
  .transcript .spk.same { display: none; }
  .seg { box-shadow: 0 6px 10px -8px rgba(14, 26, 46, .4); }
  .seg button { flex: 1; border: 0; background: none; padding: 7px; border-radius: 999px; font: 500 .88rem var(--font-body); color: var(--muted); }
  .seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
  .split .questions { display: none; }
  .split.show-q .questions { display: block; }
  .split.show-q .passage { display: none; }
  .split > .passage { border-right: 0; border-bottom: 1px solid var(--line); }
  main .row.between > h1.sky + .mini { position: static; margin-top: 10px; }
  main .row.between:has(> h1.sky + .mini) + .tabs { padding-right: 0; }
  main h1.sky { font-size: 1.6rem; min-height: 112px; }

  .journey .jtitle { font-size: 1.7rem; }
  .journey .jsub { display: block; margin: 10px 0 0; }
}

/* per-word "add to review deck" button in vocabulary tables */
.vtable td.vact { white-space: nowrap; }
.vtable td.vact .icon + .vadd, .vtable td.vact .icon + span.vadd { margin-left: 6px; }
.vadd { font-weight: 700; font-size: 1.05rem; line-height: 1; color: var(--cobalt, #3367a8); }
span.vadd.done { display: inline-grid; place-items: center; width: 34px; height: 34px; color: var(--emerald, #2e7d5b); vertical-align: middle; }
.icon.vadd { min-width: 38px; min-height: 34px; display: inline-grid; place-items: center; vertical-align: middle; }
.icon.ex-say { min-width: 30px; min-height: 28px; padding: 2px 6px; font-size: .8rem; vertical-align: middle; }

/* ---------- in-lesson practice (lesson-practice.js) ---------- */
.gset h3 { margin-top: 0; }
.gq { padding: 10px 0 10px 12px; border-left: 3px solid transparent; border-bottom: 1px dashed var(--line); }
.gq:last-of-type { border-bottom: 0; }
.gq .qtext { margin-bottom: 6px; }
.gq .gin { max-width: 340px; }
.gq.right { border-left-color: var(--emerald, #4f8f6f); background: rgba(111, 165, 138, .06); }
.gq.wrong { border-left-color: #c0563f; background: rgba(192, 86, 63, .05); }
.gq .qfb, .gset .qfb { font-size: .9rem; margin-top: 6px; }
.gq del, .fixes del { color: #c0563f; } .gq ins, .fixes ins { color: var(--emerald, #4f8f6f); text-decoration: none; font-weight: 600; }
.gscore { margin-left: 8px; }
.lp-read { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.lp-read .passage { position: sticky; top: 76px; max-height: calc(100vh - 110px); overflow-y: auto; padding-right: 10px; line-height: 1.7; }
.lp-read .passage p { position: relative; padding-left: 1.9rem; }
.lp-read .plabel { position: absolute; left: 0; top: .2rem; font: 600 .78rem/1.3rem var(--font-title); color: var(--cobalt, #3367a8); background: rgba(51, 103, 168, .1); border-radius: 6px; min-width: 1.35rem; text-align: center; }
.lp-read .passage p.pflash { animation: pflash 1.6s ease; }
.lp-player { flex-wrap: wrap; align-items: center; gap: 10px; }
.lp-script .transcript p { margin: .35rem 0; }
.clist { list-style: none; padding-left: 0; } .clist li.ok { color: var(--emerald, #4f8f6f); } .clist li.bad { color: #c0563f; }
@media (max-width: 860px) {
  .lp-read { grid-template-columns: 1fr; }
  .lp-read .passage { position: static; max-height: none; overflow: visible; }
}

/* earlier practice results */
.prevres { margin: 6px 0 12px; padding: 8px 12px; border-radius: 10px; border-left: 4px solid; font-size: .92rem; background: var(--bg-panel, rgba(51,103,168,.05)); }
.prevres.ok { border-left-color: var(--emerald, #4f8f6f); } .prevres.warn { border-left-color: var(--star, #e8b931); } .prevres.bad { border-left-color: #c0563f; }
.prevres .adv { font-weight: 600; }
.tscore { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: .72rem; font-weight: 700; line-height: 1.5; vertical-align: middle; color: #fff; }
.tscore.ok { background: var(--emerald, #4f8f6f); } .tscore.warn { background: #b98a12; } .tscore.bad { background: #c0563f; }
.lres { margin-top: 4px; }

/* select-to-look-up */
.dictpop { max-width: calc(100vw - 16px); }
.dictpop .dmean { font-weight: 600; }
.top .icon.lookup { width: auto; padding: 0 10px; font-size: .78rem; white-space: nowrap; }
.top .icon.lookup[aria-pressed="false"] { opacity: .6; }
@media (max-width: 640px) { .top .icon.lookup { font-size: .7rem; padding: 0 6px; } }

/* accounts */
.acctbox { display: inline-flex; align-items: center; gap: 8px; margin-right: 6px; }
.acct { color: var(--chrome-text, #f4ead2); text-decoration: none; font-weight: 600; font-size: .85rem; padding: 4px 10px; border: 1px solid #2a3c60; border-radius: 999px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct:hover { border-color: var(--star, #e8b931); }
.sync { font-size: .72rem; color: #9fb0cc; white-space: nowrap; } .sync.bad { color: #f0a08c; }
.auth { display: grid; place-items: start center; padding-top: 4vh; }
.auth-card { width: min(440px, 100%); }
.auth-card .form label { display: flex; flex-direction: column; gap: 4px; }
.auth-card .form label.inline { flex-direction: row; align-items: flex-start; gap: 8px; }
.auth-card #amsg.bad, #amsg.bad { color: #c0563f; } #amsg.ok { color: var(--emerald, #4f8f6f); }
@media (max-width: 640px) { .sync { display: none; } .acct { max-width: 90px; } }

/* motivation: XP chip, calendar, badges, league */
.xpchip { display: inline-flex; align-items: center; gap: 5px; margin-right: 6px; padding: 2px 10px 2px 4px; border: 1px solid #2a3c60; border-radius: 999px; color: var(--chrome-text, #f4ead2); text-decoration: none; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.xpchip.done { border-color: var(--star, #e8b931); }
.xpchip .stk { margin-left: 2px; }
.cal { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.cal .wk { display: grid; grid-template-rows: repeat(7, 13px); gap: 3px; }
.cal i, .legend i { display: inline-block; width: 13px; height: 13px; border-radius: 3px; background: rgba(51, 103, 168, .1); vertical-align: middle; }
.cal i.c1, .legend i.c1 { background: rgba(232, 185, 49, .35); }
.cal i.c3, .legend i.c3 { background: var(--cobalt, #3367a8); }
.cal i.c4, .legend i.c4 { background: #1e3f73; }
.cal i.cz, .legend i.cz { background: repeating-linear-gradient(45deg, #7fa6c9, #7fa6c9 3px, #cfe0ee 3px, #cfe0ee 6px); }
.cal i.cf { background: transparent; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.bdg { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--line, #ccd); opacity: .55; }
.bdg.on { opacity: 1; border-style: solid; border-color: var(--star, #e8b931); background: rgba(232, 185, 49, .08); }
.bdg .ic { color: var(--star, #e8b931); }
.league { list-style: none; padding: 0; margin: 8px 0 0; }
.league li { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 8px; padding: 7px 10px; border-radius: 8px; }
.league li:nth-child(odd) { background: rgba(51, 103, 168, .05); }
.league li.me { background: rgba(232, 185, 49, .18); font-weight: 700; }
.league li.gap { display: block; text-align: center; color: var(--muted, #889); background: none; }
.league .rk { font-weight: 700; color: var(--cobalt, #3367a8); }
@media (max-width: 640px) { .xpchip .xpn { display: none; } }

/* ---------- games (#/games) ---------- */
.gm-src { display: grid; gap: 6px; }
.gm-src select { max-width: 520px; }
.gm-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 14px 0; }
.gm-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--border-ink); border-radius: var(--radius-panel); padding: 16px; cursor: pointer; }
.gm-tile:hover { border-color: var(--pri); }
.gm-tile:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
.gm-tile b { font-family: var(--font-title); font-size: 1.25rem; }
.gm-skill { font-size: 0.8rem; color: var(--coral); font-weight: 600; }
.gm-desc { font-size: 0.9rem; color: var(--muted); flex: 1; }
.gm-rec { font-size: 0.82rem; }
.gm-tile .btn { margin-top: 4px; pointer-events: none; }
.gm-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.gm-head small { display: block; }
.gm-head b { font-family: var(--font-title); font-size: 1.2rem; }
.gm-stats { display: flex; align-items: center; gap: 12px; }
.gm-score { font-family: var(--font-title); font-size: 1.6rem; font-weight: 700; color: var(--pri); min-width: 2ch; text-align: right; }
.gm-lives { color: var(--bad); font-size: 1.15rem; letter-spacing: 2px; }
.gm-bar { height: 6px; background: var(--line); border-radius: 3px; margin: 10px 0 4px; overflow: hidden; }
.gm-bar i { display: block; height: 100%; background: var(--pri); transition: width 0.1s linear; }
.gm-bar.low i { background: var(--bad); }
.gm-match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gm-col { display: grid; gap: 8px; align-content: start; }
.gm-card { font: inherit; text-align: left; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-ink); background: var(--bg-panel); color: var(--text); cursor: pointer; min-height: 46px; }
.gm-card.en { font-weight: 600; }
.gm-card:hover:not(:disabled) { border-color: var(--pri); }
.gm-card.sel { border-color: var(--pri); background: var(--pri-soft); box-shadow: 0 0 0 1px var(--pri); }
.gm-card.ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); opacity: 0.55; cursor: default; }
.gm-card.no, .gm-in.no { animation: gm-shake 0.4s; border-color: var(--bad); background: var(--bad-soft); }
@keyframes gm-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.gm-listen { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.gm-mask { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0; }
.gm-mask i { font-style: normal; width: 1.4em; height: 1.8em; border-bottom: 2px solid var(--muted); text-align: center; font-weight: 700; font-size: 1.1rem; line-height: 1.8em; }
.gm-mask i.sp { border: 0; width: 0.8em; }
.gm-in { font-size: 1.1rem; }
.gm-ans { padding: 10px 12px; border-radius: var(--radius-sm); margin: 8px 0; }
.gm-ans.ok { background: var(--ok-soft); }
.gm-ans.no { background: var(--bad-soft); }
.gm-ans p { margin: 6px 0 0; }
.gm-pts { font-weight: 700; color: var(--ok); margin-left: 6px; }
.gm-sent { font-size: 1.2rem; line-height: 2.2; margin: 14px 0; }
.gm-tok { font: inherit; padding: 2px 6px; border: 1px solid transparent; border-bottom-color: var(--line); border-radius: 6px; background: none; color: var(--text); cursor: pointer; }
.gm-tok:hover:not(:disabled) { background: var(--pri-soft); border-color: var(--pri); }
.gm-tok.bad { background: var(--ok-soft); border-color: var(--ok); }
.gm-tok.miss { background: var(--bad-soft); border-color: var(--bad); text-decoration: line-through; }
.gm-tok:disabled { cursor: default; }
.gm-combo { color: var(--coral); font-weight: 600; font-size: 0.85rem; }
.gm-final { display: flex; align-items: baseline; gap: 10px; }
.gm-big { font-family: var(--font-title); font-size: 3rem; font-weight: 700; color: var(--pri); line-height: 1; }
.gm-final span:last-child { display: flex; flex-direction: column; }
.gm-new { font-style: normal; color: var(--coral); font-weight: 700; }
.gm-miss { padding-left: 18px; }
.gm-miss li { margin: 6px 0; }
@media (max-width: 520px) { .gm-match { gap: 6px; } .gm-card { padding: 8px; font-size: 0.9rem; } }
@media (prefers-reduced-motion: reduce) { .gm-card.no, .gm-in.no { animation: none; } .gm-bar i { transition: none; } }
.gm-list[hidden], .gm-src[hidden] { display: none; }
