/* ==========================================================================
   Explorable lessons (5 Oct 2026) — styled after 3blue1brown.com, which Poach
   named as the inspiration: a dark canvas so the figures glow, his blue /
   yellow / green so colour carries meaning (yellow = from the left, green =
   from the right, blue = the function), a calm reading column, and figures
   wider than the text. Scoped to .xp so no other page changes.
   ========================================================================== */

.xp {
  --xp-bg: #0e1116;
  --xp-panel: #151a21;
  --xp-ink: #e8e6e3;
  --xp-muted: #9aa3ad;
  --xp-rule: rgba(255, 255, 255, 0.09);
  --xp-blue: #58C4DD;
  --xp-yellow: #F4D345;
  --xp-green: #83C167;
  --xp-red: #FC6255;
  --xp-strong: #fff;
  --xp-fg-rgb: 255, 255, 255;
  --xp-bg-rgb: 14, 17, 22;
  background: var(--xp-bg);
  color: var(--xp-ink);
  font-family: var(--font-body);
  font-size: clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);
  line-height: 1.85;
  padding: clamp(32px, 6vw, 72px) 16px 96px;
}
.xp > * { max-width: 760px; margin-inline: auto; }
.xp .xp-figure, .xp .xp-videos { max-width: 980px; }

.xp h1, .xp h2 { font-family: var(--font-display); color: var(--xp-strong); line-height: 1.25; }
.xp h1 { font-size: clamp(3rem, 2rem + 6vw, 5.5rem); margin: 0.1em 0 0.15em; letter-spacing: -0.01em; }
.xp h2 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); margin: 0 0 0.6em; }
.xp p { margin: 0 0 1.1em; }
.xp a { color: var(--xp-blue); }
.xp b { color: var(--xp-strong); }
.xp em { color: var(--xp-strong); font-style: normal; border-bottom: 1px dotted var(--xp-muted); }

.xp-kicker { color: var(--xp-muted); font-size: 0.85em; letter-spacing: 0.02em; }
.xp-lede { font-size: clamp(1.2rem, 1rem + 1vw, 1.6rem); color: var(--xp-muted); margin-bottom: 1.4em; }
.xp-hero { text-align: center; }
.xp-hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.xp-section { padding: clamp(40px, 7vw, 80px) 0 0; }
.xp-section + .xp-section { border-top: 1px solid var(--xp-rule); margin-top: clamp(40px, 7vw, 80px); }

/* colour words: the same colour as the thing in the figure */
.xp-y { color: var(--xp-yellow); }
.xp-g { color: var(--xp-green); }
.xp-b { color: var(--xp-blue); }
.xp-hl { color: var(--xp-yellow); font-weight: 600; }

/* figures */
.xp-figure {
  margin: 28px auto 32px;
  background: var(--xp-panel);
  border: 1px solid var(--xp-rule);
  border-radius: 14px;
  overflow: hidden;
}
.xp-figure--hero { margin-top: 8px; }
.xp-canvas { display: block; width: 100%; height: clamp(260px, 42vw, 400px); }
.xp-canvas--tall { height: clamp(280px, 50vw, 460px); }
.xp-figure figcaption { padding: 12px 18px 16px; color: var(--xp-muted); font-size: 0.92em; line-height: 1.7; }
.xp-readout { font-family: var(--font-mono); color: var(--xp-ink) !important; text-align: center; white-space: pre-wrap; }
.xp-readout--row { display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: center; }

/* Buttons you press sit on the right, near the right thumb and the chat (Poach, 15 Oct 2026); text stays left. */
.xp-controls { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; justify-content: flex-end; padding: 14px 18px 0; }
.xp-slider { display: flex; align-items: center; gap: 12px; flex: 1 1 320px; color: var(--xp-muted); font-size: 0.9em; }
.xp-slider span { white-space: nowrap; }
.xp-slider input { flex: 1; accent-color: var(--xp-yellow); min-width: 120px; }
.xp-slider output { font-family: var(--font-mono); color: var(--xp-ink); min-width: 7.5em; font-size: 0.9em; }
.xp-toggle { display: inline-flex; gap: 8px; align-items: center; color: var(--xp-ink); font-size: 0.9em; cursor: pointer; }
.xp-toggle input { accent-color: var(--xp-blue); width: 18px; height: 18px; }

.xp-table { width: calc(100% - 36px); margin: 12px 18px 0; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.85em; }
.xp-table th { text-align: left; color: var(--xp-muted); font-weight: 500; padding: 4px 8px; width: 4em; }
.xp-table td { padding: 4px 8px; border-left: 1px solid var(--xp-rule); }

/* mathematics set as type */
.xp-math { font-family: var(--font-display); font-size: 1.35em; text-align: center; margin: 18px 0 24px; color: var(--xp-strong); }
.xp-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 0.2em; line-height: 1.35; }
.xp-frac > span:first-child { border-bottom: 2px solid currentColor; padding: 0 0.25em 0.1em; }
.xp-frac > span:last-child { padding: 0.1em 0.25em 0; }
.xp sub { font-size: 0.65em; }

.xp-definition {
  background: linear-gradient(180deg, rgba(88,196,221,0.10), rgba(88,196,221,0.03));
  border: 1px solid rgba(88,196,221,0.35);
  border-radius: 14px; padding: 6px 22px 10px; margin: 24px 0 32px; text-align: center;
}
.xp-definition p { color: var(--xp-muted); }

/* the algebra, revealed one move at a time */
.xp-figure--algebra { padding: 22px 18px 18px; }
.xp-step {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px;
  font-family: var(--font-display); font-size: 1.3em; color: var(--xp-strong);
  padding: 10px 6px; border-radius: 10px;
  opacity: 0; max-height: 0; overflow: hidden;
  transition: opacity 500ms ease, max-height 500ms ease, background 300ms ease;
}
.xp-step.is-shown { opacity: 0.55; max-height: 260px; }
.xp-step.is-current { opacity: 1; background: rgba(var(--xp-fg-rgb),0.03); }
.xp-step-n { font-family: var(--font-mono); font-size: 0.6em; color: var(--xp-muted); width: 1.6em; }
.xp-note { font-family: var(--font-body); font-size: 0.62em; color: var(--xp-muted); flex-basis: 100%; padding-left: 2.6em; }
.xp-cancel { color: var(--xp-yellow); transition: opacity 400ms ease; }
.xp-step.is-shown:not(.is-current) .xp-cancel { text-decoration: line-through; text-decoration-color: var(--xp-red); opacity: 0.7; }
.xp-answer { color: var(--xp-yellow); }
.xp-step-actions { display: flex; gap: 10px; padding: 12px 6px 0; justify-content: flex-end; }   /* buttons right (15 Oct 2026) */
.xp-step-actions [data-again] { order: -1; }                                                   /* main action outermost */

/* buttons */
.xp-btn {
  display: inline-block; border: 1px solid var(--xp-blue); background: var(--xp-blue); color: #0b1418;
  border-radius: 999px; padding: 10px 20px; font: 600 0.95rem var(--font-body); text-decoration: none; cursor: pointer;
}
/* `display` above outranks the browser's own [hidden] rule (6 Oct 2026: the
   0/0 steps showed "Next step" and "Start over" together). Same fix as app.css. */
