/* MathClicks — navy base + blue & gold accents (matches the MathClicks logo). */

:root {
  --navy: #1b2f5e;
  --navy-2: #204089;
  --navy-deep: #132455;

  /* Gold = primary CTA / "clicks" accent / American Pathway track */
  --coral: #f5a623;
  --coral-deep: #dd8f12;
  --coral-soft: #fef2e0;
  --gold: #f5a623;
  --gold-deep: #dd8f12;
  --gold-soft: #fef2e0;

  /* Blue = brand "Math" / IGCSE track / links */
  --blue: #2f8fe0;
  --blue-deep: #1f6fbf;
  --blue-soft: #e8f2fd;

  /* Green kept for "done" states + geometry domain */
  --teal: #0CA678;
  --teal-deep: #087F5B;
  --teal-soft: #E6FCF5;
  --yellow: #f5a623;
  --yellow-deep: #8a5d00;
  --yellow-soft: #fef2e0;

  --bg: #f7f8fc;
  --card: #ffffff;
  --ink: #16213e;
  --muted: #5c6785;
  /* Text on the fixed dark-navy footer, which does not follow the theme. */
  --footer-link: #C3CCE8;
  --line: #e7ebf5;
  --chip-bg: #eef2fb;
  --track-bg: #e7ebf5;

  /* Keyboard focus ring — solid brand blue + soft halo so it reads on light
     surfaces AND on the dark navy hero/CTA bands */
  --focus-ring: #1f6fbf;
  --focus-halo: rgba(47, 143, 224, .35);

  --grad-hero: linear-gradient(160deg, #132455 0%, #1b2f5e 55%, #204089 100%);
  --grad-brand: linear-gradient(135deg, #1b2f5e 0%, #204089 100%);
  --grad-warm: linear-gradient(90deg, #f5a623 0%, #f7c467 100%);

  --good: #16a34a;
  --good-deep: #15803d;
  --good-soft: #f0fdf4;
  --bad: #dc2626;
  --bad-deep: #b91c1c;
  --bad-soft: #fef2f2;

  /* Ink for the "hard" difficulty badge — needs its own value per theme
     because --coral-deep is only 2.37:1 on --coral-soft in light mode. */
  --hard-ink: #8a3c00;

  --radius: 18px;
  --shadow: 0 1px 2px rgba(27, 47, 94, .05), 0 10px 28px -14px rgba(27, 47, 94, .2);
  --shadow-lift: 0 2px 4px rgba(27, 47, 94, .07), 0 18px 40px -14px rgba(27, 47, 94, .26);

  --font-head: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* SAT domain accent colors */
.dom-algebra                            { --dc: #3B5BDB; --dc-soft: #EDF2FF; --dc-text: #3B5BDB; }
.dom-advanced-math                      { --dc: #7048E8; --dc-soft: #F3F0FF; --dc-text: #7048E8; }
.dom-problem-solving-and-data-analysis  { --dc: #D9480F; --dc-soft: #FFF0E6; --dc-text: #C6420E; }
.dom-geometry-and-trigonometry          { --dc: #0CA678; --dc-soft: #E6FCF5; --dc-text: #09805C; }
.dom-mixed                              { --dc: #1F2B5B; --dc-soft: #EDF0FA; --dc-text: #1F2B5B; }
/* IGCSE strand accents */
.dom-coordinate-geometry                { --dc: #2f8fe0; --dc-soft: #e8f2fd; --dc-text: #1C71B9; }
.dom-graphs-functions                   { --dc: #7048E8; --dc-soft: #F3F0FF; --dc-text: #7048E8; }
.dom-proportion                         { --dc: #0CA678; --dc-soft: #E6FCF5; --dc-text: #09805C; }
.dom-functions                          { --dc: #D9480F; --dc-soft: #FFF0E6; --dc-text: #C6420E; }
.dom-differentiation                    { --dc: #C2255C; --dc-soft: #FFF0F6; --dc-text: #C2255C; }
.dom-trigonometry                       { --dc: #0B7285; --dc-soft: #E3FAFC; --dc-text: #0B7285; }
.dom-bearings-scale                     { --dc: #1098AD; --dc-soft: #E7F8FA; --dc-text: #0D7B8C; }
.dom-transformations                    { --dc: #E8590C; --dc-soft: #FFF4E6; --dc-text: #C14A0A; }
.dom-vectors                            { --dc: #1864AB; --dc-soft: #E7F5FF; --dc-text: #1864AB; }
.dom-data-handling                      { --dc: #5F3DC4; --dc-soft: #F3F0FF; --dc-text: #5F3DC4; }
.dom-averages-spread                    { --dc: #087F5B; --dc-soft: #E6FCF5; --dc-text: #087F5B; }
.dom-sets                               { --dc: #A61E4D; --dc-soft: #FFF0F6; --dc-text: #A61E4D; }
.dom-probability                        { --dc: #862E9C; --dc-soft: #F8F0FC; --dc-text: #862E9C; }
.dom-symmetry-circles                   { --dc: #2B8A3E; --dc-soft: #EBFBEE; --dc-text: #28803A; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-head);
  letter-spacing: -.01em;
}

.hidden { display: none !important; }
body.no-scroll { overflow: hidden; }

/* Skip-to-content link — visually hidden until keyboard-focused */
.skip-link {
  position: fixed;
  top: -10rem;
  left: 1rem;
  z-index: 100;
  padding: .6rem 1.1rem;
  border-radius: 999px;
  /* --navy is a near-white in the dark theme, so a hard-coded #fff foreground
     turned this into white-on-white — on the first control a keyboard user
     ever reaches. Both ends of the pair now follow the theme. */
  background: var(--navy);
  color: var(--card);
  font-family: var(--font-head);
  font-weight: 700;
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus { top: 1rem; }
#main:focus { outline: none; }

a { color: var(--navy-2); }

/* Keyboard-only focus ring for every interactive element (links, buttons,
   inputs, chat, game controls). No border-radius here — elements keep their
   own shape and the outline follows it. */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--focus-halo);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Sticky top navbar ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topnav-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem;
  height: 3.7rem;
  display: flex;
  align-items: center;
  gap: .9rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
  flex: none;
}
.brand-logo { display: block; width: 34px; height: 34px; object-fit: contain; }

.brand-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.bn-math { color: var(--blue); }
.bn-clicks { color: var(--navy); }
.brand-accent { color: var(--blue); }

.nav-tools {
  display: flex;
  gap: .45rem;
  margin-left: auto;
  align-items: center;
}

.nav-links { display: flex; gap: .2rem; margin-right: .2rem; }
/* .nav-tools prefix outweighs the later .tool-chip display rule */
.nav-tools .nav-menu-btn { display: none; }
.exam-chip-short { display: none; }

/* The inline links collapse into the ☰ dropdown until the header actually
   fits. Measured: brand 157px + links 499px + tool chips leaves the header
   needing about 1020px of viewport at full size, and about 900px once the
   chips below are compressed. At the old 768px threshold every width from
   769px up to roughly 980px overflowed the page sideways — every phone in
   landscape, and small tablets. */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav-tools .nav-menu-btn { display: inline-flex; }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: calc(100% + .35rem);
    right: .75rem;
    min-width: 13rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(19, 36, 85, .18);
    padding: .4rem;
    z-index: 60;
  }
  .nav-links.open .nav-link { padding: .6rem .85rem; }
}
.nav-link {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: .93rem;
  color: var(--muted);
  text-decoration: none;
  padding: .42rem .85rem;
  border-radius: 999px;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--navy); background: var(--chip-bg); }
.nav-link.active { color: var(--navy); background: var(--chip-bg); }

.tool-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: .85rem;
  color: var(--navy);
  background: var(--chip-bg);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: .42rem .9rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
}
.tool-chip:hover { border-color: #C9D2EC; transform: translateY(-1px); }
.tool-icon { padding: .42rem .6rem; font-size: 1rem; }

/* ---------- "What do you need right now?" bar ---------- */

.need-bar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.need-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: .7rem 1rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  flex-wrap: wrap;
}

.need-label {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .92rem;
  color: var(--muted);
  white-space: nowrap;
}

.need-btns {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
  flex: 1;
}

.need-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .92rem;
  border: none;
  border-radius: 999px;
  padding: .55rem 1.15rem;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 3px 10px -4px rgba(20, 29, 64, .4);
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.need-btn:hover { transform: translateY(-2px); }
.need-btn:active { transform: none; opacity: .92; }
.nb-trick  { background: linear-gradient(120deg, var(--coral), var(--coral-deep)); }
.nb-resume { background: linear-gradient(120deg, var(--teal), var(--teal-deep)); }
.nb-new    { background: var(--grad-brand); }

/* ---------- Layout ---------- */

main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.4rem 1rem 3.5rem;
  animation: rise .3s ease;
}
main[data-view="home"] { max-width: 64rem; }

h2.page-title {
  font-size: 1.55rem;
  font-weight: 900;
  margin: .4rem 0 .35rem;
  color: var(--navy);
}
.page-sub { color: var(--muted); font-size: .93rem; margin: 0 0 1.2rem; }

/* h2 as well as h3: the generated American Pathway pages have emitted
   <h2 class="section-title"> since build.mjs was written, and were falling back
   to the browser's default h2 because this selector was tag-qualified to h3.
   The heading level is chosen by document structure; the look is the same. */
h2.section-title,
h3.section-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 1.12rem;
  font-weight: 900;
  color: var(--navy);
  margin: 2rem 0 .8rem;
}

/* Introduces a group of cards that needs a sentence of context before the
   student can tell which group is the one they want. */
.collection-head { margin: 2rem 0 .9rem; }
.collection-head .section-title { margin: 0 0 .3rem; }
.collection-lede {
  color: var(--muted);
  font-size: .93rem;
  max-width: 62ch;
  margin: 0 0 .2rem;
}

.back-link {
  /* inline-flex + min-height clears the 24px target minimum; this was 23px. */
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: .25rem 0 .75rem;
  color: var(--navy-2);
  text-decoration: none;
  font-family: var(--font-head);
  font-size: .9rem;
  font-weight: 800;
}
.back-link:hover { color: var(--coral-deep); }

/* ---------- Home: hero ---------- */

.hero {
  position: relative;
  overflow: hidden;
  background: var(--grad-hero);
  border-radius: 28px;
  padding: 3.4rem 2rem 3.6rem;
  color: #fff;
  box-shadow: var(--shadow-lift);
  margin: .4rem 0 1rem;
}
.hero-glow { position: absolute; border-radius: 50%; pointer-events: none; }
.hero-glow--blue {
  top: -90px; right: -70px; width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(47, 143, 224, .55) 0%, transparent 70%);
  animation: pulseGlow 6s ease-in-out infinite;
}
.hero-glow--gold {
  bottom: -100px; left: -80px; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(245, 166, 35, .4) 0%, transparent 70%);
  animation: pulseGlow 7s ease-in-out infinite 1s;
}
@keyframes pulseGlow { 0%,100% { opacity: .5; transform: scale(1); } 50% { opacity: .85; transform: scale(1.08); } }
@keyframes spinSlow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes floaty2 { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.hero-inner {
  position: relative; z-index: 1;
  max-width: 60rem; margin: 0 auto;
  display: flex; align-items: center; gap: 3rem; flex-wrap: wrap;
}
.hero-copy { flex: 1 1 22rem; min-width: 0; }

.hero-eyebrow {
  display: inline-block;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: .78rem;
  color: #f5c264;
  background: rgba(245, 166, 35, .15);
  border: 1px solid rgba(245, 166, 35, .4);
  border-radius: 999px;
  padding: .35rem .95rem;
  margin-bottom: 1.15rem;
}
.hero-title {
  font-family: var(--font-head);
  font-size: clamp(2.1rem, 5.5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.08;
  margin: 0 0 1rem;
}
.hero-click { color: var(--gold); }
.hero-sub {
  color: #c5cfe8;
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 0 0 1.7rem;
  max-width: 30rem;
}
.hero-cta { display: flex; gap: .8rem; flex-wrap: wrap; }

/* "Continue where you left off" — shown on the hero once a track is saved */
.continue-pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: 1rem;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .28);
  padding: .45rem .95rem;
  border-radius: 999px;
  transition: background .15s;
}
.continue-pill:hover { background: rgba(255, 255, 255, .22); }

/* Orbiting-logo "planet" */
.hero-planet { flex: 1 1 18rem; display: flex; justify-content: center; }
.planet-stage {
  --stage: 300px; --orbit-r: 140px;
  position: relative; width: var(--stage); height: var(--stage);
  max-width: 82vw;
}
.planet-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px dashed rgba(245, 166, 35, .4);
  animation: spinSlow 38s linear infinite reverse;
}
.planet-ring--inner {
  inset: calc(var(--stage) * .12);
  border-color: rgba(47, 143, 224, .35);
  animation-duration: 26s; animation-direction: normal;
}
.planet-core {
  position: absolute; inset: calc(var(--stage) * .17);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,.16), rgba(255,255,255,.03));
  box-shadow: inset 0 0 40px rgba(0,0,0,.28), 0 14px 40px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  animation: floaty2 5s ease-in-out infinite;
}
.planet-logo { width: 66%; height: 66%; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); }

.planet-orbit { position: absolute; inset: 0; }
.orbit-chip {
  position: absolute; left: 50%; top: 50%;
  width: 42px; height: 42px; margin: -21px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 800; font-size: 1.15rem;
  box-shadow: 0 6px 16px rgba(0,0,0,.28);
  animation: orbit 30s linear infinite;
}
/* Decorative symbols orbiting the logo. They are aria-hidden in app.js, but
   white on --blue is 3.43:1 and they are still text on screen, so use the
   deeper blue rather than relying on the decorative exemption. */
/* These sit on the hero's fixed dark navy in BOTH themes, so their colours are
   fixed too. Using --blue-deep/--navy here meant they flipped with the theme
   while their backdrop did not: white on a light blue, and near-white on gold. */
.oc0 { animation-delay: 0s;   background: #1f6fbf; color: #fff; }
.oc1 { animation-delay: -5s;  background: var(--gold); color: #1b2f5e; }
.oc2 { animation-delay: -10s; background: rgba(255,255,255,.16); color: #fff; }
.oc3 { animation-delay: -15s; background: var(--gold); color: #1b2f5e; }
.oc4 { animation-delay: -20s; background: #1f6fbf; color: #fff; }
.oc5 { animation-delay: -25s; background: rgba(255,255,255,.16); color: #fff; }
@keyframes orbit {
  from { transform: rotate(0deg) translateX(var(--orbit-r)) rotate(0deg); }
  to   { transform: rotate(-360deg) translateX(var(--orbit-r)) rotate(360deg); }
}
@media (max-width: 560px) { .planet-stage { --stage: 250px; --orbit-r: 116px; } }

@media (prefers-reduced-motion: reduce) {
  .hero-glow, .planet-ring, .planet-core, .orbit-chip { animation: none; }
  main, .q-card, .feedback, .result-card, .reveal { animation: none; }
  /* Missed by the list above: falling confetti after a perfect score is the
     single most motion-heavy thing on the site, .typing loops forever, and the
     badge tilt fires on hover. */
  .confetti { animation: none; display: none; }
  .typing { animation: none; }
  .arena-card:hover .arena-badge { animation: none; }
}

/* ---------- Home sections (shared) ---------- */

.btn-ghost {
  background: rgba(255, 255, 255, .1);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, .28);
}
.btn-ghost:hover { background: rgba(255, 255, 255, .2); transform: translateY(-2px); }

.home-sec { max-width: 60rem; margin: 0 auto; padding: 3.2rem 0 .5rem; }
.sec-head { text-align: center; margin-bottom: 2.2rem; }
.sec-eyebrow {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  margin-bottom: .5rem;
}
.sec-eyebrow.blue { color: var(--blue); }
/* --gold-deep is 2.47:1 on --bg in light mode; --yellow-deep flips per theme */
.sec-eyebrow.gold { color: var(--yellow-deep); }
.sec-title {
  font-family: var(--font-head);
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  color: var(--navy);
  margin: 0;
}
/* The header is sticky and 60px tall, so a section scrolled to exactly its own
   top has its heading hidden behind the nav. Honoured by scrollIntoView. */
#tracks,
#about { scroll-margin-top: 4.75rem; }

/* One line of orientation under a section title — used where the heading alone
   leaves a real question open, e.g. "which of these two courses is mine?" */
.sec-lede {
  color: var(--muted);
  max-width: 46ch;
  margin: .7rem auto 0;
}

/* Quick Wins keeps its own compact left-aligned heading */
.home-sec-title {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--navy);
  margin: 0 0 .3rem;
}
.home-sec-sub { color: var(--muted); font-size: .92rem; margin: 0 0 1rem; }

.reveal { opacity: 0; transform: translateY(28px); transition: opacity .7s ease-out, transform .7s ease-out; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* ---------- Home: subject cards (Two tracks) ---------- */

.subject-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
}
@media (max-width: 640px) { .subject-grid { grid-template-columns: 1fr; } }

.subject {
  position: relative;
  display: block;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 2rem 1.8rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform .25s, box-shadow .25s, border-color .25s;
  overflow: hidden;
}
.subject:hover { transform: translateY(-8px); box-shadow: var(--shadow-lift); }
.subject.igcse:hover { border-color: var(--blue); }
.subject.ap:hover { border-color: var(--gold); }

.subject-icon {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.5rem;
  margin-bottom: 1.1rem;
}
.subject.igcse .subject-icon { background: var(--blue-soft); color: var(--blue); }
.subject.ap .subject-icon { background: var(--gold-soft); color: var(--gold-deep); }

.subject-title { font-family: var(--font-head); font-weight: 700; font-size: 1.35rem; color: var(--navy); }
.subject-sub { color: var(--muted); font-size: .95rem; line-height: 1.6; margin: .4rem 0 1rem; }

.subject-meta { display: flex; gap: .45rem; flex-wrap: wrap; margin-bottom: 1rem; }
.subject-chip {
  font-size: .76rem;
  font-weight: 700;
  padding: .2rem .7rem;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--navy-2);
}

.subject-go { font-family: var(--font-head); font-weight: 700; font-size: .95rem; }
/* --blue is 3.43:1 and --gold-deep 2.62:1 on a light card; the -deep tokens
   flip to light values in dark mode, so both themes clear AA. */
.subject.igcse .subject-go { color: var(--blue-deep); }
.subject.ap .subject-go { color: var(--yellow-deep); }
.subject:hover .subject-go { text-decoration: underline; text-underline-offset: 4px; }

/* IGCSE Past Papers entry card (links to the standalone question bank) */
.pp-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  background: linear-gradient(135deg, var(--card) 0%, var(--blue-soft) 220%);
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 1.3rem 1.5rem;
  margin: 0 0 1.4rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform .22s, box-shadow .22s, border-color .22s;
  overflow: hidden;
}
.pp-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); border-color: var(--blue); }
.pp-card-icon {
  width: 3.2rem; height: 3.2rem; flex: none;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  background: var(--blue-soft); color: var(--blue);
  border: 1px solid color-mix(in srgb, var(--blue) 25%, transparent);
}
.pp-card-body { flex: 1; min-width: 0; }
.pp-card-title { font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; color: var(--navy); }
.pp-card-sub { color: var(--muted); font-size: .92rem; line-height: 1.55; margin: .3rem 0 .7rem; }
.pp-card-meta { display: flex; gap: .45rem; flex-wrap: wrap; }
.pp-card-chip {
  font-size: .74rem; font-weight: 700; padding: .2rem .7rem; border-radius: 999px;
  background: var(--chip-bg); color: var(--navy-2);
}
.pp-card-go { font-family: var(--font-head); font-weight: 700; font-size: .92rem; color: var(--blue-deep); flex: none; align-self: flex-end; white-space: nowrap; }
.pp-card:hover .pp-card-go { text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 560px) {
  .pp-card { flex-wrap: wrap; }
  .pp-card-go { align-self: flex-start; }
}

.soon-badge {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--gold);
  color: var(--navy);
  border-radius: 999px;
  padding: .28rem .75rem;
}

/* ---------- How it works ---------- */

.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
@media (max-width: 720px) { .steps-grid { grid-template-columns: 1fr; } }
.step-item { text-align: center; padding: 0 .5rem; }
.step-badge {
  width: 3.6rem; height: 3.6rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 800; font-size: 1.4rem;
  margin: 0 auto 1rem;
  box-shadow: 0 8px 20px rgba(27, 47, 94, .1);
}
.step-badge.blue { background: var(--blue-soft); color: var(--blue); }
.step-badge.gold { background: var(--gold-soft); color: var(--yellow-deep); }
.step-title { font-family: var(--font-head); font-size: 1.15rem; font-weight: 700; color: var(--navy); margin: 0 0 .4rem; }
.step-desc { color: var(--muted); font-size: .92rem; line-height: 1.6; margin: 0; }

/* ---------- About ---------- */

.about-sec { background: var(--blue-soft); border-radius: 24px; padding: 3rem 2rem; margin: 3.2rem 0 0; }
.about-inner { max-width: 58rem; margin: 0 auto; display: flex; gap: 2.6rem; align-items: center; flex-wrap: wrap; }
.about-photo {
  flex: 0 0 10rem; width: 10rem; height: 10rem; margin: 0 auto;
  border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-lift);
  background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.about-photo img { width: 100%; height: 100%; object-fit: cover; }
.about-photo.is-placeholder { border: 2px dashed #b9c6e6; }
.about-photo-emoji { font-size: 3.4rem; }
.about-photo-note { font-size: .8rem; color: var(--muted); margin-top: .4rem; font-weight: 600; }
.about-body { flex: 1 1 18rem; min-width: 0; }
.about-text { color: var(--ink); opacity: .85; font-size: 1.02rem; line-height: 1.7; margin: .4rem 0 1.4rem; }
.about-links { display: flex; gap: .8rem; flex-wrap: wrap; }
.about-link {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--card); border: 1px solid var(--line);
  color: var(--navy); font-family: var(--font-head); font-weight: 600; font-size: .9rem;
  padding: .6rem 1.1rem; border-radius: 999px; text-decoration: none;
  transition: border-color .2s, color .2s;
}
.about-link:hover { border-color: var(--blue); color: var(--blue); }

/* ---------- Closing CTA band ---------- */

.cta-sec { padding: 3.2rem 0 .5rem; }
.cta-band {
  position: relative; overflow: hidden;
  background: var(--grad-brand);
  border-radius: 26px; padding: 3.2rem 2rem; text-align: center;
  box-shadow: var(--shadow-lift);
}
.cta-glow {
  position: absolute; top: -40px; left: -40px; width: 200px; height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 166, 35, .35), transparent 70%);
}
.cta-title { font-family: var(--font-head); font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; color: #fff; margin: 0 0 .6rem; position: relative; }
.cta-sub { color: #c5cfe8; font-size: 1rem; margin: 0 0 1.4rem; position: relative; }
.cta-band .btn { position: relative; }

/* ---------- Quick Wins & Mental Math ---------- */

.qw-section { margin-bottom: 2.4rem; }

.qw-wrap { position: relative; }

.qw-row {
  display: flex;
  gap: .8rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: .25rem .1rem .8rem;
  scrollbar-width: thin;
}
.qw-row::-webkit-scrollbar { height: 6px; }
.qw-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.qw-card {
  scroll-snap-align: start;
  flex: 0 0 13.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .35rem;
  text-align: left;
  font-family: inherit;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 1.1rem 1.05rem 1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.qw-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
/* Each card's text colour is chosen against its LIGHTEST gradient stop so the
   whole surface clears WCAG AA 4.5:1 — the sub-text is only 12.8px. */
.qw-coral  { background: linear-gradient(140deg, var(--coral), var(--coral-deep)); color: #4A2800; }
.qw-teal   { background: linear-gradient(140deg, #087F5B, #065F46); }
.qw-yellow { background: linear-gradient(140deg, #FFC43D, #F59F00); color: #4A3200; }
.qw-navy   { background: var(--grad-brand); }
.qw-violet { background: linear-gradient(140deg, #6741D9, #5535C4); }
.qw-blue   { background: linear-gradient(140deg, #1F6FBF, #17548F); }
.qw-rose   { background: linear-gradient(140deg, #C2255C, #A61E4D); }
.qw-indigo { background: linear-gradient(140deg, #3B5BDB, #2F4BC4); }
.qw-cyan   { background: linear-gradient(140deg, #0B7285, #095C6B); }
.qw-green  { background: linear-gradient(140deg, #15803D, #116932); }

.qw-icon { font-size: 1.7rem; line-height: 1; }
.qw-title { font-family: var(--font-head); font-weight: 900; font-size: 1.02rem; }
.qw-sub { font-size: .8rem; opacity: .92; line-height: 1.4; flex: 1; }
.qw-go { font-family: var(--font-head); font-weight: 900; font-size: .85rem; margin-top: .3rem; }

.qw-arrow {
  position: absolute;
  top: 42%;
  transform: translateY(-50%);
  z-index: 2;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--navy);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .12s, background .15s;
}
.qw-arrow:hover { transform: translateY(-50%) scale(1.08); }
.qw-arrow--left { left: -0.9rem; }
.qw-arrow--right { right: -0.9rem; }
/* Touch devices swipe instead */
@media (hover: none) { .qw-arrow { display: none; } }

/* ---------- Topics & Modules grid ---------- */

.browse-section { margin-bottom: 1rem; }

.browse-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: .4rem;
}
.browse-head .home-sec-title { margin: 0; }

.track-toggle {
  display: inline-flex;
  background: var(--chip-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .22rem;
  gap: .2rem;
}
.track-btn {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .85rem;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: .35rem 1.1rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.track-btn--sat.active { background: var(--teal); color: #fff; box-shadow: 0 2px 8px -2px rgba(12, 166, 120, .5); }
.track-btn--igcse.active { background: var(--yellow); color: #4A3200; box-shadow: 0 2px 8px -2px rgba(255, 196, 61, .6); }

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .8rem;
  margin-top: .9rem;
}
@media (min-width: 900px) { .module-grid { grid-template-columns: repeat(4, 1fr); } }

.gcard {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-top: 5px solid var(--tc);
  border-radius: 18px;
  padding: .85rem .9rem .9rem;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 29, 64, .05);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.gcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--tc); border-top-width: 5px; }
.gcard.track-sat   { --tc: var(--teal); --tc-soft: var(--teal-soft); --tc-ink: var(--teal-deep); }
.gcard.track-igcse { --tc: var(--yellow); --tc-soft: var(--yellow-soft); --tc-ink: var(--yellow-deep); }

.gcard-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}
.gcard-track {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .66rem;
  letter-spacing: .06em;
  background: var(--tc-soft);
  color: var(--tc-ink);
  border-radius: 6px;
  padding: .14rem .5rem;
}
.gcard-status {
  font-size: .66rem;
  font-weight: 800;
  border-radius: 999px;
  padding: .14rem .55rem;
  white-space: nowrap;
}
.st-done     { background: var(--teal-soft); color: var(--teal-deep); }
.st-progress { background: var(--yellow-soft); color: var(--yellow-deep); }
.st-none     { background: var(--chip-bg); color: var(--muted); }

.gcard-icon { font-size: 1.5rem; line-height: 1; margin-top: .2rem; }
.gcard-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: .95rem;
  color: var(--navy);
  line-height: 1.3;
  flex: 1;
}
.gcard-sub { color: var(--muted); font-size: .78rem; }
.gcard .mprog-bar { flex: none; max-width: none; margin-top: .35rem; }
.gcard .mprog-label { margin-top: .15rem; }

/* ---------- Stats strip ---------- */

.stats {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: 0 0 1.1rem;
}

.stat-chip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .32rem .9rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  box-shadow: 0 1px 2px rgba(20, 29, 64, .05);
}

/* ---------- Cards & lists ---------- */

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: .85rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--dc, var(--navy-2));
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  margin-bottom: .7rem;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(20, 29, 64, .05);
  transition: transform .15s, box-shadow .15s;
}
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
a.card:active { transform: none; }

.card-icon {
  flex: none;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: 13px;
  background: var(--dc-soft, #EDF0FA);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.card-body { min-width: 0; flex: 1; }
.card .card-title { font-family: var(--font-head); font-weight: 800; font-size: 1rem; color: var(--navy); }
.card .card-sub { color: var(--muted); font-size: .83rem; margin-top: .12rem; }

.card-arrow { color: var(--dc-text, var(--navy-2)); font-weight: 700; font-size: 1.15rem; }

/* Step / done indicator on lesson lists */
.step-dot {
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: var(--dc-soft, #EDF0FA);
  color: var(--dc-text, var(--navy-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1rem;
}
.step-dot.done {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 3px 8px -2px rgba(12, 166, 120, .6);
}

/* Module progress bar */
.mprog { display: flex; align-items: center; gap: .55rem; margin-top: .45rem; }
.mprog-bar {
  flex: 1;
  height: 7px;
  background: var(--track-bg);
  border-radius: 999px;
  overflow: hidden;
  max-width: 14rem;
}
.mprog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #3B5BDB);
  border-radius: 999px;
  transition: width .3s;
}
.mprog-label { font-size: .75rem; font-weight: 700; color: var(--muted); }

.badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  font-family: var(--font-body);
  padding: .14rem .58rem;
  border-radius: 999px;
  background: var(--dc-soft, #EDF0FA);
  color: var(--dc-text, var(--navy-2));
  margin-left: .45rem;
  vertical-align: middle;
  white-space: nowrap;
}
.badge.soon { background: var(--chip-bg); color: #828AA6; }
.badge.score { background: var(--yellow-soft); color: var(--yellow-deep); }

/* ---------- Lesson page ---------- */

.meta-chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: -.1rem 0 .6rem; }
.chip {
  font-size: .76rem;
  font-weight: 700;
  padding: .2rem .72rem;
  border-radius: 999px;
  background: var(--dc-soft, #EDF0FA);
  color: var(--dc-text, var(--navy-2));
}
.chip.plain { background: var(--chip-bg); color: var(--muted); }

.video-row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-start; }
.video-row .video-card { flex: 1 1 100%; }
.video-row .video-card--short { flex: 1 1 12rem; max-width: 15rem; }
@media (max-width: 560px) {
  .video-row .video-card--short { max-width: 100%; flex-basis: 100%; }
}

.video-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(20, 29, 64, .05);
  overflow: hidden;
  margin-bottom: .8rem;
}
.video-row .video-card { margin-bottom: 0; }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--navy-deep); }
.video-frame--tall { aspect-ratio: 9 / 16; }
.video-frame iframe, .video-frame video {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.video-title { padding: .6rem .9rem; font-weight: 600; font-size: .92rem; }

/* ---------- Past-paper practice cards ---------- */
.pp-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: .8rem; flex-wrap: wrap;
  background: var(--grad-brand); color: #fff;
  border-radius: 14px; padding: .85rem 1.15rem; margin: 1.4rem 0 1rem;
}
.pp-banner strong { font-family: var(--font-head); font-size: 1.05rem; }
.pp-banner-sub { font-size: .85rem; opacity: .9; margin-top: .15rem; max-width: 52ch; }
.pp-banner-count {
  background: rgba(255, 255, 255, .18); border-radius: 20px;
  padding: .28rem .8rem; font-size: .82rem; font-weight: 600; white-space: nowrap;
}
.pp-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 1rem 1.05rem; margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.pp-head {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
  margin-bottom: .8rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line);
}
.pp-num {
  background: var(--dc-text, var(--navy-2)); color: #fff; font-weight: 700;
  font-size: .78rem; padding: .25rem .6rem; border-radius: 6px; white-space: nowrap;
}
.pp-code {
  font-family: "Courier New", monospace; font-size: .82rem;
  color: var(--muted); font-weight: 600;
}
.pp-tag {
  margin-left: auto; font-size: .74rem; color: var(--muted);
  font-style: italic; text-align: right;
}
.pp-img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
/* The scans are wrapped in <picture> to offer WebP; <picture> is inline by
   default, which would leave a descender gap under every question image. */
.pp-card picture, .pp-panel picture { display: block; }
.pp-actions { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: .85rem; }
.pp-btn {
  font-family: var(--font-body); font-weight: 600; font-size: .88rem;
  padding: .5rem .95rem; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--dc-text, var(--navy-2)); color: var(--dc-text, var(--navy-2));
  background: var(--dc-soft, var(--chip-bg)); transition: background .15s, color .15s;
}
.pp-btn:hover { background: var(--dc-text, var(--navy-2)); color: #fff; }
.pp-btn--video {
  border-color: var(--bad); color: var(--bad-deep); background: var(--bad-soft);
}
.pp-btn--video:hover { background: var(--bad); color: #fff; }
.pp-btn.is-soon {
  border-color: var(--line); color: var(--muted); background: var(--chip-bg);
  cursor: default; opacity: .85;
}
.pp-btn.is-soon:hover { background: var(--chip-bg); color: var(--muted); }
.pp-panel {
  max-height: 0; overflow: hidden; transition: max-height .4s ease; margin-top: 0;
}
.pp-panel.open { max-height: 6000px; margin-top: .85rem; }
.pp-ms-img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--dc, var(--navy-2)); border-radius: 8px; background: #fff;
}

.empty-note {
  background: var(--card);
  border: 2px dashed #CBD2E8;
  border-radius: var(--radius);
  padding: 1.6rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .93rem;
}
.empty-note.big { padding: 2.6rem 1.4rem; }
.empty-emoji { font-size: 2.6rem; line-height: 1; margin-bottom: .5rem; }
.empty-title {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.3rem;
  color: var(--navy);
  margin-bottom: .3rem;
}
.empty-note.big p { max-width: 26rem; margin: 0 auto 1.2rem; }

/* ---------- Quiz ---------- */

.progress {
  height: 9px;
  background: var(--track-bg);
  border-radius: 999px;
  overflow: hidden;
  margin: .5rem 0 1rem;
}
.progress > div { height: 100%; background: var(--grad-warm); border-radius: 999px; transition: width .3s; }

.q-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.15rem;
  animation: rise .25s ease;
}

.q-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.q-count { font-size: .82rem; color: var(--muted); font-weight: 700; }

.diff { font-size: .72rem; font-weight: 800; padding: .14rem .62rem; border-radius: 999px; }
.diff-easy   { background: var(--teal-soft); color: var(--teal-deep); }
.diff-medium { background: var(--yellow-soft); color: var(--yellow-deep); }
.diff-hard   { background: var(--coral-soft); color: var(--hard-ink); }

.q-prompt { font-size: 1.06rem; margin: .3rem 0 1rem; }
.q-image { max-width: 100%; border-radius: 10px; margin: 0 0 1rem; display: block; }

.choices { display: flex; flex-direction: column; gap: .6rem; }

.choice {
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  text-align: left;
  font-size: 1rem;
  font-family: inherit;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: .72rem .85rem;
  cursor: pointer;
  color: var(--ink);
  transition: border-color .12s, background .12s, transform .12s;
}
.choice .letter {
  flex: none;
  width: 1.8rem; height: 1.8rem;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 800; color: var(--muted);
  transition: inherit;
}
.choice:not(:disabled):hover { border-color: var(--navy-2); transform: translateX(3px); }
.choice:not(:disabled):hover .letter { border-color: var(--navy-2); color: var(--navy-2); }
.choice.correct { border-color: var(--good); background: var(--good-soft); }
.choice.correct .letter { border-color: var(--good); color: #fff; background: var(--good); }
.choice.incorrect { border-color: var(--bad); background: var(--bad-soft); }
.choice.incorrect .letter { border-color: var(--bad); color: #fff; background: var(--bad); }
.choice:disabled { cursor: default; opacity: 1; }

.gridin { display: flex; gap: .6rem; }
.gridin input {
  flex: 1;
  font-size: 1.05rem;
  font-family: inherit;
  padding: .65rem .85rem;
  border: 2px solid var(--line);
  border-radius: 14px;
  min-width: 0;
}
.gridin input:focus { border-color: var(--navy-2); box-shadow: 0 0 0 4px rgba(42, 58, 124, .16); }
.gridin input.correct { border-color: var(--good); background: var(--good-soft); box-shadow: none; }
.gridin input.incorrect { border-color: var(--bad); background: var(--bad-soft); box-shadow: none; }

.feedback {
  margin-top: 1rem;
  border-radius: 14px;
  padding: .85rem .95rem;
  font-size: .95rem;
  animation: rise .25s ease;
}
.feedback.good { background: var(--good-soft); border: 1px solid #bbf7d0; }
.feedback.bad  { background: var(--bad-soft); border: 1px solid #fecaca; }
.feedback .verdict { font-weight: 800; margin-bottom: .25rem; }
.feedback.good .verdict { color: var(--good-deep); }
.feedback.bad .verdict { color: var(--bad-deep); }

/* ---------- Buttons ---------- */

.btn {
  display: inline-block;
  font-size: 1rem;
  font-family: var(--font-head);
  font-weight: 900;
  border: none;
  border-radius: 14px;
  padding: .7rem 1.5rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform .12s, box-shadow .12s, opacity .12s, background .12s;
}
.btn-primary {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 5px 16px -5px rgba(31, 43, 91, .6);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px -6px rgba(31, 43, 91, .7); }
.btn-primary:active { transform: none; opacity: .92; }

.btn-cta {
  background: linear-gradient(120deg, var(--coral) 0%, var(--coral-deep) 100%);
  /* Deep navy, not white: white on this gold is 2.03:1 in light mode and
     1.62:1 in dark. Navy clears 5.47:1 against the palest stop of both. */
  color: #16294f;
  box-shadow: 0 5px 16px -4px rgba(232, 73, 47, .55);
}
.btn-cta:hover { transform: translateY(-2px); box-shadow: 0 9px 22px -6px rgba(232, 73, 47, .65); }
.btn-cta:active { transform: none; opacity: .92; }

.btn-quiet { background: var(--card); color: var(--navy); border: 2px solid var(--line); }
.btn-quiet:hover { border-color: var(--navy-2); transform: translateY(-1px); }

.q-actions { margin-top: 1rem; display: flex; gap: .6rem; }

/* ---------- Results ---------- */

.result-card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1rem 1.75rem;
  text-align: center;
  animation: rise .3s ease;
}

.score-ring {
  width: 8.5rem;
  height: 8.5rem;
  border-radius: 50%;
  margin: .5rem auto .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(var(--ring, var(--teal)) calc(var(--pct) * 1%), var(--track-bg) 0);
}
.score-ring > div {
  width: 6.7rem;
  height: 6.7rem;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-num { font-family: var(--font-head); font-size: 1.55rem; font-weight: 900; line-height: 1.1; color: var(--navy); }
.score-pct { color: var(--muted); font-size: .85rem; font-weight: 700; }

.result-note { color: var(--muted); margin-bottom: 1.25rem; }
.result-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }

.confetti {
  position: absolute;
  top: -1.5rem;
  font-size: 1.3rem;
  animation: fall 1.6s ease-in forwards;
}
@keyframes fall {
  to { transform: translateY(28rem) rotate(360deg); opacity: 0; }
}

/* ---------- Lesson notes (interactive content) ---------- */

[hidden] { display: none !important; }

.lesson-content { --dc: #3B5BDB; --dc-soft: #EDF2FF; }

.lesson-sec { margin-bottom: 1.75rem; }

.lesson-sec-title {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 1.5rem 0 .8rem;
}
.lesson-sec-title .num {
  width: 1.95rem; height: 1.95rem;
  flex: none;
  background: var(--dc);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-weight: 900; font-size: .88rem;
}
.lesson-sec-title h4 { margin: 0; font-size: 1.1rem; font-weight: 900; color: var(--navy); }

.concept-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--dc);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  margin-bottom: .85rem;
  box-shadow: 0 1px 2px rgba(20, 29, 64, .05);
}
.concept-card.accent { border-left-color: #E8590C; }
.concept-card.green { border-left-color: var(--teal); }
.concept-card h5 {
  margin: 0 0 .5rem;
  font-size: 1rem;
  font-weight: 800;
  color: var(--dc-text);
}
.concept-card.accent h5 { color: #C2410C; }
.concept-card.green h5 { color: var(--teal-deep); }
.concept-card h5 .hint { font-weight: 500; font-family: var(--font-body); color: var(--muted); font-size: .8rem; }
.concept-card p, .concept-card li { font-size: .93rem; color: #39415E; }
.concept-card p { margin: 0 0 .4rem; }
.concept-card ul { margin: .3rem 0 0 1.1rem; padding: 0; }
.concept-card li { margin-bottom: .35rem; }

.key-rule {
  background: var(--dc-soft);
  border: 1.5px solid color-mix(in srgb, var(--dc) 30%, white);
  border-radius: 12px;
  padding: .75rem 1rem;
  margin: .7rem 0;
  font-size: .92rem;
}
.key-rule strong:first-child { color: var(--dc-text); display: block; margin-bottom: .25rem; }

/* Vocabulary flip cards */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: .6rem;
  margin-top: .6rem;
}
.vocab-card { perspective: 700px; height: 6.5rem; cursor: pointer; }
.vc-inner {
  position: relative;
  width: 100%; height: 100%;
  transition: transform .5s;
  transform-style: preserve-3d;
}
.vocab-card.flipped .vc-inner { transform: rotateY(180deg); }
.vc-front, .vc-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: .5rem .6rem;
}
.vc-front { background: var(--dc-soft); color: var(--dc-text); font-weight: 700; font-size: .88rem; }
.vc-back { background: var(--dc-text); color: #fff; transform: rotateY(180deg); font-size: .78rem; line-height: 1.35; }

/* Steps */
.steps-list .step, .reveal-seq .step { display: flex; gap: .7rem; margin-bottom: .9rem; align-items: flex-start; }
.step-num {
  width: 1.7rem; height: 1.7rem; flex: none;
  background: var(--dc);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 800;
}
.step-content { flex: 1; min-width: 0; }
.step-content .slabel {
  font-weight: 700; color: var(--dc-text);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: .2rem;
}
.step-content p { font-size: .92rem; color: #39415E; margin: 0 0 .35rem; }

/* Worked math */
.math-block {
  background: var(--dc-soft);
  border-left: 3px solid var(--dc);
  border-radius: 8px;
  padding: .6rem .85rem;
  margin: .4rem 0;
  overflow-x: auto;
}
.mline { margin: .3rem 0; font-size: .95rem; }
.mline .note { color: var(--muted); font-size: .8rem; margin-left: .4rem; }

.cases-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
  margin: .5rem 0;
}
@media (max-width: 560px) { .cases-grid { grid-template-columns: 1fr; } }
.case-box {
  background: var(--dc-soft);
  border: 1px solid color-mix(in srgb, var(--dc) 25%, white);
  border-radius: 12px;
  padding: .7rem .8rem;
  overflow-x: auto;
}
.case-box h6, .check-box h6, .fail-box h6, .warning-box h6 {
  margin: 0 0 .35rem;
  font-size: .84rem;
}
.case-box h6 { color: var(--dc-text); }

.check-box {
  background: var(--good-soft);
  border: 1.5px solid #86efac;
  border-radius: 12px;
  padding: .65rem .85rem;
  margin-top: .5rem;
  overflow-x: auto;
}
.check-box h6 { color: var(--good-deep); }

.fail-box {
  background: var(--bad-soft);
  border: 1.5px solid #fca5a5;
  border-radius: 12px;
  padding: .65rem .85rem;
  margin-top: .5rem;
  overflow-x: auto;
}
.fail-box h6 { color: var(--bad-deep); }

.warning-box {
  background: #fff7ed;
  border: 1.5px solid #fdba74;
  border-radius: 12px;
  padding: .65rem .85rem;
  margin: .6rem 0;
}
.warning-box h6 { color: #c2410c; }
.warning-box p { font-size: .88rem; color: #7c2d12; margin: 0; }
.warning-box.standalone { padding: .9rem 1rem; }

.solution-display {
  background: var(--dc-soft);
  border-radius: 12px;
  padding: .7rem .9rem;
  margin-top: .6rem;
  font-size: .93rem;
}
.solution-display strong { color: var(--dc-text); }

/* Collapsible examples */
.example-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: .8rem;
  box-shadow: 0 1px 2px rgba(20, 29, 64, .05);
  overflow: hidden;
}
.example-header {
  padding: .85rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  user-select: none;
  background: linear-gradient(90deg, var(--dc-soft) 0%, var(--card) 85%);
}
.example-header:hover { filter: brightness(.98); }
.ex-label { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.ex-label h6 { margin: 0; font-size: .92rem; font-weight: 700; font-family: var(--font-body); }
.ex-badge {
  background: var(--coral-deep);
  color: #fff;
  border-radius: 8px;
  padding: .15rem .6rem;
  font-size: .7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.ex-badge.blue { background: #3B5BDB; }
.ex-badge.green { background: var(--teal); }
.toggle-icon { color: var(--dc-text); font-size: .85rem; transition: transform .3s; flex: none; }
.example-body { display: none; padding: 1rem 1rem 1.1rem; border-top: 1px solid var(--line); }
.example-card.open .example-body { display: block; }
.example-card.open .toggle-icon { transform: rotate(180deg); }

.reveal-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .9rem;
  font-family: var(--font-head);
  font-weight: 800;
  color: var(--dc-text);
  background: var(--dc-soft);
  border: 1.5px dashed var(--dc);
  border-radius: 12px;
  padding: .5rem 1rem;
  cursor: pointer;
  transition: filter .12s, transform .12s;
}
.reveal-btn:hover { filter: brightness(.97); transform: translateY(-1px); }

/* Rules table */
/* position:relative matters: KaTeX renders a position:absolute .katex-mathml
   copy for screen readers. With a static scroll container its containing block
   is a further ancestor, so it escapes the clip and still widens the page —
   76px of sideways scroll on the Transformations lesson. */
.table-scroll { overflow-x: auto; position: relative; }
.ineq-table { width: 100%; border-collapse: collapse; margin: .5rem 0; font-size: .85rem; min-width: 34rem; }
.ineq-table th { background: var(--dc-text); color: #fff; padding: .5rem .7rem; text-align: left; font-weight: 700; }
.ineq-table td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
.ineq-table tr:last-child td { border-bottom: none; }
.ineq-table tr:nth-child(even) td { background: var(--dc-soft); }

/* Number line explorer */
.nl-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1.1rem;
  align-items: center;
  margin: .6rem 0;
}
.nl-controls label {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
  font-weight: 600;
  color: #39415E;
}
.nl-controls select {
  font-size: 1rem;
  font-family: inherit;
  font-weight: 700;
  padding: .25rem .45rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  color: var(--dc-text);
}
.nl-controls input[type="range"] { accent-color: var(--dc); width: min(100%, 14rem); height: 2.75rem; }
.nl-controls output { font-weight: 800; color: var(--dc-text); min-width: 1.4rem; text-align: center; }
.nl-join {
  font-size: .72rem;
  font-weight: 800;
  padding: .18rem .65rem;
  border-radius: 999px;
  background: var(--dc);
  color: #fff;
}
.nl-readout {
  background: var(--dc-soft);
  border-radius: 12px;
  padding: .6rem .9rem;
  margin: .5rem 0;
  font-size: .95rem;
  overflow-x: auto;
}
.nl-svg svg { width: 100%; height: auto; display: block; }

/* ---------- Lesson page: mark as done ---------- */

.topic-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  flex-wrap: wrap;
  margin-bottom: .8rem;
}
.topic-title-row .page-title { margin-bottom: 0; }

/* End of an IGCSE lesson: exam questions + mark scheme, then onward */
.lesson-foot-lead { color: var(--muted); margin: 0 0 1rem; max-width: 60ch; }
.lesson-foot-links { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.lesson-foot-card {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line); border-left: 4px solid var(--blue-deep);
  border-radius: 14px; padding: .9rem 1.1rem; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.lesson-foot-card:hover { transform: translateY(-2px); border-color: var(--blue-deep); }
.lesson-foot-card b { display: block; font-family: var(--font-head); color: var(--navy); margin-bottom: .2rem; }
.lesson-foot-card span { font-size: .9rem; color: var(--muted); }
.lesson-foot-nav { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; justify-content: space-between; margin: 1.4rem 0 .5rem; }
.lesson-foot-back { font-family: var(--font-head); font-weight: 700; color: var(--blue-deep); text-decoration: none; padding: .6rem 0; }
.lesson-foot-back:hover { text-decoration: underline; text-underline-offset: 4px; }

.mark-done {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .85rem;
  color: var(--teal-deep);
  background: var(--card);
  border: 2px dashed var(--teal);
  border-radius: 999px;
  padding: .42rem 1rem;
  cursor: pointer;
  transition: background .15s, transform .12s, border-style .15s;
}
.mark-done:hover { transform: translateY(-1px); background: var(--teal-soft); }
.mark-done.is-done {
  /* Fixed deep teal rather than --teal: white on --teal is only 3.12:1. */
  background: #087F5B;
  border-style: solid;
  color: #fff;
  box-shadow: 0 3px 10px -3px rgba(12, 166, 120, .6);
}

/* ---------- Generic modal (tricks, exam date) ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 29, 64, .55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  padding: 3.5rem 1rem 1.5rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
}

.modal-panel {
  position: relative;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-lift);
  width: 100%;
  max-width: 30rem;
  padding: 1.5rem 1.4rem 1.4rem;
  animation: rise .2s ease;
}

.icon-close {
  position: absolute;
  top: .9rem;
  right: .9rem;
  flex: none;
  border: none;
  background: var(--chip-bg);
  color: var(--navy);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.icon-close:hover { filter: brightness(.95); }

.modal-title {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--navy);
  margin: 0 1.8rem .4rem 0;
}
.modal-sub { color: var(--muted); font-size: .9rem; margin: 0 0 1rem; }
.modal-actions { display: flex; gap: .6rem; margin-top: 1rem; }

.exam-input {
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  padding: .6rem .8rem;
  border: 2px solid var(--line);
  border-radius: 14px;
  width: 100%;
}
.exam-input:focus { border-color: var(--navy-2); }

/* ---------- Quick-trick modal content ---------- */

.trick-ctrl {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .9rem;
}
.trick-lbl { font-size: .88rem; font-weight: 700; color: var(--muted); }
.trick-input {
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--card);
  width: 5.2rem;
  padding: .45rem .6rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  text-align: center;
}
.trick-input:focus { border-color: var(--navy-2); }
.trick-ctrl input[type="range"] { flex: 1; accent-color: var(--coral); min-width: 8rem; height: 2.75rem; }
.trick-n { font-family: var(--font-head); font-weight: 900; color: var(--navy); min-width: 3.2rem; }

.trick-step {
  background: var(--chip-bg);
  border-radius: 12px;
  padding: .6rem .85rem;
  margin-bottom: .5rem;
  animation: rise .4s ease backwards;
}
.trick-step--big { text-align: center; padding: .9rem; }
.trick-step-lbl { font-size: .78rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.trick-step-math {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.25rem;
  color: var(--navy);
  letter-spacing: .04em;
}
.trick-check { color: var(--teal-deep); font-weight: 700; font-size: .9rem; margin: .6rem 0 0; animation: rise .4s ease backwards; }
.trick-warn { color: var(--coral-deep); font-weight: 700; font-size: .9rem; }

.trick-presets { display: flex; gap: .45rem; flex-wrap: wrap; margin-top: .8rem; }
.trick-preset {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: .82rem;
  color: var(--navy-2);
  background: var(--chip-bg);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: .3rem .8rem;
  cursor: pointer;
  transition: background .15s, transform .12s;
}
.trick-preset:hover { transform: translateY(-1px); border-color: var(--navy-2); }

.trick-svg { text-align: center; margin: .4rem 0 .6rem; }
.trick-svg svg { width: 100%; height: auto; }
.trick-oddline { text-align: center; font-size: 1.05rem; overflow-x: auto; }

.trick-tips { display: flex; flex-direction: column; gap: .55rem; }
.trick-tip {
  display: flex;
  gap: .65rem;
  background: var(--chip-bg);
  border-radius: 12px;
  padding: .6rem .75rem;
}
.trick-tip-num {
  flex: none;
  width: 1.6rem; height: 1.6rem;
  border-radius: 50%;
  background: var(--navy-2);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .78rem;
}
.trick-tip-title { font-weight: 800; font-size: .9rem; color: var(--navy); }
.trick-tip-sub { font-size: .83rem; color: var(--muted); line-height: 1.45; }

/* ---------- Floating action buttons (stacked) ---------- */

.fab-stack {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .6rem;
}

.fab {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .95rem;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: .78rem 1.25rem;
  cursor: pointer;
  box-shadow: 0 6px 20px -4px rgba(20, 29, 64, .45);
  transition: transform .15s, box-shadow .15s;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -6px rgba(20, 29, 64, .6); }
.fab-formula { background: var(--grad-brand); }

.fpanel-backdrop {
  position: fixed;
  inset: 0;
  z-index: 94;
  background: rgba(20, 29, 64, .4);
}

.fpanel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  width: min(24rem, 92vw);
  background: var(--card);
  box-shadow: -8px 0 30px rgba(20, 29, 64, .25);
  transform: translateX(105%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
}
.fpanel.open { transform: translateX(0); }

.fpanel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-head);
  font-size: 1.05rem;
  color: var(--navy);
}
.fpanel-head .icon-close { position: static; }

.fpanel-body { flex: 1; overflow-y: auto; padding: .9rem 1rem 1.4rem; }

.fgroup { margin-bottom: 1.3rem; }
.fgroup-name {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-radius: 8px;
  padding: .4rem .7rem;
  margin-bottom: .55rem;
}
.fg-sat .fgroup-name { background: var(--teal-soft); color: var(--teal-deep); }
.fg-igcse .fgroup-name { background: var(--yellow-soft); color: var(--yellow-deep); }

.fsec {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: .5rem;
  overflow: hidden;
}
.fsec summary {
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: .92rem;
  color: var(--navy);
  padding: .6rem .8rem;
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.fsec summary::-webkit-details-marker { display: none; }
.fsec summary::after { content: "▾"; color: var(--muted); font-size: .8rem; transition: transform .2s; }
.fsec[open] summary::after { transform: rotate(180deg); }
.fsec[open] summary { border-bottom: 1px dashed var(--line); }

.frow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .8rem;
  padding: .45rem .8rem;
  font-size: .85rem;
}
.frow + .frow { border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.frow-label { color: var(--muted); font-weight: 600; flex: none; }
.frow-math { text-align: right; overflow-x: auto; color: var(--ink); }

/* ---------- Ask Mr Hamouda chat ---------- */

.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 94;
  background: rgba(20, 29, 64, .35);
}

.chat {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 96;
  width: min(23rem, calc(100vw - 2rem));
  height: min(34rem, calc(100vh - 2rem));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 18px 48px -12px rgba(20, 29, 64, .5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(.96);
  opacity: 0;
  pointer-events: none;
  transform-origin: bottom right;
  transition: transform .2s ease, opacity .2s ease;
}
.chat.open { transform: none; opacity: 1; pointer-events: auto; }

.chat-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .8rem .9rem;
  background: var(--grad-brand);
  color: #fff;
}
.chat-avatar {
  flex: none;
  width: 2.3rem; height: 2.3rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.chat-id { flex: 1; min-width: 0; line-height: 1.2; }
.chat-id strong { font-family: var(--font-head); font-size: 1rem; }
.chat-status { display: flex; align-items: center; gap: .35rem; font-size: .74rem; opacity: .9; }
.chat-dot { width: .5rem; height: .5rem; border-radius: 50%; background: #6EE7B7; box-shadow: 0 0 0 3px rgba(110,231,183,.3); }
.chat-head .icon-close { position: static; background: rgba(255,255,255,.2); color: #fff; }
.chat-head .icon-close:hover { background: rgba(255,255,255,.32); filter: none; }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: .9rem .85rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  background: var(--bg);
}

.msg { display: flex; gap: .45rem; align-items: flex-end; max-width: 100%; }
.msg-user { flex-direction: row-reverse; }
.msg-avatar {
  flex: none;
  width: 1.8rem; height: 1.8rem;
  border-radius: 50%;
  background: var(--chip-bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.bubble {
  max-width: 82%;
  padding: .6rem .8rem;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.msg-bot .bubble {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  color: var(--ink);
}
.msg-user .bubble {
  background: var(--grad-brand);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.bubble .ans {
  background: var(--chip-bg);
  border-radius: 10px;
  padding: .45rem .6rem;
  margin: .45rem 0 .2rem;
  overflow-x: auto;
}
.bubble .ans-lesson { margin-top: .5rem; font-size: .85rem; }
.bubble .ans-lesson a { font-weight: 700; color: var(--coral-deep); }
.bubble .bot-list { margin: .4rem 0 .2rem; padding-left: 1.1rem; }
.bubble .bot-list li { margin: .15rem 0; }
.bubble a { color: var(--coral-deep); }

.typing { display: inline-flex; gap: .25rem; padding: .1rem 0; }
.typing i {
  width: .45rem; height: .45rem; border-radius: 50%;
  background: var(--muted);
  animation: typing 1s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-chips {
  display: flex;
  gap: .4rem;
  padding: 0 .7rem;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: none;
}
.chat-chips::-webkit-scrollbar { display: none; }
.chat-chips:not(:empty) { padding-bottom: .55rem; padding-top: .1rem; }
.chat-chip {
  flex: none;
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 600;
  color: var(--navy-2);
  background: var(--chip-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .32rem .7rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .12s;
}
.chat-chip:hover { transform: translateY(-1px); border-color: var(--coral); }

.chat-form {
  display: flex;
  gap: .5rem;
  padding: .6rem .7rem .7rem;
  border-top: 1px solid var(--line);
  background: var(--card);
}
.chat-form input {
  flex: 1;
  font-family: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: .55rem .9rem;
  min-width: 0;
}
.chat-form input:focus { border-color: var(--coral); }
.chat-send {
  flex: none;
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: linear-gradient(120deg, var(--coral), var(--coral-deep));
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.chat-send:hover { transform: translateY(-1px); box-shadow: 0 6px 14px -4px rgba(232,73,47,.6); }

/* ---------- Footer ---------- */

.site-footer {
  background: var(--navy-deep);
  color: #C6CCE4;
  padding: 2rem 1rem 1.4rem;
  margin-top: 2rem;
}

.footer-inner {
  max-width: 64rem;
  margin: 0 auto 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-logo { display: block; max-width: 150px; height: auto; border-radius: 10px; }
.footer-tag { margin: .55rem 0 0; font-size: .85rem; color: #9AA3C7; }

.footer-social { display: flex; gap: .6rem; }
.social-btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: .88rem;
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: .45rem 1.05rem;
  transition: background .15s, transform .12s;
}
.social-btn:hover { background: rgba(255, 255, 255, .2); transform: translateY(-1px); }

.footer-small {
  max-width: 64rem;
  margin: 0 auto;
  text-align: center;
  font-size: .78rem;
  color: #8A93BC;
  border-top: 1px solid rgba(255, 255, 255, .1);
  padding-top: 1.1rem;
}

/* ---------- Small screens ---------- */

/* 901px-1024px: the links are shown but the header is close to its limit, so
   the two chips that carry text give it up. "Search" drops to its icon and the
   exam date drops to its short form ("12d"), together saving about 120px. */
@media (max-width: 1024px) {
  .nav-search-label { display: none; }
  #exam-chip-label { display: none; }
  .exam-chip-short:not(:empty) { display: inline; }
}

@media (max-width: 560px) {
  .topnav-inner { gap: .4rem; }
  .hero { padding: 2.4rem 1.1rem 2.6rem; border-radius: 22px; }
  .about-sec { padding: 2rem 1.2rem; }
  .about-inner { gap: 1.5rem; }
  .about-photo { flex-basis: 8.5rem; width: 8.5rem; height: 8.5rem; }
  .footer-inner { flex-direction: column; text-align: center; }
  .nav-search-label { display: none; }
  .fab-formula .fab-label { display: none; }
  .fab-formula { padding: .78rem .95rem; font-size: 1.15rem; }
  .chat {
    right: .5rem; left: .5rem; bottom: .5rem;
    width: auto;
    height: min(80vh, 34rem);
  }
}

@media (max-width: 480px) {
  /* Compact exam chip so the header fits — full label swaps for "12d" */
  #exam-chip-label { display: none; }
  .exam-chip-short:not(:empty) { display: inline; }
  /* 44px targets with room between them: four adjacent controls at 33px and
     5px apart were easy to mis-tap. Still fits 360px with no overflow. */
  .nav-tools { gap: .5rem; }
  .nav-tools .tool-chip { min-width: 2.75rem; min-height: 2.75rem; padding: .5rem; justify-content: center; }
}

@media (max-width: 420px) {
  .card-icon { display: none; }
  .brand-name { font-size: 1.1rem; }
  .tool-chip { font-size: .78rem; }
}

.by-line { font-weight: 700; font-size: .8em; color: #9AA3C7; }

/* ---------- Dark mode ---------- */

[data-theme="dark"] {
  --bg: #10152B;
  --card: #1A2140;
  --ink: #E8ECFA;
  --muted: #9AA6CC;
  --line: #2B3560;
  --chip-bg: #232C52;
  --track-bg: #2B3560;

  --navy: #DCE3FA;
  --navy-2: #A9B8F0;

  --blue: #6bb0f0;
  --blue-deep: #8cc4f5;
  --blue-soft: #17233f;

  --focus-ring: #8cc4f5;
  --focus-halo: rgba(140, 196, 245, .28);
  --gold: #f5a623;
  --gold-deep: #FFD673;
  --gold-soft: #3B2F14;
  --coral: #f5a623;
  --coral-deep: #FFC062;
  --hard-ink: #FFC062;
  --coral-soft: #3B2F14;

  --teal-soft: #14322B;
  --yellow-soft: #3B2F14;
  --yellow-deep: #FFD673;
  --teal-deep: #4BD6AC;

  --good: #4ade80;
  --good-deep: #86efac;
  --good-soft: #14321F;
  --bad: #f87171;
  --bad-deep: #fca5a5;
  --bad-soft: #381D1D;

  --grad-brand: linear-gradient(120deg, #3A4D9E 0%, #2A3A7C 100%);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -14px rgba(0, 0, 0, .6);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 16px 36px -14px rgba(0, 0, 0, .7);
}

/* Domain accents readable on dark cards */
/* Dark theme: --dc is already a light tint, so it doubles as --dc-text.
   Leaving --dc-text unset here would inherit the light theme's dark ink. */
[data-theme="dark"] .dom-algebra                           { --dc: #91A7FF; --dc-soft: #1E2A55; --dc-text: #91A7FF; }
[data-theme="dark"] .dom-advanced-math                     { --dc: #B197FC; --dc-soft: #2A2352; --dc-text: #B197FC; }
[data-theme="dark"] .dom-problem-solving-and-data-analysis { --dc: #FFA94D; --dc-soft: #3B2A18; --dc-text: #FFA94D; }
[data-theme="dark"] .dom-geometry-and-trigonometry         { --dc: #63E6BE; --dc-soft: #14322B; --dc-text: #63E6BE; }
[data-theme="dark"] .dom-mixed                             { --dc: #A9B8F0; --dc-soft: #232C52; --dc-text: #A9B8F0; }
[data-theme="dark"] .dom-coordinate-geometry               { --dc: #6bb0f0; --dc-soft: #17233f; --dc-text: #6bb0f0; }
[data-theme="dark"] .dom-graphs-functions                  { --dc: #B197FC; --dc-soft: #2A2352; --dc-text: #B197FC; }
[data-theme="dark"] .dom-proportion                        { --dc: #63E6BE; --dc-soft: #14322B; --dc-text: #63E6BE; }
[data-theme="dark"] .dom-functions                         { --dc: #FFA94D; --dc-soft: #3B2A18; --dc-text: #FFA94D; }
[data-theme="dark"] .dom-differentiation                   { --dc: #FF8FAB; --dc-soft: #3A1E2A; --dc-text: #FF8FAB; }
[data-theme="dark"] .dom-trigonometry                      { --dc: #66D9E8; --dc-soft: #16323A; --dc-text: #66D9E8; }
[data-theme="dark"] .dom-bearings-scale                    { --dc: #66D9E8; --dc-soft: #123038; --dc-text: #66D9E8; }
[data-theme="dark"] .dom-transformations                   { --dc: #FFA94D; --dc-soft: #3B2A18; --dc-text: #FFA94D; }
[data-theme="dark"] .dom-vectors                           { --dc: #74C0FC; --dc-soft: #16283F; --dc-text: #74C0FC; }
[data-theme="dark"] .dom-data-handling                     { --dc: #B197FC; --dc-soft: #2A2352; --dc-text: #B197FC; }
[data-theme="dark"] .dom-averages-spread                   { --dc: #63E6BE; --dc-soft: #14322B; --dc-text: #63E6BE; }
[data-theme="dark"] .dom-sets                              { --dc: #FF8FAB; --dc-soft: #3A1E2A; --dc-text: #FF8FAB; }
[data-theme="dark"] .dom-probability                       { --dc: #E599F7; --dc-soft: #2E1A38; --dc-text: #E599F7; }
[data-theme="dark"] .dom-symmetry-circles                  { --dc: #8CE99A; --dc-soft: #16321F; --dc-text: #8CE99A; }
[data-theme="dark"] .lesson-content { --dc: #91A7FF; --dc-soft: #1E2A55; }

[data-theme="dark"] .topnav { background: rgba(16, 21, 43, .92); }
[data-theme="dark"] .badge.soon { color: var(--muted); }
[data-theme="dark"] .feedback.good { border-color: #1E5232; }
[data-theme="dark"] .feedback.bad { border-color: #5A2727; }
[data-theme="dark"] .check-box { border-color: #1E5232; }
[data-theme="dark"] .fail-box { border-color: #5A2727; }
[data-theme="dark"] .warning-box { background: #3B2A18; border-color: #7A4A1D; }
[data-theme="dark"] .warning-box h6 { color: #FFA94D; }
[data-theme="dark"] .warning-box p { color: #F3D9BC; }
[data-theme="dark"] .concept-card p, [data-theme="dark"] .concept-card li,
[data-theme="dark"] .step-content p, [data-theme="dark"] .nl-controls label { color: #C4CCE8; }
[data-theme="dark"] .key-rule { border-color: color-mix(in srgb, var(--dc) 40%, var(--card)); }
[data-theme="dark"] .case-box { border-color: color-mix(in srgb, var(--dc) 40%, var(--card)); }
[data-theme="dark"] .diff-easy { color: var(--teal-deep); }
[data-theme="dark"] .diff-medium { color: var(--yellow-deep); }
[data-theme="dark"] .diff-hard { color: var(--coral-deep); }
[data-theme="dark"] .qw-arrow { color: var(--ink); }
[data-theme="dark"] .track-btn--igcse.active { color: #4A3200; }
[data-theme="dark"] .qw-yellow { color: #4A3200; }
[data-theme="dark"] .mark-done { color: var(--teal-deep); }
[data-theme="dark"] .mark-done.is-done { color: #06281F; }
[data-theme="dark"] .st-done { color: var(--teal-deep); }
[data-theme="dark"] .st-progress { color: var(--yellow-deep); }
[data-theme="dark"] .exam-input { color-scheme: dark; }
/* Elements with a --dc background need dark text when --dc is a light tint */
[data-theme="dark"] .ineq-table th,
[data-theme="dark"] .nl-join,
[data-theme="dark"] .step-num,
[data-theme="dark"] .lesson-sec-title .num,
[data-theme="dark"] .vc-back { color: #10152B; }

/* ============================================================
   Standalone American Pathway pages (american-pathway/**)
   Generated by build/build.mjs. These pages don't load app.js,
   so they need their own layout primitives — everything below
   reuses the tokens above so light/dark stay in sync.
   ============================================================ */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 1rem;
}
.breadcrumbs a { color: var(--blue-deep); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .crumb-sep { color: var(--line); }
.breadcrumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }

.lesson-intro {
  color: var(--muted);
  max-width: 62ch;
  margin: .6rem 0 1.4rem;
}

/* The four progress states, used in the "How progress works" explanation. */
.progress-legend { list-style: none; padding: 0; margin: .6rem 0 1rem; display: grid; gap: .55rem; }
.progress-legend li { font-size: .92rem; color: var(--muted); }
.progress-pill {
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  padding: .12rem .5rem;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--ink);
  white-space: nowrap;
}
.progress-pill.is-mastered { background: var(--good-soft, var(--chip-bg)); color: var(--good-deep, var(--ink)); }
.progress-pill.is-done { background: var(--chip-bg); color: var(--blue-deep); }
/* A button sitting in the row of stat chips; matches them but is clickable. */
.stat-chip--btn {
  cursor: pointer;
  border: 1px dashed var(--line);
  font: inherit;
  font-size: .78rem;
  color: var(--blue-deep);
}
.stat-chip--btn:hover { border-style: solid; }

/* Explains how a headline question count splits between the question banks and
   the in-lesson quizzes, so the smaller number on the test-builder button below
   reads as detail rather than a contradiction. */
.count-note {
  color: var(--muted);
  font-size: .92rem;
  max-width: 62ch;
  margin: -.6rem 0 1.2rem;
}

/* Module + hub card grids */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: .9rem;
  margin-bottom: 2rem;
}

.topic-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 5px solid var(--navy-2);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(20, 29, 64, .05);
  transition: transform .15s, box-shadow .15s;
}
.topic-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.topic-card:active { transform: none; }

.topic-card-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.02rem;
  color: var(--navy);
  margin: 0 0 .3rem;
  /* Long lesson names must wrap, not push the card wide (390px check) */
  overflow-wrap: anywhere;
}

.topic-card-sub {
  color: var(--muted);
  font-size: .85rem;
  margin: 0 0 .6rem;
}

/* Related lessons in the same module */
.related { margin-top: 2.5rem; }
.related-list {
  list-style: none;
  padding: 0;
  margin: .6rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: .45rem;
}
.related-list a {
  display: block;
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--blue-deep);
  text-decoration: none;
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.related-list a:hover { border-color: var(--blue); }

/* Previous / next lesson */
.lesson-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .6rem;
  margin: 2.2rem 0 1rem;
}
.lesson-pager a {
  flex: 1 1 14rem;
  padding: .7rem .9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--blue-deep);
  text-decoration: none;
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.lesson-pager a:hover { border-color: var(--blue); }
.lesson-pager .pager-next { text-align: right; }

@media (max-width: 560px) {
  .topic-grid, .related-list { grid-template-columns: 1fr; }
  .lesson-pager .pager-next { text-align: left; }
}

/* Crawlable site directory in the footer (index.html) */
.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem 1.1rem;
  margin: .4rem 0 1rem;
  font-size: .86rem;
}
/* The footer sits on dark navy, so --muted (a light-background token, #5c6785)
   was 2.65:1 here — the whole crawlable site directory failed AA in both
   themes. --footer-link is fixed rather than theme-dependent because the
   footer background is fixed. min-height meets the 24px target minimum; these
   were 22px tall standalone nav links. */
.footer-links a {
  color: var(--footer-link);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
}
.footer-links a:hover { color: #fff; text-decoration: underline; }

/* Wide tables inside a generated lesson body scroll in their own box so the
   page itself never scrolls sideways on a narrow phone. */
.lesson-content .table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  position: relative;
}

/* ============================================================
   Mental Math Arena — home entry card
   Lives here, NOT in css/game.css: game.css only loads on the
   #/game route, so styling this card there left it rendering as
   a bare blue link on the home page.
   ============================================================ */

.arena-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.15rem;
  background: var(--grad-hero);
  border-radius: var(--radius);
  padding: 1.3rem 1.45rem;
  margin: 0 0 1.5rem;
  color: #fff;
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.arena-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.arena-card:active { transform: none; }

/* Soft gold light behind the badge — pure decoration */
.arena-shine {
  position: absolute;
  z-index: -1;
  left: -3rem;
  top: 50%;
  width: 15rem;
  height: 15rem;
  transform: translateY(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 166, 35, .30) 0%, rgba(245, 166, 35, 0) 68%);
  pointer-events: none;
}

.arena-badge {
  flex: none;
  width: 4.15rem;
  height: 4.15rem;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .3));
}
.arena-badge svg { width: 100%; height: 100%; display: block; }
.arena-card:hover .arena-badge { animation: arena-tilt .5s ease; }

.arena-body { min-width: 0; display: flex; flex-direction: column; gap: .1rem; }

.arena-eyebrow {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .66rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--gold);
}
.arena-title {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.3rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.arena-title-accent { color: var(--gold); }
.arena-sub {
  font-size: .87rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, .82);
  margin-top: .18rem;
}

.arena-modes { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.arena-mode {
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  font-size: .74rem;
  font-weight: 700;
  padding: .26rem .62rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
  white-space: nowrap;
}
.arena-mode-icon { font-size: .82rem; }

/* Reads as a button, not a link */
.arena-cta {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .95rem;
  background: var(--grad-warm);
  color: #16294f;
  border-radius: 999px;
  padding: .72rem 1.35rem;
  white-space: nowrap;
  box-shadow: 0 4px 14px -4px rgba(245, 166, 35, .75);
}
.arena-cta-play { font-size: .78rem; }
.arena-card:hover .arena-cta { filter: brightness(1.06); }

@keyframes arena-tilt {
  0%, 100% { transform: rotate(0); }
  35%      { transform: rotate(-7deg) scale(1.06); }
  70%      { transform: rotate(4deg) scale(1.03); }
}

@media (max-width: 620px) {
  .arena-card {
    grid-template-columns: auto 1fr;
    gap: .9rem 1rem;
    padding: 1.15rem 1.15rem 1.25rem;
  }
  .arena-badge { width: 3.3rem; height: 3.3rem; }
  .arena-title { font-size: 1.15rem; }
  /* CTA drops to its own full-width row under both columns */
  .arena-cta { grid-column: 1 / -1; justify-content: center; padding: .78rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .arena-card:hover { transform: none; }
  .arena-card:hover .arena-badge { animation: none; }
}

/* ---------- Quick Wins: widgets used by the newer tricks ---------- */

.trick-ctrl--tight { margin-top: 1.1rem; }

.trick-select {
  padding-right: 1.6rem;
  cursor: pointer;
  max-width: 100%;
}

.trick-input--ratio { width: 6.5rem; text-align: center; }

/* Divisibility results */
.trick-flags {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: .45rem;
  margin: 1rem 0 .3rem;
}
.trick-flag {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: .45rem;
  padding: .5rem .65rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: .8rem;
}
.trick-flag.is-yes { border-color: rgba(22, 163, 74, .45); background: var(--good-soft); }
/* The "no" state is secondary, but never dimmed with opacity — that dropped
   its label to 2.6:1. Full-strength muted colour instead. */
.trick-flag.is-no  { background: var(--bg); }
.trick-flag.is-no .trick-flag-num { color: var(--muted); }
.trick-flag-num {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .95rem;
  color: var(--navy);
  min-width: 1.2rem;
}
.trick-flag.is-yes .trick-flag-mark { color: var(--good-deep); font-weight: 900; }
.trick-flag.is-no  .trick-flag-mark { color: var(--muted); }
.trick-flag-why { color: var(--muted); font-size: .76rem; overflow-wrap: anywhere; }

[data-theme="dark"] .trick-flag.is-yes {
  background: rgba(22, 163, 74, .16);
  border-color: rgba(74, 222, 128, .4);
}
[data-theme="dark"] .trick-flag.is-yes .trick-flag-mark { color: #4ade80; }

/* Square-root estimate bar */
.trick-rootbar {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 1.1rem 0 .4rem;
  font-size: .78rem;
  color: var(--muted);
  font-weight: 700;
}
.trick-rootbar-end { flex: none; white-space: nowrap; }
.trick-rootbar-track {
  position: relative;
  flex: 1;
  height: .55rem;
  min-width: 3rem;
  border-radius: 999px;
  background: var(--chip-bg);
  border: 1px solid var(--line);
}
.trick-rootbar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--navy-2));
  transition: width .25s;
}
.trick-rootbar-dot {
  position: absolute;
  top: 50%;
  width: .95rem;
  height: .95rem;
  margin-left: -.475rem;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--card);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  transition: left .25s;
}

@media (max-width: 480px) {
  .trick-flags { grid-template-columns: 1fr 1fr; }
  .trick-rootbar { flex-wrap: wrap; }
  .trick-rootbar-track { order: 3; flex-basis: 100%; }
}

/* ---------- Test Me entry point on the generated American Pathway pages ---------- */

.hub-cta {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .95rem;
  padding: 1rem 1.15rem;
  margin: 0 0 1.6rem;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(20, 29, 64, .05);
  transition: transform .15s, box-shadow .15s;
}
.hub-cta:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.hub-cta:active { transform: none; }

.hub-cta-icon {
  flex: none;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 14px;
  background: var(--gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}
.hub-cta-body { min-width: 0; display: flex; flex-direction: column; gap: .12rem; }
.hub-cta-title {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.02rem;
  color: var(--navy);
}
.hub-cta-sub { font-size: .84rem; color: var(--muted); line-height: 1.45; }
.hub-cta-go {
  flex: none;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .88rem;
  background: var(--grad-warm);
  color: #16294f;
  border-radius: 999px;
  padding: .55rem 1.05rem;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .hub-cta { grid-template-columns: auto 1fr; }
  .hub-cta-go { grid-column: 1 / -1; text-align: center; }
}

/* ============================================================
   Lesson search overlay
   The markup has been in index.html since v1 but NONE of its
   classes were ever styled — so tapping 🔍 rendered ~950px of
   unstyled content below the fold, focused an invisible input,
   and looked to a student like the button did nothing.
   Mirrors .modal so the two overlays feel like one system.
   ============================================================ */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(20, 29, 64, .55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  padding: 3.5rem 1rem 1.5rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
}
/* .hidden is display:none !important, so it still wins */

.search-panel {
  position: relative;
  width: 100%;
  max-width: 34rem;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
  animation: rise .2s ease;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 5rem);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem .8rem .7rem 1rem;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.search-icon { font-size: 1.05rem; flex: none; }

#search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: .55rem 0;
  outline: none;
}
#search-input::placeholder { color: var(--muted); }
#search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.search-close {
  flex: none;
  width: 2.75rem;          /* 44px — meets the minimum touch target */
  height: 2.75rem;
  border: none;
  border-radius: 50%;
  background: var(--chip-bg);
  color: var(--navy);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.search-close:hover { background: var(--track-bg); }

.search-results {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: .55rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.search-hit {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .7rem;
  border-radius: 13px;
  border: 1px solid transparent;
  color: var(--ink);
  text-decoration: none;
  transition: background .12s, border-color .12s;
}
.search-hit:hover,
.search-hit:focus-visible { background: var(--bg); border-color: var(--line); }

.hit-code {
  flex: none;
  min-width: 2.5rem;
  padding: .3rem .45rem;
  border-radius: 9px;
  text-align: center;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: .78rem;
  background: var(--dc-soft, var(--chip-bg));
  color: var(--dc-text, var(--navy-2));
}
.hit-body { min-width: 0; flex: 1; }
.hit-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: .93rem;
  color: var(--navy);
  overflow-wrap: anywhere;
}
.hit-sub {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .1rem;
  overflow-wrap: anywhere;
}

.search-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .92rem;
}

/* Which curriculum a result belongs to, and what kind of page it is. Results
   span two curricula and four content types, so a bare title left the student
   guessing whether "Vectors" was their vectors. */
.hit-tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .2rem; }
.hit-tag {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .02em;
  padding: .1rem .4rem;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--muted);
  white-space: nowrap;
}
.hit-tag--igcse { background: var(--chip-bg); color: var(--blue-deep); }
.hit-tag--ap { background: var(--chip-bg); color: var(--navy-2); }
.search-suggest-head {
  padding: .4rem .7rem .2rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
}
/* The hit is a two-line block once it carries tags, so stop centring it. */
.search-hit { align-items: flex-start; }
.search-hit .hit-code { margin-top: .15rem; }

@media (max-width: 560px) {
  .search-overlay { padding: 1rem .7rem; }
  .search-panel { max-height: calc(100vh - 2rem); }
}

/* Buttons on the "we couldn't find that lesson" screen */
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  justify-content: center;
  margin-top: .4rem;
}
