:root {
  /* Mathesis: warm palette taken from the Saraswati drawing (deep brown → orange → gold) */
  --bg: #fbf6ee;
  --panel: #fffdf9;
  --text: #2b1a0e;
  --muted: #7d6753;
  --line: #ecdfcc;
  --grid: #f4eadb;
  --accent: #c4561a;
  --accent-2: #e5a019;
  --accent-soft: #fbead9;
  --good: #2b8a3e;
  --warn: #e8590c;
  --danger: #c92a4b;
  --radius: 18px;
  --on-accent: #fff;
  --c1: #c4561a; --c2: #1c7c86; --c3: #5c940d; --c4: #8e3b6a; --c5: #d6336c; --c6: #d99a0b;
  --font-body: "Source Sans 3", "Noto Sans Bengali", "Noto Sans Devanagari", "Noto Sans JP", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: "Source Serif 4", "Noto Serif Bengali", "Noto Serif Devanagari", "Noto Serif JP", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "Noto Sans Bengali", "Noto Sans Devanagari", "Noto Sans JP", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --tri-fill: rgba(196, 86, 26, .12);
  --shadow: 0 1px 2px rgba(60, 30, 10, .05), 0 10px 30px rgba(60, 30, 10, .08);
  --shadow-lg: 0 2px 4px rgba(60, 30, 10, .06), 0 22px 50px rgba(60, 30, 10, .16);
  --glass: rgba(255, 252, 246, .76);
  --grad: linear-gradient(135deg, #8a3f0e, var(--accent) 45%, var(--accent-2));
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 var(--font-body);
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 8px; font-family: var(--font-head); }
h4 { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95em; }
.row { display: flex; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
.gap { gap: 8px; }
.grow { flex: 1; min-width: 200px; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.logo { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-family: Georgia, serif; font-size: 20px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.banner { background: #fff4e6; color: #7a3a00; padding: 8px 20px; font-size: 14px; border-bottom: 1px solid #ffd8a8; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; }

/* ---------- controls ---------- */
input[type=text], input[type=search], input[type=number], select, textarea {
  font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, .geo-handle:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
textarea { width: 100%; resize: vertical; }
.btn {
  font: inherit; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn.icon { width: 34px; height: 34px; padding: 0; font-size: 18px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
.check { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.chip {
  font: inherit; font-size: 14px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip.static { cursor: default; background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }

/* ---------- library ---------- */
.hero { margin: 8px 0 16px; }
.hero h1 { font-size: 28px; }
.levels { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.level {
  font: inherit; font-weight: 600; flex: none; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.level.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.level .count { font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 0 7px; }
.level.active .count { background: rgba(255, 255, 255, 0.25); color: var(--on-accent); }
.filters { display: flex; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; transition: transform .12s, box-shadow .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(12, 16, 30, .1); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--accent-soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-ph { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--accent); font-weight: 600; font-size: 14px;
  background: linear-gradient(135deg, var(--accent-soft), transparent); }
.thumb-icon { font-size: 34px; }
.done-badge { position: absolute; top: 8px; right: 8px; background: var(--good); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.card-body { padding: 10px 12px 12px; }
.card-title { font-weight: 600; margin-bottom: 2px; }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); grid-column: 1 / -1; }

/* ---------- lesson ---------- */
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; }
.lesson { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 980px) { .lesson { grid-template-columns: 1fr; } }
.lesson-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; }
.player iframe, .player video, .player > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.player-ph { background: linear-gradient(135deg, #2c3a7a, #3b5bdb); color: #fff; }
.player-ph > div { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; gap: 8px; }
.ph-icon { font-size: 40px; width: 72px; height: 72px; border-radius: 50%; background: rgba(255, 255, 255, .2); display: grid; place-items: center; }
.lesson-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.lesson-title { font-size: 22px; margin: 0; }
.desc { white-space: pre-line; margin: 0; }
.notes-panel summary { cursor: pointer; font-weight: 600; }
.notes { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.notes li { display: flex; align-items: flex-start; gap: 8px; }
.note-text { flex: 1; white-space: pre-wrap; padding-top: 4px; }
.time { font: inherit; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; background: var(--accent-soft); color: var(--accent); border: 0; border-radius: 6px; padding: 4px 8px; cursor: pointer; }
.more h3 { font-size: 17px; margin-top: 8px; }
.small-cards { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.small-cards .card-title { font-size: 14px; }

/* ---------- tools panel ---------- */
.tools-panel { position: sticky; top: 72px; min-width: 0; }
.tools-panel.full { position: static; }
@media (max-width: 980px) { .tools-panel { position: static; } }
.tools-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.tools-head h2 { font-size: 18px; }
.tool-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin: 4px 0 8px; scrollbar-width: thin; }
.tool-tab {
  font: inherit; font-size: 14px; font-weight: 500; flex: none; padding: 7px 11px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; gap: 4px;
}
.tool-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sugg { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; background: var(--good); color: #fff; border-radius: 4px; padding: 0 5px; margin-left: 4px; }
.tool-blurb { margin: 0 0 8px; }
.fn-error { color: var(--danger); min-height: 0; }
.fn-error:empty { display: none; }

/* grapher */
.tool-grapher { display: flex; flex-direction: column; gap: 10px; }
.tools-panel.full .tool-grapher { display: grid; grid-template-columns: 340px 1fr; align-items: start; }
@media (max-width: 860px) { .tools-panel.full .tool-grapher { grid-template-columns: 1fr; } }
.tool-controls { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fn-list { display: flex; flex-direction: column; gap: 6px; }
.fn-row { display: grid; grid-template-columns: 12px auto 1fr auto; align-items: center; gap: 6px; }
.fn-row .fn-error { grid-column: 3 / 5; font-size: 13px; }
.fn-row input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; width: 100%; }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.fn-label { font-style: italic; color: var(--muted); }
.sliders { display: flex; flex-direction: column; gap: 4px; }
.slider { display: grid; grid-template-columns: minmax(36px, auto) minmax(0, 1fr) minmax(48px, auto); align-items: center; gap: 8px; }
.slider b { font-style: italic; font-weight: 600; }
.slider-val { font-variant-numeric: tabular-nums; text-align: right; }
.calc-options { font-size: 14px; }
.calc-options summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.calc-options label { display: flex; margin: 6px 0; flex-wrap: wrap; }
.num-sm { width: 72px; padding: 3px 6px !important; }
.graph-info { color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.graph-wrap { position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.graph-canvas { display: block; width: 100%; height: 380px; touch-action: none; cursor: crosshair; }
.tools-panel.full .graph-canvas { height: min(70vh, 620px); }
.graph-readout { position: absolute; left: 8px; top: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-variant-numeric: tabular-nums; pointer-events: none; }
.graph-readout:empty { display: none; }
.graph-zoom { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 4px; }

/* number line */
.tool-numberline { display: flex; flex-direction: column; gap: 8px; }
.tool-numberline input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 18px; }
.nl-svg svg { width: 100%; height: auto; display: block; }
.nl-axis { stroke: var(--text); stroke-width: 2; }
.nl-arrow { fill: var(--text); }
.nl-tick { stroke: var(--text); stroke-width: 2; }
.nl-tick-sm { stroke: var(--muted); stroke-width: 1; }
.nl-label { fill: var(--text); font-size: 19px; text-anchor: middle; }
.nl-jump { fill: none; stroke-width: 3; }
.nl-jump.up { stroke: var(--good); }
.nl-jump.down { stroke: var(--warn); }
.nl-jump.head { stroke-width: 2; stroke-linejoin: round; }
.nl-jump.head.up { fill: var(--good); }
.nl-jump.head.down { fill: var(--warn); }
.nl-jump.lbl { stroke: none; font-size: 21px; font-weight: 700; text-anchor: middle; }
.nl-jump.lbl.up { fill: var(--good); }
.nl-jump.lbl.down { fill: var(--warn); }
.nl-start { fill: var(--panel); stroke: var(--accent); stroke-width: 3; }
.nl-end { fill: var(--accent); }
.nl-endlabel { fill: var(--accent); font-weight: 700; font-size: 22px; text-anchor: middle; }
.nl-steps { margin: 4px 0; padding-left: 22px; }
.nl-steps li { margin: 2px 0; }

/* fractions */
.tool-fractions { display: flex; flex-direction: column; gap: 10px; }
.frac-in { width: 110px; text-align: center; font-size: 20px !important; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.fbars { display: flex; flex-direction: column; gap: 8px; }
.fbar-group { display: grid; grid-template-columns: fit-content(45%) minmax(80px, 1fr); gap: 4px 10px; align-items: center; }
.fbar-label { grid-row: span 6; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-align: right; min-width: 60px; }
.fbar { display: grid; gap: 2px; height: 26px; grid-column: 2; }
.fbar span { background: var(--grid); border-radius: 3px; border: 1px solid var(--line); }
.fbar-smooth { display: flex; background: var(--grid); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.fbar-smooth span { border: 0; border-radius: 0; height: 100%; }

/* numbers */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.subtab { font: inherit; font-size: 14px; background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 10px; color: var(--muted); cursor: pointer; }
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.num-lg { font-size: 20px !important; width: 160px; }
.tool-numbers label { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.tool-numbers sup { font-size: 0.7em; }
.ladder { display: inline-flex; flex-direction: column; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0 0 8px; }
.ladder-row { display: grid; grid-template-columns: 36px auto; }
.ladder-p { text-align: right; padding-right: 8px; color: var(--accent); font-weight: 700; }
.ladder-n { border-left: 2px solid var(--text); border-bottom: 2px solid var(--text); padding: 1px 10px; }
.ladder-row:last-child .ladder-n { border: 0; }
.div-rules { display: flex; flex-direction: column; gap: 3px; font-size: 14px; margin: 8px 0; }
.div-rule.no { color: var(--muted); }
.div-badge { display: inline-block; min-width: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.div-rule.yes .div-badge { color: var(--good); }
.pf-table { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.pf-table th, .pf-table td { border: 1px solid var(--line); padding: 4px 10px; text-align: center; }
.pf-table tr.hl td { background: var(--accent-soft); }
.pf-table td:first-child { text-align: left; }
.grid100 { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; max-width: 460px; }
.cell { font: inherit; font-size: 14px; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); cursor: pointer; padding: 0; font-variant-numeric: tabular-nums; }
.cell.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.cell.pick { background: var(--warn); border-color: var(--warn); }
.calc-in { width: 100%; font-size: 20px !important; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.calc-out { font-size: 26px; font-weight: 700; margin: 6px 0; font-variant-numeric: tabular-nums; word-break: break-all; }
.calc-out.fn-error { font-size: 16px; font-weight: 400; }
.calc-history { padding-left: 18px; }

/* geometry */
.tool-geometry { display: flex; flex-direction: column; gap: 8px; }
.geo-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.geo-svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
.geo-grid line { stroke: var(--grid); stroke-width: 0.03; }
.geo-tri { fill: var(--tri-fill); stroke: var(--accent); stroke-width: 0.07; stroke-linejoin: round; }
.geo-arc { fill: none; stroke: var(--warn); stroke-width: 0.05; }
.geo-anglabel { font-size: 0.42px; fill: var(--warn); font-weight: 700; text-anchor: middle; dominant-baseline: middle; }
.geo-sidelabel { font-size: 0.4px; fill: var(--text); text-anchor: middle; dominant-baseline: middle; font-style: italic; }
.geo-vlabel { font-size: 0.5px; font-weight: 700; fill: var(--accent); text-anchor: middle; dominant-baseline: middle; }
.geo-handle { cursor: grab; outline: none; }
.geo-handle circle { fill: var(--accent); }
.geo-handle circle.hit { fill: var(--accent); opacity: 0.15; }
.geo-handle:focus-visible circle.hit { opacity: 0.4; }
.geo-sq { stroke-width: 0.04; }
.geo-sq.sq-a { fill: rgba(232, 89, 12, .15); stroke: #e8590c; }
.geo-sq.sq-b { fill: rgba(47, 158, 68, .15); stroke: #2f9e44; }
.geo-sq.sq-c { fill: rgba(174, 62, 201, .15); stroke: #ae3ec9; }
.geo-sqlabel { font-size: 0.45px; font-weight: 700; fill: var(--text); text-anchor: middle; dominant-baseline: middle; }
.geo-med { stroke: #2f9e44; stroke-width: 0.04; stroke-dasharray: 0.15 0.1; }
.geo-alt { stroke: #c2255c; stroke-width: 0.04; stroke-dasharray: 0.15 0.1; }
.geo-ext { stroke: #c2255c; stroke-width: 0.03; opacity: .5; }
.geo-circ { fill: none; stroke: #1098ad; stroke-width: 0.05; }
.geo-inc { fill: none; stroke: #ae3ec9; stroke-width: 0.05; }
.geo-dot.med { fill: #2f9e44; } .geo-dot.alt { fill: #c2255c; } .geo-dot.circ { fill: #1098ad; } .geo-dot.inc { fill: #ae3ec9; }
.geo-facts p { margin: 4px 0; }
.pyth { background: var(--accent-soft); padding: 6px 10px; border-radius: 8px; }

@media (max-width: 600px) {
  main { padding: 14px 12px; }
  .topbar { padding: 8px 12px; }
  .nav a { padding: 6px 8px; font-size: 15px; }
  .hero h1 { font-size: 24px; }
  .panel { padding: 12px; }
  .graph-canvas { height: 320px; }
  .lesson-head { flex-direction: column; }
}

/* ---------- theme switch ---------- */
.topbar { flex-wrap: wrap; }
.theme-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; margin-left: auto; }
.theme-switch button { font: inherit; font-size: 13px; font-weight: 600; border: 0; background: none; color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.theme-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
@media (max-width: 600px) { .theme-switch { order: 3; margin: 4px auto 0; } .theme-switch button { padding: 4px 10px; } }

/* ---------- Archemath: Greek gold on deep blue ---------- */
:root[data-theme="archemath"] {
  color-scheme: dark;
  --bg: #070a14;
  --panel: #0e1322;
  --text: #f4ead0;
  --muted: #bdb291;
  --line: #2b3350;
  --grid: #171d31;
  --accent: #d9b44a;
  --accent-soft: rgba(217, 180, 74, .16);
  --on-accent: #070a14;
  --good: #7fd18b;
  --warn: #f2a65a;
  --danger: #ff8f8f;
  --c1: #f2cf63; --c2: #ff9f6e; --c3: #7fd18b; --c4: #d4a5ff; --c5: #ff8fb8; --c6: #6fd6e8;
  --tri-fill: rgba(217, 180, 74, .14);
  --font-body: "Spectral", "Noto Serif Bengali", "Noto Serif Devanagari", "Noto Serif JP", Georgia, "Times New Roman", serif;
  --font-head: "Spectral", "Noto Serif Bengali", "Noto Serif Devanagari", "Noto Serif JP", Georgia, "Times New Roman", serif;
  --gold-grad: linear-gradient(180deg, #f7e08f 0%, #d9b44a 45%, #a9822a 100%);
  --meander: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12' viewBox='0 0 24 12'%3E%3Cpath d='M0 11h4V3h8v5H8V6' fill='none' stroke='%23d9b44a' stroke-width='1.4'/%3E%3Cpath d='M12 11h4V3h8' fill='none' stroke='%23d9b44a' stroke-width='1.4'/%3E%3C/svg%3E");
}
:root[data-theme="archemath"] body {
  font-size: 18px;
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(217, 180, 74, .12), transparent 70%),
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, .05) 1px, transparent 1.5px) 0 0 / 46px 46px,
    radial-gradient(circle at 70% 80%, rgba(255, 255, 255, .04) 1px, transparent 1.5px) 0 0 / 71px 71px,
    var(--bg);
}
[data-theme="archemath"] .topbar { background: var(--meander) repeat-x left bottom 4px / 24px 12px, #0a0e1b; border-bottom: 1px solid #d9b44a55; padding-bottom: 22px; }
[data-theme="archemath"] .brand { font-family: var(--font-head); font-size: 22px; letter-spacing: .04em;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="archemath"] .brand .logo { -webkit-text-fill-color: #070a14; background: var(--gold-grad); border-radius: 50%; box-shadow: 0 0 0 2px #0a0e1b, 0 0 0 3px #d9b44a; font-family: var(--font-head); }
[data-theme="archemath"] .hero h1, [data-theme="archemath"] .lesson-title, [data-theme="archemath"] .tools-head h2 {
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; letter-spacing: .03em; }
[data-theme="archemath"] .hero h1 { font-size: 34px; }
[data-theme="archemath"] .hero { margin-top: 18px; }
[data-theme="archemath"] .panel, [data-theme="archemath"] .card { border-color: #d9b44a66; box-shadow: inset 0 0 0 3px var(--panel), inset 0 0 0 4px #d9b44a2e; }
[data-theme="archemath"] .card:hover { box-shadow: inset 0 0 0 3px var(--panel), inset 0 0 0 4px #d9b44a55, 0 8px 24px rgba(0, 0, 0, .35); }
[data-theme="archemath"] .btn.primary, [data-theme="archemath"] .level.active, [data-theme="archemath"] .chip.active, [data-theme="archemath"] .theme-switch button[aria-pressed="true"] { background: var(--gold-grad); border-color: #a9822a; }
[data-theme="archemath"] .level, [data-theme="archemath"] .tool-tab, [data-theme="archemath"] .subtab { font-family: var(--font-head); letter-spacing: .02em; }
[data-theme="archemath"] .nav a.active { background: var(--accent-soft); color: var(--accent); }
[data-theme="archemath"] .banner { background: #2a2410; color: #f4e2a8; border-color: #5c4a17; }
[data-theme="archemath"] .player-ph { background: radial-gradient(circle at 50% 40%, #232c47, #070a14); color: var(--text); border: 1px solid #d9b44a66; }
[data-theme="archemath"] .thumb-ph { background: radial-gradient(circle at 50% 40%, #1f273f, #0f1424); color: var(--accent); }
[data-theme="archemath"] input, [data-theme="archemath"] select, [data-theme="archemath"] textarea { background: #0b0f1d; }
[data-theme="archemath"] .fbar-smooth { background: #1a2136; border-color: #2c3f74; }
[data-theme="archemath"] .fbar span:not(.on) { background: #1a2136; border-color: #2c3f74; }
[data-theme="archemath"] .done-badge, [data-theme="archemath"] .sugg { color: #070a14; }
[data-theme="archemath"] .mono, [data-theme="archemath"] .fn-row input, [data-theme="archemath"] .calc-in { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- friends in the corner ---------- */
.mascot { position: fixed; right: 14px; bottom: 10px; z-index: 20; display: flex; flex-direction: column; align-items: flex-end; pointer-events: none; }
.mascot > * { pointer-events: auto; }
.mascot > .mascot-bubble { pointer-events: none; }
.mascot-pair { display: flex; align-items: flex-end; gap: 0; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .25)); }
.mascot-owl { width: 74px; height: 74px; }
.mascot-pi { width: 50px; height: 58px; margin-right: -6px; }
.mascot-bubble { max-width: 230px; background: var(--panel); color: var(--text); border: 1px solid var(--accent); border-radius: 14px; padding: 6px 12px; font-weight: 600; font-size: 15px;
  margin-bottom: 6px; opacity: 0; transform: translateY(6px) scale(.95); transition: opacity .2s, transform .2s; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.mascot.happy .mascot-bubble, .mascot.sad .mascot-bubble, .mascot.talk .mascot-bubble { opacity: 1; transform: none; }
.mascot-hide, .mascot-show { font: inherit; border: 0; background: none; cursor: pointer; color: var(--muted); }
.mascot-hide { position: absolute; right: -6px; bottom: 60px; font-size: 16px; opacity: 0; transition: opacity .2s; }
.mascot:hover .mascot-hide, .mascot-hide:focus-visible { opacity: 1; }
.mascot-show { display: none; font-size: 26px; }
.mascot.hidden .mascot-pair, .mascot.hidden .mascot-bubble, .mascot.hidden .mascot-hide, .mascot.hidden .mascot-stars { display: none; }
.mascot.hidden .mascot-show { display: block; }
.mascot .eyes-happy, .mascot .mouth-happy { display: none; }
.mascot.happy .eyes-open { display: none; }
.mascot.happy .eyes-happy, .mascot.happy .mouth-happy { display: inline; }
.mascot.happy .mouth-calm { display: none; }
.mascot.happy .blush { opacity: .7; }
.mascot .wing, .mascot .arm { transform-box: fill-box; }
.mascot .wing-l { transform-origin: 100% 15%; } .mascot .wing-r { transform-origin: 0% 15%; }
.mascot .arm-l { transform-origin: 100% 100%; } .mascot .arm-r { transform-origin: 0% 100%; }
.mascot.happy .wing-l { animation: clap-l .32s ease-in-out 6; } .mascot.happy .wing-r { animation: clap-r .32s ease-in-out 6; }
.mascot.happy .arm-l { animation: arm-l .32s ease-in-out 6; } .mascot.happy .arm-r { animation: arm-r .32s ease-in-out 6; }
.mascot.happy .mascot-owl, .mascot.happy .mascot-pi { animation: hop .64s ease-in-out 3; }
.mascot.happy .mascot-pi { animation-delay: .16s; }
.mascot.sad .mascot-owl { animation: tilt 1.2s ease-in-out 1; transform-origin: 50% 100%; }
.mascot.talk .mascot-owl { animation: hop .6s ease-in-out 1; }
.mascot .owl { animation: blink 5s infinite; transform-origin: 50% 44%; }
@keyframes clap-l { 50% { transform: rotate(-55deg) translateX(8px); } }
@keyframes clap-r { 50% { transform: rotate(55deg) translateX(-8px); } }
@keyframes arm-l { 50% { transform: rotate(35deg); } }
@keyframes arm-r { 50% { transform: rotate(-35deg); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12px); } }
@keyframes tilt { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes blink { 0%, 96%, 100% { transform: scaleY(1); } 98% { transform: scaleY(.92); } }
.mascot-stars { position: absolute; right: 20px; bottom: 50px; width: 120px; height: 80px; pointer-events: none; }
.mascot-stars span { position: absolute; bottom: 0; left: 50%; color: var(--accent); font-size: 18px; opacity: 0; }
.mascot.happy .mascot-stars span { animation: burst 1.1s ease-out 2; }
.mascot.happy .mascot-stars span:nth-child(1) { --dx: -60px; --dy: -50px; }
.mascot.happy .mascot-stars span:nth-child(2) { --dx: -20px; --dy: -75px; animation-delay: .1s; }
.mascot.happy .mascot-stars span:nth-child(3) { --dx: 25px; --dy: -70px; animation-delay: .2s; }
.mascot.happy .mascot-stars span:nth-child(4) { --dx: 55px; --dy: -40px; animation-delay: .05s; }
.mascot.happy .mascot-stars span:nth-child(5) { --dx: -45px; --dy: -15px; animation-delay: .15s; }
@keyframes burst { 0% { opacity: 1; transform: translate(0, 0) scale(.6); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.3) rotate(90deg); } }
@media (prefers-reduced-motion: reduce) { .mascot * { animation: none !important; } }
@media (max-width: 600px) { .mascot-owl { width: 56px; height: 56px; } .mascot-pi { width: 38px; height: 44px; } main { padding-bottom: 90px; } }

/* ---------- proportion ---------- */
.tool-proportion { display: flex; flex-direction: column; gap: 6px; }
.slider.wide { grid-template-columns: minmax(80px, auto) minmax(0, 1fr) minmax(64px, auto); }
.big-num { font-size: 20px; font-weight: 700; color: var(--accent); text-align: right; font-variant-numeric: tabular-nums; }
.prop-svg { width: 100%; height: auto; display: block; }
.prop-pic { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; }
.ring { fill: none; stroke: var(--grid); stroke-width: 1.5; stroke-dasharray: 4 4; }
.ring.on { stroke: var(--c1); stroke-dasharray: none; fill: color-mix(in srgb, var(--c1) 6%, transparent); }
.ring.current { stroke-width: 3.5; }
.ring.grow, .unroll.grow { transform-box: fill-box; animation: grow .6s ease-out; }
.ring.grow { transform-origin: center; }
.unroll.grow { transform-origin: left center; }
@keyframes grow { from { transform: scale(0.2); opacity: .2; } to { transform: scale(1); opacity: 1; } }
.unroll { fill: var(--grid); }
.unroll.on { fill: color-mix(in srgb, var(--c1) 55%, transparent); }
.unroll.current { fill: var(--c1); }
.radius-line { stroke: var(--c2); stroke-width: 3; }
.centre { fill: var(--c2); }
.prop-label { fill: var(--text); font-size: 15px; text-anchor: middle; font-weight: 600; }
.prop-label.left { text-anchor: start; }
.prop-label.small { font-size: 12px; font-weight: 500; fill: var(--muted); }
.prop-label.job { fill: var(--on-accent); }
.prop-label.balanced { fill: var(--good); font-size: 22px; }
.prop-explain p { margin: 6px 0; }
.prop-more summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.prop-table { margin: 8px 0; }
.plank-group { transition: transform .5s cubic-bezier(.3, 1.4, .5, 1); }
.plank { fill: #b07a3e; stroke: #7a4d22; stroke-width: 2; }
.pivot { fill: var(--muted); }
.ground { stroke: var(--line); stroke-width: 3; }
.tick { stroke: #fff8; stroke-width: 2; }
.job-block { fill: var(--accent); stroke: color-mix(in srgb, var(--accent) 60%, black); stroke-width: 2; }
.worker { font-size: 19px; text-anchor: middle; }
.drop { stroke: var(--c2); stroke-width: 1.5; stroke-dasharray: 3 3; }
.seesaw-status { margin: 4px 0; }
.ok { color: var(--good); }
.bad { color: var(--danger); font-weight: 600; }
.practice { margin-top: 10px; border: 2px dashed var(--accent); border-radius: 12px; padding: 12px 14px; background: var(--accent-soft); transition: border-color .3s; }
.practice.solved { border-style: solid; border-color: var(--good); }
.practice-head { display: flex; justify-content: space-between; align-items: center; }
.practice p { margin: 8px 0; }
.practice .num-lg { width: 130px; }
.practice-feedback { min-height: 24px; margin: 6px 0 2px; }

/* ---------- number system ---------- */
.tool-numsystem { display: flex; flex-direction: column; gap: 6px; }
.wide-in { width: min(320px, 100%) !important; }
.ns-box { fill: transparent; stroke: var(--line); stroke-width: 2.5; }
.ns-R { fill: none; stroke: var(--muted); stroke-dasharray: 6 5; }
.ns-Q { stroke: var(--c1); } .ns-Z { stroke: var(--c3); } .ns-W { stroke: var(--c6); } .ns-N { stroke: var(--c4); } .ns-I { stroke: var(--c2); }
.ns-box.flash { animation: flash 1s ease-out; }
@keyframes flash { 0% { fill: color-mix(in srgb, var(--accent) 40%, transparent); } 100% { fill: transparent; } }
.ns-label { fill: var(--muted); font-size: 14px; font-weight: 700; text-anchor: end; }
.ns-chip rect { fill: var(--panel); stroke: var(--accent); stroke-width: 1.5; }
.ns-chip text { fill: var(--text); font-size: 15px; font-weight: 700; text-anchor: middle; }
.ns-chip.fresh { transform-box: fill-box; transform-origin: center; animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.ns-msg { min-height: 24px; }
.ns-question { font-size: 34px; font-weight: 800; color: var(--accent); margin: 4px 0 10px; font-family: var(--font-head); }
.ns-pick { font-size: 14px; }
.ns-pick:disabled { opacity: .4; text-decoration: line-through; cursor: default; }
.nl-axis.thin { stroke-width: 1.5; }
.sp-tri { fill: color-mix(in srgb, var(--c1) 12%, transparent); stroke: none; }
.sp-tri.perfect { fill: color-mix(in srgb, var(--c3) 30%, transparent); }
.sp-tri.last { fill: color-mix(in srgb, var(--c1) 30%, transparent); }
.sp-tri.grow { transform-box: view-box; animation: fadein .6s ease-out; }
@keyframes fadein { from { opacity: 0; } }
.sp-leg { stroke: var(--muted); stroke-width: 2; }
.sp-hyp { stroke: var(--c1); stroke-width: 2; }
.sp-hyp.last { stroke-width: 4; }
.sp-lbl { font-size: 14px; font-weight: 800; fill: var(--text); paint-order: stroke; stroke: var(--panel); stroke-width: 3px; }
.sp-lbl.perfect { fill: var(--accent); }
.sp-arc { fill: none; stroke: var(--c2); stroke-width: 2.5; stroke-dasharray: 6 5; }

/* ---------- mensuration ---------- */
.tool-mensuration { display: flex; flex-direction: column; gap: 8px; }
.anim-controls input[type=range] { flex: 1; min-width: 160px; }
.slice { stroke: var(--panel); stroke-width: 1; }
.slice.top { fill: var(--c1); } .slice.bottom { fill: var(--c2); }
.dim { stroke: var(--text); stroke-width: 1.5; }
.dim.dash { stroke-dasharray: 5 4; stroke: var(--muted); }
.mgrid { stroke: var(--grid); stroke-width: 1; }
.shape { stroke-width: 2.5; stroke-linejoin: round; }
.shape.ghost { fill: none; stroke: var(--muted); stroke-dasharray: 5 4; }
.shape.main { fill: color-mix(in srgb, var(--c1) 45%, transparent); stroke: var(--c1); }
.shape.piece { fill: color-mix(in srgb, var(--c2) 55%, transparent); stroke: var(--c2); }
.box-floor { fill: color-mix(in srgb, var(--muted) 12%, transparent); stroke: var(--muted); stroke-dasharray: 4 4; }
.box-top { fill: none; stroke: var(--muted); stroke-dasharray: 4 4; }
.box-edge { stroke: var(--muted); stroke-dasharray: 4 4; }
.box-edge.front { stroke: var(--text); fill: none; stroke-dasharray: none; opacity: .5; }
.cube { stroke: color-mix(in srgb, var(--panel) 60%, black); stroke-width: 1; stroke-linejoin: round; }
.cube.top.a { fill: color-mix(in srgb, var(--c1) 100%, white 25%); } .cube.right.a { fill: var(--c1); } .cube.left.a { fill: color-mix(in srgb, var(--c1) 100%, black 30%); }
.cube.top.b { fill: color-mix(in srgb, var(--c6) 100%, white 25%); } .cube.right.b { fill: var(--c6); } .cube.left.b { fill: color-mix(in srgb, var(--c6) 100%, black 30%); }
.cube.newest { animation: fadein .25s ease-out; }
.big-num.inline { font-size: 18px; }

/* =====================================================================
   Round 3: modern look (shared by both themes; Archemath overrides colours and fonts)
   ===================================================================== */
:root[data-theme="archemath"] {
  --accent-2: #f7e08f;
  --grad: linear-gradient(180deg, #f7e08f 0%, #d9b44a 50%, #a9822a 100%);
  --glass: rgba(10, 14, 27, .84);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .3);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .35), 0 22px 50px rgba(0, 0, 0, .5);
  --radius: 14px;
}
body {
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 500px at 85% -120px, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 70%),
    radial-gradient(800px 500px at -10% 10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
.mono, code, pre, .fn-row input, .calc-in, .frac-in { font-family: var(--font-mono) !important; }
main { max-width: 1200px; padding: 28px 24px 80px; }
.topbar { background: var(--glass); backdrop-filter: saturate(1.6) blur(14px); -webkit-backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); padding: 12px 28px; }
.brand { font-family: var(--font-head); font-size: 22px; letter-spacing: -.01em; }
.logo { border-radius: 10px; background: var(--grad); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent); }
.nav { gap: 2px; }
.nav a { border-radius: 999px; padding: 8px 14px; font-size: 15px; transition: background .15s, color .15s; }
.nav a:hover { color: var(--text); }
.btn { border-radius: 12px; padding: 9px 16px; transition: transform .12s, box-shadow .15s, border-color .15s; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--grad); border: 0; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.big { padding: 13px 22px; font-size: 16px; font-weight: 600; }
.panel, .card { border-radius: var(--radius); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--line) 80%, transparent); }
.panel { padding: 22px; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card-body { padding: 14px 16px 16px; }
.card-title { font-family: var(--font-head); font-size: 18px; font-weight: 600; line-height: 1.3; }
.thumb-ph { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, transparent), color-mix(in srgb, var(--accent-2) 16%, transparent)); }
.level { border-radius: 14px; padding: 11px 18px; box-shadow: var(--shadow); border-color: transparent; transition: transform .12s; }
.level:hover { transform: translateY(-2px); }
.level.active { background: var(--grad); }
.chip { border-radius: 999px; transition: background .15s; }
.chip.active { background: var(--grad); border-color: transparent; }
input[type=text], input[type=search], input[type=number], select, textarea { border-radius: 12px; padding: 10px 12px; }
input[type=range] { accent-color: var(--accent); }
.subtab { font-weight: 500; }
.practice { border-radius: var(--radius); }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.lead { font-size: 19px; line-height: 1.6; color: color-mix(in srgb, var(--text) 82%, var(--muted)); max-width: 62ch; }
.section-title { font-size: clamp(28px, 4vw, 38px); letter-spacing: -.02em; }
.hero { margin: 48px 0 18px; }
.ns-link { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; }
.ns-link:hover { text-decoration: underline; }

/* home hero */
.home-hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: center; padding: 28px 0 8px; }
.hh-title { font-size: clamp(40px, 6.2vw, 72px); line-height: 1.02; letter-spacing: -.035em; margin: 0 0 18px; font-weight: 700; }
.hh-accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-style: italic; }
.home-hero .lead { margin: 0 0 24px; }
.hero-art { width: 100%; max-width: 520px; justify-self: end; overflow: visible; }
.ha-circle { fill: color-mix(in srgb, var(--accent) 8%, transparent); stroke: var(--accent); stroke-width: 2.5; }
.ha-axis { stroke: var(--line); stroke-width: 2; }
.ha-wave { fill: none; stroke: var(--c2); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 700; stroke-dashoffset: 700; animation: draw 3s ease-out .3s forwards; }
.ha-spin { transform-origin: 80px 150px; animation: spin 6s linear infinite; }
.ha-radius { stroke: var(--accent); stroke-width: 3; }
.ha-dot { fill: var(--c2); }
.ha-tri { fill: color-mix(in srgb, var(--c3) 30%, transparent); stroke: var(--c3); stroke-width: 2.5; animation: float 5s ease-in-out infinite; transform-origin: 360px 60px; }
.ha-sym { font-family: var(--font-head); font-size: 64px; fill: var(--accent-2); font-style: italic; animation: float 6s ease-in-out infinite; }
.ha-sym.small { font-size: 30px; fill: var(--muted); animation-delay: -2s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(-360deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@media (max-width: 820px) { .home-hero { grid-template-columns: 1fr; } .hero-art { max-width: 300px; justify-self: center; } }

/* explore cards */
.explore-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 28px 0 8px; }
.explore-row.wide { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 980px) { .explore-row, .explore-row.wide { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .explore-row, .explore-row.wide { grid-template-columns: 1fr; } }
.explore-card { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 4px; min-height: 190px; padding: 20px; border-radius: 22px; color: #fff; text-decoration: none; box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s; isolation: isolate; }
.explore-card:hover { transform: translateY(-5px) rotate(-.4deg); box-shadow: var(--shadow-lg); }
.explore-card::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 85% 10%, rgba(255, 255, 255, .28), transparent 55%); z-index: -1; }
.tone-a { background: linear-gradient(140deg, #7a3410, #c4561a 60%, #e5a019); }
.tone-b { background: linear-gradient(140deg, #e8590c, #c2255c); }
.tone-c { background: linear-gradient(140deg, #0b5f66, #1c8f99); }
.tone-d { background: linear-gradient(140deg, #d99a0b, #c4561a); }
.tone-e { background: linear-gradient(140deg, #4c7a0b, #82a91a); }
.tone-f { background: linear-gradient(140deg, #6b3a1a, #b5651d); }
.ec-sym { position: absolute; right: 14px; bottom: -6px; font-family: var(--font-head); font-size: 64px; font-weight: 700; opacity: .25; line-height: 1; z-index: -1; transition: transform .3s; }
.explore-card:hover .ec-sym { transform: scale(1.1) rotate(-6deg); }
.ec-tag { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.ec-title { font-family: var(--font-head); font-size: 22px; font-weight: 700; line-height: 1.15; margin-top: 4px; }
.ec-text { font-size: 14px; opacity: .92; }
.ec-go { margin-top: auto; font-weight: 700; font-size: 14px; }

/* page hero for explore / read pages */
.page-hero { padding: 26px 0 18px; }
.page-hero h1 { font-size: clamp(36px, 5.4vw, 60px); letter-spacing: -.03em; line-height: 1.05; margin-bottom: 14px; }

/* ---------- number families page ---------- */
.illus { width: 100%; height: auto; display: block; overflow: visible; }
.page-hero .illus { max-width: 560px; margin-top: 10px; }
.nest ellipse { fill: none; stroke-width: 3; }
.nest text { font-family: var(--font-head); font-size: 22px; font-weight: 700; }
.nest { animation: rise .6s ease-out backwards; }
.nest-r ellipse { stroke: var(--muted); stroke-dasharray: 7 6; } .nest-r text { fill: var(--muted); }
.nest-q ellipse { stroke: #12b886; } .nest-q text { fill: #12b886; }
.nest-z ellipse { stroke: #ff7a59; } .nest-z text { fill: #ff7a59; }
.nest-w ellipse { stroke: #15aabf; } .nest-w text { fill: #15aabf; }
.nest-n ellipse { stroke: #8a4b14; fill: color-mix(in srgb, #8a4b14 10%, transparent); } .nest-n text { fill: #8a4b14; }
.nest-i ellipse { stroke: #f03e78; fill: color-mix(in srgb, #f03e78 8%, transparent); } .nest-i text { fill: #f03e78; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.chapter-nav { position: sticky; top: 64px; z-index: 3; display: flex; gap: 6px; overflow-x: auto; padding: 10px 2px; margin: 0 -2px 10px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); }
.chapter-nav a { flex: none; display: inline-flex; gap: 8px; align-items: center; padding: 7px 14px 7px 8px; border-radius: 999px; background: var(--panel); box-shadow: var(--shadow); color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
.cn-sym { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-family: var(--font-head); }
.cn-n .cn-sym { background: #8a4b14; } .cn-w .cn-sym { background: #15aabf; } .cn-z .cn-sym { background: #ff7a59; }
.cn-q .cn-sym { background: #12b886; } .cn-i .cn-sym { background: #f03e78; } .cn-r .cn-sym { background: #3b5bdb; }
.fam { --tone: #8a4b14; position: relative; background: var(--panel); border-radius: 26px; padding: 30px; margin: 22px 0; box-shadow: var(--shadow); border-top: 6px solid var(--tone); scroll-margin-top: 120px; }
.fam-n { --tone: #8a4b14; } .fam-w { --tone: #15aabf; } .fam-z { --tone: #ff7a59; } .fam-q { --tone: #12b886; } .fam-i { --tone: #f03e78; } .fam-r { --tone: #3b5bdb; } .fam-b { --tone: #f59f00; }
.fam-head { display: flex; gap: 18px; align-items: center; margin-bottom: 14px; }
.fam-head h2 { font-size: clamp(26px, 3.6vw, 36px); margin: 0; letter-spacing: -.02em; }
.fam-sym { flex: none; width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center; font-family: var(--font-head); font-size: 44px; font-weight: 700; color: #fff; background: var(--tone); box-shadow: 0 10px 24px color-mix(in srgb, var(--tone) 40%, transparent); }
.fam .eyebrow { color: var(--tone); margin-bottom: 2px; }
.fam-set { color: var(--muted); font-size: 15px; }
.fam-body { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; align-items: center; }
@media (max-width: 860px) { .fam-body { grid-template-columns: 1fr; } .fam { padding: 22px 18px; } .fam-sym { width: 60px; height: 60px; font-size: 34px; } }
.fam-art { background: color-mix(in srgb, var(--tone) 7%, var(--panel)); border-radius: 18px; padding: 16px; }
.fam .lead { font-size: 18px; margin: 0 0 8px; }
.facts { padding-left: 20px; margin: 6px 0 14px; }
.facts li { margin: 6px 0; }
.facts li::marker { color: var(--tone, var(--accent)); }
.illus .axis { stroke: var(--text); stroke-width: 2; } .illus .axis.thick { stroke-width: 3; }
.illus .tick-t { fill: var(--text); font-size: 15px; text-anchor: middle; font-weight: 600; }
.illus .tick-t.neg, .illus .illus-text.neg { fill: #ff7a59; } .illus .tick-t.pos, .illus .illus-text.pos { fill: var(--tone, var(--accent)); }
.illus .illus-text { fill: var(--text); font-size: 17px; font-weight: 600; } .illus .muted-t { fill: var(--muted); font-weight: 500; } .illus .small-t { font-size: 12px; fill: var(--muted); }
.illus .illus-big { fill: var(--tone); font-family: var(--font-head); font-size: 44px; font-weight: 700; text-anchor: middle; }
.stone { fill: var(--tone); } .stone-num { fill: #fff; font-weight: 800; font-size: 20px; text-anchor: middle; }
.hop { animation: hop2 2.4s ease-in-out infinite; transform-box: fill-box; }
@keyframes hop2 { 0%, 30%, 100% { transform: translateY(0); } 15% { transform: translateY(-14px); } }
.next-arrow { fill: none; stroke: var(--muted); stroke-width: 2; }
.basket { fill: color-mix(in srgb, #b07a3e 40%, transparent); stroke: #b07a3e; stroke-width: 3; } .basket-weave { stroke: #b07a3e; stroke-width: 1.5; fill: none; opacity: .6; }
.zero-pop { animation: float 3s ease-in-out infinite; }
.mirror { stroke: var(--tone); stroke-width: 2; stroke-dasharray: 5 5; }
.mirror-arc { fill: none; stroke: var(--tone); stroke-width: 2; opacity: .7; stroke-dasharray: 400; stroke-dashoffset: 400; animation: draw 1.4s ease-out forwards; }
.slice-r { fill: color-mix(in srgb, #e8a33d 25%, var(--panel)); stroke: #c47f1f; stroke-width: 2; } .slice-r.on { fill: #e8a33d; }
.dot-on { fill: var(--tone); }
.sq { fill: color-mix(in srgb, var(--tone) 10%, transparent); stroke: var(--text); stroke-width: 2.5; } .diag { stroke: var(--tone); stroke-width: 4; }
.digit-stream { fill: var(--tone); font-family: var(--font-mono); font-size: 22px; font-weight: 600; animation: stream 14s linear infinite; }
@keyframes stream { from { transform: translateX(0); } to { transform: translateX(-520px); } }
.pin { animation: rise .6s ease-out backwards; } .pin-line { stroke: var(--muted); stroke-width: 1.5; }
.quick { margin-top: 18px; padding: 16px 18px; border-radius: 16px; background: color-mix(in srgb, var(--tone, var(--accent)) 8%, transparent); border: 1px dashed color-mix(in srgb, var(--tone, var(--accent)) 50%, transparent); }
.quick-q { font-weight: 600; margin-bottom: 10px; font-size: 17px; }
.quick-tag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #fff; background: var(--tone, var(--accent)); border-radius: 6px; padding: 2px 7px; margin-right: 10px; vertical-align: 2px; }
.quick-out { margin-top: 8px; min-height: 20px; }
.bases { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.bases label { display: flex; flex-direction: column; gap: 2px; }
.places { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.place { min-width: 64px; text-align: center; padding: 10px 8px; border-radius: 14px; background: color-mix(in srgb, var(--tone) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent); animation: rise .4s ease-out backwards; }
.place-d { font-family: var(--font-mono); font-size: 30px; font-weight: 700; color: var(--tone); }
.place-w { font-size: 14px; font-weight: 600; }

/* ---------- groups page ---------- */
.sym-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 900px) { .sym-grid { grid-template-columns: 1fr; } }
.sym-play { display: flex; flex-direction: column; gap: 10px; }
.sym-stage { max-width: 340px; margin: 0 auto; width: 100%; }
.sym-svg { width: 100%; height: auto; display: block; }
.sym-shape { transition: transform .6s cubic-bezier(.4, 1.3, .5, 1); }
.sym-poly { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; }
.sym-num { fill: #fff; font-weight: 800; font-size: 15px; text-anchor: middle; }
.sym-mark { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.sym-ghost { fill: none; stroke: var(--line); stroke-width: 2; stroke-dasharray: 3 3; }
.sym-axis { stroke: var(--line); stroke-width: 1.2; stroke-dasharray: 4 5; }
.sym-state { text-align: center; }
.big-sym { font-family: var(--font-head); font-size: 26px; color: var(--accent); }
.sym-moves { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sym-move { flex-direction: column; align-items: flex-start; gap: 0; white-space: normal; text-align: left; }
.sym-move b { font-family: var(--font-head); font-size: 20px; color: var(--accent); }
.axioms li { margin: 10px 0; }
.cayley-wrap { overflow-x: auto; }
.cayley { border-collapse: separate; border-spacing: 4px; margin: 6px 0; }
.cayley th, .cayley td { width: 46px; height: 40px; text-align: center; font-family: var(--font-head); font-size: 17px; border-radius: 10px; padding: 0; }
.cayley th { color: var(--muted); font-weight: 700; }
.cayley th.corner { font-family: var(--font-body); font-size: 11px; }
.cayley td.filled.is-turn { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); font-weight: 700; animation: pop .4s ease-out; }
.cayley td.filled.is-flip { background: color-mix(in srgb, var(--c2) 18%, transparent); color: var(--c2); font-weight: 700; animation: pop .4s ease-out; }
.cayley td.empty { background: var(--grid); color: var(--muted); cursor: pointer; }
.cayley td.empty:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- reading ---------- */
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 4px; background: var(--grad); transform-origin: 0 50%; transform: scaleX(0); z-index: 30; }
.read-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 40px; align-items: start; }
@media (max-width: 900px) { .read-layout { grid-template-columns: minmax(0, 1fr); } .toc { display: none !important; } }
.toc { position: sticky; top: 90px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; max-height: calc(100vh - 110px); overflow: auto; }
.toc-title { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.toc a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-left: 2px solid var(--line); line-height: 1.35; }
.toc a.on { color: var(--accent); border-left-color: var(--accent); font-weight: 600; background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.reading { max-width: 760px; min-width: 0; font-size: 18px; line-height: 1.75; }
.read-ch { padding: 10px 0 30px; border-bottom: 1px solid var(--line); scroll-margin-top: 90px; }
.read-ch h2 { font-size: clamp(26px, 3.4vw, 34px); letter-spacing: -.02em; margin: 26px 0 12px; }
.read-ch h3 { font-family: var(--font-body); font-size: 18px; font-weight: 700; margin: 26px 0 6px; }
.reading p { margin: 10px 0; }
.terms { margin: 12px 0; display: grid; gap: 10px; }
.terms.grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.term { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.term dt { font-weight: 700; color: var(--accent); }
.term dd { margin: 2px 0 0; font-size: 16px; line-height: 1.5; }
.two-col, .role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 14px 0; }
@media (max-width: 640px) { .two-col, .role-grid { grid-template-columns: 1fr; } }
.mini-card { background: var(--panel); border-radius: 16px; padding: 14px 16px; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 16px; line-height: 1.55; }
.mini-card > b { font-family: var(--font-head); font-size: 19px; }
.mini-card p { margin: 6px 0; }
.steps li { margin: 4px 0; }
.code-fig { margin: 16px 0; border-radius: 14px; overflow: hidden; background: #14162a; box-shadow: var(--shadow); }
.code-bar { display: flex; gap: 6px; align-items: center; padding: 8px 12px; background: #1d2040; color: #ff6b6b; font-size: 11px; }
.code-bar span:nth-child(2) { color: #fcc419; } .code-bar span:nth-child(3) { color: #51cf66; }
.code-bar em { margin-left: auto; color: #8e93b8; font-style: normal; font-size: 12px; font-family: var(--font-mono); }
.code { margin: 0; padding: 14px 18px; overflow-x: auto; color: #e6e8ff; font-size: 14.5px; line-height: 1.6; }
.code-fig figcaption { padding: 8px 18px 12px; color: #b4b8d8; font-size: 14px; background: #14162a; }
.tk-k { color: #c792ea; } .tk-s { color: #c3e88d; } .tk-n { color: #f78c6c; } .tk-c { color: #697098; font-style: italic; } .tk-f { color: #82aaff; }
.insight { margin: 18px 0; padding: 14px 18px; border-radius: 14px; background: var(--accent-soft); border-left: 4px solid var(--accent); font-size: 17px; }
.insight-tag { display: block; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.pull { margin: 24px 0; padding: 4px 0 4px 22px; border-left: 4px solid var(--c2); font-family: var(--font-head); font-size: 24px; line-height: 1.4; font-style: italic; }
.fig { margin: 18px 0; padding: 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; font-size: 16px; }
.fig figcaption { color: var(--muted); font-size: 14px; }
.bits { display: flex; gap: 6px; flex-wrap: wrap; }
.bit { font: inherit; width: 52px; padding: 8px 0; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; transition: background .15s, transform .1s; }
.bit:active { transform: scale(.94); }
.bit.on { background: var(--grad); color: #fff; border-color: transparent; }
.bit-v { font-family: var(--font-mono); font-size: 22px; font-weight: 700; }
.bit-w { font-size: 11px; opacity: .75; }
.letter-in { width: 60px; text-align: center; font-size: 20px !important; }
.cycle { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 560px) { .cycle { grid-template-columns: 1fr; } }
.cycle-step { padding: 12px; border-radius: 14px; border: 2px solid var(--line); display: flex; flex-direction: column; transition: all .3s; }
.cycle-step.on { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-3px); }
.layers { display: flex; flex-direction: column; gap: 6px; }
.layer { padding: 12px 16px; border-radius: 12px; color: #fff; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 0 auto; width: 100%; }
.layer span { opacity: .9; font-size: 14px; }
.layer.l0 { background: linear-gradient(90deg, #c4561a, #8a4b14); width: 70%; } .layer.l1 { background: linear-gradient(90deg, #8a4b14, #3b5bdb); width: 80%; }
.layer.l2 { background: linear-gradient(90deg, #3b5bdb, #15aabf); width: 90%; } .layer.l3 { background: linear-gradient(90deg, #15aabf, #12b886); }
.ds-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ds-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.ds { min-height: 170px; border: 2px dashed var(--line); border-radius: 12px; padding: 8px; display: flex; gap: 6px; }
.ds.stack { flex-direction: column-reverse; justify-content: flex-start; }
.ds.queue { flex-direction: row; align-items: center; flex-wrap: wrap; align-content: center; }
.ds-item { min-width: 44px; padding: 6px 10px; text-align: center; border-radius: 10px; background: var(--grad); color: #fff; font-weight: 700; font-family: var(--font-mono); }
.ds-item.fresh { animation: pop .35s ease-out; }
.ds-msg { min-height: 20px; }
.arr { display: flex; gap: 6px; flex-wrap: wrap; }
.arr-cell { min-width: 46px; padding: 8px 6px; text-align: center; border-radius: 10px; border: 2px solid var(--line); font-family: var(--font-mono); font-weight: 700; display: flex; flex-direction: column; transition: all .2s; }
.arr-cell small { font-size: 10px; color: var(--muted); font-weight: 500; }
.arr-cell.seen { opacity: .45; }
.arr-cell.look { border-color: var(--c2); background: color-mix(in srgb, var(--c2) 15%, transparent); }
.arr-cell.hit { border-color: var(--good); background: color-mix(in srgb, var(--good) 20%, transparent); transform: translateY(-4px); }
.bigo { width: 100%; height: 260px; display: block; }
.bigo-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.bigo-key { display: inline-flex; align-items: center; gap: 6px; }
.bigo-key i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }

/* Archemath keeps its gold-on-blue character on the new pages */
[data-theme="archemath"] .explore-card { border: 1px solid #d9b44a66; }
[data-theme="archemath"] .tone-a, [data-theme="archemath"] .tone-b, [data-theme="archemath"] .tone-c, [data-theme="archemath"] .tone-d, [data-theme="archemath"] .tone-e, [data-theme="archemath"] .tone-f, [data-theme="archemath"] .tone-g { background: radial-gradient(circle at 80% 0%, #24407e, #121829 70%); color: var(--text); }
[data-theme="archemath"] .ec-sym { color: var(--accent); opacity: .35; }
[data-theme="archemath"] .ec-title, [data-theme="archemath"] .hh-title, [data-theme="archemath"] .page-hero h1, [data-theme="archemath"] .section-title, [data-theme="archemath"] .fam-head h2 { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
[data-theme="archemath"] .hh-accent { font-style: normal; }
:root[lang="bn"] .hh-accent, :root[lang="hi"] .hh-accent, :root[lang="ja"] .hh-accent { font-style: normal; padding-inline-end: .1em; } /* slanted Bengali/Japanese gets cut off */
[data-theme="archemath"] .fam, [data-theme="archemath"] .term, [data-theme="archemath"] .mini-card, [data-theme="archemath"] .fig { border: 1px solid #d9b44a55; }
[data-theme="archemath"] .chapter-nav a { border: 1px solid #d9b44a55; }
[data-theme="archemath"] .reading { font-size: 20px; }

/* Lesson: only keyword-matched tools and pages */
.lesson.solo { grid-template-columns: minmax(0, 1fr); max-width: 900px; margin: 0 auto; }
.lesson-pages { display: grid; gap: 10px; margin-top: 14px; }
.lesson-page { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--text); background: var(--panel); transition: transform .15s, box-shadow .15s; }
.lesson-page:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.lesson-page > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; }
.lp-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--grad); color: #fff; font-family: var(--font-head); font-weight: 700; flex: none; }

/* Saraswati Mata, beside the name and on the home page */
.brand .saraswati { width: 50px; height: 50px; flex: none; margin: -6px 0 -6px -4px; }
[data-theme="archemath"] .brand .saraswati { filter: grayscale(1) sepia(.9) saturate(1.7) hue-rotate(-4deg) brightness(1.6) contrast(.95) drop-shadow(0 0 4px rgba(255, 246, 224, .35)); }

@media (max-width: 420px) { .brand .saraswati { width: 42px; height: 42px; } }
.hero-saraswati { margin: 0; justify-self: center; position: relative; width: min(100%, 440px); text-align: center; }
.hero-saraswati::before { content: ""; position: absolute; inset: 6% 8% 14%; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 70%); z-index: -1; }
.hero-saraswati img { width: 100%; height: auto; display: block; animation: float 7s ease-in-out infinite; }
.hero-saraswati figcaption { font-family: var(--font-head); font-style: italic; color: var(--muted); font-size: 15px; margin-top: 4px; }
/* Archemath: the Saraswati drawing in whitish champagne gold (the person's ask, 2026-11-23). */
[data-theme="archemath"] .hero-saraswati img { filter: grayscale(1) sepia(.9) saturate(1.7) hue-rotate(-4deg) brightness(1.5) contrast(.95) drop-shadow(0 0 10px rgba(255, 246, 224, .18)); }
@media (max-width: 820px) { .hero-saraswati { width: min(70%, 300px); } }
@media (prefers-reduced-motion: reduce) { .hero-saraswati img { animation: none; } }
.tone-g { background: linear-gradient(140deg, #2b1a0e, #8a3f0e 55%, #e5a019); }

/* ---------- Understanding AI ---------- */
.read-hero.with-art { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: center; }
@media (max-width: 820px) { .read-hero.with-art { grid-template-columns: 1fr; } .read-hero.with-art .ai-hero { max-width: 260px; } }
.ai-hero { width: 100%; max-width: 360px; justify-self: end; }
.ai-hero .hw { stroke: var(--accent); stroke-opacity: .18; stroke-width: 1.4; animation: hw 2.4s ease-in-out infinite; }
.ai-hero .hn { fill: var(--panel); stroke: var(--accent); stroke-width: 2.5; animation: hn 2.4s ease-in-out infinite; }
@keyframes hw { 50% { stroke-opacity: .6; } }
@keyframes hn { 50% { fill: var(--accent); } }
@media (prefers-reduced-motion: reduce) { .ai-hero .hw, .ai-hero .hn { animation: none; } }

.eq { font-family: var(--font-mono); font-size: 15px; background: var(--accent-soft); color: var(--text); border-radius: 10px; padding: 10px 14px; margin: 10px 0; overflow-x: auto; white-space: break-spaces; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 18px 0; border-left: 2px solid var(--accent); }
.timeline li { position: relative; padding: 4px 0 10px 18px; display: grid; grid-template-columns: 70px 1fr; gap: 10px; font-size: 16px; line-height: 1.5; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 10px; width: 12px; height: 12px; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); }
.timeline b { color: var(--accent); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .timeline li { grid-template-columns: 1fr; gap: 0; } }

.ai-canvas { width: 100%; height: 320px; display: block; border-radius: 12px; background: var(--bg); cursor: crosshair; touch-action: manipulation; }
.ai-canvas.short { height: 220px; cursor: default; }
.ai-canvas.square { height: auto; aspect-ratio: 1 / 1; max-height: 440px; }
.ai-canvas.tiny { height: 54px; width: 160px; background: transparent; cursor: default; }
.fit-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.tiny-wrap { display: flex; align-items: center; gap: 6px; }
.slider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 4px 18px; }
.neuron-out { font-size: 15px; line-height: 1.7; }
.neuron-pic, .layer-pic { width: 100%; max-width: 520px; display: block; margin: 0 auto; }
.wire { stroke-linecap: round; }
.wire.pos { stroke: #2f9e44; }
.wire.neg { stroke: #e03131; }
.wire.thin { stroke: var(--muted); stroke-opacity: .45; stroke-width: 1.2; }
.node { stroke-width: 2.5; }
.node.in { fill: var(--panel); stroke: var(--c3, #2f9e44); }
.node.sum { fill: var(--accent); stroke: var(--accent); }
.node.out { fill: var(--panel); stroke: var(--c2, #f06548); }
.node-t { text-anchor: middle; font: 600 14px var(--font-body); fill: var(--text); }
.node-t.small { font-size: 11px; }
.node-t.big { font-size: 22px; fill: var(--accent); }
.w-t { font: 13px var(--font-mono); fill: var(--muted); }
.w-t.mid { text-anchor: middle; font-family: var(--font-body); }

.sm-said { font-family: var(--font-head); font-size: 22px; }
.sm-said .blank { color: var(--accent); border-bottom: 2px dashed var(--accent); padding: 0 6px; }
.sm-said .blank.filled { border-bottom-style: solid; animation: pop .4s ease-out; }
.sm-bars { display: grid; gap: 6px; }
.sm-row { display: grid; grid-template-columns: 60px 76px 1fr 56px; gap: 10px; align-items: center; font-size: 15px; }
.sm-bar { height: 14px; border-radius: 7px; background: var(--grid, var(--line)); overflow: hidden; }
.sm-bar i { display: block; height: 100%; background: var(--grad); border-radius: 7px; transition: width .25s; }
@media (max-width: 520px) { .sm-row { grid-template-columns: 54px 1fr 50px; } .sm-z { display: none; } }

.table-wrap { overflow-x: auto; }
.maths-map { border-collapse: collapse; width: 100%; font-size: 16px; }
.maths-map th, .maths-map td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.maths-map th { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.link-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 12px; }
.link-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); color: var(--text); text-decoration: none; line-height: 1.45; transition: transform .15s, box-shadow .15s; }
.link-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.lc-top { display: flex; justify-content: space-between; gap: 8px; align-items: start; font-size: 16px; }
.lc-tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.lc-tag.os { background: color-mix(in srgb, #2f9e44 15%, transparent); color: #2f9e44; }
.lc-url { color: var(--accent); word-break: break-all; }
[data-theme="archemath"] .eq { background: rgba(242, 210, 122, .08); border: 1px solid rgba(242, 210, 122, .25); }
.sm-z { white-space: nowrap; }
.kdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }


/* Logo: the golden spiral (Fibonacci squares) */
.logo .logo-spiral { width: 24px; height: auto; display: block; }
[data-theme="archemath"] .brand .logo { color: #070a14; }

/* Glaux and Pi, more present */
.mascot-owl { width: 96px; height: 96px; }
.mascot-pi { width: 64px; height: 74px; margin-right: -8px; }
.mascot-pair { cursor: pointer; animation: idle 4s ease-in-out infinite; }
.mascot-pair:hover { transform: translateY(-3px); }
@keyframes idle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.mascot-bubble { max-width: 280px; font-size: 15px; box-shadow: var(--shadow); }
@media (max-width: 600px) { .mascot-owl { width: 70px; height: 70px; } .mascot-pi { width: 46px; height: 54px; } .mascot-bubble { max-width: 220px; font-size: 14px; } }
@media (prefers-reduced-motion: reduce) { .mascot-pair { animation: none; } }

.friend { display: flex; align-items: flex-end; gap: 10px; margin: 16px 0; }
.friend-pic { width: 64px; height: 64px; flex: none; }
.friend-pic.pi-pic { width: 54px; height: 62px; }
.friend-bubble { position: relative; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 16px 16px 16px 4px; padding: 10px 14px; font-size: 16px; line-height: 1.5; }
.friend-name { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); }
.friend-pi .friend-bubble { background: color-mix(in srgb, #4c6ef5 10%, var(--panel)); border-color: color-mix(in srgb, #4c6ef5 35%, transparent); }
.friend-pi .friend-name { color: #4c6ef5; }

.meet { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; margin: 34px 0 6px; padding: 24px 28px; border-radius: 26px; background: var(--panel); box-shadow: var(--shadow); border: 1px solid var(--line); }
.meet-pics { display: flex; align-items: flex-end; }
.meet-owl { width: 150px; height: 150px; animation: idle 4s ease-in-out infinite; }
.meet-pi { width: 96px; height: 110px; margin-right: -10px; animation: idle 4s ease-in-out -2s infinite; }
.meet p { margin: 6px 0 14px; font-size: 17px; line-height: 1.6; max-width: 62ch; }
.meet .section-title { margin: 0; }
@media (max-width: 640px) { .meet { grid-template-columns: 1fr; text-align: center; } .meet-pics { justify-content: center; } .meet-owl { width: 110px; height: 110px; } .meet-pi { width: 72px; height: 84px; } }
[data-theme="archemath"] .meet { background: rgba(255, 255, 255, .04); border-color: rgba(242, 210, 122, .25); }
[data-theme="archemath"] .friend-bubble { background: rgba(242, 210, 122, .08); border-color: rgba(242, 210, 122, .3); }

/* Blockchain */
.tone-h { background: linear-gradient(140deg, #0b3d4a, #1c7c86 55%, #e5a019); }
[data-theme="archemath"] .tone-h { background: radial-gradient(circle at 80% 0%, #24407e, #121829 70%); color: var(--text); }
.chain-hero { width: 100%; max-width: 380px; justify-self: end; }
.ch-block { fill: var(--panel); stroke: var(--accent); stroke-width: 2.5; animation: hn 2.4s ease-in-out infinite; }
.ch-link { stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 4 5; }
.ch-t { text-anchor: middle; font: 700 18px var(--font-head); fill: var(--text); }
.ch-h { text-anchor: middle; font: 12px var(--font-mono); fill: var(--muted); }
.hash { font-size: 13px; word-break: break-all; padding: 2px 6px; border-radius: 6px; background: var(--grid); }
.hash.ok { background: color-mix(in srgb, #2f9e44 15%, transparent); color: #2b8a3e; }
.hash.bad { background: color-mix(in srgb, #e03131 12%, transparent); color: #c92a2a; }
.hash-out { line-height: 1.8; }
.chain { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .chain { grid-template-columns: 1fr; } }
.block { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 14px; border: 2px solid; background: var(--panel); font-size: 15px; }
.block.good { border-color: #2f9e44; }
.block.bad { border-color: #e03131; }
.block-head { display: flex; justify-content: space-between; }
.block.good .block-head span { color: #2b8a3e; } .block.bad .block-head span { color: #c92a2a; }
.block textarea { font: inherit; font-size: 15px; resize: vertical; }
.sig-out { line-height: 1.9; font-size: 15px; }
.sig-out .ok, .hash-out .ok { color: #2b8a3e; font-weight: 600; }
.bad-t { color: #c92a2a; font-weight: 600; }

/* ---------- Topics: one place for everything ---------- */
.page-hero.compact { padding: 14px 0 6px; }
.page-hero.compact h1 { font-size: clamp(30px, 4.4vw, 46px); margin-bottom: 8px; }
.topic-nav { position: sticky; top: 64px; z-index: 5; display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; margin: 6px 0 4px; background: var(--bg); scrollbar-width: none; }
.topic-nav a { white-space: nowrap; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600; }
.topic-nav a:hover { border-color: var(--accent); color: var(--accent); }
.topic-sec { margin: 18px 0 26px; scroll-margin-top: 130px; }
.ts-head { display: flex; align-items: baseline; gap: 12px; border-bottom: 2px solid var(--line); padding-bottom: 6px; margin-bottom: 12px; }
.ts-head h2 { margin: 0; font-size: 24px; }
.ts-level { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.topic-tile { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); color: var(--text); text-decoration: none; transition: transform .15s, box-shadow .15s, border-color .15s; }
.topic-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.tt-icon { flex: none; width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--grad); color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 18px; }
.tt-body { display: flex; flex-direction: column; gap: 2px; line-height: 1.35; }
.tt-body b { font-size: 16px; }

/* compact index on the home page */
.topic-index { margin: 40px 0 10px; }
.ti-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ti-head .section-title { margin: 0; }
.ti-rows { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.ti-row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.ti-row:first-child { border-top: 0; }
.ti-sec { font-family: var(--font-head); font-size: 16px; }
.ti-links { display: flex; flex-wrap: wrap; gap: 6px; }
.ti-link { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: 14px; }
.ti-link:hover { border-color: var(--accent); color: var(--accent); }
.ti-ic { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
@media (max-width: 700px) { .ti-row { grid-template-columns: 1fr; gap: 6px; } }

/* compact home hero */
.home-hero { padding: 6px 0 0; gap: 16px; }
.hh-title { font-size: clamp(36px, 5vw, 58px); margin-bottom: 12px; }
.hero-saraswati { width: min(100%, 340px); }
@media (max-width: 820px) { .hero-saraswati { width: min(56%, 220px); } }
#lessons.hero { margin-top: 26px; }

/* lesson: explore links under the lesson */
.lesson-explore { margin: 18px 0; }
.lesson-explore h3 { margin: 0 0 8px; }
.lesson-explore .lesson-pages { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-top: 0; }
.lesson-explore .lesson-page b { flex: 1; }

/* music page */
.music-hero { width: 100%; max-width: 380px; justify-self: end; }
.mw { fill: none; stroke-linecap: round; stroke-dasharray: 900; stroke-dashoffset: 900; animation: draw 3s ease-out forwards; }
.mw1 { stroke: var(--accent); stroke-width: 4; } .mw2 { stroke: var(--accent-2); stroke-width: 3; animation-delay: .4s; } .mw3 { stroke: var(--c2); stroke-width: 2; animation-delay: .8s; }
.pi-digits { display: flex; flex-wrap: wrap; gap: 3px; font-size: 18px; }
.pi-digits span { width: 24px; text-align: center; border-radius: 6px; padding: 2px 0; background: var(--grid); transition: background .15s, transform .15s; }
.pi-digits span.on { background: var(--accent); color: #fff; transform: translateY(-3px); }

/* prodledger page */
.pl-hero { width: 100%; max-width: 340px; justify-self: end; }
.pl-earth { fill: color-mix(in srgb, #2f9e44 12%, transparent); stroke: #2f9e44; stroke-width: 2; }
.pl-arrow { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.pl-block { fill: var(--panel); stroke: var(--accent-2); stroke-width: 2.5; animation: hn 2.4s ease-in-out infinite; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 12px; }
.calc-field { display: flex; flex-direction: column; gap: 3px; }
.calc-field input { width: 100%; }
.years { display: flex; flex-wrap: wrap; gap: 6px; }
.year { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 86px; padding: 6px 8px; border-radius: 12px; border: 2px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.year.pass { border-color: #2f9e44; } .year.pass b { color: #2b8a3e; }
.year.fail { border-color: #e03131; } .year.fail b { color: #c92a2a; }
.year.add { justify-content: center; color: var(--muted); border-style: dashed; }
.calc-out { display: grid; gap: 4px; font-size: 15px; }
.calc-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.calc-row.sub { justify-content: flex-start; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 14px; }
.meter { height: 12px; border-radius: 6px; background: var(--grid); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: linear-gradient(90deg, #2f9e44, #82c91e); transition: width .3s; }
.ledger { display: grid; gap: 2px; font-size: 15px; }
.lg-row { display: grid; grid-template-columns: 1.1fr .7fr .9fr 1.4fr; gap: 8px; padding: 6px 10px; border-radius: 8px; background: color-mix(in srgb, #2f9e44 8%, transparent); }
.lg-row.lg-head { background: none; }
.lg-row.bad { background: color-mix(in srgb, #e03131 12%, transparent); color: #c92a2a; }
@media (max-width: 520px) { .lg-row { grid-template-columns: 1fr .6fr .8fr; } .lg-row span:last-child { display: none; } }

/* ---------- construction studio ---------- */
.tool-construct { display: grid; gap: 10px; }
.tool-construct > p { margin: 0; }
.cs-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cs-row input { flex: 1 1 220px; font-size: 17px; padding: 10px 12px; }
.tool-construct .chips { margin: 0; }
.tool-construct .chip { font-size: 13px; color: var(--muted); }
.tool-construct .chip:hover { color: var(--accent); border-color: var(--accent); }
.cs-err { color: var(--danger); font-size: 14px; min-height: 1em; }
.cs-err:empty { display: none; }
.cs-stage { background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 8px; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 24px 24px; }
.cs-canvas { width: 100%; aspect-ratio: 4 / 3; max-height: 70vh; display: block; }
.cs-cap { min-height: 56px; padding: 8px 6px 2px; font-size: 17px; }
.cs-cap small { color: var(--muted); display: block; font-size: 13px; }
.cs-ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 6px; }
.cs-ctl .slider { flex: 1 1 140px; min-width: 0; accent-color: var(--accent); }
.cs-written summary { cursor: pointer; font-weight: 600; }
.cs-steps { padding-left: 22px; font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.cs-steps li.on { color: var(--text); font-weight: 600; }
.cs-kb { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.cs-kb[hidden] { display: none; }
.cs-kw { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.cs-kw .btn { border-radius: 999px; color: var(--accent); }
.cs-pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.cs-pad .btn { font-size: 17px; padding: 10px 0; }
.cs-row input { flex-basis: 160px; }
.cs-more { display: contents; }
.cs-more summary { list-style: none; color: var(--accent); }
.cs-more summary::-webkit-details-marker { display: none; }
.cs-more[open] summary { background: var(--accent-soft); }
.cs-more > .chips { flex-basis: 100%; margin: 0; }

/* ---------- languages ---------- */
.lang-switch { margin-left: 6px; }
.lang-switch button { padding: 5px 9px; }
@media (max-width: 600px) { .lang-switch { order: 3; margin: 4px auto 0; } .theme-switch:not(.lang-switch) { margin-right: 0; } }
:root[lang="bn"] body, :root[lang="hi"] body, :root[lang="ja"] body { line-height: 1.7; }
:root[lang="ja"] body { word-break: normal; line-break: strict; overflow-wrap: anywhere; }
:root[lang="bn"] *, :root[lang="hi"] *, :root[lang="ja"] * { letter-spacing: normal !important; font-variant: normal !important; }

/* =====================================================================
   Round 6: golden touch (Mathesis) and artistic type (gold line-work removed at the person's request)
   ===================================================================== */
:root:not([data-theme="archemath"]) body {
  background:
    radial-gradient(1000px 620px at 88% -140px, rgba(240, 190, 80, .26), transparent 70%),
    radial-gradient(760px 520px at -8% 105%, rgba(229, 160, 25, .16), transparent 70%),
    radial-gradient(900px 520px at -10% 12%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%),
    linear-gradient(165deg, #fdf9f1 0%, #fbf3e3 55%, #f8ecd4 100%);
  background-attachment: fixed;
}
/* a slow gold sheen drifting across the page */
:root:not([data-theme="archemath"]) body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 214, 120, .16) 47%, rgba(255, 236, 180, .22) 50%, rgba(255, 214, 120, .16) 53%, transparent 62%);
  background-size: 260% 100%; animation: goldSheen 16s ease-in-out infinite alternate;
}
@keyframes goldSheen { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { :root:not([data-theme="archemath"]) body::before { animation: none; } }
/* gold hairlines */
:root:not([data-theme="archemath"]) .topbar { border-bottom: 0; box-shadow: 0 1px 0 rgba(201, 145, 40, .35); }
:root:not([data-theme="archemath"]) .topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, #e5b54a 20%, #f7e08f 50%, #e5b54a 80%, transparent); pointer-events: none; }
:root:not([data-theme="archemath"]) .eyebrow { background: linear-gradient(90deg, #b5651d, #d9a032); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* type: Playfair Display headings, Jost text */
:root:not([data-theme="archemath"]) h1, :root:not([data-theme="archemath"]) h2, :root:not([data-theme="archemath"]) .section-title, :root:not([data-theme="archemath"]) .hh-title { font-weight: 700; letter-spacing: -.005em; }
:root:not([data-theme="archemath"]) .hh-accent { font-weight: 600; font-style: italic; }
:root:not([data-theme="archemath"]) .brand { font-weight: 700; }
:root[lang="bn"]:not([data-theme="archemath"]) .hh-accent, :root[lang="hi"]:not([data-theme="archemath"]) .hh-accent, :root[lang="ja"]:not([data-theme="archemath"]) .hh-accent { font-style: normal; }

/* Long numbers and long words (Bengali, Hindi) wrap inside their boxes instead of spilling out. */
main { overflow-wrap: break-word; }
.nl-steps li, .steps li, .mono, .fn-error, .calc-out, .fbar-label { overflow-wrap: anywhere; }

/* Fundamental Theorem of Algebra page */
.fta-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .fta-pair { grid-template-columns: 1fr; } }
.fta-pair .ai-canvas { cursor: grab; }
.fta-hero { width: 100%; max-width: 300px; }
.fta-hero .fh { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .85; }
.fta-hero .fh2 { stroke: var(--gold, #e5a019); }
.fta-hero .fh3 { stroke: var(--muted); stroke-dasharray: 4 4; }
.fta-hero .fh-0 { fill: var(--warn, #e8590c); }

/* Data structures and algorithms page */
.lvl-tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); vertical-align: 2px; }
.lvl-tag.msc { background: color-mix(in srgb, #5f3dc4 14%, transparent); color: #6741d9; }
.dsa-hero { width: 100%; max-width: 300px; }
.dsa-hero .dh-e { stroke: var(--line); stroke-width: 2; }
.dsa-hero .dh-n { fill: var(--accent); animation: idle 3s ease-in-out infinite; }
.dsa-hero .dh-b { fill: var(--gold, #e5a019); opacity: .8; }
.dsa-grow { display: flex; flex-direction: column; gap: 6px; }
.dg-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) minmax(64px, auto); gap: 8px; align-items: center; }
.dg-bar { height: 14px; background: var(--grid); border-radius: 6px; overflow: hidden; }
.dg-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.dg-fill.off { background: var(--warn, #e8590c); }
.dg-val { text-align: right; font-size: 13px; overflow-wrap: anywhere; }
.bs-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px; }
.bs-cell { text-align: center; padding: 6px 0; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); font-family: var(--font-mono); font-size: 13px; transition: opacity .2s; }
.bs-cell.out { opacity: .25; }
.bs-cell.mid { background: var(--accent); color: var(--on-accent, #fff); border-color: var(--accent); opacity: 1; }
.hash-grid { display: flex; flex-direction: column; gap: 4px; }
.hash-b { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); min-height: 34px; }
.hash-b.clash { border-color: var(--warn, #e8590c); }
.hash-i { font-weight: 700; color: var(--accent); }
.hash-items { overflow-wrap: anywhere; }
.bst-svg { width: 100%; height: auto; max-height: 460px; }
.bst-edge { stroke: var(--line); stroke-width: 2; }
.bst-node { fill: var(--panel); stroke: var(--accent); stroke-width: 2.5; }
.bst-t { fill: var(--text); font-size: 20px; font-weight: 700; text-anchor: middle; font-family: var(--font-mono); }
.maze { display: grid; gap: 2px; max-width: 520px; }
.mz { aspect-ratio: 1; border: 0; border-radius: 3px; padding: 0; background: var(--grid); cursor: pointer; min-width: 0; }
.mz.wall { background: var(--text); }
.mz.seen { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.mz.path { background: var(--gold, #e5a019); }
.mz.start { background: #2f9e44; }
.mz.goal { background: var(--warn, #e8590c); }
.dp-out { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dp-card { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); min-width: 0; }
.dp-card .big-num { text-align: left; overflow-wrap: anywhere; }
.dp-card.good { border-color: #2f9e44; }
[data-theme="archemath"] .mz.wall { background: #f2d27a; }

/* Gradient-filled headings only paint inside their box: give tall letters (Cinzel, Bengali and Hindi
   vowel signs, descenders) room so nothing is cut off. */
[data-theme="archemath"] .hero h1, [data-theme="archemath"] .lesson-title, [data-theme="archemath"] .tools-head h2,
[data-theme="archemath"] .ec-title, [data-theme="archemath"] .hh-title, [data-theme="archemath"] .page-hero h1,
[data-theme="archemath"] .section-title, [data-theme="archemath"] .fam-head h2, :root:not([data-theme="archemath"]) .eyebrow { padding-block: .12em .2em; }

/* Archemath: no Greek key line under the top bar (the person's ask, 2026-11-23). */
[data-theme="archemath"] .topbar { background: #0a0e1b; padding-bottom: 12px; }
/* Archemath headings in Cormorant Garamond (the person asked for a different font than Cinzel). Cinzel had
   no lower case, so the headings were all capitals; Cormorant is set at a heavier weight and larger size. */
[data-theme="archemath"] h1, [data-theme="archemath"] h2, [data-theme="archemath"] h3, [data-theme="archemath"] .hh-title, [data-theme="archemath"] .section-title { font-weight: 700; letter-spacing: .005em; }
[data-theme="archemath"] .brand { font-weight: 700; font-size: 26px; letter-spacing: .02em; }

/* Rajhangsa the swan (2026-11-23) */
.mascot-swan { width: 62px; height: 62px; margin-right: -4px; cursor: pointer; }
.mascot-owl, .mascot-pi { cursor: pointer; }
@media (max-width: 600px) { .mascot-swan { width: 46px; height: 46px; } }
.swan .swan-wing { transform-box: fill-box; transform-origin: 20% 60%; }
.mascot.happy .swan .swan-wing { animation: swanflap .4s ease-in-out 5; }
.mascot.happy .mascot-swan { animation: hop .7s ease-in-out 3; animation-delay: .3s; }
.mascot.talk .swan-brow { transform: translateY(-1.2px) rotate(-8deg); transform-box: fill-box; transform-origin: 0 50%; }
@keyframes swanflap { 50% { transform: rotate(-18deg) translateY(-3px); } }
.meet-swan { grid-column: 1 / -1; display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; padding-top: 16px; border-top: 1px dashed var(--line); }
.meet-swan-pic { width: 104px; height: 104px; animation: idle 4.5s ease-in-out -1s infinite; }
.meet-swan p { margin: 0 0 10px; font-size: 17px; line-height: 1.6; max-width: 62ch; }
@media (max-width: 640px) { .meet-swan { grid-template-columns: 1fr; justify-items: center; } .meet-swan-pic { width: 88px; height: 88px; } }
.friend-pic.swan-pic { width: 64px; height: 64px; }
.friend-swan .friend-bubble { background: color-mix(in srgb, #f08c2b 9%, var(--panel)); border-color: color-mix(in srgb, #f08c2b 35%, transparent); }
.friend-swan .friend-name { color: #d9731a; }
@media (prefers-reduced-motion: reduce) { .meet-swan-pic, .mascot-swan, .swan * { animation: none !important; } }

/* Durga Puja guests: only one visits at a time (set by mascot.guest) */
.mascot-guest { display: none; }
.mascot[data-guest="swan"] .mascot-swan, .mascot[data-guest="peacock"] .mascot-peacock, .mascot[data-guest="mouse"] .mascot-mouse { display: block; }
.mascot-peacock { width: 66px; height: 66px; margin-right: -4px; cursor: pointer; }
.mascot-mouse { width: 54px; height: 54px; margin-right: -2px; cursor: pointer; }
@media (max-width: 600px) { .mascot-peacock { width: 50px; height: 50px; } .mascot-mouse { width: 48px; height: 48px; } }
.peacock-tail { transform-box: fill-box; transform-origin: 50% 100%; }
.mascot.happy .peacock-tail, .mascot.talk .peacock-tail { animation: fanout .5s ease-in-out 3; }
.mascot.happy .mascot-peacock, .mascot.happy .mascot-mouse { animation: hop .6s ease-in-out 3; animation-delay: .25s; }
.mouse-ears { transform-box: fill-box; transform-origin: 50% 100%; }
.mascot.talk .mouse-ears { animation: wiggle .35s ease-in-out 4; }
.mascot .mouse .mouth-happy { display: none; }
.mascot.happy .mouse .mouth-happy { display: inline; } .mascot.happy .mouse .mouth-calm { display: none; }
@keyframes fanout { 50% { transform: scale(1.08, 1.12); } }
@keyframes wiggle { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
.friend-peacock .friend-name { color: #1f8a5c; }
.friend-mouse .friend-name { color: #7a6f80; }
[data-theme="archemath"] .friend-peacock .friend-name { color: #6fd3a2; }
[data-theme="archemath"] .friend-mouse .friend-name { color: #c9c0cf; }
.meet-more { grid-column: 1 / -1; margin: 0 !important; padding-top: 14px; border-top: 1px dashed var(--line, rgba(127,127,127,.35)); font-size: 16px !important; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .peacock *, .mouse * { animation: none !important; } }

/* Rajhangsa floats like a swan on a lake */
.mascot[data-guest="swan"] .mascot-swan { animation: swanfloat 3.8s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes swanfloat { 0%, 100% { transform: translate(0, 0) rotate(-2deg); } 50% { transform: translate(-3px, -4px) rotate(2deg); } }
/* Squeaky scurries in when an answer is wrong, then runs off again */
.mascot-mouse { display: none; }
.mascot[data-visitor="mouse"] .mascot-guest { display: none !important; }
.mascot[data-visitor="mouse"] .mascot-mouse { display: block; animation: scurry .55s cubic-bezier(.2, .9, .3, 1.2) both, mousebob .25s ease-in-out .55s 6; }
@keyframes scurry { from { transform: translateX(-70px) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes mousebob { 50% { transform: translateY(-3px); } }
.mascot[data-visitor="mouse"] .mascot-bubble { border-color: #8f8696; }
/* Shikhi dances when notes agree, droops when they clash */
.mascot.dance .mascot-peacock, .peacock-stage.dance .peacock-big { animation: pdance .55s ease-in-out infinite; transform-origin: 50% 95%; }
.mascot.dance .peacock-tail, .peacock-stage.dance .peacock-tail { animation: fanout .55s ease-in-out infinite; }
.mascot.droop .mascot-peacock, .peacock-stage.droop .peacock-big { filter: grayscale(.65) brightness(.9); transform: rotate(-6deg) translateY(4px); transform-origin: 50% 95%; transition: transform .4s, filter .4s; }
.mascot.droop .peacock-tail, .peacock-stage.droop .peacock-tail { transform: scale(.72, .45) rotate(8deg); transition: transform .4s; }
@keyframes pdance { 0%, 100% { transform: rotate(-5deg) translateY(0); } 50% { transform: rotate(5deg) translateY(-5px); } }
.peacock-stage { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 18px; align-items: center; }
.peacock-big { width: 100%; height: auto; max-width: 200px; }
.peacock-stage .mood { font-weight: 700; }
.peacock-stage .mood.ok { color: #1f8a5c; } .peacock-stage .mood.bad { color: #c0392b; }
[data-theme="archemath"] .peacock-stage .mood.ok { color: #6fd3a2; }
@media (max-width: 560px) { .peacock-stage { grid-template-columns: 1fr; justify-items: center; text-align: center; } .peacock-big { max-width: 150px; } }
@media (prefers-reduced-motion: reduce) { .mascot-swan, .mascot-mouse, .peacock-big, .peacock-tail { animation: none !important; } }

/* Copyright footer */
.site-footer { max-width: 1100px; margin: 10px auto 0; padding: 22px 20px 28px; border-top: 1px solid var(--line, rgba(127,127,127,.3)); text-align: center; color: var(--muted); font-size: 14px; }
.site-footer p { margin: 2px 0; }
.site-footer .small { font-size: 13px; }
@media (max-width: 600px) { .site-footer { padding-bottom: 96px; padding-right: 20px; } }

/* Shikhi's tuning slider: three octaves, marks for every sweet ratio */
.tune-slider { margin: 12px 0 6px; }
.tune-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.tune-track { position: relative; padding-bottom: 26px; }
.tune-track input[type="range"] { width: 100%; margin: 0; display: block; }
.tune-marks { position: absolute; left: 9px; right: 9px; top: 100%; margin-top: -24px; height: 24px; }
.tune-mark { position: absolute; top: 0; width: 2px; height: 8px; margin-left: -1px; background: var(--muted); opacity: .7; cursor: pointer; }
.tune-mark::before { content: ''; position: absolute; inset: -4px -6px; }
.tune-mark.oct { height: 13px; background: var(--accent); opacity: 1; }
.tune-mark i { position: absolute; top: 13px; left: 50%; transform: translateX(-50%); font: 600 11px/1.2 var(--mono, ui-monospace, monospace); font-style: normal; color: var(--muted); white-space: nowrap; }
.tune-pick { font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line, rgba(127,127,127,.35)); background: var(--panel); color: var(--text); max-width: 100%; }
.tune-mark:first-child i { left: -1px; transform: none; } .tune-mark:last-child i { left: auto; right: -1px; transform: none; }

/* Rajhangsa and Shikhi are line drawings traced from the person's sketches */
.mascot-swan { width: 74px; height: 60px; }
.mascot-peacock { width: 52px; height: 80px; }
.friend-pic.peacock-pic { width: 46px; height: 70px; }
.peacock-big { max-width: 170px; }
@media (max-width: 600px) { .mascot-swan { width: 58px; height: 47px; } .mascot-peacock { width: 42px; height: 64px; } .peacock-big { max-width: 130px; } }
[data-theme="archemath"] .mascot-swan, [data-theme="archemath"] .mascot-peacock, [data-theme="archemath"] .swan-pic, [data-theme="archemath"] .peacock-pic, [data-theme="archemath"] .peacock-big { filter: brightness(1.7) saturate(.8); }
.peacock-big, .mascot-peacock, .mascot-swan, .friend-pic { overflow: visible; }

/* Rajhangsa's own pond, bottom-left, apart from Glaux, Pi and the others */
.swan-dock { position: fixed; left: 14px; bottom: 10px; z-index: 20; display: flex; flex-direction: column; align-items: flex-start; pointer-events: none; }
.swan-dock[hidden], .swan-dock.hidden { display: none; }
.swan-pond { pointer-events: auto; position: relative; border: 0; padding: 6px 10px 10px; cursor: pointer; border-radius: 50% / 40%;
  background: radial-gradient(ellipse at 50% 85%, rgba(90, 170, 200, .35), rgba(90, 170, 200, .12) 55%, transparent 72%); }
.swan-pond::after { content: ''; position: absolute; left: 14%; right: 14%; bottom: 9px; height: 6px; border-radius: 50%; border-bottom: 2px solid rgba(70, 140, 175, .55); animation: ripple 3.8s ease-in-out infinite; }
.swan-dock .mascot-swan { display: block; width: 78px; height: 63px; animation: swanfloat 3.8s ease-in-out infinite; transform-origin: 50% 90%; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .18)); }
@keyframes ripple { 50% { transform: scaleX(1.15); opacity: .6; } }
.swan-bubble { max-width: min(270px, 70vw); margin: 0 0 6px 6px; background: var(--panel); color: var(--text); border: 1.5px solid #4f9fbf; border-radius: 14px 14px 14px 4px; padding: 7px 12px; font-weight: 600; font-size: 15px; line-height: 1.4; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }
.swan-dock.talk .swan-bubble { opacity: 1; transform: none; }
.swan-dock.talk .mascot-swan { animation: swanfloat 3.8s ease-in-out infinite, hop .6s ease-in-out 1; }
[data-theme="archemath"] .swan-dock .mascot-swan { filter: brightness(1.7) saturate(.8); }
@media (max-width: 600px) { .swan-dock { left: 6px; } .swan-dock .mascot-swan { width: 60px; height: 48px; } .swan-bubble { font-size: 14px; max-width: 64vw; } }
@media (prefers-reduced-motion: reduce) { .swan-pond::after, .swan-dock .mascot-swan { animation: none !important; } }
[data-theme="archemath"] .peacock-stage.droop .peacock-big, [data-theme="archemath"] .mascot.droop .mascot-peacock { filter: brightness(1.5) grayscale(.6); }
.swan-bubble .swan-link { pointer-events: auto; display: inline-block; margin-left: 2px; font-weight: 700; color: #2b7fa3; text-decoration: underline; }
.swan-dock.talk .swan-bubble { pointer-events: auto; }
.seq-list { overflow-wrap: anywhere; color: var(--muted); }
.fta-hero .fh-1 { fill: #1f6fb2; }

/* Finished, full-colour Shikhi and Rajhangsa */
.mascot-peacock { width: 66px; height: 76px; }
.friend-pic.peacock-pic { width: 58px; height: 67px; }
.peacock-big { max-width: 210px; }
.swan-dock .mascot-swan { width: 88px; height: 70px; }
@media (max-width: 600px) { .mascot-peacock { width: 50px; height: 58px; } .swan-dock .mascot-swan { width: 66px; height: 53px; } .peacock-big { max-width: 160px; } }
[data-theme="archemath"] .mascot-swan, [data-theme="archemath"] .mascot-peacock, [data-theme="archemath"] .swan-pic, [data-theme="archemath"] .peacock-pic, [data-theme="archemath"] .peacock-big, [data-theme="archemath"] .swan-dock .mascot-swan { filter: none; }
[data-theme="archemath"] .peacock-stage.droop .peacock-big, [data-theme="archemath"] .mascot.droop .mascot-peacock { filter: grayscale(.65) brightness(.95); }
.swan-dock.talk .swan-wing { animation: swanwing 1.1s ease-in-out 2; transform-box: fill-box; transform-origin: 10% 100%; }
@keyframes swanwing { 50% { transform: rotate(-6deg) scale(1.04); } }
/* shapes follow the person's outlines: tall fan, tall raised wing */
.mascot-peacock { width: 62px; height: 76px; }
.friend-pic.peacock-pic { width: 54px; height: 66px; }
.swan-dock .mascot-swan { width: 82px; height: 76px; }
.friend-pic.swan-pic { width: 64px; height: 60px; }
@media (max-width: 600px) { .mascot-peacock { width: 48px; height: 58px; } .swan-dock .mascot-swan { width: 62px; height: 58px; } }

/* Painted friends: Shikhi, Rajhangsa, Glaux and Squeaky (img/*.webp) */
.art-pic { display: block; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.mascot-peacock { width: 58px; height: 82px; }
.swan-dock .mascot-swan { width: 92px; height: 88px; }
.friend-pic.peacock-pic { width: 50px; height: 70px; }
.friend-pic.swan-pic { width: 68px; height: 65px; }
.peacock-big { width: 100%; max-width: 190px; height: auto; }
@media (max-width: 600px) { .mascot-peacock { width: 44px; height: 62px; } .swan-dock .mascot-swan { width: 70px; height: 67px; } .peacock-big { max-width: 150px; } }
/* a touch warmer on the cream Mathesis theme; natural colours on dark Archemath */
:root:not([data-theme="archemath"]) .art-pic { filter: sepia(.12) saturate(1.05); }
/* Shikhi's dance: a sway with a breathing fan; droop: folds down and greys out */
.mascot.dance .mascot-peacock, .peacock-stage.dance .peacock-big { animation: pdance2 .6s ease-in-out infinite; transform-origin: 50% 92%; }
@keyframes pdance2 { 0%, 100% { transform: rotate(-5deg) scale(1, 1); } 50% { transform: rotate(5deg) scale(1.06, 1.03) translateY(-4px); } }
.mascot.droop .mascot-peacock, .peacock-stage.droop .peacock-big { animation: none; transform: rotate(-4deg) scale(.86, .74) translateY(10%); transform-origin: 50% 100%; filter: grayscale(.7) brightness(.92); transition: transform .45s, filter .45s; }
.peacock-stage .peacock-big { transition: transform .45s, filter .45s; }
.mascot:not([data-guest="peacock"]) .mascot-peacock { display: none !important; }
/* the full-fan Shikhi (wider than tall) */
.mascot-peacock { width: 74px; height: 68px; }
.friend-pic.peacock-pic { width: 66px; height: 61px; }
.peacock-big { max-width: 220px; }
@media (max-width: 600px) { .mascot-peacock { width: 56px; height: 52px; } .peacock-big { max-width: 170px; } }
[data-theme="archemath"] .art-pic { filter: drop-shadow(0 0 6px rgba(242, 210, 122, .22)); }
[data-theme="archemath"] .peacock-stage.droop .peacock-big, [data-theme="archemath"] .mascot.droop .mascot-peacock { filter: grayscale(.7) brightness(.85); }
/* back to the first pair: the tall peacock with two plume fans */
.mascot-peacock { width: 58px; height: 82px; }
.friend-pic.peacock-pic { width: 50px; height: 70px; }
.peacock-big { max-width: 190px; }
@media (max-width: 600px) { .mascot-peacock { width: 44px; height: 62px; } .peacock-big { max-width: 150px; } }
/* golden Rajhangsa in Mathesis, her own colours in Archemath */
[data-theme="archemath"] .art-mathesis, :root:not([data-theme="archemath"]) .art-archemath { display: none !important; }
:root:not([data-theme="archemath"]) .art-mathesis { filter: drop-shadow(0 2px 3px rgba(120, 60, 10, .2)); }
:root .mascot.droop .mascot-peacock.art-pic, :root .peacock-stage.droop .peacock-big.art-pic { filter: grayscale(.7) brightness(.9); }
/* the corner Shikhi matches the big one in the tuning figure, in either theme */
.mascot[data-tune="dance"] .mascot-peacock { animation: pdance2 .6s ease-in-out infinite; transform-origin: 50% 92%; }
.mascot[data-tune="droop"] .mascot-peacock { animation: none; transform: rotate(-4deg) scale(.86, .74) translateY(10%); transform-origin: 50% 100%; transition: transform .45s, filter .45s; }
:root .mascot[data-tune="droop"] .mascot-peacock.art-pic { filter: grayscale(.7) brightness(.9); }
/* Rajhangsa in her pond gets the same soft gold glow as the others in Archemath */
[data-theme="archemath"] .swan-dock .mascot-swan.art-pic { filter: drop-shadow(0 0 6px rgba(242, 210, 122, .22)); }
@media (prefers-reduced-motion: reduce) { .mascot[data-tune] .mascot-peacock { animation: none !important; } }
/* "What should we hope for?" essay */
.hope-hero { width: 100%; max-width: 340px; justify-self: end; }
.hope-wave { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.hope-stem { fill: none; stroke: var(--good); stroke-width: 4; stroke-linecap: round; }
.hope-leaf { fill: color-mix(in srgb, var(--good) 30%, transparent); stroke: var(--good); stroke-width: 2.5; transform-origin: 240px 58px; animation: hopeleaf 4s ease-in-out infinite; }
.hope-leaf.l2 { transform-origin: 236px 84px; animation-delay: -2s; }
.hope-ground { stroke: var(--accent-2); stroke-width: 3; stroke-linecap: round; }
@keyframes hopeleaf { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(5deg); } }
.hope-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.hope-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel); display: grid; gap: 8px; align-content: start; transition: border-color .3s, background .3s; }
.hope-say { margin: 0; font-style: italic; }
.hope-card.is-problem { border-color: var(--good); background: color-mix(in srgb, var(--good) 8%, var(--panel)); }
.hope-card.is-ideal { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 10%, var(--panel)); }
.hope-why:empty { display: none; }
.hope-score { margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .hope-leaf { animation: none; } }
/* corner Shikhi: bigger (close to Glaux) and brighter, in both themes */
.mascot .mascot-peacock { width: 70px; height: 100px; }
@media (max-width: 600px) { .mascot .mascot-peacock { width: 52px; height: 74px; } }
:root:not([data-theme="archemath"]) .mascot:not(.droop):not([data-tune="droop"]) .mascot-peacock.art-mathesis { filter: brightness(1.12) saturate(1.25) drop-shadow(0 0 5px rgba(229, 160, 25, .45)); }
[data-theme="archemath"] .mascot:not(.droop):not([data-tune="droop"]) .mascot-peacock.art-archemath { filter: brightness(1.3) saturate(1.2) drop-shadow(0 0 7px rgba(242, 210, 122, .5)); }
/* why base ten: fingers */
.ten-fingers { display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; background: var(--accent-soft); margin: 14px 0; }
.ten-fingers p { margin: 6px 0 0; }
.tf-hands { font-size: 40px; line-height: 1; white-space: nowrap; display: flex; gap: 2px; }
.tf-hands :first-child { transform: scaleX(-1); }
[data-theme="archemath"] .ten-fingers { background: color-mix(in srgb, #d9b44a 8%, transparent); }
@media (max-width: 520px) { .ten-fingers { flex-direction: column; align-items: flex-start; } }
/* music maker */
.mk-scroll { overflow-x: auto; margin: 10px 0; }
.mk-grid { display: grid; grid-template-columns: 64px repeat(8, minmax(30px, 1fr)); gap: 4px; min-width: 330px; }
.mk-key { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); padding: 2px; line-height: 1.1; cursor: pointer; font: inherit; }
.mk-key .small { font-size: 11px; opacity: .7; }
.mk-key.sour, .mk-cell.sour { border-style: dashed; }
.mk-cell { height: 30px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); cursor: pointer; padding: 0; transition: background .15s, transform .15s; }
.mk-cell.col { background: color-mix(in srgb, var(--accent-2) 12%, var(--panel)); }
.mk-cell.on { background: var(--accent); border-color: var(--accent); }
.mk-cell.sour.on { background: #c0392b; border-color: #c0392b; }
.mk-cell.now { box-shadow: 0 0 0 2px var(--accent-2); }
.mk-cell.on.now { transform: scale(1.08); }
.mk-head { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; border-radius: 6px; padding: 2px 0; border-bottom: 3px solid transparent; }
.mk-head.col { color: var(--text); font-weight: 700; }
.mk-head[data-mood="very-sweet"], .mk-head[data-mood="sweet"] { border-bottom-color: #2b8a3e; }
.mk-head[data-mood="mild"] { border-bottom-color: var(--accent-2); }
.mk-head[data-mood="tense"] { border-bottom-color: #c0392b; }
.mk-why { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.mk-score { margin-bottom: 8px; }
.mk-badge { display: inline-block; padding: 1px 10px; border-radius: 99px; font-weight: 700; font-size: 14px; color: #fff; background: #2b8a3e; }
.mk-badge.mild { background: var(--accent-2); color: #2b1a0e; }
.mk-badge.tense { background: #c0392b; }
.mk-harm { width: 100%; max-width: 520px; display: block; margin: 8px 0; }
.mk-axis { stroke: var(--line); stroke-width: 1.5; }
.mk-match { stroke: #2b8a3e; stroke-width: 2.5; }
.mk-h1 { fill: var(--accent); } .mk-h2 { fill: #3b5bdb; }
.mk-lab { font-size: 11px; fill: var(--muted); }
[data-theme="archemath"] .mk-match { stroke: #6fd3a2; }
[data-theme="archemath"] .mk-h2 { fill: #8fb3ff; }
@media (max-width: 600px) { .mk-grid { grid-template-columns: 46px repeat(8, minmax(0, 1fr)); gap: 3px; min-width: 0; } .mk-cell { height: 26px; border-radius: 5px; } .mk-key b { font-size: 13px; } .mk-key .small { font-size: 10px; } }
.mk-badge { margin-right: 6px; }
/* golden Rajhangsa in Archemath too: a warm glow on the dark blue */
[data-theme="archemath"] .art-gold { filter: drop-shadow(0 0 4px rgba(242, 210, 122, .16)); }
:root:not([data-theme="archemath"]) .art-gold { filter: drop-shadow(0 2px 3px rgba(120, 60, 10, .2)); }
/* top bar: Lessons and Topics are the main thing; look and language sit in a small menu at the side */
.topbar { flex-wrap: nowrap; }
.topbar .nav { margin-left: auto; gap: 6px; }
.topbar .nav a { font-size: 17px; font-weight: 600; padding: 9px 20px; color: var(--text); }
.topbar .nav a.active { background: var(--accent); color: var(--on-accent); box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 30%, transparent); }
[data-theme="archemath"] .topbar .nav a.active { background: var(--gold-grad); color: #070a14; }
.prefs { position: relative; margin-left: 14px; flex: none; }
.prefs-btn { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; color: var(--muted); font-size: 13px; font-weight: 600; user-select: none; }
.prefs-btn::-webkit-details-marker { display: none; }
.prefs-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.prefs-btn:hover, .prefs[open] .prefs-btn { color: var(--text); border-color: var(--accent-2); }
.prefs-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 12px; box-shadow: 0 12px 30px rgba(0, 0, 0, .18); display: grid; gap: 6px; min-width: 230px; }
[data-theme="archemath"] .prefs-panel { background: #0d1224; border-color: #d9b44a55; }
.prefs-panel .theme-switch { margin: 0 !important; order: 0 !important; justify-self: start; }
.prefs-label { margin-top: 4px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .topbar .brand { order: 1; }
  .prefs { order: 2; margin-left: auto; }
  .topbar .nav { order: 3; flex: 1 0 100%; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .topbar .nav a { text-align: center; padding: 9px 8px; font-size: 16px; border: 1px solid var(--line); }
  .topbar .nav a.active { border-color: transparent; }
}
/* little Shikhi and Squeaky icons above the corner friends */
.mascot-tray { display: flex; gap: 6px; margin: 0 6px 4px 0; pointer-events: auto; }
.tray-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); padding: 2px; cursor: pointer; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); transition: transform .15s; }
.tray-btn:hover { transform: translateY(-2px) scale(1.06); }
.tray-btn .tray-pic { width: 26px; height: 26px; object-fit: contain; }
.tray-btn svg.tray-pic { width: 28px; height: 28px; }
[data-theme="archemath"] .tray-btn { background: #0d1224; border-color: #d9b44a66; }
.mascot[data-guest="peacock"] .tray-peacock, .mascot[data-visitor="mouse"] .tray-mouse, .mascot.hidden .mascot-tray { display: none; }
@media (max-width: 600px) { .tray-btn { width: 28px; height: 28px; } .tray-btn .tray-pic { width: 21px; height: 21px; } .tray-btn svg.tray-pic { width: 23px; height: 23px; } }
.meet-more { display: flex; align-items: center; gap: 14px; }
.meet-mini { display: flex; align-items: flex-end; gap: 6px; flex: none; }
.meet-mini .mini-pic { width: 44px; height: 44px; object-fit: contain; }
.meet-mini svg.mini-pic { width: 40px; height: 40px; }
@media (max-width: 640px) { .meet-more { flex-direction: column; text-align: center; } }
/* easier to tuck the friends away: a clear round button, and swipe down on phones */
.mascot-hide { position: absolute; right: 2px; bottom: auto; top: auto; opacity: .9; pointer-events: auto; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); display: grid; place-items: center; font-size: 20px; line-height: 1; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); z-index: 2; }
.mascot-hide span { transform: translateY(-3px); }
.mascot-hide:hover { color: var(--text); opacity: 1; }
.mascot .mascot-hide { position: static; align-self: flex-end; margin: 0 2px 4px 0; order: 0; }
[data-theme="archemath"] .mascot-hide, [data-theme="archemath"] .mascot-show { background: #0d1224; border-color: #d9b44a66; color: #e9c766; }
.mascot-show { pointer-events: auto; width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 3px 10px rgba(0, 0, 0, .2); font-size: 26px; line-height: 1; place-items: center; }
.mascot.hidden .mascot-show { display: grid; }
.mascot-tray { align-items: center; }
.mascot-tray .mascot-hide { margin: 0 0 0 4px; }
.mascot.hidden .mascot-tray { display: none !important; }
/* stars on interesting, lesser-known topics; the tile you came back from */
.tt-star { color: #e5a019; margin-left: 6px; font-size: .95em; }
[data-theme="archemath"] .tt-star { color: #f2d27a; text-shadow: 0 0 6px rgba(242, 210, 122, .5); }
.topic-tile.last { border-color: var(--accent-2); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 40%, transparent); }
.star-key { margin-top: 6px; }
/* Back button in the top bar, on every page except home */
.back-btn { flex: none; display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 15px; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 7px 14px 7px 11px; cursor: pointer; }
.back-btn:hover { border-color: var(--accent-2); }
.back-btn[hidden] { display: none; }
[data-theme="archemath"] .back-btn { background: #0d1224; border-color: #d9b44a66; color: #f2d27a; }
@media (max-width: 600px) { .back-btn { order: 0; padding: 6px 10px; } .back-btn .back-word { display: none; } .back-btn span[aria-hidden] { font-size: 18px; } .topbar .brand { order: 1; } }
.swan-hint { display: block; margin-top: 4px; font-size: 13px; opacity: .75; font-style: italic; }
/* each friend can be tucked away on its own */
.mascot[data-tuck~="owl"] .mascot-owl, .mascot[data-tuck~="pi"] .mascot-pi { display: none; }
.mascot[data-tuck~="owl"] .mascot-show, .mascot[data-tuck~="pi"] .mascot-show { display: grid; width: 38px; height: 38px; font-size: 20px; }
.mascot.hidden .mascot-show { width: 46px; height: 46px; font-size: 26px; }
.swan-back { display: none; pointer-events: auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 20px; cursor: pointer; box-shadow: 0 3px 10px rgba(0, 0, 0, .2); }
.swan-dock.tucked .swan-pond, .swan-dock.tucked .swan-bubble { display: none !important; }
.swan-dock.tucked .swan-back { display: grid; place-items: center; }
[data-theme="archemath"] .swan-back { background: #0d1224; border-color: #d9b44a66; }

/* Type, 2026-11-23: sharper, modest, scholarly. Mathesis: Source Serif 4 headings with Source Sans 3 text.
   Archemath: Spectral throughout. Bengali, Hindi and Japanese use the matching Noto Sans / Noto Serif. */
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-kerning: normal; }
h1, h2, h3, .section-title, .hh-title, .page-hero h1, .ec-title, .card-title { font-weight: 600 !important; letter-spacing: -.01em; }
.page-hero h1 { letter-spacing: -.015em; }
.pull { font-weight: 400; }
.topbar .nav a { font-weight: 600; letter-spacing: .005em; }
.brand, [data-theme="archemath"] .brand { font-weight: 600 !important; letter-spacing: .01em; }
[data-theme="archemath"] h1, [data-theme="archemath"] h2, [data-theme="archemath"] h3 { letter-spacing: 0; }
:root[lang="bn"] body, :root[lang="hi"] body { line-height: 1.7; }
/* Logo: a little more orange, with a soft glint sweeping across and a twinkle */
.brand .logo { position: relative; overflow: hidden; isolation: isolate; }
:root:not([data-theme="archemath"]) .brand .logo { background: linear-gradient(135deg, #f0a23c 0%, #e07a22 45%, #c4561a 100%); }
[data-theme="archemath"] .brand .logo { background: linear-gradient(160deg, #fbe3a0 0%, #f0b552 40%, #e08a2c 75%, #b8641e 100%) !important; box-shadow: 0 0 0 2px #0a0e1b, 0 0 0 3px #e9a646, 0 0 14px rgba(240, 170, 80, .45); }
.brand .logo::after { content: ""; position: absolute; inset: -40%; background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .85) 50%, transparent 60%); transform: translateX(-120%); animation: logoglint 4.5s ease-in-out infinite; pointer-events: none; }
@keyframes logoglint { 0%, 62% { transform: translateX(-120%); } 82%, 100% { transform: translateX(120%); } }
.brand { position: relative; }
.brand::before { content: "✦"; position: absolute; left: 26px; top: -2px; font-size: 11px; color: #fff3c4; text-shadow: 0 0 6px #ffcf6b, 0 0 12px #f0a23c; opacity: 0; animation: twinkle 4.5s ease-in-out infinite; pointer-events: none; z-index: 2; }
@keyframes twinkle { 0%, 70% { opacity: 0; transform: scale(.4) rotate(0); } 80% { opacity: 1; transform: scale(1.1) rotate(20deg); } 92%, 100% { opacity: 0; transform: scale(.4) rotate(40deg); } }
@media (prefers-reduced-motion: reduce) { .brand .logo::after, .brand::before { animation: none; } }

/* Floating friends: drag them anywhere; in the top half the bubble opens below them. */
.mascot.up, .swan-dock.up { flex-direction: column-reverse; }
.mascot.dragging, .swan-dock.dragging { transition: none; }
.mascot.dragging .mascot-bubble, .swan-dock.dragging .swan-bubble { opacity: .4; }
.mascot-owl, .mascot-pi, .swan-pond { cursor: grab; }
.mascot.dragging .mascot-owl, .mascot.dragging .mascot-pi, .swan-dock.dragging .swan-pond { cursor: grabbing; }
/* Painted Glaux and Squeaky */
img.mascot-owl { width: 90px; height: 100px; }
img.meet-owl { width: 160px; height: 180px; }
img.mascot-mouse { width: 66px; height: 46px; }
.friend-pic.owl-pic { width: 62px; height: 72px; }
.friend-pic.mouse-pic { width: 70px; height: 50px; }
@media (max-width: 600px) { img.mascot-owl { width: 66px; height: 74px; } img.mascot-mouse { width: 56px; height: 38px; } }
@media (max-width: 640px) { img.meet-owl { width: 120px; height: 136px; } }
/* Painted Pi (a wide feathered π) */
img.mascot-pi { width: 70px; height: 52px; align-self: flex-end; }
img.meet-pi { width: 120px; height: 90px; }
.friend-pic.pi-pic { width: 70px; height: 52px; }
@media (max-width: 600px) { img.mascot-pi { width: 56px; height: 42px; } }
@media (max-width: 640px) { img.meet-pi { width: 96px; height: 72px; } }
.mascot .mascot-mouse { display: none; }
.mascot[data-visitor="mouse"] .mascot-mouse, .mascot[data-guest="mouse"] .mascot-mouse { display: block; }
.mascot-show .show-pic { width: 78%; height: 78%; }
/* Topics: pick your class */
.class-pick { margin: 4px 0 6px; }
.class-label { display: block; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.class-chips { margin: 6px 0 2px; }
.class-note { margin: 4px 0 0; min-height: 1em; }
.topic-tile[hidden], .topic-sec[hidden], .topic-nav a[hidden] { display: none !important; }
@media (max-width: 640px) { .class-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; } .class-chips .chip { flex: none; } }
/* The three friends under "You'll get to know them all" can be tapped */
.mini-btn { display: inline-grid; place-items: center; padding: 4px; border: 0; background: none; border-radius: 12px; cursor: pointer; transition: transform .15s ease; }
.mini-btn:hover, .mini-btn:focus-visible { transform: translateY(-3px) scale(1.06); }
.mini-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Number theory page */
.nt-thm { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 12px 16px; margin: 14px 0; background: var(--panel); }
.nt-tag { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.nt-name { display: block; font-family: var(--font-head); font-size: 1.08em; margin: 2px 0 4px; }
.nt-stmt { margin: 0; font-style: italic; }
.nt-proof { margin-top: 8px; }
.nt-proof summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.nt-proof p { margin: 8px 0 0; }
.nt-lab { display: inline-flex; align-items: center; gap: 8px; }
.nt-in { width: 110px; font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
.nt-in.small-in { width: 72px; padding: 4px 8px; }
.nt-cong { margin: 6px 0; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nt-out { margin-top: 10px; }
.nt-steps { font-size: 14px; line-height: 1.7; overflow-x: auto; }
.nt-table-wrap { overflow-x: auto; }
.nt-table { border-collapse: collapse; font-family: var(--font-mono); font-size: 13px; margin: 6px 0; }
.nt-table th, .nt-table td { border: 1px solid var(--line); padding: 3px 7px; text-align: center; min-width: 26px; }
.nt-table th { color: var(--muted); font-weight: 600; }
.nt-table td.nt-one { background: var(--accent-soft); font-weight: 700; }
.nt-table .nt-last { border-left: 2px solid var(--accent); }
.nt-table tr.nt-root th { color: var(--accent); }
.nt-table tr.nt-root th::after { content: ' ★'; }
.nt-cong .nt-in { width: 76px; flex: none; }
.nt-check { line-height: 1.6; }

/* One typeface family everywhere (the person's choice): Source Serif 4 with the matching Noto Serif scripts. */
:root, :root[data-theme="archemath"], [data-theme="archemath"] {
  --font-body: "Source Serif 4", "Noto Serif Bengali", "Noto Serif Devanagari", "Noto Serif JP", Georgia, "Times New Roman", serif;
  --font-head: "Source Serif 4", "Noto Serif Bengali", "Noto Serif Devanagari", "Noto Serif JP", Georgia, "Times New Roman", serif;
}
.num-story { margin: 14px 0; padding: 14px 18px; border-radius: 14px; border: 1px dashed var(--accent); background: var(--accent-soft); }
.num-story > b { display: block; font-family: var(--font-head); font-size: 1.1em; margin-bottom: 4px; }
.num-story p { margin: 6px 0; }
.num-story .num-q { font-weight: 600; }
.num-story summary { cursor: pointer; font-weight: 600; color: var(--accent); margin-top: 6px; }
.num-story { scroll-margin-top: 200px; }