.xp-btn[hidden] { display: none; }
.xp a.xp-btn { color: #0b1418; }
.xp-btn--ghost, .xp a.xp-btn--ghost { background: transparent; color: var(--xp-blue); }
.xp-btn:hover { filter: brightness(1.1); }

/* questions */
.xp-quiz {
  border: 1px solid var(--xp-rule); border-left: 4px solid var(--xp-yellow);
  border-radius: 12px; background: var(--xp-panel); padding: 18px 20px; margin: 30px 0;
}
.xp-q { color: var(--xp-strong); font-weight: 600; }
.xp-option {
  display: block; width: 100%; text-align: left; margin: 8px 0; padding: 10px 14px;
  background: transparent; color: var(--xp-ink); border: 1px solid var(--xp-rule); border-radius: 10px;
  font: inherit; font-size: 0.95em; cursor: pointer;
}
.xp-option:hover { border-color: var(--xp-muted); }
.xp-option.is-picked { border-color: var(--xp-blue); background: rgba(88,196,221,0.08); }
.xp-option.is-right { border-color: var(--xp-green); background: rgba(131,193,103,0.14); }
.xp-option.is-right::after { content: "  ✓ ถูก"; color: var(--xp-green); }
html[lang="en"] .xp-option.is-right::after { content: "  ✓ right"; }
.xp-option.is-wrong { border-color: var(--xp-red); background: rgba(252,98,85,0.12); }
.xp-option.is-wrong::after { content: "  ✗"; color: var(--xp-red); }
.xp-check { display: block; margin: 8px 0 0 auto; border: 0; background: var(--xp-yellow); color: #1a1600; border-radius: 999px; padding: 9px 18px; font: 600 0.9rem var(--font-body); cursor: pointer; }
.xp-check:disabled { opacity: 0.4; cursor: default; }
.xp-why { margin-top: 14px; color: var(--xp-ink); border-top: 1px solid var(--xp-rule); padding-top: 12px; }

.xp-list { padding-left: 1.4em; margin: 0 0 1.2em; }
.xp-list li { margin: 0.35em 0; }

/* go deeper */
.xp-deeper {
  margin-top: clamp(40px, 7vw, 80px); border: 1px solid var(--xp-rule); border-radius: 14px;
  background: var(--xp-panel); padding: 6px 22px;
}
.xp-deeper summary { cursor: pointer; font-family: var(--font-display); font-size: 1.15em; color: var(--xp-strong); padding: 14px 0; }
.xp-deeper[open] summary { border-bottom: 1px solid var(--xp-rule); margin-bottom: 14px; }
.xp-deeper .xp-figure { background: var(--xp-bg); }
.xp-small { font-size: 0.85em; color: var(--xp-muted); }

/* videos */
.xp-videos { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin: 24px auto; }
.xp-videos figure { margin: 0; }
.xp-video { position: relative; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.xp-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.xp-videos figcaption { color: var(--xp-muted); font-size: 0.88em; padding-top: 8px; }

/* next lesson */
.xp-footer { margin-top: clamp(48px, 8vw, 96px); }
.xp-next {
  display: block; text-decoration: none; border-radius: 16px; padding: 22px 24px; margin-bottom: 18px;
  background: linear-gradient(135deg, rgba(88,196,221,0.16), rgba(131,193,103,0.10));
  border: 1px solid rgba(88,196,221,0.4);
}
.xp-next-kicker { display: block; color: var(--xp-muted); font-size: 0.85em; }
.xp-next-title { display: block; color: var(--xp-strong); font-family: var(--font-display); font-size: 1.35em; margin: 4px 0; }
.xp-next-why { display: block; color: var(--xp-ink); font-size: 0.92em; }
.xp-footer-nav { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 12px; }

@media (max-width: 560px) {
  .xp-slider { flex-basis: 100%; flex-wrap: wrap; }
  .xp-slider span { white-space: normal; }
  .xp-step { font-size: 1.1em; }
}

/* The squeeze figure: graph and number-line map side by side, stacked on a
   phone (5 Oct 2026). */
.xp-duo { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1px; background: var(--xp-rule); }
.xp-duo .xp-canvas { background: var(--xp-bg); cursor: ew-resize; }
@media (max-width: 700px) { .xp-duo { grid-template-columns: 1fr; } }
.xp-controls .xp-btn { padding: 8px 16px; }
.xp-film { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.xp-versions {
  position: sticky; top: 8px; z-index: 30; display: flex; gap: 6px; align-items: center; justify-content: center;
  width: max-content; margin: 0 auto 12px; padding: 6px 10px; border-radius: 999px;
  /* From the board's own colours, so it reads on the light board too (27 Oct 2026: it was a fixed dark pill, and
     in light its dark text sat on it unreadable). */
  background: color-mix(in srgb, var(--xp-panel) 90%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--xp-rule); box-shadow: 0 2px 10px rgba(var(--xp-fg-rgb), 0.08);
  font-size: 0.85rem; color: var(--xp-muted);
}
.xp-versions a { color: var(--xp-ink); text-decoration: none; padding: 2px 12px; border-radius: 999px; border: 1px solid transparent; }
.xp-versions a:hover, .xp-versions a:focus-visible { border-color: var(--xp-rule); }
.xp-versions a[aria-current="page"] { background: var(--xp-blue); color: var(--xp-bg); font-weight: 600; }

/* 5 Oct 2026, after Poach's notes on version B --------------------------- */
.xp-legend { display: flex; flex-direction: column; gap: 6px; font-size: 0.92em; margin: 18px 0 8px; }
.xp-legend span { display: flex; gap: 10px; align-items: baseline; }
.xp-swatch { display: inline-block; width: 26px; height: 6px; border-radius: 3px; flex: 0 0 auto; transform: translateY(-2px); }
.xp-swatch--b { background: var(--xp-blue); }
.xp-swatch--y { background: var(--xp-yellow); }
.xp-steps { margin: 8px 0 0; padding-left: 1.4em; font-size: 0.92em; color: var(--xp-muted); }
.xp-steps li { margin: 2px 0; }
.xp-slider--ends span { color: var(--xp-muted); font-size: 0.85em; }
.xp-slider--ends input { accent-color: var(--xp-blue); }

/* The algebra steps sat hard left with the right half empty while other
   equations are centred ("unbalance"): centre each step, number kept left. */
.xp-figure--algebra .xp-step { justify-content: center; position: relative; padding-left: 2.6em; padding-right: 2.6em; }
.xp-figure--algebra .xp-step-n { position: absolute; left: 10px; top: 16px; }
.xp-figure--algebra .xp-note { text-align: center; padding-left: 0; }


/* Room to breathe on a big screen (5 Oct 2026, Poach: "we have very big screen
   space ... it shouldnt be restricting"): text keeps a reading width, figures
   and videos take up to 1200 px. */
.xp .xp-figure { max-width: min(1200px, 100%); }
.xp .xp-section--wide { max-width: 1280px; }
.xp .xp-section--wide > h2, .xp .xp-narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
/* A video, then what it explains and where to jump, side by side beneath it:
   the video keeps its full size and the page keeps one format. */
.xp-watch { display: block; max-width: 1000px; margin: 28px auto 40px; }
.xp-watch .xp-video { aspect-ratio: 16 / 9; }
.xp-watch-panel {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 6px 28px; margin-top: 14px;
  background: var(--xp-panel); border: 1px solid var(--xp-rule); border-radius: 14px; padding: 16px 20px;
  font-size: 0.92em; line-height: 1.7;
}
.xp-watch-jump .xp-chapters { margin-top: 4px; }
@media (max-width: 760px) { .xp-watch-panel { grid-template-columns: 1fr; } }
.xp-watch-panel h3 { font-family: var(--font-display); color: var(--xp-strong); font-size: 1.25em; margin: 4px 0 8px; line-height: 1.35; }
.xp-watch-kicker { color: var(--xp-muted); font-size: 0.85em; }
.xp-chapters { list-style: none; padding: 0; margin: 10px 0 8px; border-top: 1px solid var(--xp-rule); }
.xp-chapters li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--xp-rule); }
.xp-chapters button {
  flex: 0 0 auto; font: 600 0.85em var(--font-mono); color: #0b1418; background: var(--xp-yellow);
  border: 0; border-radius: 6px; padding: 2px 8px; cursor: pointer;
}
.xp-chapters button:hover { filter: brightness(1.1); }
/* Figures break out of the text column, centred on the page: up to 1100 px
   on a big screen, the full width minus the gutter on a phone. */
/* Only figures that need the room take it (5 Oct 2026: the algebra steps
   went wide "for useless reason"): mark them .xp-figure--wide. */
.xp .xp-figure--wide {
  position: relative; left: 50%; transform: translateX(-50%);
  width: min(1100px, calc(100vw - var(--np-space, 0px) - 48px)); max-width: none;
}

.xp-film-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.xp-voices { display: inline-flex; gap: 6px; }
.xp-voices button {
  font: 600 0.9rem var(--font-body); color: var(--xp-ink); background: transparent; cursor: pointer;
  border: 1px solid var(--xp-rule); border-radius: 999px; padding: 4px 14px;
}
.xp-voices button[aria-pressed="true"] { background: var(--xp-blue); color: #0b1418; border-color: var(--xp-blue); }

/* The living cover over the film (5 Oct 2026). */
.xp-film-wrap { position: relative; aspect-ratio: 16 / 9; background: #000; }
.xp-film-wrap .xp-film { position: absolute; inset: 0; width: 100%; height: 100%; }
.xp-film-cover { position: absolute; inset: 0; cursor: pointer; background: var(--xp-bg); }
.xp-film-cover .xp-canvas { height: 100%; }
.xp-film-cover .xp-readout { position: absolute; left: 0; right: 0; top: 10px; padding: 0 12px; pointer-events: none; }
.xp-film-start {
  /* bottom-left, so it never covers the hole and the point creeping into it */
  position: absolute; left: 18px; bottom: 34px;
  background: var(--xp-blue); color: #0b1418; font: 700 1.05rem var(--font-body);
  padding: 12px 22px; border-radius: 999px; box-shadow: 0 6px 30px rgba(0,0,0,0.5); pointer-events: none;
}
.xp-film-cover:hover .xp-film-start { filter: brightness(1.1); }
.xp-film-wrap.is-playing .xp-film-cover { display: none; }

.xp-r { color: var(--xp-red); }
/* `.xp b` is white; a coloured mark keeps its colour */
.xp b.xp-g { color: var(--xp-green); } .xp b.xp-r { color: var(--xp-red); } .xp b.xp-y { color: var(--xp-yellow); }
.xp-muted { color: var(--xp-muted); }

.xp-h3 { font-family: var(--font-display); color: var(--xp-strong); font-size: 1.2em; margin: 1.6em 0 0.4em; }
.xp-definition--left { text-align: left; }
.xp-definition--left p { color: var(--xp-ink); margin: 12px 0; }

/* Refreshers (6 Oct 2026, docs/FOUNDATIONS.md): a closed one-line strip at the
   step that needs it. Quieter than "go deeper": it is a side door, not the road. */
.xp-refresh {
  margin: 4px 0 22px; border: 1px dashed rgba(244, 211, 69, 0.35); border-radius: 12px;
  padding: 0 18px; font-size: 0.95em;
}
.xp-refresh summary { cursor: pointer; padding: 10px 0; color: var(--xp-ink); list-style-position: inside; }
.xp-refresh-tag {
  display: inline-block; margin-right: 8px; padding: 0 8px; border-radius: 999px;
  background: rgba(244, 211, 69, 0.14); color: var(--xp-yellow); font-size: 0.8em; letter-spacing: 0.02em;
}
.xp-refresh[open] summary { border-bottom: 1px solid var(--xp-rule); margin-bottom: 12px; }
.xp-refresh-body { padding-bottom: 6px; }
.xp-refresh .xp-figure { background: var(--xp-bg); margin: 16px auto 20px; }
.xp-refresh .xp-h3:first-child { margin-top: 0.4em; }
.xp-refresh-more { font-size: 0.85em; color: var(--xp-muted); }
.xp code { font-family: var(--font-mono); font-size: 0.9em; background: rgba(var(--xp-fg-rgb),0.06); padding: 1px 6px; border-radius: 6px; color: var(--xp-strong); }

.xp-chip {
  font: inherit; font-size: 0.88em; color: var(--xp-ink); background: transparent; cursor: pointer;
  border: 1px solid var(--xp-rule); border-radius: 999px; padding: 4px 14px;
}
.xp-chip:hover { border-color: var(--xp-muted); }
.xp-chip[aria-pressed="true"] { border-color: var(--xp-blue); background: rgba(88,196,221,0.12); color: var(--xp-strong); }
.xp-chip--mono { font-family: var(--font-mono); }
.xp-controls:has(.xp-chip) { gap: 8px; }
.xp-readout--stack { display: flex; flex-direction: column; gap: 4px; align-items: center; }

/* boxes inside boxes: one box per operation; the yellow ones go first */
.xp-stage {
  font-family: var(--font-display); font-size: 1.35em; color: var(--xp-strong); text-align: center;
  padding: 22px 12px 6px; min-height: 3.2em; line-height: 2.4;
}
.xp-box {
  display: inline-block; border: 1.5px solid rgba(88,196,221,0.45); border-radius: 8px;
  padding: 0.12em 0.4em; margin: 0 0.1em; line-height: 1.7; vertical-align: middle;
}
/* the whole expression needs no frame of its own: every box inside it has one */
.xp-stage > .xp-box:not(.is-next) { border-color: transparent; padding: 0; }
.xp-box.is-next { border-color: var(--xp-yellow); background: rgba(244,211,69,0.10); }
.xp-box .xp-frac { line-height: 1.5; }
.xp-n--none { color: var(--xp-yellow); font-size: 0.8em; }
.xp-figure--boxes .xp-readout { font-family: var(--font-body); }
.xp-figure--boxes .xp-step-actions { padding-bottom: 4px; }

/* Derivatives (6 Oct 2026) */
.xp-swatch--g { background: var(--xp-green); }
/* f above, f′ below, on one shared x */
.xp-stack2 { display: grid; grid-template-rows: auto auto; gap: 1px; background: var(--xp-rule); }
.xp-stack2 .xp-canvas { background: var(--xp-bg); }
.xp-canvas--half { height: clamp(200px, 30vw, 290px); }
.xp-roadmap li { margin: 0.7em 0; }
.xp-roadmap a { font-size: 0.88em; overflow-wrap: anywhere; }
/* (x + h)² cut into x², two strips x·h and h² — the colours of the square figure */
.xp-area {
  display: grid; grid-template-columns: 3fr 1fr; grid-template-rows: 1fr 3fr;
  width: min(220px, 60%); aspect-ratio: 1; margin: 6px auto 16px; gap: 2px;
  font-family: var(--font-display); color: var(--xp-strong);
}
.xp-area span { display: grid; place-items: center; border-radius: 3px; font-size: 0.95em; }
.xp-area-a { background: rgba(88,196,221,0.28); border: 1.5px solid var(--xp-blue); grid-column: 1; grid-row: 2; }
.xp-area-b { background: rgba(244,211,69,0.32); border: 1.5px solid var(--xp-yellow); }
.xp-area-b:nth-child(2) { grid-column: 2; grid-row: 2; }
.xp-area-b:nth-child(3) { grid-column: 1; grid-row: 1; }
.xp-area-c { background: rgba(131,193,103,0.5); border: 1.5px solid var(--xp-green); grid-column: 2; grid-row: 1; font-size: 0.8em; }
/* the derivatives the sheet gives as pieces */
.xp-rules { border-collapse: collapse; font-family: var(--font-display); margin: 12px auto 18px; min-width: 260px; }
.xp-rules th { color: var(--xp-muted); font-weight: 500; padding: 6px 22px; border-bottom: 1px solid var(--xp-rule); }
.xp-rules td { padding: 5px 22px; text-align: center; color: var(--xp-strong); }
.xp-rules td + td { color: var(--xp-yellow); border-left: 1px solid var(--xp-rule); }

/* The topic bar inside a lesson's dark page (7 Oct 2026). */
.xp .topic-bar { border-bottom-color: var(--xp-rule); margin-bottom: clamp(24px, 5vw, 48px); }
.xp .tb-path, .xp .tb-prev, .xp .tb-next, .xp .tb-tab, .xp .tb-page { color: var(--xp-muted); }
.xp .tb-path:hover, .xp .tb-prev:hover, .xp .tb-next:hover, .xp .tb-tab:hover { color: var(--xp-blue); }
.xp .tb-title { color: var(--xp-ink); }
.xp .tb-tab.is-active { color: var(--xp-strong); border-color: var(--xp-rule); background: var(--xp-panel); }
.xp .tb-page.is-active { background: var(--xp-yellow); color: #111; }

/* The click-to-load cover on 3Blue1Brown's videos (7 Oct 2026). */
.xp-video { position: relative; }
.xp-video-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 14px;
  background: #0b0e12; color: var(--xp-ink); border: 1px solid var(--xp-rule); border-radius: 12px;
  font: inherit; font-size: 1.05em; cursor: pointer; padding: 16px; text-align: left;
}
.xp-video-play:hover { border-color: var(--xp-blue); }
.xp-video-play small { display: block; color: var(--xp-muted); font-size: 0.78em; margin-top: 4px; }
.xp-video-icon {
  width: 56px; height: 56px; border-radius: 50%; background: var(--xp-blue); color: #0b0e12;
  display: grid; place-items: center; font-size: 1.3em; flex: none;
}

/* The formal Thai term under an English heading (7 Oct 2026): present, not shouting. */
.xp h1 .xp-h1-th { display: block; font-size: 0.32em; color: var(--xp-muted); font-weight: 400; margin-top: 0.15em; }

/* Integrals (7 Oct 2026) */
.xp-swatch--r { background: var(--xp-red); }
.xp-math-inline { font-family: var(--font-display); white-space: nowrap; }
.xp-parts th { color: var(--xp-blue); font-size: 1.1em; font-weight: 500; }
.xp-parts td, .xp-parts td + td { text-align: left; color: var(--xp-ink); border-left: 0; }
@media (max-width: 560px) {
  .xp-rules { font-size: 0.86em; min-width: 0; }
  .xp-rules th, .xp-rules td { padding: 5px 8px; }
}
.xp-swatch--t { background: #5CD0B3; }
/* On a phone a two-column formula table breaks formulas mid-expression;
   stack each pair instead, the derivative above its integral (7 Oct 2026). */
@media (max-width: 560px) {
  .xp-rules--stack, .xp-rules--stack tbody, .xp-rules--stack tr, .xp-rules--stack td { display: block; }
  .xp-rules--stack { width: 100%; font-size: 0.95em; }
  .xp-rules--stack thead { display: none; }
  .xp-rules--stack tr { padding: 7px 2px; border-bottom: 1px solid var(--xp-rule); }
  .xp-rules--stack td, .xp-rules--stack td + td { text-align: left; border-left: 0; padding: 1px 4px; }
  .xp-rules--stack td + td::before { content: "→ "; color: var(--xp-muted); }
}

/* Visible controls (8 Oct 2026): ◀ ▶ beside every slider, a drag cue on pictures. */
.xp-slider label { white-space: nowrap; }
.xp-step-btn { font: inherit; font-size: 0.85em; display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px;
  border: 1px solid var(--xp-rule); border-radius: 6px; background: rgba(var(--xp-fg-rgb),0.04); color: var(--xp-ink); cursor: pointer; }
.xp-step-btn:hover, .xp-step-btn:focus-visible { border-color: var(--xp-yellow); color: var(--xp-yellow); }
.xp-step-btn small { font-size: 0.85em; color: var(--xp-muted); }
.xp-cue { position: absolute; right: 12px; padding: 4px 10px; border-radius: 999px; font-size: 12px; pointer-events: none;
  background: color-mix(in srgb, var(--xp-bg) 82%, transparent); border: 1px solid var(--xp-rule); color: var(--xp-ink); transition: opacity .4s; }
.xp-cue.is-gone { opacity: 0; }
/* A teacher's note beside the figure, not a warning (8 Oct 2026: "not sure the
   teaching text should be in yellow like there is something wrong"). */
.xp-guide { display: grid; gap: 6px; margin: 12px 0 0; padding: 2px 0 2px 16px;
  border-left: 2px solid rgba(88,196,221,0.45); font-size: 0.94em; color: var(--xp-ink); }
.xp-guide .xp-try { color: var(--xp-blue); }
.xp-guide .xp-try::before { content: "→ "; }
.xp-hero-steps { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 8px 0 2px; }
@media (max-width: 560px) {
  .xp-step-btn small { display: none; }
  .xp-slider label { white-space: normal; flex-basis: 100%; }
}
.xp-hero-or { align-self: center; font-size: 0.82em; color: var(--xp-muted); }
@media (max-width: 560px) { .xp-hero-steps .xp-step-btn small { display: inline; } .xp-hero-or { flex-basis: 100%; text-align: center; } }

/* A small switch between a figure's examples or ways of slicing (8 Oct 2026). */
.xp-seg { display: flex; flex-wrap: wrap; gap: 6px; flex-basis: 100%; }
.xp-seg button { font: inherit; font-size: 0.85em; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--xp-rule); background: transparent; color: var(--xp-muted); }
.xp-seg button[aria-pressed="true"] { color: var(--xp-ink); border-color: var(--xp-blue); background: rgba(88,196,221,0.12); }
.xp-seg-gap { width: 10px; }

/* The light board (8 Oct 2026): for projectors and big screens; accents deepened so they read on paper.
   Its ground follows the chosen colour palette (27 Oct 2026, Poach: "why is it so yellow?"): it was a fixed warm
   #f3f1ec, which matched the original warm page but reads yellow beside the sky palette's cool #F7F8FA. Now the board
   is the page's own --paper and the control strip its --surface-2 (explore.js draws the figures to match); the old
   warm values remain only as the fallback. */
:root[data-theme="light"] .xp {
  --xp-bg: var(--paper, #f3f1ec); --xp-panel: var(--surface-2, #e8e5de); --xp-ink: #1f252b; --xp-muted: #5b6570;
  --xp-rule: rgba(20, 26, 32, 0.13); --xp-blue: #1b7fa6; --xp-yellow: #a87b05; --xp-green: #3a8a36;
  --xp-red: #c9453a; --xp-strong: #11161b; --xp-fg-rgb: 20, 26, 32; --xp-bg-rgb: 243, 241, 236;
}
:root[data-theme="light"] .xp-swatch--t { background: #1f9479; }
.xp-canvas--short { height: clamp(150px, 20vw, 210px); }

/* A film with its narrator live beside it (14 Oct 2026, static/js/film-live.js).
   The film keeps its whole frame; the character stands in a column to its
   right. His canvas reaches LEFT over the film's edge so a pointing arm is
   never cut (Poach: "finger point should really point and not cut off"); it is
   transparent and lets every click through to the film's controls. */
.film-live-row {
  position: relative; display: grid; align-items: stretch;
  grid-template-columns: minmax(0, 1fr) clamp(150px, 19%, 230px);
}
.film-live.is-avatar-off .film-live-row { grid-template-columns: minmax(0, 1fr); }
.film-live-side { position: relative; pointer-events: none; }
.film-live-side[hidden] { display: none; }
.film-live-side .avatar-stage {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 2;
  width: calc(100% + 240px); max-width: none; pointer-events: none;  /* film-live.js sizes the reach */
}
.film-live-side .avatar-stage > canvas { width: 100%; height: 100%; }
.film-live-toggle {
  font: 600 0.9rem var(--font-body); color: var(--xp-ink); background: transparent; cursor: pointer;
  border: 1px solid var(--xp-rule); border-radius: 999px; padding: 4px 14px;
}
.film-live-toggle[aria-pressed="true"] { background: var(--xp-blue); color: #0b1418; border-color: var(--xp-blue); }
/* A phone that chose to show him: below the film, no reach over it. */
@media (max-width: 899px) {
  .film-live-row { grid-template-columns: minmax(0, 1fr); }
  .film-live-side { height: 220px; }
  .film-live-side .avatar-stage { left: 0; }
}

/* Two films compared (14 Oct 2026, static/js/film-compare.js): stacked in the
   order drawn for this visitor, then the question. */
.film-compare { display: flex; flex-direction: column; gap: 28px; }
.film-compare-name { font: 700 1.1rem var(--font-body); color: var(--xp-ink); margin-bottom: 8px; }
.film-live-controls { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.film-compare-ask {
  display: grid; gap: 14px; padding: 18px 20px; border: 1px solid var(--xp-rule); border-radius: 14px;
}
.film-compare-ask fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.film-compare-ask legend { font-weight: 700; margin-bottom: 8px; width: 100%; }
.film-compare-ask label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.film-compare-why { display: grid !important; gap: 6px; }
.film-compare-why textarea { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--xp-rule);
  background: transparent; color: var(--xp-ink); resize: vertical; }
.film-compare-ask .xp-btn { justify-self: start; }
.film-compare-thanks { margin: 0; color: var(--xp-blue); font-weight: 600; }
.film-compare-open {
  display: flex; gap: 18px; align-items: center; padding: 26px 24px; border-radius: 12px; text-decoration: none;
  background: #0b1418; color: var(--xp-ink); border: 1px solid var(--xp-rule);
}
.film-compare-open:hover { border-color: var(--xp-blue); }
.film-compare-open small { display: block; color: var(--xp-muted, #9aa3ad); margin-top: 4px; }
.film-compare-play {
  flex: none; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--xp-blue); color: #0b1418; font-size: 1.2rem;
}
.film-compare-open > span:last-child { text-align: left; }

/* Techniques of integration — "choose the u" (15 Oct 2026, static/js/techniques/spotu.js). */
.tq-spot { display: grid; gap: 12px; padding: 16px 18px; border-radius: 14px; background: var(--xp-panel, rgba(255,255,255,0.03));
  border: 1px solid var(--xp-rule); }
.tq-tabs, .tq-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.tq-tabs button, .tq-choices button {
  font: 600 0.88rem var(--font-body); color: var(--xp-ink); background: transparent; cursor: pointer;
  border: 1px solid var(--xp-rule); border-radius: 999px; padding: 5px 14px;
}
.tq-choices button { font-family: var(--font-mono, monospace); font-weight: 500; }
.tq-tabs button[aria-pressed="true"] { border-color: var(--xp-muted); background: rgba(255,255,255,0.06); }
.tq-choices button[aria-pressed="true"] { border-color: var(--xp-blue); color: var(--xp-blue); }
.tq-integral { font: 1.35rem/1.5 "Cambria Math", "STIX Two Math", "Times New Roman", serif; color: var(--xp-ink); overflow-x: auto; white-space: nowrap; }
.tq-u { color: var(--xp-blue); background: rgba(88,196,221,0.14); border-radius: 6px; padding: 0 3px; }
.tq-ask { margin: 0; color: var(--xp-muted); font-size: 0.92em; }
.tq-result { display: grid; gap: 6px; padding: 10px 14px; border-radius: 10px; border-left: 3px solid; }
.tq-result--ok { border-color: var(--xp-green); background: rgba(131,193,103,0.08); }
.tq-result--no { border-color: var(--xp-red); background: rgba(252,98,85,0.07); }
.tq-line { font-family: var(--font-mono, monospace); font-size: 0.95rem; overflow-x: auto; }
.tq-verdict { line-height: 1.6; }
.tq-result--ok .tq-verdict { color: var(--xp-green); }
.tq-result--no .tq-verdict { color: var(--xp-red); }
/* Text tables in the techniques lesson: readable words, scrolling sideways on a phone. */
.tq-table-wrap { overflow-x: auto; margin: 14px 0; }
.tq-table { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: 0.9em; }
.tq-table th { text-align: left; color: var(--xp-muted); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--xp-rule); }
.tq-table td { padding: 8px 10px; border-bottom: 1px solid var(--xp-rule); vertical-align: top; line-height: 1.55; }
.tq-table td:first-child { color: var(--xp-blue); white-space: nowrap; }

/* Typeset maths and its colours (15 Oct 2026). The same quantity wears the same colour in the formula
   and in the picture: u blue, du (the width) green — variables, so light and dark themes both read. */
.xp .katex { font-size: 1.12em; }
.xp .katex-display { margin: 0.6em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.katex .tq-u { color: var(--xp-blue); }
.katex .tq-du { color: var(--xp-green); }
.tq-spot .katex .tq-u { background: rgba(88,196,221,0.16); border-radius: 4px; padding: 0 2px; }
/* "This picture answers: …" — every figure says what it is for before it is used. */
.tq-purpose { margin: 22px 0 8px; padding: 10px 14px; border-left: 3px solid var(--xp-blue);
  background: rgba(88,196,221,0.06); border-radius: 0 10px 10px 0; line-height: 1.6; }
.tq-purpose b { color: var(--xp-blue); }
/* The formula above the warp figure, morphing x-form into u-form in step with the picture. */
.tq-morph { position: relative; min-height: 4.2em; margin: 4px 0 6px; }
.tq-morph > div { position: absolute; inset: 0; transition: opacity 0.15s linear; }
/* Worked steps: numbered cards, maths on its own line. */
.tq-steps { display: grid; gap: 10px; margin: 18px 0; }
.tq-step { padding: 10px 14px 4px; border: 1px solid var(--xp-rule); border-radius: 12px; line-height: 1.6; }
.tq-n { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; margin-right: 8px; border-radius: 50%;
  background: rgba(88,196,221,0.18); color: var(--xp-blue); font-weight: 700; font-size: 0.85em; }
.tq-choices button .katex { font-size: 1em; }
.tq-integral .katex-display { margin: 0.2em 0; }

/* Techniques — a compact first screen (15 Oct 2026, Poach: the header "take too many lines and only at
   the end of page I start to see content"). One-line title, the opening figure on the first screen, and
   the jump links as one quiet line instead of a row of buttons. Only pages that ask for it. */
/* bigger again, still one line (Poach, 15 Oct: "bigger") */
.xp-hero--compact h1 { font-size: clamp(2.3rem, 1.4rem + 3.6vw, 4.3rem); margin: 0.05em 0 0.1em; white-space: nowrap; }
@media (max-width: 420px) { .xp-hero--compact h1 { white-space: normal; } }
.xp-hero--compact .xp-lede { font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.25rem); margin-bottom: 0.6em; }
.xp-hero--compact + .xp-figure { margin-top: 8px; }
.xp-jump { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: flex-end; align-items: baseline;
  margin: 10px auto 0; font-size: 0.9em; color: var(--xp-muted); }
/* One right edge for what you press: as wide as the figure above, with its inner padding (18px + 1px
   border), so the last link ends exactly under the figure's ▶ button. */
.xp .xp-jump { max-width: 860px; padding-inline: 19px; }
.xp-jump a { text-decoration: none; border-bottom: 1px solid transparent; }
.xp-jump a:hover, .xp-jump a:focus-visible { border-bottom-color: currentColor; }

/* the opening: derivatives forwards, then backwards */
.tq-back { display: grid; gap: 10px; padding: 18px 18px 6px; }
.tq-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 8px 12px; border-radius: 12px; border: 1px solid var(--xp-rule);
  opacity: 0.18; transform: translateX(-8px); transition: opacity 0.45s ease, transform 0.45s ease; }
.tq-row.is-on { opacity: 1; transform: none; }
.tq-cell { font-size: 1.2rem; color: var(--xp-strong); overflow-x: auto; }
.tq-cell:first-child { text-align: right; }
.tq-arrow { display: grid; justify-items: center; gap: 2px; color: var(--xp-muted); }
.tq-chip { font-size: 0.78em; padding: 1px 9px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--xp-rule); color: var(--xp-muted); }
.tq-row--chain .tq-chip { color: var(--xp-blue); border-color: var(--xp-blue); }
.tq-row--prod .tq-chip { color: var(--xp-yellow); border-color: var(--xp-yellow); }
/* backwards: the sides stay put and the arrow turns round — the integrand (right) lights up as the start */
.tq-back.is-back .tq-arrow { color: var(--xp-ink); }
.tq-back.is-back .tq-cell:last-child { color: var(--xp-strong); }
.tq-back.is-back .tq-cell:first-child { color: var(--xp-green); }
/* phones (Poach, 15 Oct: "think of phone user too"): each row stays one line — stacked, one row
   took a third of the screen. Smaller maths, a smaller arrow, the chip under it. */
@media (max-width: 560px) {
  .tq-back { padding: 10px 8px 2px; gap: 6px; }
  .tq-row { gap: 6px; padding: 6px 6px; }
  .tq-cell { font-size: 0.92rem; }
  .tq-chip { font-size: 0.7em; padding: 0 6px; }
  .xp-hero--compact .xp-kicker { display: none; }
}
@media (prefers-reduced-motion: reduce) { .tq-row { transition: none; transform: none; } }

/* the formula card: always one tap away, stacked just above the narrator's "ask" button in the bottom-right
   corner (15 Oct 2026, Poach: "can we keep in bottom right"; he also floated a tab half-way up the right
   edge, then kept this — one cluster in one place on every screen). The ask button sits var(--s-5) from
   the corner (var(--s-3) below 34rem, app.css) and is about 52px tall. */
.tq-formula-btn { position: fixed; right: var(--s-5, 24px); bottom: calc(var(--s-5, 24px) + 62px + env(safe-area-inset-bottom, 0px));
  z-index: 59; width: 52px; height: 52px; padding: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; align-content: center; gap: 0;
  font: inherit; font-size: 0.68em; line-height: 1.1;
  background: var(--xp-panel); color: var(--xp-muted); border: 1px solid var(--xp-rule);
  box-shadow: 0 4px 18px rgba(0,0,0,0.25); }
.tq-formula-btn b { font-family: var(--font-display); font-size: 2em; line-height: 1; color: var(--xp-blue); }
@media (max-width: 34rem) {
  .tq-formula-btn { right: var(--s-3, 12px); bottom: calc(var(--s-3, 12px) + 62px + env(safe-area-inset-bottom, 0px)); }
}
.tq-formula-btn:hover { color: var(--xp-ink); border-color: var(--xp-blue); }
.tq-arrow .katex { font-size: 1.45em; }
/* The basic integrals card (15 Oct 2026, regrouped the same day: "make the visual for this better, and
   alignment fix too"). Four groups; in each, integral | = | answer as three columns, so the integral signs
   start on one line and the = signs stand in one column. Wide: the long trig group fills the right side. */
.tq-formulas { max-width: min(780px, calc(100vw - 24px)); width: 100%; max-height: 88vh; padding: 0; border-radius: 16px;
  background: var(--xp-bg); color: var(--xp-ink); border: 1px solid var(--xp-rule); }
/* opens in the middle of the screen (a rule for the lesson column was pinning it to the top) */
.tq-formulas[open] { display: flex; flex-direction: column; position: fixed; inset: 0; margin: auto; height: fit-content; }
.tq-formulas::backdrop { background: rgba(0,0,0,0.55); }
.tq-formulas-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 0; font-size: 1.1em; }
.tq-formulas-x { font: inherit; font-size: 1.5em; line-height: 1; background: none; border: 0; color: var(--xp-muted); cursor: pointer; padding: 0 4px; }
.tq-formulas .tq-formulas-note { margin: 4px 20px 14px; color: var(--xp-muted); font-size: 0.9em; }
.tq-formulas-groups { display: grid; gap: 12px; padding: 0 20px 20px; overflow-y: auto; }
@media (min-width: 720px) {
  .tq-formulas-groups { grid-template-columns: 1fr 1fr; grid-template-areas: "a c" "b c" "d c"; align-items: start; }
  .tq-fgroup:nth-child(1) { grid-area: a; } .tq-fgroup:nth-child(2) { grid-area: b; }
  .tq-fgroup:nth-child(3) { grid-area: c; } .tq-fgroup:nth-child(4) { grid-area: d; }
}
.tq-fgroup { background: var(--xp-panel); border: 1px solid var(--xp-rule); border-radius: 12px; padding: 10px 14px 12px; }
.tq-fgroup h3 { margin: 0 0 6px; font: 600 0.82rem var(--font-body, sans-serif); letter-spacing: 0.02em; color: var(--xp-blue); }
/* cells stretch to the row's height and centre their content, so each row's divider is one straight line */
.tq-ftable { width: 100%; border-collapse: collapse; }
.tq-ftable td { vertical-align: baseline; padding: 8px 0; border-top: 1px solid var(--xp-rule); }
.tq-ftable tr:first-child td { border-top: 0; }
.tq-fl { white-space: nowrap; width: 1%; }
.tq-feq { width: 1%; padding: 8px 10px !important; color: var(--xp-muted); }
.tq-fr { white-space: nowrap; }
.tq-fr small { color: var(--xp-muted); font-size: 0.78em; }
.tq-fgroup .katex { font-size: 1.08em; }
/* phones: after the rules above so they win. */
@media (max-width: 560px) {
  .tq-arrow .katex { font-size: 1.1em; }
  .tq-formulas-groups { padding: 0 12px 14px; }
  .tq-fgroup { padding: 8px 10px 10px; }
  .tq-fgroup .katex { font-size: 1em; }
}

/* Techniques — the trig machine (15 Oct 2026, static/js/techniques/trigmachine.js). Tiles start in their
   own colours (sin/tan red, cos/sec yellow); the spare one turns green when it becomes du, and everything
   else turns blue once it is written in u — the lesson's u-blue, du-green throughout. Steps only change
   classes on .tq-tiles, so every move is a transition. */
.tq-tm { display: grid; gap: 14px; padding: 16px 18px 10px; }
.tq-tm-top { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; }
.tq-tm-top .xp-seg { flex-basis: auto; }
.tq-steppers { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.tq-stepper { display: inline-flex; align-items: center; gap: 6px; color: var(--xp-muted); font-size: 0.92em; }
.tq-stepper button { font: inherit; width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--xp-rule); background: transparent; color: var(--xp-ink); }
.tq-stepper button:disabled { opacity: 0.3; cursor: default; }
.tq-stepper output { min-width: 1.2em; text-align: center; font: 600 1.1em var(--font-mono, monospace); color: var(--xp-strong); }
.tq-tiles { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
  min-height: 84px; padding: 26px 4px 6px; border-radius: 12px; }
.tq-tile { display: inline-grid; place-items: center; min-width: 54px; padding: 8px 9px; border-radius: 10px;
  border: 2px solid; font-size: 0.95rem; color: var(--xp-strong);
  transition: border-color 0.5s, background-color 0.5s, transform 0.6s cubic-bezier(.3,1.4,.5,1); }
.tq-tile.is-a { border-color: var(--xp-red); background: rgba(252,98,85,0.10); }
.tq-tile.is-b { border-color: var(--xp-yellow); background: rgba(244,211,69,0.09); }
.tq-tile.is-empty { border-style: dashed; border-color: var(--xp-rule); }
.tq-pair { display: inline-grid; padding: 3px; border-radius: 13px; border: 1.5px dashed transparent; transition: border-color 0.4s; }
.tq-pair-a, .tq-pair-b { grid-area: 1 / 1; transition: opacity 0.5s, transform 0.5s; }
.tq-pair-a { display: flex; gap: 4px; }
.tq-pair-b { place-self: center; padding: 8px 10px; border-radius: 10px; border: 2px solid; opacity: 0; transform: rotateX(90deg);
  font-size: 0.95rem; color: var(--xp-strong); white-space: nowrap; }
.tq-pair.is-a .tq-pair-b { border-color: var(--xp-yellow); background: rgba(244,211,69,0.09); }
.tq-pair.is-b .tq-pair-b { border-color: var(--xp-red); background: rgba(252,98,85,0.10); }
.tq-spare { position: relative; display: inline-flex; gap: 4px; transition: transform 0.6s cubic-bezier(.3,1.4,.5,1); }
.tq-spare::before { content: attr(data-du); position: absolute; left: 50%; top: -22px; transform: translateX(-50%);
  font: 700 0.85rem var(--font-mono, monospace); color: var(--xp-green); opacity: 0; transition: opacity 0.4s; }
/* step 1: the pairs show themselves, the spare steps up and turns into du */
.tq-tiles.is-peeled .tq-pair, .tq-tiles.is-stuck .tq-pair { border-color: var(--xp-muted); }
.tq-tiles.is-peeled .tq-spare { transform: translateY(-6px) scale(1.06); margin-left: 14px; }
.tq-tiles.is-peeled .tq-spare::before { opacity: 1; }
.tq-tiles.is-peeled .tq-spare .tq-tile { border-color: var(--xp-green); background: rgba(131,193,103,0.16); }
.tq-tiles.is-stuck { animation: tq-stuck 0.5s ease-in-out 1; background: rgba(252,98,85,0.06); }
@keyframes tq-stuck { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
/* step 2: each pair flips into the other function */
.tq-tiles.is-swapped .tq-pair-a { opacity: 0; transform: rotateX(90deg); }
.tq-tiles.is-swapped .tq-pair-b { opacity: 1; transform: none; }
/* step 3: everything but du is now u */
.tq-tiles.is-in-u > .tq-tile, .tq-tiles.is-in-u .tq-pair-b { border-color: var(--xp-blue); background: rgba(88,196,221,0.12); }
.tq-tm-formula { min-height: 3.4em; overflow-x: auto; overflow-y: hidden; }
.tq-tm-formula .katex-display { margin: 0.3em 0; }
.tq-tm-note { margin: 0; color: var(--xp-ink); line-height: 1.65; min-height: 3.3em; }
.tq-tm-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
/* One group at the right edge (Poach, 15 Oct): the step dots, then ‹ ›, then ▶ — the main action outermost. */
.tq-tm-ctl .tq-tm-dots { order: 0; margin: 0 6px 0 0; }
.tq-tm-ctl [data-back], .tq-tm-ctl [data-fwd] { order: 1; }
.tq-tm-ctl [data-play] { order: 2; }
.tq-tm-ctl .xp-btn--ghost { min-width: 44px; }
.tq-tm-dots { display: inline-flex; gap: 6px; margin-left: 6px; }
.tq-tm-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--xp-rule); transition: background 0.3s; }
.tq-tm-dots i.is-on { background: var(--xp-blue); }
@media (prefers-reduced-motion: reduce) {
  .tq-tile, .tq-pair-a, .tq-pair-b, .tq-spare { transition: none; }
  .tq-tiles.is-stuck { animation: none; }
}
/* the triangle's sides, the same colours in the formula as in the picture */
.katex .tq-hyp { color: var(--xp-yellow); }
.katex .tq-opp { color: var(--xp-blue); }
.katex .tq-adj { color: var(--xp-green); }
@media (max-width: 560px) {
  .tq-tm { padding: 12px 10px 8px; }
  .tq-tile { min-width: 44px; padding: 6px 6px; font-size: 0.82rem; }
  .tq-pair-b { font-size: 0.82rem; padding: 6px 7px; }
  .tq-tm-formula { font-size: 0.88em; }
}
.tq-pair.is-half .tq-pair-b { border-color: var(--xp-muted); background: transparent; }
/* worked steps never widen the page: a long line scrolls inside its own card */
.tq-step { min-width: 0; overflow-x: auto; overflow-y: hidden; }

/* The opening (15 Oct 2026, Poach: "the space on the side it is so big compare to equation size"): the
   width of the text column, bigger equations, and the caption on one line with the button. */
.xp .tq-back-fig { max-width: 860px; }
.tq-back-fig .tq-cell { font-size: 1.6rem; }
.tq-back-fig .tq-row { padding: 12px 16px; }
.tq-back-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 8px 18px 16px; }
.tq-back-foot p { margin: 0; flex: 1 1 240px; color: var(--xp-muted); font-size: 0.92em; line-height: 1.5; }
.tq-back-foot .xp-btn { flex: none; margin-left: auto; }

/* Quizzes whose answers are all short (maths, a word or two) lay them out as a grid of centred tiles
   rather than full-width bars with the answer at the far left (15 Oct 2026). explore.js measures. */
.xp-quiz--grid .xp-options-grid { display: grid; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); gap: 10px; margin: 12px 0 4px; }
.xp-quiz--grid .xp-option { margin: 0; text-align: center; padding: 14px 10px; font-size: 1.05em; }
@media (max-width: 560px) { .tq-back-fig .tq-cell { font-size: 1.05rem; } }

/* A link to another part of the site, inside a lesson: the next-topic card, with an arrow (15 Oct 2026). */
.xp-next--side { position: relative; margin: 26px auto 8px; padding-right: 64px; }
.xp-next--side::after { content: "→"; position: absolute; right: 24px; top: 50%; transform: translateY(-50%);
  font-size: 1.6em; color: var(--xp-blue); transition: transform 0.2s; }
.xp-next--side:hover::after { transform: translate(4px, -50%); }

/* One slider and its buttons: the slider centred under the figure, the buttons at the right (Poach's
   annotated Derivatives screenshot, 15 Oct 2026). explore.js adds the spacer, as wide as the buttons. */
.xp-controls--centred { flex-wrap: nowrap; }
.xp-controls--centred > .xp-slider { flex: 1 1 auto; }
.xp-controls-side { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: flex-end; flex: none; }
.xp-controls-spacer { flex: none; }
@media (max-width: 640px) {
  .xp-controls--centred { flex-wrap: wrap; }
  .xp-controls-spacer { display: none; }
  .xp-controls-side { flex-basis: 100%; }
}
.xp-controls--centred.is-tight { flex-wrap: wrap; }
.xp-controls--centred.is-tight .xp-controls-spacer { display: none; }
.xp-controls--centred.is-tight .xp-controls-side { flex-basis: 100%; }

/* By parts (16 Oct 2026): three "how to choose u" patterns as cards, and the figure's note on the choice */
.tq-cards3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; margin: 14px 0 6px; }
.tq-card { display: grid; gap: 6px; align-content: start; padding: 12px 14px; border: 1px solid var(--xp-rule); border-radius: 12px; }
.tq-card b { color: var(--xp-strong); }
.tq-card p { margin: 0; color: var(--xp-muted); font-size: 0.92em; line-height: 1.6; }
.tq-card-math { overflow-x: auto; overflow-y: hidden; }
.tq-card-math .katex-display { margin: 0.4em 0 0; text-align: left; }
.tq-card-math .katex-display > .katex { text-align: left; }
.tq-parts-note { flex-basis: 100%; color: var(--xp-muted); font-family: var(--font-body, inherit); }
/* partial fractions: A green and B yellow, as their curves */
.katex .tq-pa { color: var(--xp-green); }
.katex .tq-pb { color: var(--xp-yellow); }

