/* Math Mastery for All — site styles (v2)
   Palette taken from the original mathmasteryforall.in: slate header/footer, sky-blue
   section bands, bright sky accent, with the logo's sunny orange as the action colour.
   Type: Sora for headings, Space Grotesk for body — as on the original. Self-hosted. */

@font-face { font-family: "Sora"; src: url("../fonts/sora-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Sora"; src: url("../fonts/sora-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Sora"; src: url("../fonts/sora-latin-800-normal.woff2") format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("../fonts/space-grotesk-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("../fonts/space-grotesk-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("../fonts/space-grotesk-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --slate: #3a4755;        /* original header/footer band */
  --slate-deep: #2b3744;
  --sky-wash: #d9e9f5;     /* original section band */
  --sky-wash-2: #eaf3fa;
  --sky: #3d9be9;          /* original accent */
  --sky-deep: #1f7ccc;
  --ink: #05111f;          /* original text */
  --paper: #fff9f9;        /* original warm off-white */
  --white: #ffffff;
  --sun: #f5a623;          /* from the logo: action colour */
  --sun-deep: #d98d0b;
  --grass: #3aaa5c;        /* from the logo: correct */
  --coral: #e5532f;        /* from the logo: wrong / margin rule */
  --muted: #55606c;
  --rule: #cfdde9;
  --grid: #c9dcee;

  --heading: "Sora", "Segoe UI", system-ui, sans-serif;
  --body: "Space Grotesk", "Segoe UI", system-ui, sans-serif;

  --step--1: 0.9rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.55rem;
  --step-3: clamp(1.8rem, 1.4rem + 1.4vw, 2.4rem);
  --step-4: clamp(2.3rem, 1.6rem + 2.8vw, 3.75rem);

  --measure: 64ch;
  --wrap: 74rem;
  --gutter: clamp(1rem, 0.6rem + 2vw, 2rem);
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 4px rgba(5, 17, 31, 0.06), 0 14px 30px -16px rgba(5, 17, 31, 0.25);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 5rem; }
body { margin: 0; background: var(--white); color: var(--ink); font-family: var(--body); font-size: var(--step-0); line-height: 1.6; overflow-x: hidden; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--sky-deep); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3, h4 { font-family: var(--heading); font-weight: 700; line-height: 1.15; color: var(--ink); margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: var(--step-4); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); line-height: 1.3; }
p, ul, ol { margin: 0 0 1em; }
p, li { max-width: var(--measure); }
strong { font-weight: 700; }
.skip { position: absolute; left: -999px; top: 0; background: var(--white); padding: 0.5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; top: 1rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }
.muted { color: var(--muted); }
.small { font-size: var(--step--1); }
.mt-1 { margin-top: 1.25rem; } .mt-2 { margin-top: 2rem; } .mt-3 { margin-top: 2.5rem; } .m-0 { margin: 0; }
.h3 { font-size: var(--step-1); line-height: 1.3; }

/* ---------- Header: slate band as on the original ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--slate); color: var(--white); box-shadow: 0 1px 0 rgba(255,255,255,0.08), 0 6px 20px -12px rgba(5,17,31,0.6); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4.5rem; }
.brand { display: inline-flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--white); }
.brand:hover { color: var(--white); }
.brand img.brand-logo { width: 76px; height: 55px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35)); }
.brand-name { font-family: var(--heading); font-weight: 700; font-size: 1.15rem; line-height: 1.05; }
.brand-name small { display: block; font-family: var(--body); font-weight: 400; font-size: 0.78rem; color: var(--sky-wash); }
.nav-toggle { display: none; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.1rem; align-items: center; }
.site-nav a { display: block; padding: 0.55rem 0.8rem; border-radius: var(--radius-sm); color: var(--white); text-decoration: none; font-weight: 500; font-size: 1rem; }
.site-nav a:hover { background: rgba(255,255,255,0.1); color: var(--white); }
.site-nav a[aria-current="page"] { background: var(--sky); color: var(--white); }
.site-nav .nav-cta a { background: var(--sun); color: var(--ink); font-weight: 700; margin-left: 0.5rem; }
.site-nav .nav-cta a:hover, .site-nav .nav-cta a[aria-current="page"] { background: var(--sun-deep); color: var(--ink); }

@media (max-width: 1000px) {
  .nav-toggle { display: inline-flex; align-items: center; gap: 0.5rem; font: inherit; font-size: 1rem; font-weight: 500; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25); color: var(--white); border-radius: 999px; padding: 0.45rem 0.9rem; cursor: pointer; }
  .nav-toggle svg { width: 18px; height: 18px; }
  .site-nav { position: absolute; left: 0; right: 0; top: 100%; background: var(--slate-deep); display: none; box-shadow: var(--shadow); }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; align-items: stretch; padding: 0.5rem var(--gutter) 1rem; gap: 0; }
  .site-nav a { padding: 0.85rem 0.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); border-radius: 0; }
  .site-nav a[aria-current="page"] { background: none; box-shadow: inset 4px 0 0 var(--sky); padding-left: 0.9rem; }
  .site-nav .nav-cta a { margin: 0.75rem 0 0; border-radius: 999px; text-align: center; border-bottom: 0; }
  .no-js .site-nav { display: block; position: static; }
}

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; font: inherit; font-family: var(--body); font-weight: 700; font-size: 1rem; line-height: 1.2; padding: 0.85rem 1.4rem; border-radius: 999px; border: 2px solid var(--sun); background: var(--sun); color: var(--ink); text-decoration: none; cursor: pointer; box-shadow: 0 4px 14px -6px rgba(245,166,35,0.7); }
.btn:hover { background: var(--sun-deep); border-color: var(--sun-deep); color: var(--ink); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--sky-deep); border-color: var(--sky); box-shadow: none; }
.btn-ghost:hover { background: var(--sky-wash); color: var(--ink); border-color: var(--sky-deep); }
.btn-small { padding: 0.5rem 0.95rem; font-size: 0.95rem; border-width: 1.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }
.on-dark .btn-ghost { color: var(--white); border-color: rgba(255,255,255,0.6); }
.on-dark .btn-ghost:hover { background: rgba(255,255,255,0.12); color: var(--white); }

/* ---------- Sections and bands ---------- */
main { display: block; }
.section { padding-block: clamp(3rem, 2rem + 4vw, 5.5rem); }
.band-sky { background: var(--sky-wash); }
.band-paper { background: var(--paper); }
.band-slate { background: var(--slate); color: var(--white); }
.band-slate h2, .band-slate h3 { color: var(--white); }
.band-slate .muted { color: var(--sky-wash); }
.section-head { max-width: 46rem; margin-bottom: 2rem; }
.section-head p { color: var(--muted); }
.band-slate .section-head p { color: var(--sky-wash); }
.lede { font-size: var(--step-1); line-height: 1.5; max-width: 40rem; }

/* Page header for interior pages: sky band with the logo's shapes faintly behind */
.page-head { background: var(--sky-wash); padding-block: clamp(2.5rem, 2rem + 3vw, 4.5rem) clamp(1.75rem, 1rem + 2vw, 2.75rem); position: relative; overflow: hidden; }
.page-head::after { content: ""; position: absolute; right: -4rem; top: -3rem; width: 24rem; height: 24rem; border-radius: 50%; background: radial-gradient(closest-side, rgba(61,155,233,0.22), transparent 70%); pointer-events: none; }
.page-head .wrap { position: relative; z-index: 1; }
.page-head h1 { max-width: 22ch; }
.page-head .lede { margin-bottom: 0; }
.page-head-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 2rem; align-items: center; }
.page-head-grid img { border-radius: var(--radius); box-shadow: var(--shadow); }
@media (max-width: 860px) { .page-head-grid { grid-template-columns: minmax(0, 1fr); } .page-head-grid img { max-height: 16rem; width: 100%; object-fit: cover; } }
.crumbs { font-size: var(--step--1); color: var(--muted); margin-bottom: 1rem; }
.crumbs a { color: var(--muted); }

/* ---------- Hero: photo-led as the original, with the medals poster ---------- */
.hero { position: relative; background: var(--slate); color: var(--white); overflow: hidden; }
.hero-photo { position: absolute; inset: 0; }
.hero-photo img { width: 100%; height: 100%; object-fit: cover; object-position: 70% 40%; opacity: 0.38; }
.hero-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(43,55,68,0.97) 0%, rgba(43,55,68,0.85) 45%, rgba(43,55,68,0.35) 100%); }
.hero .wrap { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: clamp(2rem, 1rem + 4vw, 4rem); align-items: center; padding-block: clamp(3rem, 2rem + 5vw, 6rem); }
.hero h1 { color: var(--white); max-width: 16ch; }
.hero .lede { color: #e9f1f8; margin-top: 1.25rem; }
.hero-facts { list-style: none; padding: 0; margin: 2rem 0 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; color: var(--sky-wash); font-size: 1rem; }
.hero-facts li { display: flex; align-items: center; gap: 0.45rem; }
.hero-facts svg { width: 20px; height: 20px; color: var(--sun); flex: none; }
.hero-poster { justify-self: end; width: 100%; max-width: 22rem; margin: 0; transform: rotate(2deg); }
.hero-poster img { border-radius: var(--radius); box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6), 0 0 0 6px rgba(255,255,255,0.08); }
.hero-poster figcaption { color: var(--sky-wash); font-size: var(--step--1); margin-top: 0.75rem; text-align: center; }
.hero-poster figcaption a, .band-slate a:not(.btn) { color: var(--white); }
@media (max-width: 860px) { .hero .wrap { grid-template-columns: minmax(0, 1fr); } .hero-poster { justify-self: center; max-width: 18rem; transform: none; } }

