/* qcalculate base styles. Mobile first; light and dark themes follow the visitor's system setting. */

/* ---------- Design tokens ---------- */
:root {
  /* Brand */
  --c-brand: #0f766e;          /* teal: links, primary buttons, "changed" values */
  --c-brand-strong: #115e59;
  --c-brand-soft: #ccfbf1;
  --c-on-brand: #ffffff;
  /* Step highlights: the colours the animations use to point at numbers */
  --c-accent: #f59e0b;         /* current step / main highlight (amber) */
  --c-accent-soft: #fef3c7;
  --c-accent-text: #92400e;
  --c-hl-2: #7c3aed;           /* second value (violet) */
  --c-hl-2-soft: #ede9fe;
  --c-hl-3: #e11d48;           /* third value / errors (rose) */
  --c-hl-3-soft: #ffe4e6;
  --c-good: #15803d;           /* daily puzzle: right first time (white text) */
  --c-warn: #eab308;           /* right at the second try (dark text) */
  --c-bad: #dc2626;            /* missed (white text) */
  /* Chart series: checked for colour-blind separation, chroma and contrast in both themes */
  --c-series-1: #0d9488;       /* teal: principal, the main series */
  --c-series-2: #d97706;       /* amber: interest */
  --c-series-muted: #64748b;   /* grey: comparisons */
  --c-series-3: #7c3aed;       /* violet: starting amount */
  /* Neutrals */
  --c-bg: #f8fafc;
  --c-surface: #ffffff;
  --c-surface-2: #f1f5f9;
  --c-text: #0f172a;
  --c-muted: #475569;
  --c-border: #e2e8f0;
  --c-border-strong: #cbd5e1;
  --c-focus: #2563eb;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Bengali", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.05), 0 6px 20px rgb(15 23 42 / 0.06);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --measure: 46rem;  /* reading and calculator column */
  --wide: 72rem;     /* page frame */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-brand: #2dd4bf;
    --c-brand-strong: #5eead4;
    --c-brand-soft: #134e4a;
    --c-on-brand: #042f2e;
    --c-accent: #fbbf24;
    --c-accent-soft: #422006;
    --c-accent-text: #fde68a;
    --c-hl-2: #a78bfa;
    --c-hl-2-soft: #2e1065;
    --c-hl-3: #fb7185;
    --c-hl-3-soft: #4c0519;
    --c-series-1: #14a89a;
    --c-series-2: #d97706;
    --c-series-muted: #64748b;
    --c-series-3: #8b5cf6;
    --c-bg: #0b1220;
    --c-surface: #111a2b;
    --c-surface-2: #172238;
    --c-text: #e2e8f0;
    --c-muted: #94a3b8;
    --c-border: #1e293b;
    --c-border-strong: #334155;
    --c-focus: #60a5fa;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
  }
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 var(--space-3); }
h1 { font-size: clamp(1.875rem, 1.3rem + 2.6vw, 2.75rem); font-weight: 800; }
h2 { font-size: clamp(1.375rem, 1.15rem + 1vw, 1.75rem); font-weight: 750; margin-top: var(--space-7); }
h3 { font-size: 1.125rem; font-weight: 700; }
p { margin: 0 0 var(--space-4); }
ul, ol { margin: 0 0 var(--space-4); padding-left: 1.4em; }
li + li { margin-top: var(--space-1); }

a { color: var(--c-brand); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { color: var(--c-brand-strong); }

:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; border-radius: 4px; }

code, kbd, .mono { font-family: var(--font-mono); font-size: 0.95em; }

.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: 10;
  background: var(--c-surface); color: var(--c-text);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.skip-link:focus { top: var(--space-4); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.container { width: 100%; max-width: var(--wide); margin-inline: auto; padding-inline: var(--space-4); }
.narrow { max-width: calc(var(--measure) + 2 * var(--space-4)); }

.muted { color: var(--c-muted); }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--c-text); text-decoration: none; }
.brand:hover { color: var(--c-text); }
.brand__mark { width: 32px; height: 32px; flex: none; }
.brand__mark-bg { fill: var(--c-brand); }
.brand__mark-q { fill: none; stroke: var(--c-on-brand); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.brand__name { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.03em; }
.brand__q { color: var(--c-brand); }
.brand--small .brand__mark { width: 24px; height: 24px; }
.brand--small .brand__name { font-size: 1.05rem; }

/* ---------- Header and footer ---------- */
.site-header { background: var(--c-surface); border-bottom: 1px solid var(--c-border); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 64px; }
.site-header__nav { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.site-header__nav a { color: var(--c-text); font-weight: 650; font-size: 0.95rem; text-decoration: none; }
.site-header__nav a:hover { color: var(--c-brand); text-decoration: underline; }
.site-header__nav .nav-wide { display: none; }
@media (min-width: 600px) { .site-header__nav .nav-wide { display: inline; } .site-header__nav .nav-narrow { display: none; } }
.site-header__nav { align-items: center; }
.site-header__nav .lang-switch { padding: 2px 10px; border: 1.5px solid var(--c-border-strong); border-radius: 999px; font-size: 0.85rem; font-weight: 700; }
/* Number style switch on pages in languages that write decimals with a comma */
.number-style { display: inline-flex; gap: 2px; padding: 2px; margin: 0 0 var(--space-3); border-radius: 999px; background: var(--c-surface-2); font-size: 0.85rem; }
.number-style button { min-height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--c-muted); font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; }
.number-style button[aria-pressed="true"] { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow); }
.switch-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.site-footer { margin-top: var(--space-8); border-top: 1px solid var(--c-border); background: var(--c-surface); color: var(--c-muted); font-size: 0.95rem; }
.site-footer__inner { padding-block: var(--space-6); }
.site-footer__inner p { margin: var(--space-2) 0 0; }
.site-footer__copy { font-size: 0.875rem; }
.site-footer__links { list-style: none; padding: 0; margin: var(--space-4) 0 0; display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.site-footer__links li { margin: 0; }
.site-footer__links a { color: var(--c-muted); }
.site-footer__links a:hover { color: var(--c-brand); }

/* ---------- Text pages (About, Privacy …) and long-form sections ---------- */
.page-prose { padding-top: var(--space-6); }
.prose h2 { margin-top: var(--space-6); }
.prose h3 { margin-top: var(--space-5); }
.prose li + li { margin-top: var(--space-2); }
.prose code { padding: 1px 6px; border-radius: 6px; background: var(--c-surface-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: 0 var(--space-4);
  border: 1px solid var(--c-border-strong); border-radius: 999px;
  background: var(--c-surface); color: var(--c-text);
  font: inherit; font-size: 0.95rem; font-weight: 650; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--c-brand); color: var(--c-text); }
.btn--primary { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); }
.btn--primary:hover { background: var(--c-brand-strong); border-color: var(--c-brand-strong); color: var(--c-on-brand); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--small { min-height: 36px; padding: 0 var(--space-3); font-size: 0.875rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- Cards, tags, grids ---------- */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--space-4);
}
@media (min-width: 640px) { .card { padding: var(--space-5); } }
.card > :last-child { margin-bottom: 0; }