/* Limits version 3 (26 Oct 2026): the rule as the page's backbone, "what was done?" before each line, the lines of a
   worked problem with one left blank, and the way on to the worked chain. Colours from the --xp tokens, so the light
   board follows. */
.xp-figure--rule { padding: 18px; }
.xp-rule-examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.xp-rule-ex { padding: 8px 12px; border: 1px solid var(--xp-rule); border-radius: 10px; background: transparent;
  color: var(--xp-ink); font: inherit; font-size: 0.92em; cursor: pointer; }
.xp-rule-ex:hover { border-color: var(--xp-muted); }
.xp-rule-ex[aria-pressed="true"] { border-color: var(--xp-yellow); background: rgba(244,211,69,0.10); }
.xp-rule-sub { text-align: center; margin: 14px 0 6px; min-height: 1.7em; color: var(--xp-ink); font-family: var(--font-mono); }
/* four branches: 2 × 2 (never one alone on a row), one column on a phone; each card as tall as its own words */
.xp-rule-branches { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; align-items: start;
  grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .xp-rule-branches { grid-template-columns: minmax(0, 1fr); } }
.xp-rule-branch { padding: 12px 14px; border: 1px solid var(--xp-rule); border-radius: 12px; transition: opacity 250ms ease, border-color 250ms ease; }
.xp-rule-branch.is-on { border-color: var(--xp-yellow); background: rgba(244,211,69,0.06); }
.xp-rule-branch.is-off { opacity: 0.45; }
.xp-rule-branch p { margin: 6px 0; color: var(--xp-muted); font-size: 0.92em; line-height: 1.6; }
.xp-rule-head { display: flex; align-items: center; gap: 8px; }
.xp-rule-n { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 0.75em;
  border: 1px solid var(--xp-muted); color: var(--xp-muted); flex: none; }