/* ---------- Chapter tiles with lesson thumbnails ---------- */
.chapter-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.25rem; }
.chapter-grid > li { max-width: none; }
.tile { display: flex; flex-direction: column; height: 100%; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; color: var(--ink); border: 1px solid var(--rule); transition: transform 150ms ease, box-shadow 150ms ease; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(5,17,31,0.08), 0 22px 36px -16px rgba(5,17,31,0.35); color: var(--ink); }
.tile figure { margin: 0; aspect-ratio: 16 / 9; background: var(--slate); position: relative; }
.tile figure img { width: 100%; height: 100%; object-fit: cover; }
.tile .ch-num { position: absolute; left: 0.75rem; top: 0.75rem; background: var(--sun); color: var(--ink); font-family: var(--heading); font-weight: 700; font-size: 0.85rem; padding: 0.2rem 0.6rem; border-radius: 999px; }
.tile .tile-body { padding: 1rem 1.15rem 1.25rem; }
.tile h3 { margin-bottom: 0.35rem; font-size: 1.15rem; }
.tile p { color: var(--muted); font-size: 0.98rem; margin: 0; }
.tile-cta { background: var(--sky); color: var(--white); border-color: var(--sky-deep); }
.tile-cta figure { background: var(--sky-deep); display: grid; place-items: center; }
.tile-cta h3, .tile-cta p { color: var(--white); }
.tile-cta:hover { color: var(--white); }