.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--c-surface-2); color: var(--c-muted);
  font-size: 0.8rem; font-weight: 650; white-space: nowrap;
}
.tag--soon { background: var(--c-accent-soft); color: var(--c-accent-text); }
.tag--brand { background: var(--c-brand-soft); color: var(--c-brand-strong); }
.tag--wrap { white-space: normal; border-radius: 12px; }
a.tag { text-decoration: none; }
a.tag:hover { text-decoration: underline; }

.grid { display: grid; gap: var(--space-4); }
@media (min-width: 720px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } .grid--2 { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Home page ---------- */
.hero { padding-block: var(--space-7) var(--space-5); }
.hero h1 { max-width: 18ch; }
.hero h1 em { font-style: normal; color: var(--c-brand); }
.eyebrow { margin: 0 0 var(--space-3); color: var(--c-brand); font-weight: 750; font-size: 0.875rem; letter-spacing: 0.06em; text-transform: uppercase; }
.lead { font-size: clamp(1.0625rem, 1rem + 0.4vw, 1.25rem); color: var(--c-muted); max-width: 40rem; }

.feature h3 { margin-top: var(--space-2); }
.feature__icon {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--c-brand-soft); color: var(--c-brand-strong); font-weight: 800;
}

.calc-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.calc-category { margin: var(--space-6) 0 var(--space-3); font-size: 1.1rem; }
.calc-category a { color: var(--c-text); text-decoration: none; }
.calc-category a:hover { color: var(--c-brand); text-decoration: underline; }
.calc-search { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-3); }
.calc-search h2 { margin: 0; }
.calc-search__box input {
  width: min(22rem, 100%); min-height: 44px; padding: 0 var(--space-4); border: 1.5px solid var(--c-border-strong); border-radius: 999px;
  background: var(--c-surface); color: var(--c-text); font: inherit;
}
.calc-search__box input:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--c-brand-soft); }
.calc-search__box { flex: 0 1 22rem; }
@media (min-width: 720px) { .calc-list { grid-template-columns: repeat(2, 1fr); } }
.calc-list li { margin: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.calc-list strong { display: block; }
.calc-list span.muted { font-size: 0.95rem; }

/* ---------- Example steps (home) and step lists ---------- */
.example { display: grid; gap: var(--space-5); align-items: center; }
@media (min-width: 860px) { .example { grid-template-columns: 1.1fr 1fr; } }
.example__title { margin-top: 0; }
.example__caption { text-align: center; margin: var(--space-3) 0 0; }
.example__more { margin: var(--space-4) 0 0; font-weight: 650; }
.calc-list__live strong a { color: var(--c-text); }
.calc-list__live strong a:hover { color: var(--c-brand); }
.hero__actions { margin: var(--space-5) 0 var(--space-4); }

.step-list { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.step-list > li {
  counter-increment: step; position: relative; margin: 0;
  padding: var(--space-3) var(--space-4) var(--space-3) 52px;
  border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-surface);
}
.step-list > li::before {
  content: counter(step); position: absolute; left: var(--space-3); top: var(--space-3);
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--c-surface-2); color: var(--c-muted); font-weight: 750; font-size: 0.875rem;
}
.step-list > li[aria-current="step"] { border-color: var(--c-accent); background: var(--c-accent-soft); }
.step-list > li[aria-current="step"]::before { background: var(--c-accent); color: #1f2937; }
.step-list__title { display: block; font-weight: 700; }
.step-list__math { display: block; margin-top: var(--space-1); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Highlighted numbers inside step text */
.num { font-variant-numeric: tabular-nums; font-weight: 700; padding: 0 3px; border-radius: 4px; }
.num--a { background: var(--c-accent-soft); color: var(--c-accent-text); }
.num--b { background: var(--c-hl-2-soft); color: var(--c-hl-2); }
.num--c { background: var(--c-brand-soft); color: var(--c-brand-strong); }

/* SVG drawing colours (used by step animations) */
.svg-track { fill: var(--c-surface-2); stroke: var(--c-border-strong); }
.svg-fill-a { fill: var(--c-accent); }
.svg-line { stroke: var(--c-border-strong); }
.svg-text { fill: var(--c-text); font: 600 16px var(--font); }
.svg-text--muted { fill: var(--c-muted); font-weight: 500; }
.svg-text--strong { font-weight: 800; font-size: 18px; }

/* The animation stage: where a step's picture is drawn */
.stage { padding: var(--space-4); border-radius: var(--radius-sm); background: var(--c-surface-2); }
.stage svg { display: block; width: 100%; max-width: 520px; margin-inline: auto; }

/* ---------- Calculator page ---------- */
.calc-page { padding-top: var(--space-5); }
.breadcrumb { font-size: 0.875rem; color: var(--c-muted); margin-bottom: var(--space-3); }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.breadcrumb li { margin: 0; }
.breadcrumb li + li::before { content: "›"; margin-right: var(--space-2); }
.calc-intro { color: var(--c-muted); font-size: 1.125rem; }

.calc-card { padding: var(--space-4); }
@media (min-width: 640px) { .calc-card { padding: var(--space-5); } }

.segmented { display: flex; flex-wrap: wrap; gap: var(--space-1); padding: var(--space-1); margin-bottom: var(--space-4); background: var(--c-surface-2); border-radius: 12px; }
.segmented button {
  flex: 1 0 auto; min-height: 40px; padding: 0 var(--space-3);
  border: 0; border-radius: 9px; background: transparent; color: var(--c-muted);
  font: inherit; font-size: 0.9rem; font-weight: 650; cursor: pointer; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow); }

.sentence-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: 1.25rem; font-weight: 600; }
.field { display: grid; gap: var(--space-1); }
.field label { font-size: 0.875rem; font-weight: 650; color: var(--c-muted); }
.input-wrap { display: flex; align-items: center; border: 1.5px solid var(--c-border-strong); border-radius: 10px; background: var(--c-surface); }
.input-wrap:focus-within { border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--c-brand-soft); }
.input-wrap input {
  width: 7.5ch; min-height: 48px; padding: 0 var(--space-3); border: 0; background: transparent;
  color: var(--c-text); font: inherit; font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.input-wrap input:focus { outline: none; }
.input-wrap .unit { padding-right: var(--space-3); color: var(--c-muted); font-weight: 650; }
.select-wrap select {
  min-height: 48px; padding: 0 var(--space-3); border: 1.5px solid var(--c-border-strong); border-radius: 10px;
  background: var(--c-surface); color: var(--c-text); font: inherit; font-size: 1.125rem; font-weight: 700; cursor: pointer;
}
.select-wrap select:focus-visible { border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--c-brand-soft); outline: none; }

.result {
  margin-top: var(--space-4); padding: var(--space-4); border-radius: var(--radius-sm);
  background: var(--c-brand-soft); color: var(--c-text);
}
.result__label { font-size: 0.875rem; font-weight: 650; color: var(--c-brand-strong); margin: 0; }
.result__value { font-size: clamp(2rem, 1.6rem + 2vw, 2.75rem); font-weight: 800; line-height: 1.1; margin: var(--space-1) 0; font-variant-numeric: tabular-nums; }
.result__sentence { margin: 0; }