.xp-rule-branch.is-on .xp-rule-n { border-color: var(--xp-yellow); color: var(--xp-yellow); }
.xp-rule-ways { list-style: none; margin: 4px 0 8px; padding: 0; display: grid; gap: 6px; }
.xp-rule-ways li { display: grid; gap: 2px; font-size: 0.88em; padding: 4px 8px; border-radius: 8px; }   /* the links always under the words */
.xp-rule-ways li.is-on { background: rgba(244,211,69,0.12); color: var(--xp-strong); }
.xp-rule-links { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.85em; }
.xp-rule-branch > .xp-rule-links { display: flex; justify-content: flex-end; }
.xp-ask { padding: 10px 6px 0; }
.xp-ask[hidden] { display: none; }
.xp-ask-q { margin: 0 0 4px; color: var(--xp-strong); font-weight: 600; font-family: var(--font-body); }
.xp-ask-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 0 10px; }
.xp-ask-choices .xp-option:disabled { cursor: default; }
.xp-ask-why { margin: 8px 0 0; padding: 8px 12px; border-left: 3px solid var(--xp-yellow); color: var(--xp-ink); line-height: 1.7; font-family: var(--font-body); }
.xp-ask-why[hidden] { display: none; }
.xp-lines { margin: 10px 0; padding-left: 1.6em; line-height: 2; color: var(--xp-ink); }
.xp-lines-blank { color: var(--xp-yellow); font-weight: 700; }
.xp-option:disabled { cursor: default; }
.xp-chain-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin: 28px 0 0;
  padding: 16px 20px; border: 1px solid rgba(88,196,221,0.4); border-radius: 14px; background: rgba(88,196,221,0.08); }