/* ---------- How it works ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.5rem; counter-reset: step; }
.steps li { counter-increment: step; background: var(--white); border-radius: var(--radius); padding: 1.4rem 1.4rem 1.5rem; box-shadow: var(--shadow); max-width: none; position: relative; }
.steps li::before { content: counter(step); font-family: var(--heading); font-weight: 800; font-size: 1.1rem; color: var(--white); background: var(--sky); width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; margin-bottom: 0.9rem; }
.steps h3 { font-size: 1.12rem; margin-bottom: 0.35rem; }
.steps p { color: var(--muted); font-size: 0.98rem; margin: 0; }
@media (max-width: 960px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .steps { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Record ledger ---------- */
.ledger-wrap { overflow-x: auto; border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.ledger { width: 100%; border-collapse: collapse; font-size: 1rem; min-width: 30rem; }
.ledger th, .ledger td { text-align: left; padding: 0.9rem 1.25rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger thead th { font-weight: 700; font-size: 0.92rem; color: var(--muted); background: var(--sky-wash-2); }
.ledger tbody th { font-weight: 500; }
.ledger td.num { font-family: var(--heading); font-weight: 800; font-size: 1.45rem; color: var(--sky-deep); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger tbody tr:last-child > * { border-bottom: 0; }

/* Stat strip (home, results) */
.stats { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.stats li { background: var(--white); border-radius: var(--radius); padding: 1.25rem 1.25rem 1.1rem; box-shadow: var(--shadow); max-width: none; border-top: 5px solid var(--sun); }
.stats li:nth-child(2) { border-top-color: var(--sky); } .stats li:nth-child(3) { border-top-color: var(--grass); } .stats li:nth-child(4) { border-top-color: var(--coral); }
.stats .num { display: block; font-family: var(--heading); font-weight: 800; font-size: 2.4rem; line-height: 1; color: var(--ink); }
.stats .lbl { display: block; color: var(--muted); font-size: 0.95rem; margin-top: 0.4rem; }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Press ---------- */
.press { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.press article { background: var(--white); border-radius: var(--radius); overflow: hidden; display: grid; grid-template-columns: 10rem 1fr; box-shadow: var(--shadow); }
.press figure { margin: 0; background: var(--sky-wash); }
.press figure img { width: 100%; height: 100%; object-fit: cover; object-position: left top; }
.press .body { padding: 1.25rem 1.25rem 1.4rem; }
.press .outlet { font-size: 0.92rem; color: var(--muted); margin-bottom: 0.35rem; }
.press h3, .press .h3 { font-size: 1.15rem; margin-bottom: 0.4rem; }
.press h3 a, .press .h3 a { color: var(--ink); text-decoration: none; }
.press h3 a:hover, .press .h3 a:hover { color: var(--sky-deep); text-decoration: underline; }
.press p { font-size: 0.98rem; color: var(--muted); }
@media (max-width: 860px) { .press { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 480px) { .press article { grid-template-columns: minmax(0, 1fr); } .press figure { aspect-ratio: 16 / 9; } }

/* ---------- Ways to help ---------- */
.ways { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
.ways > div { padding: 1.5rem; border-radius: var(--radius); background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18); display: flex; flex-direction: column; }
.ways h3 { margin-bottom: 0.4rem; color: var(--white); }
.ways p { color: var(--sky-wash); font-size: 0.98rem; flex: 1; }
@media (max-width: 860px) { .ways { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Split layouts, photos, prose ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(2rem, 1rem + 4vw, 4rem); align-items: start; }
.split-wide { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
@media (max-width: 860px) { .split, .split-wide { grid-template-columns: minmax(0, 1fr); } }
.photo { margin: 0; }
.photo img { border-radius: var(--radius); width: 100%; object-fit: cover; background: var(--sky-wash); box-shadow: var(--shadow); }
.photo figcaption { font-size: var(--step--1); color: var(--muted); margin-top: 0.6rem; }
.photo-square { max-width: 24rem; justify-self: end; }
.photo-square img { aspect-ratio: 1 / 1; object-position: 50% 45%; }
@media (max-width: 860px) { .photo-square { justify-self: start; } }
.prose h2 { margin-top: 2.25rem; font-size: var(--step-2); }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: 1.75rem; }
.prose ul, .prose ol { padding-left: 1.2rem; }
.prose li { margin-bottom: 0.4rem; }

.arc { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--sky); }
.arc li { position: relative; padding: 0 0 1.75rem 1.5rem; max-width: none; }
.arc li::before { content: ""; position: absolute; left: -10px; top: 0.5rem; width: 14px; height: 14px; border-radius: 50%; background: var(--sun); border: 3px solid var(--white); box-shadow: 0 0 0 2px var(--sky); }
.arc li:last-child { padding-bottom: 0; }
.arc h3 { margin-bottom: 0.3rem; }
.arc p { margin: 0; }

.principles { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.25rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.principles li { max-width: none; background: var(--white); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow); }
.principles h3 { font-size: 1.12rem; margin-bottom: 0.3rem; }
.principles p { color: var(--muted); font-size: 0.98rem; margin: 0; }
@media (max-width: 860px) { .principles { grid-template-columns: minmax(0, 1fr); } }

.team { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1.25rem; }
.person { border-radius: var(--radius); padding: 1.4rem; background: var(--white); box-shadow: var(--shadow); }
.person h3 { margin-bottom: 0.15rem; font-size: 1.2rem; }
.person .role { color: var(--sky-deep); font-weight: 500; font-size: 0.95rem; margin-bottom: 0.6rem; }
.person p { font-size: 0.98rem; margin: 0; }
.person-open { border: 2px dashed var(--sky); background: transparent; box-shadow: none; }

.callout { border-radius: var(--radius); padding: 1.4rem 1.5rem; background: var(--sky-wash); }
.callout p:last-child { margin-bottom: 0; }
.callout h2, .callout h3 { font-size: 1.2rem; margin-bottom: 0.4rem; }
.callout-sun { background: #fff3dc; }
@media (min-width: 861px) { .sticky-aside { position: sticky; top: 5.75rem; } }

/* ---------- Course topics with video + worksheet ---------- */
.topics { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem; }
.topics > li { max-width: none; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.topics .topic-body { padding: 1.4rem 1.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.topics h3 { margin: 0; font-size: 1.3rem; }
.topics p { margin: 0; color: var(--muted); font-size: 0.98rem; flex: 1; }
.topics .dl { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
@media (max-width: 760px) { .topics > li { grid-template-columns: minmax(0, 1fr); } }
.file-meta { font-size: 0.82rem; color: var(--muted); font-weight: 400; }
.btn-ghost .file-meta { color: var(--muted); }

/* Video lessons: thumbnail shown; nothing loads from YouTube until pressed */
.video { position: relative; display: block; aspect-ratio: 16 / 9; width: 100%; background: var(--slate); text-decoration: none; color: var(--white); overflow: hidden; }
.video img { width: 100%; height: 100%; object-fit: cover; transition: transform 300ms ease; }
.video:hover img { transform: scale(1.03); }
.video-play { position: absolute; left: 50%; top: 50%; width: 4.25rem; height: 4.25rem; margin: -2.125rem 0 0 -2.125rem; border-radius: 50%; background: var(--sun); box-shadow: 0 8px 20px rgba(0,0,0,0.4); transition: transform 150ms ease; }
.video-play::after { content: ""; position: absolute; left: 1.7rem; top: 1.3rem; border-style: solid; border-width: 0.8rem 0 0.8rem 1.3rem; border-color: transparent transparent transparent var(--ink); }
.video:hover .video-play, .video:focus-visible .video-play { transform: scale(1.1); }
.video-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 2.5rem 1rem 0.8rem; background: linear-gradient(rgba(5,17,31,0), rgba(5,17,31,0.88) 2.25rem, rgba(5,17,31,0.94)); text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
@media (max-width: 560px) { .video-text { padding: 1.75rem 0.75rem 0.6rem; } .video-title { font-size: 0.95rem; } .video-note { font-size: 0.74rem; } }
.video-title { display: block; font-family: var(--heading); font-weight: 700; font-size: 1rem; line-height: 1.25; }
.video-note { display: block; font-size: 0.8rem; opacity: 0.85; }
.video-frame { aspect-ratio: 16 / 9; width: 100%; height: 100%; border: 0; background: #000; display: block; }
.chapter-nav { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.chapter-nav a { text-decoration: none; }
.chapter-nav span { display: block; font-size: 0.9rem; color: var(--muted); }
.chapter-nav strong { font-family: var(--heading); font-size: 1.05rem; }

/* ---------- The worksheet (signature surface, now sky-blue grid) ---------- */
.sheet { --line: 28px; position: relative; background-color: var(--white); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: var(--line) var(--line); background-position: -1px -1px; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem 1.5rem 1.5rem 4.25rem; border: 1px solid var(--rule); }
.sheet::before { content: ""; position: absolute; top: 0; bottom: 0; left: 3.1rem; width: 2px; background: var(--coral); opacity: 0.8; }
.sheet-margin { position: absolute; left: 0; top: 1.3rem; width: 3.1rem; text-align: center; font-family: var(--heading); font-weight: 800; color: var(--coral); font-size: 1.05rem; }
.sheet-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; font-size: 0.92rem; color: var(--muted); margin-bottom: 0.75rem; }
.sheet-meta .tag { color: var(--sky-deep); font-weight: 700; }
.sheet-meta a { color: var(--muted); }
.sheet h2, .sheet h3 { font-size: var(--step-1); margin-bottom: 0.35rem; }
.sheet .q { font-family: var(--heading); font-weight: 600; font-size: 1.15rem; line-height: 1.5; margin: 0 0 1.1rem; max-width: none; }
@media (max-width: 520px) { .sheet { padding: 1.25rem 1rem 1.25rem 3.1rem; } .sheet::before { left: 2.1rem; } .sheet-margin { width: 2.1rem; font-size: 0.95rem; } .sheet .q { font-size: 1.05rem; } }

.ladder { margin: 0; padding: 0; list-style: none; counter-reset: rung; }
.ladder li { counter-increment: rung; position: relative; padding: 0.75rem 0.9rem 0.75rem 2.6rem; margin-bottom: 0.5rem; background: var(--sky-wash-2); border-radius: var(--radius-sm); max-width: none; }
.ladder li::after { content: counter(rung); position: absolute; left: 0.75rem; top: 0.72rem; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--sky); color: var(--white); font-size: 0.8rem; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.ladder li[hidden] { display: none; }
.ladder li.is-new { animation: rung-in 280ms ease-out; }
@keyframes rung-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.ladder-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 0.75rem; }
.answer-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 1rem; }
.answer-form label { font-weight: 700; font-size: 1rem; width: 100%; }
.answer-form input { font: inherit; font-size: 1.1rem; width: 9.5rem; padding: 0.55rem 0.7rem; border: 2px solid var(--grid); border-radius: var(--radius-sm); background: var(--white); color: var(--ink); }
.answer-form input:focus-visible { border-color: var(--sky); outline-color: var(--sun); }
.feedback { min-height: 1.6em; margin: 0.6rem 0 0; font-weight: 700; font-size: 1rem; }
.feedback.is-right { color: var(--grass); }
.feedback.is-wrong { color: var(--coral); }
.solution { margin-top: 1rem; padding: 1rem 1.1rem; border-left: 4px solid var(--sun); background: #fff8e8; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.solution p:last-child { margin-bottom: 0; }
.solution .answer { display: inline-block; background: var(--sun); color: var(--ink); padding: 0 0.35em; font-weight: 700; border-radius: 3px; }
.solution[hidden] { display: none; }

/* ---------- Grade filters ---------- */
.grade-filter { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 2rem; padding: 0; list-style: none; }
.grade-filter[hidden] { display: none; }
.grade-filter button { font: inherit; font-size: 1rem; font-weight: 700; padding: 0.45rem 0.95rem; border-radius: 999px; border: 2px solid var(--rule); background: var(--white); color: var(--ink); cursor: pointer; min-width: 3rem; }
.grade-filter button:hover { border-color: var(--sky); color: var(--sky-deep); }
.grade-filter button[aria-pressed="true"] { background: var(--sky); border-color: var(--sky); color: var(--white); }
.grade-block { margin-bottom: 2.75rem; }
.grade-block[hidden] { display: none; }
.grade-block h2 { font-size: var(--step-2); display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.grade-block h2 .count { font-family: var(--body); font-size: 1rem; font-weight: 400; color: var(--muted); }
.papers { list-style: none; margin: 0; padding: 0; border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); }
.papers > li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.4rem 1rem; align-items: center; padding: 0.95rem 1.2rem; border-bottom: 1px solid var(--rule); max-width: none; }
.papers > li:last-child { border-bottom: 0; }
.papers .title { font-weight: 700; }
.papers .src { display: block; font-size: 0.88rem; color: var(--muted); font-weight: 400; }
.papers .links { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: flex-end; }
@media (max-width: 640px) { .papers > li { grid-template-columns: minmax(0, 1fr); } .papers .links { justify-content: flex-start; } }

/* ---------- Problems page ---------- */
.problem-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin-bottom: 1.75rem; }
.problem-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.problem-grid > [hidden] { display: none; }
@media (max-width: 960px) { .problem-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Test builder ---------- */
.tb-form fieldset { border: 0; padding: 0; margin: 0 0 1.75rem; }
.tb-form legend { font-family: var(--heading); font-weight: 700; font-size: 1.15rem; margin-bottom: 0.6rem; padding: 0; }
.tb-legend-note { font-family: var(--body); font-weight: 400; font-size: 0.92rem; color: var(--muted); }
.tb-chip { display: inline-flex; align-items: center; margin: 0 0.4rem 0.5rem 0; cursor: pointer; }
.tb-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tb-chip span { display: inline-block; padding: 0.45rem 0.95rem; border-radius: 999px; border: 2px solid var(--rule); background: var(--white); font-weight: 500; font-size: 0.98rem; }
.tb-chip:hover span { border-color: var(--sky); }
.tb-chip input:checked + span { background: var(--sky); border-color: var(--sky); color: var(--white); }
.tb-chip input:focus-visible + span { outline: 3px solid var(--sun); outline-offset: 2px; }
.tb-chip-chapter span { background: var(--sky-wash-2); font-weight: 700; }
.tb-chip-chapter input:checked + span { background: var(--slate); border-color: var(--slate); }
.tb-chapter { padding: 0.75rem 0 0.25rem; border-top: 1px solid var(--rule); }
.tb-chapter:first-of-type { border-top: 0; }
.tb-topic-list { padding-left: 0.25rem; }
.tb-topic-tools { margin-bottom: 0.5rem; }
.tb-link { font: inherit; font-size: 0.92rem; background: none; border: 0; color: var(--sky-deep); text-decoration: underline; cursor: pointer; padding: 0 0.6rem 0 0; }
.tb-help { color: var(--muted); font-size: 0.92rem; margin: 0.25rem 0 0; }
.tb-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.tb-error { color: var(--coral); font-weight: 700; margin: 0; }
.tb-paper-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; margin-bottom: 0.5rem; }
.tb-paper-head h2 { margin-bottom: 0.2rem; }
.tb-paper-tools { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.tb-timer { color: var(--muted); font-size: 0.92rem; margin-bottom: 1.25rem; }
.tb-list { list-style: none; margin: 0; padding: 0; counter-reset: tq; display: grid; gap: 1rem; }
.tb-q { counter-increment: tq; position: relative; max-width: none; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem 1.4rem 1.25rem 4rem; border-left: 5px solid var(--rule); }
.tb-q::before { content: counter(tq); position: absolute; left: 1.1rem; top: 1.2rem; width: 2rem; height: 2rem; border-radius: 50%; background: var(--sky-wash); color: var(--sky-deep); font-family: var(--heading); font-weight: 800; display: grid; place-items: center; }
.tb-q-olympiad { border-left-color: var(--sun); }
.tb-q.is-right { border-left-color: var(--grass); }
.tb-q.is-wrong { border-left-color: var(--coral); }
.tb-q-head { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; }
.tb-q .q { font-family: var(--heading); font-weight: 600; font-size: 1.1rem; line-height: 1.5; max-width: none; margin-bottom: 0.75rem; }
.tb-hints { margin-bottom: 0.75rem; }
.tb-hints summary { cursor: pointer; color: var(--sky-deep); font-weight: 500; }
.tb-hints .ladder-controls { margin-top: 0.25rem; }
.tb-ladder { margin-top: 0; }
.tb-answer { display: flex; align-items: center; gap: 0.75rem; }
.tb-answer label { font-weight: 700; }
.tb-answer input { font: inherit; font-size: 1.05rem; width: 12rem; max-width: 100%; padding: 0.5rem 0.7rem; border: 2px solid var(--grid); border-radius: var(--radius-sm); }
.tb-answer input:focus-visible { border-color: var(--sky); }
.tb-answer input:disabled { background: var(--sky-wash-2); color: var(--ink); }
.tb-result .feedback { margin-top: 0.75rem; }
.tb-submit { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1.5rem; }
.tb-score-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2rem; align-items: start; background: var(--sky-wash); border-radius: var(--radius); padding: 1.75rem; margin-top: 2rem; }
.tb-score-big { font-family: var(--heading); font-weight: 800; font-size: 2rem; color: var(--muted); line-height: 1; }
.tb-score-big span { font-size: 4rem; color: var(--ink); }
.tb-score-pct { font-family: var(--heading); font-weight: 700; font-size: 1.25rem; margin-bottom: 0.5rem; }
.tb-topic-table { border-collapse: collapse; margin: 0.75rem 0 1rem; font-size: 0.98rem; }
.tb-topic-table th, .tb-topic-table td { text-align: left; padding: 0.3rem 1.25rem 0.3rem 0; font-weight: 500; }
.tb-topic-table td { font-weight: 700; }
@media (max-width: 640px) { .tb-score-card { grid-template-columns: minmax(0, 1fr); } .tb-q { padding-left: 3.4rem; } .tb-q::before { left: 0.8rem; } }

/* ---------- Forms ---------- */
.compose { display: grid; gap: 0.9rem; max-width: 36rem; }
.compose label { font-weight: 700; font-size: 1rem; display: block; margin-bottom: 0.3rem; }
.compose input, .compose select, .compose textarea { width: 100%; font: inherit; font-size: 1rem; padding: 0.65rem 0.75rem; border: 2px solid var(--rule); border-radius: var(--radius-sm); background: var(--white); color: var(--ink); }
.compose textarea { min-height: 8rem; resize: vertical; }
.compose .hint { font-size: 0.88rem; color: var(--muted); margin-top: 0.25rem; }

/* ---------- Footer: slate band as the original ---------- */
.site-footer { background: var(--slate); color: var(--white); padding-block: 3rem 2rem; font-size: 1rem; }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr)); gap: 2rem; }
.footer-grid h2 { font-family: var(--heading); font-size: 1rem; font-weight: 700; color: var(--white); margin-bottom: 0.75rem; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 0.45rem; }
.footer-grid a { color: var(--sky-wash); text-decoration: none; }
.footer-grid a:hover { color: var(--white); text-decoration: underline; }
.footer-about img { width: 110px; margin-bottom: 0.75rem; }
.footer-about p { color: var(--sky-wash); max-width: 30rem; }
.footer-base { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid rgba(255,255,255,0.18); color: var(--sky-wash); font-size: 0.92rem; }
.footer-base p { margin: 0; max-width: none; }
.footer-base a { color: var(--sky-wash); }
@media (max-width: 860px) { .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .footer-about { grid-column: 1 / -1; } }

.notfound { min-height: 50vh; display: grid; align-content: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .site-footer, .btn-row, .ladder-controls, .answer-form, .tb-paper-tools, .tb-submit, .tb-timer, .nav-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .tb-q { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .tb-hints { display: none; }
  .tb-answer input { border: 1px solid #000; min-height: 2.2rem; }
}
.mb-2 { margin-bottom: 2rem; }

/* ---------- Generated question bank: no-repeat note, fresh problem ---------- */
.tb-seen { font-size: 0.92rem; color: var(--muted); margin: 0.75rem 0 0; }
.fresh-form { display: grid; gap: 1rem; margin-bottom: 1.5rem; }
.fresh-form fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.fresh-form legend { font-weight: 700; margin-bottom: 0.5rem; }
.fresh-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.fresh-row label { font-weight: 700; }
.fresh-row select { font: inherit; padding: 0.55rem 0.8rem; border-radius: var(--radius-sm); border: 1px solid var(--rule); background: var(--white); color: var(--ink); max-width: 100%; }
.fresh-out .sheet { max-width: 48rem; }

/* ---------- Optional accounts: header link, login prompt, account pages ---------- */
.site-nav .nav-account a { border: 1.5px solid rgba(255,255,255,0.35); margin-left: 0.4rem; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1000px) { .site-nav .nav-account a { border: 0; border-bottom: 1px solid rgba(255,255,255,0.1); margin-left: 0; max-width: none; } }
@media (min-width: 1001px) { .site-nav a { white-space: nowrap; } }
@media (min-width: 1001px) and (max-width: 1320px) { .site-nav a { padding-inline: 0.5rem; font-size: 0.94rem; } .site-nav .nav-cta a, .site-nav .nav-account a { margin-left: 0.25rem; } .site-nav .nav-account a { max-width: 8rem; } .site-header .wrap { gap: 0.5rem; } }

.login-ask { max-width: 30rem; width: calc(100% - 2rem); border: 0; border-radius: var(--radius); padding: 1.75rem; box-shadow: var(--shadow); color: var(--ink); background: var(--white); }
.login-ask::backdrop { background: rgba(5, 17, 31, 0.55); }
.login-ask h2 { font-size: var(--step-2); }
.login-ask .btn-row { margin-top: 1.25rem; }

.save-status { margin: 0.5rem 0 0; font-weight: 500; font-size: 0.98rem; min-height: 1.5em; }
.save-status.is-right { color: var(--grass); }
.save-status.is-wrong { color: var(--coral); }
.form-error { color: var(--coral); font-weight: 700; margin: 0; min-height: 0; }
.form-error:empty { display: none; }

.account-form { max-width: 28rem; }
.account-form .pass-row { display: flex; gap: 0.5rem; align-items: center; }
.account-form .pass-row input { flex: 1; min-width: 0; }
.account-form .consent { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.6rem; align-items: start; background: var(--sky-wash-2); padding: 0.8rem 0.9rem; border-radius: var(--radius-sm); }
.account-form .consent input { width: 1.25rem; height: 1.25rem; margin-top: 0.2rem; accent-color: var(--sky-deep); }
.account-form .consent label { font-weight: 500; margin: 0; }
.account-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; }
.account-head h2 { margin-bottom: 0.2rem; }
.account-head .tag { display: inline-block; margin: 0 0 0.4rem; font-weight: 700; font-size: 0.85rem; color: var(--sky-deep); text-transform: uppercase; letter-spacing: 0.06em; }
.account-section { margin-top: 2.5rem; }
.account-section h2 { font-size: var(--step-2); }
.account-box { margin-top: 1.25rem; border: 1px solid var(--rule); border-radius: var(--radius); padding: 0.9rem 1.2rem; background: var(--white); }
.account-box > summary { cursor: pointer; font-weight: 700; color: var(--sky-deep); }
.account-stats { list-style: none; padding: 0; margin: 0 0 1.75rem; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }
.account-stats li { background: var(--sky-wash); border-radius: var(--radius); padding: 1rem 1.1rem; max-width: none; }
.account-stats b { display: block; font-family: var(--heading); font-size: var(--step-3); line-height: 1.1; }
.account-stats span { color: var(--muted); font-size: 0.95rem; }
@media (max-width: 640px) { .account-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.account-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 2rem; }
@media (max-width: 860px) { .account-cols { grid-template-columns: minmax(0, 1fr); } }
.table-scroll { overflow-x: auto; position: relative; } /* keeps visually-hidden headers inside the scroller */
.account-table { border-collapse: collapse; width: 100%; font-size: 0.98rem; }
.account-table th, .account-table td { text-align: left; padding: 0.55rem 0.75rem 0.55rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.account-table thead th { font-size: 0.88rem; color: var(--muted); font-weight: 700; }
.account-table tbody th { font-weight: 700; }
.account-table .row-actions { white-space: nowrap; text-align: right; }
.account-table .row-actions .btn + .btn { margin-left: 0.4rem; }
.account-table tr.is-off th, .account-table tr.is-off td { color: var(--muted); }
.btn-danger { color: var(--coral); border-color: var(--coral); }
.btn-danger:hover { background: #fde8e3; color: var(--ink); border-color: var(--coral); }
.wrong-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 1.25rem; }
.wrong-list > li { max-width: 48rem; }
.wrong-answers { display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; margin: 0.75rem 0 0; }
.wrong-answers span:first-child b { color: var(--coral); }
.wrong-answers span:last-child b { color: var(--grass); }
.login-card { font-size: 1.1rem; background: var(--white); padding: 0.75rem 1rem; border-radius: var(--radius-sm); }
.mb-1 { margin-bottom: 1rem; }
@media print { .nav-account, .login-ask { display: none !important; } }

/* Image crops on the About page (classes, not style attributes, so the CSP allows them) */
.img-medals { max-height: 20rem; object-fit: cover; object-position: 50% 40%; }
.img-3-2 { aspect-ratio: 3 / 2; }

/* Hints and time per question on the account pages */
.wrong-meta { margin: 0.4rem 0 0; font-size: 0.92rem; color: var(--muted); }
.account-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qbq td, .qbq th { font-size: 0.95rem; }
.qbq .qbq-topic { display: block; font-size: 0.82rem; color: var(--sky-deep); font-weight: 700; }
.qbq .qbq-q { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 34rem; min-width: 14rem; }
.qbq td.is-right { color: var(--grass); font-weight: 700; }
.qbq td.is-wrong { color: var(--coral); font-weight: 700; }
@media (max-width: 640px) { .account-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Homework on the account page */
.hw-form .hw-fields { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); max-width: 40rem; margin-bottom: 1.5rem; }
@media (max-width: 640px) { .hw-form .hw-fields { grid-template-columns: minmax(0, 1fr); } }
.hw-form fieldset { margin-bottom: 1.25rem; }
.hw-paper { display: block; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
.hw-late { color: var(--coral); font-weight: 700; }
.account-table td.is-right { color: var(--grass); font-weight: 700; }
.account-table td.is-wrong { color: var(--coral); font-weight: 700; }