/* Step player */
.player { margin-top: var(--space-5); padding: var(--space-4); }
@media (min-width: 640px) { .player { padding: var(--space-5); } }
.player__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: var(--space-2); }
.player__head h2 { margin: 0; font-size: 1.25rem; }
.player__count { color: var(--c-muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.player .stage { margin: var(--space-4) 0; min-height: 160px; display: grid; place-items: center; overflow: hidden; }
.player .stage > * { width: 100%; }
.player__math { margin-top: var(--space-2); font-size: 1.1rem; overflow-x: auto; overflow-y: hidden; }
.player__math .katex-display { margin: var(--space-2) 0; }
.player__why { margin-top: var(--space-3); }
.player__why summary { cursor: pointer; font-weight: 650; color: var(--c-brand); }
.player__why p { margin: var(--space-2) 0 0; }
.player__all { margin-top: var(--space-4); }
.player__tip { margin: var(--space-4) 0 0; font-size: 0.875rem; }
.player__controls button:disabled { opacity: 0.45; cursor: default; }

/* Step list items are buttons, so any step can be opened */
.step-list__btn {
  display: block; width: 100%; margin: 0; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.step-list__text { display: block; }
.step-list__math { overflow-x: auto; overflow-y: hidden; }

/* Stage: default formula view */
.stage-formula { text-align: center; font-size: 1.35rem; overflow-x: auto; overflow-y: hidden; }
.stage-badge { display: inline-block; margin-bottom: var(--space-2); padding: 2px 12px; border-radius: 999px; background: var(--c-brand-soft); color: var(--c-brand-strong); font-size: 0.875rem; font-weight: 750; }
.stage-bar { display: block; width: 100%; max-width: 520px; margin-inline: auto; }
.svg-text--check { fill: var(--c-brand); font-weight: 800; font-size: 22px; }
.svg-fill-base { fill: var(--c-muted); opacity: 0.35; }
.svg-fill-up { fill: var(--c-brand); }
.svg-cut { fill: var(--c-hl-3-soft); stroke: var(--c-hl-3); stroke-width: 1.5; stroke-dasharray: 5 4; }
.svg-text--up { fill: var(--c-brand-strong); }
.svg-text--down { fill: var(--c-hl-3); }

/* Stage: decimal point moving */
.shift { text-align: center; }
.shift__number { display: inline-block; font-family: var(--font-mono); font-size: clamp(2.25rem, 1.6rem + 3vw, 3.25rem); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.shift__point { display: inline-block; color: var(--c-accent); }
.shift__point--pop { animation: qc-pop 450ms cubic-bezier(.2,.7,.2,1); }
.shift__caption { margin: var(--space-2) 0 0; color: var(--c-muted); }
@keyframes qc-pop { from { transform: translateY(-0.45em) scale(1.7); opacity: 0.2; } to { transform: none; opacity: 1; } }

/* Series colours: each mark takes var(--c) from its series class */
.c-s1, .c-saved { --c: var(--c-series-1); }
.c-s2, .c-extra { --c: var(--c-series-2); }
.c-s3 { --c: var(--c-series-3); }
.c-muted { --c: var(--c-series-muted); }

/* Stage and results: one bar split into parts (interest vs. principal …) */
.split { width: 100%; max-width: 520px; margin-inline: auto; }
.split__title { margin: 0 0 var(--space-2); font-weight: 700; }
.split__check { color: var(--c-brand); }
.split__bar { display: flex; gap: 2px; height: 24px; transform-origin: left center; }
.split__seg { flex: 1 1 0; min-width: 3px; background: var(--c); }
.split__seg:last-child { border-radius: 0 4px 4px 0; }
.split__seg.c-saved, .c-saved .split__key { background: var(--c-brand-soft); outline: 1.5px dashed var(--c); outline-offset: -1.5px; }
.split__seg.c-extra, .c-extra .split__key { background: var(--c-accent-soft); outline: 1.5px dashed var(--c); outline-offset: -1.5px; }
.split__legend { list-style: none; padding: 0; margin: var(--space-3) 0 0; display: grid; gap: var(--space-1); }
.split__legend li { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: var(--space-2); }
.split__key { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; align-self: center; }
.split__legend strong { font-variant-numeric: tabular-nums; }
.split__share { color: var(--c-muted); }

/* Factor tree and prime Venn diagram */
.factor-tree { max-width: 520px; }
.factor-tree__prime { fill: var(--c-brand-soft); stroke: var(--c-series-1); stroke-width: 2; }
.factor-tree__prime--done { fill: var(--c-accent-soft); stroke: var(--c-series-2); }
.repeat-cancel text { font-size: 24px; }
.repeat-cancel .repeat-cancel__label { font-size: 19px; }
.repeat-cancel__box { fill: var(--c-accent-soft); }
.repeat-cancel__tail { transition: opacity 0.4s ease-out; }
.repeat-cancel__tail.is-cancelled { opacity: 0.35; }
.repeat-cancel__strike { stroke: var(--c-hl-3); stroke-width: 3; stroke-linecap: round; }
.ladder__head { font-size: 13px; }
.ladder__rem--read { fill: var(--c-brand-strong); }
.ladder__arrow-line { stroke: var(--c-accent); stroke-width: 3; }
.ladder__arrow-head { fill: var(--c-accent); }
.ladder__answer { fill: var(--c-brand-strong); font-size: 20px; }
.place-values__cell { fill: var(--c-accent-soft); stroke: var(--c-accent); }
.place-values__value { font-size: 13px; }
.place-values__digit { font-size: 22px; }
.bit-groups__box { fill: var(--c-surface-2); stroke: var(--c-border-strong); }
.bit-groups__digit { fill: var(--c-brand-strong); font-size: 22px; }
.pyth__square path { stroke-width: 2; }
.pyth__square--a path { fill: var(--c-series-1); fill-opacity: 0.2; stroke: var(--c-series-1); }
.pyth__square--b path { fill: var(--c-series-2); fill-opacity: 0.2; stroke: var(--c-series-2); }
.pyth__square--c path { fill: var(--c-series-3); fill-opacity: 0.2; stroke: var(--c-series-3); }
.pyth__square--ghost path { fill-opacity: 0; stroke-dasharray: 6 5; opacity: 0.6; }
.pyth__triangle { fill: var(--c-surface); stroke: var(--c-text); stroke-width: 2.5; stroke-linejoin: round; }
.pyth__right { fill: none; stroke: var(--c-text); stroke-width: 1.5; }
.pyth__label { font-size: 14px; }
.pyth .svg-text { paint-order: stroke; stroke: var(--c-surface); stroke-width: 3px; }
.roof__walls { fill: var(--c-surface-2); stroke: var(--c-border-strong); stroke-width: 1.5; }
.roof__roof { fill: var(--c-series-2); fill-opacity: 0.16; stroke: var(--c-text); stroke-width: 2.5; stroke-linejoin: round; }
.roof__measure { stroke: var(--c-muted); stroke-width: 2; }
.roof__measure--dashed { stroke-dasharray: 5 4; }
.roof__rafter { stroke: var(--c-text); stroke-width: 2.5; }
.roof__arc { fill: none; stroke: var(--c-muted); stroke-width: 2; }
.roof__dim { stroke: var(--c-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.roof__focus.roof__measure, .roof__focus.roof__rafter, .roof__focus.roof__arc { stroke: var(--c-accent); stroke-width: 4; }
.roof__symbol path { fill: none; stroke: var(--c-muted); stroke-width: 1.5; }
.roof__symbol.roof__focus path { stroke: var(--c-accent); stroke-width: 2.5; }
.roof__label { font-size: 14px; }
.roof__small { font-size: 12px; }
.roof .svg-text { paint-order: stroke; stroke: var(--c-surface); stroke-width: 3px; }
.date-span__seg { fill: var(--c); fill-opacity: 0.85; }
.date-span__date { font-size: 13px; }
.date-span__label { font-size: 13px; }
.tri__part { stroke: var(--c-text); stroke-width: 2; stroke-linejoin: round; }
.tri__part--use { fill: var(--c-brand-soft); }
.tri__part--find { fill: var(--c-accent-soft); }
.tri__letter { fill: var(--c-text); font: 800 30px var(--font); }
.tri__cover { fill: var(--c-accent); stroke: var(--c-surface); stroke-width: 3; }
.tri__covered { fill: #0f172a; font: 800 30px var(--font); }
.tri__bar { stroke: var(--c-accent); stroke-width: 5; stroke-linecap: round; }
.tri__op-dot { fill: var(--c-surface); stroke: var(--c-accent); stroke-width: 3; }
.tri__times { fill: var(--c-text); font: 800 24px var(--font); }
.tri__legend { font-size: 13px; }
.uc { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 12px; padding: 22px 8px; font-size: 1.2rem; font-weight: 700; }
.uc__term, .uc__top, .uc__bottom { display: inline-flex; gap: 5px; align-items: baseline; white-space: nowrap; }
.uc__frac { display: inline-flex; flex-direction: column; align-items: center; }
.uc__top { padding: 0 8px 5px; border-bottom: 2px solid var(--c-text); }
.uc__bottom { padding: 5px 8px 0; }
.uc__unit { position: relative; color: var(--c-brand); }
.uc__unit--gone { color: var(--c-muted); }
.uc__strike { position: absolute; left: -3px; right: -3px; top: 55%; height: 2.5px; background: var(--c-hl-3); border-radius: 2px; transform-origin: left center; }
.uc__op { color: var(--c-muted); font-weight: 600; }
.uc__result { background: var(--c-accent-soft); border-radius: 8px; padding: 4px 10px; }
.thermo__tube { fill: var(--c-surface); stroke: var(--c-border-strong); stroke-width: 2; }
.thermo__bulb { fill: var(--c-surface); stroke: var(--c-border-strong); stroke-width: 2; }
.thermo__mercury { fill: var(--c-hl-3); }
.thermo__tick { stroke: var(--c-muted); stroke-width: 1.5; }
.thermo__value { stroke: var(--c-accent); stroke-width: 3; stroke-linecap: round; }
.thermo__label { font-size: 13px; }
.thermo__small { font-size: 11px; }
.thermo__reading { font-size: 16px; font-weight: 800; }
.thermo .svg-text { paint-order: stroke; stroke: var(--c-surface); stroke-width: 3px; }
.units-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--space-2); align-items: end; }
.units-pair__side { display: grid; gap: var(--space-1); min-width: 0; }
.units-pair__swap { min-height: 44px; min-width: 44px; font-size: 1.15rem; }
@media (max-width: 480px) { .units-pair { grid-template-columns: 1fr; } .units-pair__swap { justify-self: center; } }
.units-others { margin-top: var(--space-3); }
.units-others summary { cursor: pointer; font-weight: 650; color: var(--c-brand); }
.units-others .table { margin-top: var(--space-2); }
.formula-line { font-weight: 650; padding: var(--space-2) var(--space-3); background: var(--c-surface-2); border-radius: 8px; overflow-x: auto; }
.venn__circle { fill: none; stroke: var(--c-series-muted); stroke-width: 2; }
.venn__circle--on { fill: var(--c-brand-soft); stroke: var(--c-series-1); }
.venn__middle { fill: transparent; }
.venn__middle--on { fill: var(--c-accent-soft); }

/* Ratio calculator: the terms in a row with colons between them */
.ratio-form { display: grid; gap: var(--space-4); }
.ratio-set { min-width: 0; margin: 0; padding: 0; border: 0; }
.ratio-set legend { margin-bottom: var(--space-1); padding: 0; font-size: 0.875rem; font-weight: 650; color: var(--c-muted); }
.ratio-row { display: flex; align-items: center; gap: var(--space-2); }
.ratio-row .input-wrap { flex: 1 1 0; min-width: 0; }
.ratio-row .input-wrap input { width: 100%; min-width: 0; padding: 0 var(--space-2); text-align: center; }
.ratio-colon { flex: none; font-size: 1.5rem; font-weight: 800; color: var(--c-muted); }
.ratio-row--words { flex-wrap: wrap; font-weight: 650; }
.ratio-row--words .input-wrap { flex: 0 1 6.5rem; }
.ratio-kind { margin-top: var(--space-3); }

/* Ratio bars: one bar per ratio, split into its terms */
.ratio-bars { width: 100%; max-width: 520px; margin-inline: auto; }
.ratio-bars__title { margin: 0 0 var(--space-3); font-weight: 700; text-align: center; }
.ratio-bars__list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.ratio-bars__row { margin: 0; display: grid; gap: 4px; }
.ratio-bars__label { font-weight: 700; font-variant-numeric: tabular-nums; }
.ratio-bars__bar { display: flex; gap: 2px; height: 26px; transform-origin: left center; }
.ratio-bars__seg { flex: 1 1 0; min-width: 3px; background: var(--c); }
.ratio-bars__seg:first-child { border-radius: 4px 0 0 4px; }
.ratio-bars__seg:last-child { border-radius: 0 4px 4px 0; }

/* Tax bands: each band's income as a bar on one shared scale, with the tax part darker */
.bands { width: 100%; max-width: 560px; margin-inline: auto; }
.bands__title { margin: 0 0 var(--space-2); font-weight: 700; }
.bands__list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.bands__row { margin: 0; }
.bands__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); font-size: 0.9rem; }
.bands__sum { color: var(--c-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bands__tax { font-variant-numeric: tabular-nums; white-space: nowrap; }
.bands__track { height: 14px; margin-top: 3px; border-radius: 4px; background: var(--c-surface); overflow: hidden; }
.bands__seg { display: block; height: 100%; min-width: 3px; border-radius: 0 4px 4px 0; background: var(--c); transform-origin: left center; }
.bands__taxed { display: block; height: 100%; background: var(--c); transform-origin: left center; }
.bands__total { margin: var(--space-3) 0 0; }

/* Stage: a small chart with a caption */
.stage-chart { width: 100%; }
.stage-caption { margin: var(--space-2) 0 0; text-align: center; color: var(--c-muted); font-size: 0.9rem; }
.svg-area { fill: var(--c); fill-opacity: 0.12; }
.svg-series-line { fill: none; stroke: var(--c); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.svg-dot { fill: var(--c); stroke: var(--c-surface-2); stroke-width: 2; }
.svg-series { fill: var(--c); }
.stage-legend { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-4); font-size: 0.875rem; color: var(--c-muted); }
.stage-legend li { margin: 0; display: inline-flex; align-items: center; gap: var(--space-2); }

/* GPA course rows: name on its own line on phones, all in one line on wider screens */
.gpa-form { display: grid; gap: var(--space-3); justify-items: start; }
.gpa-rows { width: 100%; list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-3); }
.gpa-row { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: var(--space-2); align-items: center; }
.gpa-row .gpa-name { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .gpa-row { grid-template-columns: minmax(0, 1fr) auto auto auto auto; }
  .gpa-row .gpa-name { grid-column: auto; }
}
.gpa-row .input-wrap input { min-height: 44px; font-size: 1rem; }
.gpa-row .select-wrap select { min-height: 44px; font-size: 1rem; }
.gpa-row .gpa-credits input { width: 4ch; }
.gpa-row .select-wrap select { width: 100%; }
.gpa-level { display: none; }
.gpa-form--weighted .gpa-level { display: block; }
.gpa-remove { min-width: 40px; padding: 0; }
/* Subject rows (CGPA page): name, marks and remove on one line */
.gpa-rows .gpa-row--subject { grid-template-columns: minmax(0, 1fr) 5.5rem auto; }
.gpa-rows .gpa-row--subject .gpa-name { grid-column: auto; }
.gpa-row--subject .gpa-credits input { width: 100%; }
.gpa-form > .loan-form { width: 100%; }
.gpa-previous { width: 100%; }
.gpa-previous summary { cursor: pointer; font-weight: 650; color: var(--c-brand); }
.gpa-previous[open] summary { margin-bottom: var(--space-3); }
.table--compact th, .table--compact td { text-align: left; }

/* Long answers such as quadratic roots */
.result__value--long { font-size: clamp(1.4rem, 1.1rem + 1.6vw, 2rem); overflow-wrap: anywhere; }
.quad-form .input-wrap input { width: 5.5ch; }

/* Four results side by side (mean, median, mode, range) */
.averages { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); margin: 0 0 var(--space-3); }
@media (min-width: 560px) { .averages { grid-template-columns: repeat(4, 1fr); } }
.averages dt { font-size: 0.875rem; font-weight: 650; color: var(--c-brand-strong); }
.averages dd { margin: 0; font-size: clamp(1.4rem, 1.1rem + 1.5vw, 2rem); font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* A pasted list of numbers */
.stats-form .field > span { font-size: 0.875rem; font-weight: 650; color: var(--c-muted); }
.stats-form textarea {
  width: 100%; min-height: 110px; padding: var(--space-3); border: 1.5px solid var(--c-border-strong); border-radius: 10px;
  background: var(--c-surface); color: var(--c-text); font: 600 1.1rem/1.5 var(--font-mono); resize: vertical;
}
.stats-form textarea:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--c-brand-soft); }
.stats-form textarea[aria-invalid="true"] { border-color: var(--c-hl-3); }

/* Fraction inputs: an optional whole number beside a stacked numerator and denominator */
.fraction-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.frac-input { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; padding: 0; border: 0; min-width: 0; }
.frac-input__stack { display: inline-flex; flex-direction: column; align-items: stretch; gap: 5px; }
.frac-input__bar { height: 3px; border-radius: 2px; background: var(--c-text); }
.frac-input .input-wrap input { width: 5.5ch; min-height: 44px; text-align: center; }
.frac-input .input-wrap--whole input { width: 4ch; }
.frac-op { padding: 0 var(--space-1); font-size: 2rem; font-weight: 700; }
.fraction-hint { margin: var(--space-3) 0 0; font-size: 0.875rem; }
/* A stacked fraction in an answer */
.result__value--frac { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1em 0.25em; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: 0.72em; line-height: 1.1; }
.frac__n { padding: 0 0.15em; border-bottom: 0.09em solid currentColor; }
.frac__d { padding: 0 0.15em; }
.frac-eq { color: var(--c-muted); font-weight: 600; }
.frac-decimal { font-size: 0.72em; }

/* Answers: a small R for remainders, a bar over repeating digits */
.result__r { font-size: 0.55em; font-weight: 750; color: var(--c-muted); }
.repeat { text-decoration-line: overline; text-decoration-thickness: 0.07em; }

/* A long division written out as text in the page content */
.ld-figure { margin: 0 0 var(--space-4); }
.ld-figure pre { display: inline-block; margin: 0; padding: var(--space-3) var(--space-5); border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-surface); font: 650 1.15rem/1.35 var(--font-mono); }
.ld-figure figcaption { margin-top: var(--space-2); color: var(--c-muted); font-size: 0.9rem; }

/* Stage: fractions */
.fr-a { fill: var(--c-accent); }
.fr-b { fill: var(--c-hl-2); }
.fr-c { fill: var(--c-series-1); }
.fr-soft { opacity: 0.35; }
.fr-track { fill: var(--c-surface); stroke: var(--c-border-strong); stroke-width: 1.5; }
.fr-divider { stroke: var(--c-border-strong); stroke-width: 1.5; }
.fr-outline { fill: none; stroke: var(--c-border-strong); stroke-width: 1.5; }

/* Stage: the deviation table for standard deviation */
.st-wrap { width: 100%; max-height: 420px; overflow: auto; }
.st-table { margin-inline: auto; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.95rem; }
.st-table th, .st-table td { padding: 4px 14px; text-align: right; border-bottom: 1px solid var(--c-border); white-space: nowrap; }
.st-table thead th { font-weight: 750; color: var(--c-muted); }
.st-table .st-now { background: var(--c-accent-soft); color: var(--c-accent-text); font-weight: 700; }
.st-table tfoot th, .st-table tfoot td { border-bottom: 0; border-top: 2px solid var(--c-border-strong); font-weight: 750; }
.st-table .st-total { background: var(--c-brand-soft); color: var(--c-brand-strong); }
.st-table .st-name { text-align: left; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
.st-table--gpa { font-size: 0.875rem; }
.st-table--gpa th, .st-table--gpa td { padding: 4px 8px; }

/* Stage: numbers as chips (mean, median, mode, range) */
.chips-wrap { width: 100%; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip-num { min-width: 2.6em; padding: 6px 10px; border: 1.5px solid var(--c-border-strong); border-radius: 10px; background: var(--c-surface); text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-num--a { background: var(--c-accent-soft); border-color: var(--c-accent); color: var(--c-accent-text); }
.chip-num--b { background: var(--c-hl-2-soft); border-color: var(--c-hl-2); color: var(--c-hl-2); }
.chip-num--c { background: var(--c-brand-soft); border-color: var(--c-brand); color: var(--c-brand-strong); }
.chip-gap { align-self: center; color: var(--c-muted); }

/* Stage: the normal curve */
.nc-mark { stroke: var(--c-accent-text); stroke-width: 2; stroke-dasharray: 4 3; }
.nc-tick { font-size: 13px; }
.nc-area { fill-opacity: 0.28; }

/* Stage: a parabola */
.pb-axis { stroke: var(--c-border-strong); stroke-width: 1.5; }
.pb-symmetry { stroke: var(--c-hl-2); stroke-width: 1.5; stroke-dasharray: 4 4; }
.pb-label { font-size: 14px; }

/* Stage: polynomial long division and the synthetic division table */
.pd-wrap { width: 100%; overflow-x: auto; }
.pd, .sd { margin-inline: auto; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.pd td, .pd th { padding: 4px 8px; text-align: right; white-space: nowrap; }
.pd .pd__label { color: var(--c-muted); font-weight: 600; text-align: right; }
.pd__dividend td { border-top: 2px solid var(--c-text); font-weight: 700; }
.pd__dividend .pd__label { color: var(--c-text); font-weight: 700; }
.pd .pd__line { border-top: 1.5px solid var(--c-text); }
.pd-now-a { background: var(--c-accent-soft); color: var(--c-accent-text); font-weight: 700; border-radius: 6px; }
.pd-now-b { background: var(--c-hl-2-soft); color: var(--c-hl-2); font-weight: 700; }
.pd-now-c { background: var(--c-brand-soft); color: var(--c-brand-strong); font-weight: 700; }
.sd td, .sd th { min-width: 2.6em; padding: 6px 10px; text-align: center; }
.sd .sd__r { border-right: 2px solid var(--c-text); font-weight: 750; }
.sd__sums td, .sd__sums th { border-top: 2px solid var(--c-text); font-weight: 750; }
.sd .sd__remainder { border-left: 2px solid var(--c-text); }
.sd .sd__product { color: var(--c-muted); }

/* Stage: long division written out */
.ld-wrap { width: 100%; max-height: 440px; overflow: auto; text-align: center; }
.stage svg.ld { display: inline-block; width: auto; max-width: none; height: auto; margin: 0; }
.ld-text { font: 650 22px var(--font-mono); fill: var(--c-text); font-variant-numeric: tabular-nums; }
.ld-text--muted, .ld-text--added { fill: var(--c-muted); }
.ld-text--a { fill: var(--c-accent-text); }
.ld-text--b { fill: var(--c-hl-2); }
.ld-text--c { fill: var(--c-brand-strong); }
.ld-hl-a { fill: var(--c-accent-soft); }
.ld-hl-b { fill: var(--c-hl-2-soft); }
.ld-hl-c { fill: var(--c-brand-soft); }
.ld-line { fill: none; stroke: var(--c-text); stroke-width: 2; stroke-linecap: round; }
.ld-line--repeat { stroke: var(--c-accent-text); stroke-width: 2.5; }
.ld-arrow { fill: none; stroke: var(--c-muted); stroke-width: 1.5; stroke-dasharray: 3 3; }
.ld-arrow--head { stroke-dasharray: none; }

/* Step player in full screen (projector mode) */
.player:fullscreen { overflow: auto; padding: var(--space-6); background: var(--c-surface); }
.player:fullscreen .stage { min-height: 55vh; }
.player:fullscreen .ld-wrap { max-height: 70vh; }
.player:fullscreen .player__now { font-size: 1.35rem; }
.player:fullscreen .player__all, .player:fullscreen .player__tip { display: none; }

/* Input errors */
.field-error { margin: var(--space-2) 0 0; color: var(--c-hl-3); font-size: 0.9rem; font-weight: 600; }
.input-wrap:has(input[aria-invalid="true"]) { border-color: var(--c-hl-3); }
[hidden] { display: none !important; }
.player__now { min-height: 4.5em; }
.player__now h3 { margin-bottom: var(--space-1); }
.player__controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-4) 0; }
.player__controls select { min-height: 36px; border-radius: 999px; border: 1px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-text); font: inherit; font-size: 0.875rem; padding: 0 var(--space-3); }
.player details > summary { cursor: pointer; font-weight: 650; color: var(--c-brand); }
.player details[open] > summary { margin-bottom: var(--space-3); }

.actions { margin-top: var(--space-4); }
/* Results that belong to an earlier input, while the current one has an error */
.is-stale { opacity: 0.4; filter: grayscale(0.7); transition: opacity 0.2s; }

/* ---------- Form of labelled fields (loan calculator) ---------- */
.loan-form { display: grid; gap: var(--space-4); }
@media (min-width: 560px) { .loan-form { grid-template-columns: 1fr 1fr; } }
.field-row { display: flex; gap: var(--space-2); }
.input-wrap--grow { flex: 1; min-width: 0; }
.input-wrap--grow input { width: 100%; min-width: 0; }
.input-wrap .unit { white-space: nowrap; }
.field__optional { font-weight: 500; }
@media (min-width: 560px) { .field--wide { grid-column: 1 / -1; } }
.select-wrap--full, .select-wrap--full select { width: 100%; }
.loan-form .field { min-width: 0; }
fieldset.field { margin: 0; padding: 0; border: 0; }
fieldset.field > legend { padding: 0; margin-bottom: var(--space-1); font-size: 0.875rem; font-weight: 650; color: var(--c-muted); }
.fdp-help { margin: var(--space-3) 0 0; font-size: 0.875rem; }
.nb-swap { margin-top: var(--space-3); }
.check { display: flex; align-items: center; gap: var(--space-2); font-size: 0.95rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--c-brand); flex: none; }
.loan-form .check { grid-column: 1 / -1; }
.result__value--long { overflow-wrap: anywhere; }
.stats--bases dd { overflow-wrap: anywhere; }
@media (min-width: 640px) { .stats--bases .stats__item:first-child { grid-column: 1 / -1; } }
.select-wrap select { max-width: 100%; }

/* Totals under the answer */
.stats { display: grid; gap: var(--space-2); margin: var(--space-4) 0 0; }
.stats__item { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--c-border); border-radius: var(--radius-sm); }
.stats dt { font-size: 0.875rem; font-weight: 650; color: var(--c-muted); }
.stats dd { margin: 0; font-size: 1.15rem; font-weight: 750; text-align: right; }
.stats__sub { display: block; font-size: 0.8rem; font-weight: 600; color: var(--c-muted); }
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(3, 1fr); gap: var(--space-3); }
  .stats__item { display: block; padding: var(--space-3); }
  .stats dd { text-align: left; }
}
.stats__note { margin: var(--space-2) 0 0; font-size: 0.875rem; }
.result-split { margin-top: var(--space-5); }
.result-split .split { max-width: none; }