.xp-chain-cta p { margin: 0; max-width: 60ch; }
.xp-chain-cta .xp-btn { margin-left: auto; }


/* ==========================================================================
   The 3-D board (27 Oct 2026, static/js/board3d.js) and its page, /space.
   Poach: "maybe like desmos but better and more … make it very good looking". The stage is the lesson board's own
   ground; labels are HTML over the canvas (crisp, KaTeX, Thai fonts) with a halo of the ground so they read over any
   surface; the controls are pills on the stage (buttons right), and the hint fades once the board is touched.
   ========================================================================== */
.xp {
  --sp-blue: var(--xp-blue); --sp-yellow: var(--xp-yellow); --sp-green: var(--xp-green); --sp-red: var(--xp-red);
  --sp-orange: #FF862F; --sp-purple: #B189C6; --sp-teal: #5CD0B3;
}
:root[data-theme="light"] .xp { --sp-orange: #c76a1c; --sp-purple: #7a4f8c; --sp-teal: #1d8a72; }
.b3 {
  position: relative; overflow: hidden; border-radius: 18px; background: var(--xp-bg);
  border: 1px solid var(--xp-rule); aspect-ratio: 4 / 3; min-height: 320px;
  box-shadow: 0 1px 0 rgba(var(--xp-fg-rgb), 0.04) inset, 0 18px 48px -28px rgba(0, 0, 0, 0.55);
}
.b3-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.b3.is-dragging .b3-canvas { cursor: grabbing; }
.b3-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.b3-label {
  position: absolute; left: 0; top: 0; translate: -50% -50%; white-space: nowrap; line-height: 1;
  color: var(--xp-muted); font-size: 12px; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 3px var(--xp-bg), 0 0 6px var(--xp-bg), 0 0 10px var(--xp-bg);
}
.b3-axis { color: var(--xp-ink); font-size: 17px; }
.b3-tick { font-size: 12px; font-weight: 500; color: var(--xp-ink); opacity: 0.7; }   /* were faint and hard to read */
.b3-tick--z { translate: calc(-100% - 8px) -50%; }
.b3-name { font-size: 15px; font-weight: 600; translate: 10px calc(-100% - 6px); }
.b3-name--point { translate: 12px calc(-100% - 8px); }
.b3-pills {
  position: absolute; top: 12px; right: 12px; display: flex; gap: 2px; padding: 4px; border-radius: 999px; z-index: 2;
  background: color-mix(in srgb, var(--xp-panel) 82%, transparent); border: 1px solid var(--xp-rule);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.b3-pills button {
  font: inherit; font-size: 0.8rem; padding: 5px 13px; border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--xp-muted); transition: background .2s, color .2s;
}
.b3-pills button:hover, .b3-pills button:focus-visible { color: var(--xp-ink); }
.b3-pills button[aria-pressed="true"] { background: rgba(var(--xp-fg-rgb), 0.12); color: var(--xp-strong); }
/* the two views are one choice; after the line, switches that work in either view (28 Oct 2026) */
.b3-pills .b3-sep { flex: none; width: 1px; margin: 5px 3px; background: var(--xp-rule); }
.b3-pills [data-spin] { display: inline-flex; align-items: center; gap: 6px; }
.b3-pills [data-spin] svg { flex: none; }
.b3-pills [data-spin][aria-pressed="true"] svg { animation: b3-spin 4s linear infinite; }
@keyframes b3-spin { to { rotate: 360deg; } }
@media (prefers-reduced-motion: reduce) { .b3-pills [data-spin][aria-pressed="true"] svg { animation: none; } }
.b3-hint {
  position: absolute; left: 50%; bottom: 14px; translate: -50% 0; margin: 0; padding: 5px 14px; border-radius: 999px;
  font-size: 0.78rem; color: var(--xp-muted); pointer-events: none; transition: opacity .6s;
  background: color-mix(in srgb, var(--xp-panel) 75%, transparent); border: 1px solid var(--xp-rule);
}
.b3.is-touched .b3-hint { opacity: 0; }
.b3-nogl[hidden] { display: none; }
.b3-nogl { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; text-align: center; color: var(--xp-muted); }

/* the page */
.xp-space { padding-top: clamp(24px, 4vw, 48px); }
.xp-space > .sp-head { max-width: 1240px; }
.sp-head h1 { font-size: clamp(2.4rem, 1.8rem + 3vw, 3.8rem); margin: 0.05em 0 0.1em; }
.sp-lede { color: var(--xp-muted); max-width: 46em; margin: 0 0 1.4em; }
.xp > .sp-app { max-width: 1240px; display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.sp-board .b3 { aspect-ratio: auto; height: min(74vh, 700px); }
.sp-list { display: flex; flex-direction: column; gap: 10px; font-size: 0.95rem; }
.sp-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sp-row {
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: start;
  padding: 12px 10px 10px 14px; border-radius: 14px; background: var(--xp-panel); border: 1px solid var(--xp-rule);
}
.sp-row:focus-within { border-color: color-mix(in srgb, var(--xp-blue) 55%, transparent); }
.sp-swatch { width: 12px; height: 12px; border-radius: 50%; margin-top: 9px; box-shadow: 0 0 10px currentColor; }
.sp-field { min-width: 0; }
.sp-input {
  width: 100%; font: inherit; font-family: var(--font-mono); font-size: 0.95rem; color: var(--xp-ink);
  background: transparent; border: 0; border-bottom: 1px solid var(--xp-rule); padding: 4px 0 6px; outline: none;
}
.sp-input:focus { border-bottom-color: var(--xp-blue); }
.sp-tex { min-height: 1.5em; margin-top: 6px; color: var(--xp-strong); font-size: 0.92em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-msg { margin: 6px 0 0; font-size: 0.82em; line-height: 1.5; color: var(--xp-red); }
/* the Vectors lesson's controls (static/js/vectors/lesson.js): a vector's x, y, z, each in its axis's colour */
.vx-comps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; flex: 1 1 100%; }
.vx-comps-h { min-width: 1.4em; color: var(--xp-ink); }
.vx-comp { display: flex; align-items: center; gap: 8px; flex: 1 1 150px; font-family: var(--font-mono); font-size: 0.88em; }
.vx-comp input { flex: 1; min-width: 80px; }
.vx-comp output { min-width: 2em; text-align: right; color: var(--xp-ink); font-variant-numeric: tabular-nums; }
.vx-comp--x span, .vx-comp--x output { color: var(--xp-red); }   .vx-comp--x input { accent-color: var(--xp-red); }
.vx-comp--y span, .vx-comp--y output { color: var(--xp-green); } .vx-comp--y input { accent-color: var(--xp-green); }
.vx-comp--z span, .vx-comp--z output { color: var(--xp-blue); }  .vx-comp--z input { accent-color: var(--xp-blue); }
.vx-comps[hidden] { display: none; }
.vx-seg { flex: 1 1 100%; }
/* the surfaces figure's slice: which way, where, how see-through */
.vx-slice { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; flex: 1 1 100%; }
.vx-slice .xp-slider { flex: 1 1 240px; }
.xp-slider[hidden] { display: none; }   /* display: flex above beat [hidden]: the 2-D figure still showed z */
.vx-seg--wrap { flex-wrap: wrap; }
.xp-figure .b3 { aspect-ratio: 16 / 10; }
.vx-read { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 6px 2em; }
.vx-part { max-width: 100%; overflow-x: auto; overflow-y: hidden; }
@media (max-width: 860px) {
  .xp-figure .b3 { aspect-ratio: 1 / 1; }
  .vx-read { flex-direction: column; align-items: flex-start; gap: 8px; }
}
.sp-back { display: inline-block; margin-bottom: 10px; font-size: 0.9em; color: var(--xp-blue); text-decoration: none; }
.sp-back:hover { text-decoration: underline; }
/* how solid a surface is: faded, it leaves its grid lines, so what it hid shows through */
.sp-opac { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 0.78em; color: var(--xp-muted); }
.sp-opac input { flex: 1; min-width: 0; accent-color: var(--xp-blue); }
.sp-opac[hidden] { display: none; }
.sp-eye, .sp-del {
  font: inherit; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; border: 0; cursor: pointer;
  background: transparent; color: var(--xp-muted);
}
.sp-eye[aria-pressed="false"] { opacity: 0.35; }
.sp-eye:hover, .sp-del:hover { background: rgba(var(--xp-fg-rgb), 0.07); color: var(--xp-ink); }
.sp-del { font-size: 1.25rem; line-height: 1; }
.sp-add {
  font: inherit; padding: 11px; border-radius: 14px; cursor: pointer; color: var(--xp-muted);
  background: transparent; border: 1px dashed color-mix(in srgb, var(--xp-muted) 45%, transparent);
}
.sp-add:hover, .sp-add:focus-visible { color: var(--xp-ink); border-color: var(--xp-blue); }
.sp-examples { margin-top: 6px; }
.sp-examples-h { margin: 0 0 6px; color: var(--xp-muted); font-size: 0.8rem; letter-spacing: 0.04em; }
.sp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-chips button {
  font: inherit; font-size: 0.8rem; padding: 4px 11px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--xp-ink); border: 1px solid var(--xp-rule);
}
.sp-chips button:hover, .sp-chips button:focus-visible { border-color: var(--xp-blue); color: var(--xp-blue); }
.sp-sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 20px; margin-top: 14px; }
.sp-sliders[hidden] { display: none; }
.sp-hint { margin: 8px 0 0; font-size: 0.8em; color: var(--xp-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sp-hint[hidden] { display: none; }
.sp-hint button { font: inherit; font-size: 1em; padding: 2px 10px; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--xp-blue) 14%, transparent); color: var(--xp-ink); border: 1px solid color-mix(in srgb, var(--xp-blue) 55%, transparent); }
.b3:fullscreen { height: 100%; border-radius: 0; border: 0; }
/* the 3-D board card on a topic page: a live preview beside the words (28 Oct 2026). The preview carries the .xp
   colours for the board; the lesson's own spacing and type are switched off on it. */