/* ---------- Result panels: charts and the schedule ---------- */
.calc-panel { margin-top: var(--space-5); }
.calc-panel h2 { margin: 0 0 var(--space-2); font-size: 1.25rem; }
.chart-title { margin: var(--space-5) 0 var(--space-2); font-size: 1rem; }
.chart-help { margin: var(--space-4) 0 0; font-size: 0.875rem; }

.chart { position: relative; }
.chart__legend { list-style: none; padding: 0; margin: 0 0 var(--space-2); display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: 0.875rem; color: var(--c-muted); }
.chart__legend-item { margin: 0; display: inline-flex; align-items: center; gap: var(--space-2); }
.chart__key { display: inline-block; flex: none; }
.chart__key--box { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.chart__key--line { width: 14px; border-top: 2px solid var(--c); }
.chart__key--dash { width: 18px; border-top: 2px dashed var(--c); }
.chart__key--blank { width: 14px; }
.chart__plot { position: relative; border-radius: var(--radius-sm); touch-action: pan-y; }
.chart__plot:focus { outline: none; }
.chart__plot:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.chart__svg { display: block; width: 100%; height: 240px; overflow: visible; }
.chart__grid line { stroke: var(--c-border); stroke-width: 1; shape-rendering: crispEdges; }
.chart__baseline { stroke: var(--c-border-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart__tick { fill: var(--c-muted); font: 500 12px var(--font); font-variant-numeric: tabular-nums; }
.chart__bar { fill: var(--c); }
.chart__hover { fill: var(--c-text); opacity: 0.06; }
.chart__area { fill: var(--c); fill-opacity: 0.1; stroke: none; }
.chart__line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__line--dashed { stroke-dasharray: 6 5; }
.chart__crosshair { stroke: var(--c-muted); stroke-width: 1; shape-rendering: crispEdges; }
.chart__dot { fill: var(--c); stroke: var(--c-surface); stroke-width: 2; }
.chart__tip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 170px;
  padding: var(--space-2) var(--space-3); border: 1px solid var(--c-border); border-radius: var(--radius-sm);
  background: var(--c-surface); box-shadow: var(--shadow); font-size: 0.875rem; line-height: 1.45;
}
.chart__tip-title { margin: 0 0 var(--space-1); font-weight: 700; }
.chart__tip-rows { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.chart__tip-rows li { margin: 0; display: flex; align-items: center; gap: var(--space-2); white-space: nowrap; color: var(--c-muted); }
.chart__tip-rows strong { color: var(--c-text); font-variant-numeric: tabular-nums; }
.chart__svg--waiting .chart__marks { opacity: 0; }
.chart__svg--grow .chart__marks { animation: qc-chart-in 800ms cubic-bezier(.2,.7,.2,1); }
@keyframes qc-chart-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

.schedule__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-3); }
.schedule__head h2 { margin: 0; }
.segmented--small { margin: 0; }
.segmented--small button { min-height: 34px; font-size: 0.85rem; }
.schedule__caption { margin: var(--space-3) 0; font-size: 0.9rem; }
.schedule__actions { margin-top: var(--space-3); }

.table-wrap { max-height: 480px; overflow: auto; border: 1px solid var(--c-border); border-radius: var(--radius-sm); }
.table-wrap:focus { outline: none; }
.table-wrap + .table-wrap { margin-top: var(--space-3); }
.table-wrap:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 6px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--c-border); background: var(--c-surface); }
.table thead th { position: sticky; top: 0; z-index: 2; background: var(--c-surface-2); font-weight: 700; }
.table th:first-child { position: sticky; left: 0; z-index: 1; text-align: left; }
.table thead th:first-child { z-index: 3; }
.table tbody th { font-weight: 650; }
.table tfoot th, .table tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--c-surface-2); font-weight: 750; border-top: 1px solid var(--c-border-strong); border-bottom: 0; }
.table tfoot th:first-child { z-index: 3; }
.table__group th { color: var(--c-muted); font-weight: 700; padding-top: var(--space-3); }
.table tbody tr:hover > * { background: var(--c-surface-2); }
.table tbody tr.is-current > * { background: var(--c-brand-soft); }
.table__note { display: block; font-size: 0.75rem; font-weight: 650; color: var(--c-brand-strong); }
@media (max-width: 480px) { .table th, .table td { padding: 6px 8px; } }

.calc-section { margin-top: var(--space-7); }
.calc-section h2 { margin-top: 0; }
.formula { padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); background: var(--c-surface); border: 1px solid var(--c-border); font-size: 1.1rem; overflow-x: auto; overflow-y: hidden; }

.faq details { border-bottom: 1px solid var(--c-border); padding-block: var(--space-3); }
.faq summary { cursor: pointer; font-weight: 650; }
.faq details p { margin: var(--space-2) 0 0; }

.related { list-style: none; padding: 0; display: grid; gap: var(--space-2); }
@media (min-width: 640px) { .related { grid-template-columns: repeat(2, 1fr); } }
.related li { margin: 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-surface); display: flex; justify-content: space-between; gap: var(--space-2); }

.feedback { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-7); padding: var(--space-4); border-radius: var(--radius-sm); background: var(--c-surface-2); }
.feedback p { margin: 0; font-weight: 650; }

/* Reserved ad space: fixed height so the page never jumps when an ad loads */
.ad-slot { min-height: 280px; margin-top: var(--space-6); display: grid; place-items: center; border: 2px dashed var(--c-border-strong); border-radius: var(--radius-sm); color: var(--c-muted); font-size: 0.875rem; text-align: center; padding: var(--space-4); }

/* A live ad: no dashed placeholder, just reserved room */
.ad-slot--live { display: block; min-height: 280px; padding: 0; border: 0; }