.space-card { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: center;
  padding: 12px; border-radius: 16px; text-decoration: none; color: inherit;
  background: var(--surface-2, #151a21); border: 1px solid var(--rule, rgba(255,255,255,.09)); transition: border-color .2s, transform .2s; }
.space-card:hover, .space-card:focus-visible { border-color: var(--accent, #58C4DD); transform: translateY(-1px); }
.space-card__view.xp { display: block; padding: 0; height: 230px; font-size: 12px; line-height: 1; border-radius: 12px; overflow: hidden; }
.space-card__view .b3 { display: block; height: 100%; aspect-ratio: auto; min-height: 0; border: 0; border-radius: 12px; box-shadow: none; }
.space-card__view canvas, .space-card__view .b3-labels { pointer-events: none; }
.space-card__view.is-flat { display: none; }
.space-card__text { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 4px 8px 4px 0; }
.space-card__lede { line-height: 1.6; }
@media (max-width: 720px) {
  .space-card { grid-template-columns: minmax(0, 1fr); }
  .space-card__view.xp { height: 200px; }
  .space-card__text { padding: 0 4px 4px; }
}
/* the double-integral row: f, the order, each variable's bounds, what to show, and the answer (28 Oct 2026) */
.sp-adds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sp-adds .sp-add { margin: 0; }
.sp-int-h { margin: 0 0 6px; font-size: 0.82rem; font-weight: 600; color: var(--xp-ink); }
.sp-int-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; font-family: var(--font-mono); font-size: 0.88rem; color: var(--xp-ink); }
.sp-int-line .sp-int-in:not(.sp-int-n) { min-width: 9.5em; }   /* −√(1 − x²) has to fit; the line wraps if it must */
.sp-int-line > span:first-child { min-width: 1.2em; }
.sp-int-w { font-family: inherit; font-size: 0.78rem; color: var(--xp-muted); }
.sp-int-in { flex: 1; min-width: 0; font: inherit; padding: 4px 8px; border-radius: 8px; background: var(--xp-bg); color: var(--xp-ink); border: 1px solid var(--xp-rule); }
.sp-int-in:focus { outline: none; border-color: var(--xp-blue); }
.sp-int-n { flex: 0 1 4.5em; }
.sp-int-order { margin: 6px 0; width: fit-content; }
.sp-int-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 4px; }
.sp-int-depth button { font-size: 1.05rem; padding: 4px 14px; }
.sp-int-what { font-size: 0.78rem; color: var(--xp-muted); }
.sp-int-keys { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 8px; }
.sp-int-keys button { font: inherit; font-family: var(--font-mono); font-size: 0.78rem; padding: 3px 8px; border-radius: 7px; cursor: pointer;
  background: transparent; color: var(--xp-ink); border: 1px solid var(--xp-rule); }
.sp-int-keys button:hover { border-color: var(--xp-blue); }
.sp-int-levels { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 8px; }
.sp-int-level { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; border-radius: 10px;
  border: 1px dashed var(--xp-rule); font-family: var(--font-mono); font-size: 0.86rem; color: var(--xp-ink); }
.sp-int-ord { flex-basis: 100%; font-family: var(--font-body, inherit); font-size: 0.72rem; color: var(--xp-muted); }
.sp-int-var button { font-size: 0.8rem; padding: 3px 9px; }
.sp-int-level .sp-int-in { min-width: 6em; flex: 1 1 6em; }
.sp-int-show { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 4px; }
.sp-int-show .sp-switch { font-size: 0.8rem; }
.sp-int-nbox { margin-top: 4px; }
.sp-int-res { margin-top: 8px; overflow-x: auto; overflow-y: hidden; color: var(--xp-ink); font-size: 0.95em; }
.sp-list-tools { display: flex; gap: 8px; margin-top: 8px; }
.sp-list-tools button, .sp-undo button { font: inherit; font-size: 0.8rem; padding: 6px 12px; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--xp-muted); border: 1px solid var(--xp-rule); }
.sp-list-tools button:hover, .sp-undo button:hover { color: var(--xp-ink); border-color: var(--xp-blue); }
.sp-list-tools [data-clear]:hover { border-color: var(--xp-red); }
.sp-undo { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; font-size: 0.82rem; color: var(--xp-ink); }
.sp-undo[hidden] { display: none; }
/* ---- the board's settings panel (27 Oct 2026): three groups, real switches, segmented sizes ---- */
.sp-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 14px; }
.sp-group { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; border-radius: 14px;
  background: var(--xp-panel); border: 1px solid var(--xp-rule); }