/* Banner shown only on draft/design pages */
.dev-banner { margin: var(--space-4) 0 var(--space-4); padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm); background: var(--c-hl-2-soft); color: var(--c-hl-2); font-size: 0.9rem; font-weight: 600; }

/* ---------- Practice ---------- */
.practice__head { display: flex; justify-content: space-between; gap: var(--space-3); color: var(--c-muted); font-size: 0.9rem; font-weight: 650; }
.practice__question { margin: var(--space-3) 0 var(--space-1); font-size: clamp(2rem, 1.4rem + 3vw, 3rem); font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.practice__prompt { margin: 0 0 var(--space-3); }
.practice__form { display: flex; gap: var(--space-2); align-items: center; }
.practice__form .input-wrap input { width: 100%; font-size: 1.35rem; }
.practice__form .btn { min-height: 48px; }
.practice__feedback { min-height: 1.6em; margin: var(--space-3) 0; font-weight: 650; }
.practice__feedback--ok { color: var(--c-brand-strong); }
.practice__feedback--ok::before { content: "✓ "; }
.practice__feedback--no { color: var(--c-hl-3); }
.practice__hints { margin: var(--space-4) 0 0; padding-left: 1.4em; }
.practice__hints li { margin: 0 0 var(--space-2); }
.practice__solution .player { margin-top: var(--space-5); }

/* Daily puzzle: five squares for progress, then the result */
.daily__timer { font-variant-numeric: tabular-nums; }
.daily__marks { list-style: none; display: flex; gap: var(--space-2); padding: 0; margin: var(--space-3) 0 var(--space-4); }
.daily__marks li {
  display: grid; place-items: center; width: 40px; height: 40px; margin: 0; border-radius: 8px;
  border: 2px solid var(--c-border-strong); background: var(--c-surface); color: var(--c-muted); font-weight: 750;
}
.daily__marks li.is-current { border-color: var(--c-brand); color: var(--c-text); box-shadow: 0 0 0 3px var(--c-brand-soft); }
.daily__marks li[data-state="first"] { background: var(--c-good); border-color: var(--c-good); color: #fff; }
.daily__marks li[data-state="second"] { background: var(--c-warn); border-color: var(--c-warn); color: #111827; }
.daily__marks li[data-state="missed"] { background: var(--c-bad); border-color: var(--c-bad); color: #fff; }
.daily__score { margin: 0; font-size: 1.25rem; }
.daily__score strong { font-size: 2.5rem; font-weight: 800; }
.daily__squares { margin: var(--space-1) 0 var(--space-3); font-size: 1.75rem; letter-spacing: 0.1em; }
.daily__next { margin: var(--space-3) 0 0; }
.daily__review-title { margin: var(--space-5) 0 var(--space-2); font-size: 1.1rem; }
.daily__review { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2); }
.daily__review li { margin: 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--c-border); border-radius: var(--radius-sm); font-variant-numeric: tabular-nums; }
.daily__solution-title { margin: var(--space-6) 0 0; font-size: 1.1rem; }
.daily__older { margin: var(--space-4) 0 0; }

/* ---------- Embeddable widgets ---------- */
.embed { background: var(--c-bg); }
.embed__main { max-width: 760px; margin-inline: auto; padding: var(--space-3); }
.embed .player { margin-top: var(--space-3); }
.embed__credit { margin: 0; padding: var(--space-2) var(--space-3) var(--space-4); text-align: center; font-size: 0.85rem; color: var(--c-muted); }
.is-embed [data-copy-link] { display: none; }
.embed-code { display: grid; gap: var(--space-2); justify-items: start; }
.embed-code pre { width: 100%; margin: 0; padding: var(--space-3); overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-surface); font-size: 0.8rem; white-space: pre-wrap; word-break: break-all; }
.embed-preview { margin-top: var(--space-3); }
.embed-preview summary { cursor: pointer; font-weight: 650; color: var(--c-brand); }
.embed-preview iframe { display: block; margin-top: var(--space-3); border: 1px solid var(--c-border); border-radius: var(--radius-sm); background: var(--c-bg); }
.feedback__thanks { margin: 0; }

/* ---------- Simple pages ---------- */
.simple-page { padding-block: var(--space-8); text-align: center; }
.simple-page .lead { margin-inline: auto; }

/* ---------- Motion and print ---------- */
@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; }
}

/* Teacher page: a grid of cards */
.teach-grid { display: grid; gap: var(--space-4); margin-top: var(--space-5); }
@media (min-width: 640px) { .teach-grid { grid-template-columns: 1fr 1fr; } }
.teach-card { padding: var(--space-5); }
.teach-card h2 { margin: 0 0 var(--space-2); font-size: 1.15rem; }
.teach-card p { margin: 0 0 var(--space-2); }
.teach-links { font-size: 0.9rem; }

/* ---------- Printable worksheets: a white "paper" sheet on screen, and only the sheets in print ---------- */
.ws-note { margin: var(--space-3) 0 0; font-size: 0.9rem; }
.ws-print { margin-top: var(--space-5); display: grid; gap: var(--space-5); }
.ws-sheet { background: #fff; color: #111827; border: 1px solid var(--c-border); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 28px 32px; }
.ws-sheet[hidden] { display: none; }
.ws-sheet__head { border-bottom: 2px solid #111827; padding-bottom: 10px; margin-bottom: 6px; }
.ws-sheet__title { margin: 0; font-size: 1.4rem; color: #111827; }
.ws-sheet__meta { margin: 2px 0 0; color: #4b5563; font-size: 0.85rem; }
.ws-sheet__lines { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 14px 0 0; font-size: 0.95rem; }
.ws-sheet__instructions { margin: 10px 0 0; font-size: 0.9rem; color: #374151; }
.ws-sheet__foot { margin: 14px 0 0; color: #6b7280; font-size: 0.75rem; overflow-wrap: anywhere; }
.ws-problems { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
@media (max-width: 519px) { .ws-problems { grid-template-columns: 1fr; } .ws-sheet { padding: 20px 18px; } }
.ws-problem { display: flex; align-items: flex-start; gap: 10px; min-height: 96px; margin: 0; padding: 12px 0; border-bottom: 1px dashed #d1d5db; break-inside: avoid; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.ws-sheet[data-topic="long-division"] .ws-problem { min-height: 150px; }
.ws-sheet[data-topic="percentages"] .ws-problem { min-height: 78px; font-size: 1.05rem; }
.ws-problem__n { color: #6b7280; font-weight: 700; min-width: 2.2ch; }
.ws-ld { display: inline-flex; align-items: flex-start; margin-top: 16px; font-size: 1.25rem; letter-spacing: 0.08em; }
.ws-ld__divisor { padding: 3px 4px 0 0; }
.ws-ld__dividend { position: relative; padding: 3px 8px 0 14px; border-top: 2px solid #111827; }
.ws-ld__dividend::before { content: ""; position: absolute; left: 0; top: -2px; bottom: -6px; width: 8px; border-right: 2px solid #111827; border-radius: 0 100% 100% 0 / 0 50% 50% 0; }
.ws-frac-q { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 1.2rem; }
.ws-num { display: inline-flex; align-items: center; gap: 4px; }
.ws-frac { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.2; }
.ws-frac__top { padding: 0 4px; border-bottom: 2px solid #111827; }
.ws-frac__bottom { padding: 0 4px; }
.ws-answers { columns: 2; column-gap: 28px; margin: 12px 0 0; padding-left: 2em; font-variant-numeric: tabular-nums; }
.ws-answers li { break-inside: avoid; margin: 0 0 6px; }
.ws-answers__q { color: #4b5563; }
.ws-answers a { color: #0f766e; font-weight: 700; }

@media print {
  .site-header, .site-footer, .skip-link, .ad-slot, .feedback, .player__controls, .actions, .dev-banner { display: none !important; }
  /* A printout is the calculation: inputs, answer, every step as text, charts and the full schedule. */
  .calc-section, .breadcrumb, .stage, .player__now, .player__tip, .player__count, .player details > summary,
  .chart-help, .chart__tip, .schedule__actions, .segmented { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; break-inside: auto; }
  .chart__svg--waiting .chart__marks { opacity: 1; }
  .table-wrap { max-height: none; overflow: visible; border: 0; }
  .table thead th, .table tfoot th, .table tfoot td, .table th:first-child { position: static; }
  /* Worksheets print only the sheet and its answer key, each starting on a new page. */
  .ws-page > :not(.ws-print) { display: none !important; }
  .ws-print { display: block; margin: 0; }
  .ws-sheet { border: 0; border-radius: 0; box-shadow: none; padding: 0; }
  .ws-sheet--key { break-before: page; }
  .ws-problems { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ws-answers a { color: #000; text-decoration: none; }
}
@page { margin: 14mm; }