.sp-group--size { grid-column: span 2; }
.sp-panel-h { margin: 0 0 2px; font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--xp-muted); }
.sp-panel-h span { text-transform: none; letter-spacing: 0; margin-left: 6px; opacity: 0.8; }
.sp-switch { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; color: var(--xp-ink); cursor: pointer; user-select: none; }
.sp-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sp-switch-ui { flex: none; width: 34px; height: 20px; border-radius: 999px; background: var(--xp-rule); position: relative;
  transition: background .18s; }
.sp-switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--xp-bg); box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .18s; }
.sp-switch input:checked + .sp-switch-ui { background: var(--xp-blue); }
.sp-switch input:checked + .sp-switch-ui::after { transform: translateX(14px); }
.sp-switch input:focus-visible + .sp-switch-ui { outline: 2px solid var(--xp-blue); outline-offset: 2px; }
.sp-switch input:not(:checked) ~ span:last-child { color: var(--xp-muted); }
.sp-size-row { display: flex; align-items: center; gap: 10px; }
.sp-size-row > span { min-width: 2.6em; font-family: var(--font-mono); font-size: 0.85rem; color: var(--xp-muted); }
.sp-seg { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--xp-rule); border-radius: 10px; overflow: hidden; }
.sp-seg button { font: inherit; font-size: 0.8rem; padding: 6px 11px; border: 0; border-right: 1px solid var(--xp-rule);
  background: transparent; color: var(--xp-muted); cursor: pointer; font-variant-numeric: tabular-nums; display: inline-flex; gap: 5px; align-items: baseline; }
.sp-seg button:last-child { border-right: 0; }
.sp-seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--xp-blue) 22%, transparent); color: var(--xp-ink); }
.sp-seg button:hover { color: var(--xp-ink); }
.sp-seg button small { font-size: 0.72em; opacity: 0.7; }
.sp-seg button[hidden] { display: none; }
.sp-size-note { margin: 2px 0 0; font-size: 0.76rem; color: var(--xp-muted); }
/* where they meet: a letter on the board, the numbers here */
.sp-meets { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--xp-panel); border: 1px solid var(--xp-rule); }
.sp-meets[hidden] { display: none; }
.sp-meets ol { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; max-height: 220px; overflow-y: auto; }
.sp-meet { width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 10px; cursor: pointer;
  font: inherit; font-size: 0.85rem; text-align: left; background: transparent; color: var(--xp-ink); border: 1px solid transparent; }
.sp-meet:hover { border-color: var(--xp-rule); }
.sp-meet[aria-pressed="true"] { border-color: color-mix(in srgb, var(--xp-blue) 60%, transparent); background: color-mix(in srgb, var(--xp-blue) 12%, transparent); }
.sp-meet b { min-width: 1.2em; }
.sp-meet-of { display: inline-flex; gap: 3px; }
.sp-meet-of i { width: 8px; height: 8px; border-radius: 50%; }
.sp-meet-v { font-size: 0.95em; }
.sp-meet { flex-wrap: wrap; }
/* the exact form on its own line, in full — cut off beside the decimals it showed only "= (9/7 …" */
.sp-meet-x { flex-basis: 100%; padding: 4px 0 2px calc(1.2em + 10px + 19px + 10px); font-size: 1em; color: var(--xp-ink); overflow-x: auto; }
.sp-meet-v { font-size: 1em; }
.sp-meet-t { font-size: 0.72rem; padding: 1px 7px; border-radius: 999px; color: var(--xp-muted); border: 1px solid var(--xp-rule); white-space: nowrap; }
.sp-meet-t--x { color: var(--xp-red); } .sp-meet-t--y { color: var(--xp-green); } .sp-meet-t--z { color: var(--xp-blue); }
.sp-meet-t--min, .sp-meet-t--max, .sp-meet-t--saddle, .sp-meet-t--flat { color: var(--xp-yellow); }
/* the picked point takes the whole row, its exact form on one line (it wrapped inside one narrow column) */
.sp-meets li:has(.sp-meet[aria-pressed="true"]) { grid-column: 1 / -1; }
.sp-meet-x .katex { white-space: nowrap; }
.sp-meet-x:empty { display: none; }
.sp-settings { margin-top: 12px; }
.sp-settings > summary { cursor: pointer; font-size: 0.85rem; color: var(--xp-muted); padding: 8px 2px; list-style: none; }
.sp-settings > summary::before { content: "▸ "; }
.sp-settings[open] > summary::before { content: "▾ "; }
.sp-settings > .sp-panel { margin-top: 4px; }
/* the examples, in groups */
.sp-examples-h span { margin-left: 8px; font-size: 0.75rem; color: var(--xp-muted); font-weight: 400; }
.sp-exgroup { margin-top: 12px; }
.sp-exgroup-h { margin: 0 0 6px; font-size: 0.74rem; color: var(--xp-muted); letter-spacing: 0.04em; }
/* each example a small card: its name, and the equation it will draw (the last numbers it made, once pressed) */
.sp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.sp-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; padding: 8px 10px 9px;
  border-radius: 11px; cursor: pointer; text-align: left; font: inherit; color: var(--xp-ink);
  background: var(--xp-panel); border: 1px solid var(--xp-rule); transition: border-color .15s, transform .15s; }
.sp-card:hover, .sp-card:focus-visible { border-color: var(--xp-blue); transform: translateY(-1px); }
.sp-card-n { font-size: 0.82rem; font-weight: 600; }
.sp-card-n::after { content: ""; }
.sp-card.is-used .sp-card-n::after { content: "  ↻"; color: var(--xp-blue); font-weight: 400; }
.sp-card-f { font-size: 0.78rem; color: var(--xp-muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* which shape is which: a key in the board's corner, each equation in its shape's colour */
.b3-key { position: absolute; left: 12px; top: 12px; z-index: 2; margin: 0; padding: 8px 12px; list-style: none; pointer-events: none;
  display: flex; flex-direction: column; gap: 4px; max-width: min(46%, 320px); border-radius: 12px; font-size: 13px;
  background: color-mix(in srgb, var(--xp-bg) 78%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--xp-rule); }
.b3-key li { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.b3-key i { flex: none; width: 9px; height: 9px; border-radius: 50%; }
@media (max-width: 860px) { .b3-key { font-size: 11px; padding: 6px 9px; top: 52px; } }
@media (max-width: 860px) {
  .sp-group--size { grid-column: auto; }
  .sp-seg button { padding: 6px 9px; }
}
/* the aids, each on or off: pressed is lit, off is a quiet outline */
.sp-show { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 14px; }
.sp-show-h { font-size: 0.78rem; color: var(--xp-muted); margin-right: 2px; }
.sp-show button {
  font: inherit; font-size: 0.78rem; padding: 4px 11px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--xp-muted); border: 1px solid var(--xp-rule);
}
.sp-show button[aria-pressed="true"] { color: var(--xp-ink); border-color: color-mix(in srgb, var(--xp-blue) 55%, transparent);
  background: color-mix(in srgb, var(--xp-blue) 14%, transparent); }
.sp-show button:hover, .sp-show button:focus-visible { border-color: var(--xp-blue); }
.sp-slider { display: grid; grid-template-columns: 1.4em minmax(0, 1fr) 3.2em; gap: 10px; align-items: center; color: var(--xp-ink); }
.sp-slider input { width: 100%; accent-color: var(--xp-blue); }
.sp-slider output { text-align: right; font-variant-numeric: tabular-nums; color: var(--xp-muted); font-family: var(--font-mono); font-size: 0.9em; }
@media (max-width: 860px) {
  .xp > .sp-app { grid-template-columns: minmax(0, 1fr); }
  .sp-board { order: -1; }
  /* taller on a phone: at 78vw the board was 300px and the hint covered much of it (27 Oct 2026) */
  .sp-board .b3 { height: min(108vw, 72vh); min-height: 340px; }
  .sp-board .b3-hint { font-size: 11px; padding: 4px 10px; max-width: 70%; text-align: center; }
  .sp-meets ol { max-height: 150px; }
}

/* Multiple integrals: the slice areas as a graph under the board, the counted part green (28 Oct 2026) */
.mi-plot { display: block; width: 100%; max-width: 520px; height: auto; margin: 10px auto 0; overflow: visible; }
.mi-plot-axis { stroke: var(--xp-muted); stroke-width: 1.2; }
.mi-plot-num { fill: var(--xp-muted); font-size: 12px; font-family: inherit; }
.mi-plot-name { fill: var(--xp-ink); font-size: 13px; font-style: italic; font-family: KaTeX_Main, serif; }
.mi-plot-curve { fill: none; stroke: var(--xp-yellow); stroke-width: 2.5; }
.mi-plot-fill { fill: var(--xp-green); fill-opacity: 0.55; }
.mi-plot-stem { stroke: var(--xp-yellow); stroke-width: 2; stroke-dasharray: 4 3; }
.mi-plot-dot { fill: var(--xp-yellow); stroke: var(--xp-bg, #0d1014); stroke-width: 2; }
