:root {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #eef1f7; --ink: #141a2a; --muted: #5b6479; --line: #dde2ec; --grid: #e7eaf1; --grid-major: #d8dde8;
  --accent-1: #2563eb; --accent-2: #db2777; --ok: #15803d; --ok-bg: #e8f6ee; --bad: #b91c1c; --bad-bg: #fdecec; --warn: #b45309; --warn-bg: #fff6e6;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,26,42,.06), 0 4px 16px rgba(20,26,42,.05);
  --accent: var(--accent-1);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0e121b; --surface: #161c28; --surface-2: #1e2533; --ink: #e8ecf4; --muted: #9aa4b8; --line: #2a3242; --grid: #232b3a; --grid-major: #2c3648;
  --accent-1: #60a5fa; --accent-2: #f472b6; --ok: #4ade80; --ok-bg: #12301f; --bad: #f87171; --bad-bg: #3a1717; --warn: #fbbf24; --warn-bg: #33270f;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent-1); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 3.5vw, 2.4rem); letter-spacing: -.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
sub, sup { font-size: .72em; }
code { background: var(--surface-2); padding: 0 .3em; border-radius: 4px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 10px; top: 10px; z-index: 99; background: var(--surface); padding: 8px; }
.hidden { display: none !important; }
.small { font-size: .86rem; color: var(--muted); }
.center { text-align: center; }
.big { font-size: 1.6rem; font-weight: 700; }
.warn { color: var(--warn); }

/* top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--ink); text-decoration: none; display: flex; gap: 8px; align-items: center; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); color: #fff; }
.mainnav { display: flex; gap: 4px; align-items: center; }
.mainnav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.mainnav a:hover, .mainnav a.active { color: var(--ink); background: var(--surface-2); }
.theme-btn, .menu-btn { background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 1rem; }
.menu-btn { display: none; }
.subnav-wrap { background: var(--surface); border-bottom: 1px solid var(--line); }
.subnav { display: flex; gap: 2px; overflow-x: auto; padding: 6px 0; scrollbar-width: none; }
.subnav a { white-space: nowrap; padding: 6px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: .93rem; }
.subnav a.active, .subnav a:hover { background: var(--surface-2); color: var(--ink); }
.subnav .subnav-title { font-weight: 700; color: var(--accent); }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; padding-top: 24px; padding-bottom: 40px; }
.main-full { padding-top: 24px; padding-bottom: 40px; }
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.sidebar > * { position: relative; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
section { margin-bottom: 18px; }
.page-head { margin: 6px 0 22px; border-left: 5px solid var(--accent); padding-left: 16px; }
.page-head .lead { margin: 0; }
.eyebrow { text-transform: uppercase; font-size: .78rem; letter-spacing: .08em; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 70ch; }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent-1); color: #fff; border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
[data-theme="dark"] .btn { color: #0e121b; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ok { background: var(--ok); } .btn.warn { background: var(--warn); }
.btn.block { display: flex; width: 100%; margin: 8px 0; }
.linkish { background: none; border: 0; color: var(--accent-1); cursor: pointer; padding: 4px 0; font: inherit; text-decoration: underline; }
.linkish.danger { color: var(--bad); }
.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.form-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin: 12px 0; }
.form-row label { display: flex; flex-direction: column; font-size: .88rem; color: var(--muted); gap: 4px; }
.form-row label.grow { flex: 1 1 260px; }
.form-row > label { max-width: 100%; min-width: 0; }
label.inline { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--ink) !important; }
select { max-width: 100%; }
input[type=number], input[type=date], input[type=text], select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input[type=number] { width: 150px; }
textarea { width: 100%; margin: 8px 0; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
legend { padding: 0 6px; font-weight: 600; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; }
.check-grid label { display: flex; gap: 8px; align-items: center; }

/* progress bar */
.bar { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 4px; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

/* home */
.hero { padding: 36px 0 20px; text-align: center; }
.hero h1 { font-size: clamp(2.3rem, 6vw, 3.9rem); line-height: 1.08; letter-spacing: -.02em; margin: 16px 0 14px; color: var(--ink); }
.hero h1 .grad { background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { margin: 0 auto 24px; }
/* home hero: graph paper + live field arrows, full width behind the text */
body { overflow-x: clip; }
.hero-field { position: relative; isolation: isolate; margin-top: -24px; padding: 72px 0 56px; }
.hero-bg { position: absolute; top: 0; bottom: 0; left: calc(50% - 50vw); width: 100vw; z-index: -1; overflow: hidden;
  background-image: linear-gradient(var(--grid-major) 1px, transparent 1px), linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 136px 136px, 136px 136px, 34px 34px, 34px 34px; background-position: center top;
  -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent); mask-image: linear-gradient(to bottom, #000 75%, transparent); }
.hero-bg canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-inner { position: relative; }
.hero-inner::before { content: ""; position: absolute; inset: -40px -10%; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--bg) 88%, transparent) 35%, transparent 72%); }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 5px 14px; border-radius: 999px; font-size: .76rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--accent-1); background: color-mix(in srgb, var(--accent-1) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent-1) 30%, transparent); }
.hero-badge .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-1); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-1) 50%, transparent); animation: pulse 2.2s infinite; }
.hero-badge { white-space: nowrap; }
@media (max-width: 380px) { .hero-badge { letter-spacing: .03em; font-size: .7rem; padding: 4px 10px; } }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.charge-ctl { display: inline-flex; align-items: center; gap: 6px; margin-top: 26px; padding: 6px 8px 6px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: .86rem; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 88%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); box-shadow: var(--shadow); }
.q-btn { border: 0; background: none; padding: 5px 11px; border-radius: 8px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.q-btn:hover { color: var(--ink); }
.q-btn.on[data-q="1"] { background: var(--accent-2); color: #fff; }
.q-btn.on[data-q="-1"] { background: var(--accent-1); color: #fff; }
[data-theme="dark"] .q-btn.on { color: #0e121b; }
.hero-hint { margin: 10px 0 0; font-size: .8rem; color: var(--muted); }
@media (hover: none) { .hero-hint { display: none; } }
@media (prefers-reduced-motion: reduce) { .hero-badge .pulse { animation: none; } }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 30px 0; }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.feature p { margin: 0; color: var(--muted); font-size: .94rem; }
/* clickable feature cards on the home page */
.feature { position: relative; padding: 0; transition: border-color .15s, transform .15s; }
.feature:hover, .feature.open { border-color: var(--accent-1); }
.feature:hover { transform: translateY(-2px); }
/* an open card (and its menu) must sit above the cards below it; the hover lift would otherwise push it underneath */
.feature.open { z-index: 40; transform: none; }
.feature-btn, .feature-link { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; width: 100%; height: 100%; padding: 18px; background: none; border: 0; border-radius: inherit; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.feature-btn:focus-visible, .feature-link:focus-visible { outline: 2px solid var(--accent-1); outline-offset: 2px; }
.feature .ficon { font-size: 1.5rem; line-height: 1; }
.feature .ftitle { font-weight: 700; font-size: 1.08rem; color: var(--ink); }
.feature .fdesc { color: var(--muted); font-size: .94rem; flex: 1; }
.feature .go { margin-top: 6px; color: var(--accent-1); font-weight: 600; font-size: .9rem; }
.feature-menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 12px 32px rgba(0,0,0,.25); }
.feature-menu a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 600; }
.feature-menu a:hover, .feature-menu a:focus-visible { background: var(--surface-2); outline: none; }
.feature-menu .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
#units, #plan { scroll-margin-top: 80px; }
.ficon { font-size: 1.6rem; }
.subject h2 { margin-top: 26px; }
.course-grid, .unit-grid, .res-grid, .frq-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.course-card, .unit-card, .res-card { display: block; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--accent); border-radius: var(--radius); padding: 18px; color: var(--ink); text-decoration: none; transition: transform .15s, box-shadow .15s; }
.course-card:hover, .unit-card:hover, .res-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.course-card p, .unit-card p, .res-card p { color: var(--muted); font-size: .93rem; margin: 0 0 8px; }
.go { font-weight: 600; color: var(--accent); }
.pill { display: inline-block; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--accent); margin-bottom: 8px; }
.pill.muted { color: var(--muted); }
.unum { font-size: .78rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.note { border-left: 5px solid var(--accent-2); }

/* course */
.exam-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.exam-grid p { margin: 0; color: var(--muted); }
.frq-types { columns: 2; margin: 0 0 12px; }
.side-card h3 { margin-bottom: 8px; }
.side-units { list-style: none; padding: 0; margin: 0; }
.side-units a { display: block; padding: 6px 8px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: .92rem; }
.side-units a:hover, .side-units .current a { background: var(--surface-2); }
.side-units .bar { height: 4px; margin: 4px 0 0; }
.link-list { display: block; padding: 4px 0; font-size: .93rem; }
.plan { display: grid; gap: 12px; }
.week { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.week.review { border-left: 4px solid var(--accent-2); }
.week ul { margin: 6px 0 0; padding-left: 20px; }

/* unit */
.ideas li { margin-bottom: 8px; }
.eq-table { width: 100%; border-collapse: collapse; }
.eq-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.eq-table tr:last-child td { border-bottom: 0; }
.eq { white-space: nowrap; width: 50%; }
.eq > .katex { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 6px 2px; vertical-align: middle; }
.eq-table td.eq { padding: 14px 8px; }
.eq-table td { vertical-align: middle; }

/* KaTeX math */
.katex { font-size: 1.1em; }
.eq .katex { font-size: 1.2em; }
.choice .katex { font-size: 1.05em; }
.face .katex { font-size: 1.1em; }
.tex-fallback { font-family: ui-monospace, Consolas, monospace; }
p, li, .feedback, .why { line-height: 1.75; }
.prompt { font-size: 1.04rem; }
.steps li { margin-bottom: 6px; }
.answer { background: var(--ok-bg); padding: 10px 14px; border-radius: 8px; }
.warn-card { border-left: 5px solid var(--warn); }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
.pager a { text-decoration: none; font-weight: 600; }

/* quiz */
.quiz-head { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; margin-bottom: 6px; }
.q-unit { color: var(--accent); font-size: .85rem; font-weight: 600; margin: 0; }
.q-text { font-size: 1.08rem; font-weight: 500; }
.choices { display: grid; gap: 10px; }
.choice { display: flex; gap: 12px; align-items: flex-start; text-align: left; background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; font: inherit; cursor: pointer; }
.choice:hover:not(:disabled) { border-color: var(--accent-1); }
.choice .letter { font-weight: 700; color: var(--muted); min-width: 1.2em; }
.choice.selected { border-color: var(--accent-1); background: var(--surface-2); }
.choice.correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }
.choice:disabled { cursor: default; }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 10px; }
.feedback.ok { background: var(--ok-bg); } .feedback.bad { background: var(--bad-bg); }
.quiz-nav { display: flex; justify-content: space-between; margin-top: 16px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.timer.low { color: var(--bad); }
.dots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer; padding: 0; }
.dot.on { background: var(--accent-1); border-color: var(--accent-1); }
.dot.cur { outline: 2px solid var(--accent-2); outline-offset: 1px; }
.results .unit-break { display: grid; gap: 8px; margin: 14px 0; }
.review li { margin-bottom: 14px; padding: 10px 14px; border-radius: 10px; border-left: 4px solid var(--ok); background: var(--surface-2); }
.review li.bad { border-left-color: var(--bad); }
.review p { margin: 4px 0; }
.why { font-size: .94rem; }

/* figures (assets/js/figures.js) */
:root { --fig-ink: #1f2937; --fig-muted: #8a93a6; --fig-grid: #e3e7ef; --fig-block: #dbe6fb; --fig-soft: #eef1f6; --fig-water: #cfe6fb; --fig-glass: rgba(147,197,253,.35); --fig-bulb: #fff6d6;
  --fig-red: #dc2626; --fig-blue: #2563eb; --fig-green: #15803d; --fig-orange: #ea7a0c; --fig-purple: #7c3aed;
  --fig-red-soft: rgba(220,38,38,.16); --fig-blue-soft: rgba(37,99,235,.16); --fig-green-soft: rgba(21,128,61,.16); --fig-orange-soft: rgba(234,122,12,.18); }
[data-theme="dark"] { --fig-ink: #e5e9f2; --fig-muted: #8d97ab; --fig-grid: #2c3546; --fig-block: #29406b; --fig-soft: #252d3d; --fig-water: #1d3d5e; --fig-glass: rgba(96,165,250,.25); --fig-bulb: #4a3f1c;
  --fig-red: #f87171; --fig-blue: #60a5fa; --fig-green: #4ade80; --fig-orange: #fb923c; --fig-purple: #a78bfa;
  --fig-red-soft: rgba(248,113,113,.22); --fig-blue-soft: rgba(96,165,250,.22); --fig-green-soft: rgba(74,222,128,.2); --fig-orange-soft: rgba(251,146,60,.22); }
.fig { margin: 12px auto 14px; text-align: center; max-width: 100%; }
.fig-svg { max-width: 100%; height: auto; display: inline-block; overflow: visible; }
.fig-t { font-family: inherit; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.fig-fo { overflow: visible; pointer-events: none; }
.fig-lab { display: flex; align-items: center; width: 100%; height: 100%; line-height: 1.1; white-space: nowrap; }
.fig-lab .katex { font-size: 1.05em; }
.fig-lab > span { background: color-mix(in srgb, var(--surface) 78%, transparent); border-radius: 3px; padding: 0 2px; }
.fig figcaption { font-size: .88rem; color: var(--muted); margin-top: 4px; }
.fig-row { display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: center; align-items: flex-end; }
.fig-row .fig { margin: 8px 0; }
.fig-table { border-collapse: collapse; margin: 0 auto; font-size: .95rem; }
.fig-table th, .fig-table td { border: 1px solid var(--line); padding: 5px 12px; text-align: center; }
.fig-table th { background: var(--surface-2); font-weight: 600; }
.fig-tablewrap { overflow-x: auto; }
.choices.with-figs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choices.with-figs .choice { flex-direction: column; align-items: stretch; }
.choices.with-figs .choice .letter { align-self: flex-start; }
.choice .fig { margin: 0; }
.fig-small .fig-graph { width: 100%; max-width: 260px; }
.review .fig { margin: 6px 0; text-align: left; }
.review .fig-svg { max-width: min(100%, 340px); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tool-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tool-card h3 { margin: 4px 0 0; }
.tool-card .pill { margin-top: auto; }
.tool-icon { font-size: 1.7rem; line-height: 1; }
.tool-nav .small { align-self: center; margin-right: 4px; }
.sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px 22px; margin: 4px 0 12px; }
.slider { display: flex; flex-direction: column; gap: 4px; font-size: .92rem; min-width: 0; }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent-1); height: 28px; }
.slider-row input[type="number"] { width: 5.5em; flex: none; }
.probe-canvas { cursor: crosshair; touch-action: pan-y; }
.plot.flux-canvas { height: 400px; cursor: grab; touch-action: none; }
.flux-canvas:active { cursor: grabbing; }
.plot.gauss-canvas { height: 440px; cursor: grab; touch-action: none; }
.plot.amp-canvas { height: 440px; cursor: grab; touch-action: none; }
.plot.mf-canvas { height: 400px; cursor: grab; touch-action: none; }
.plot.mf-graph { height: 200px; margin-top: 10px; }
.report-link { display: inline-block; margin-top: 10px; font-size: .82rem; color: var(--muted); text-decoration: none; }
.report-link:hover { color: var(--ink); text-decoration: underline; }
.feedback .report-link, .review .report-link { display: block; }
.comp-list { gap: 12px; }
.comp-row .comp-field { display: flex; gap: 4px; align-items: stretch; }
.comp-row input { width: 110px; }
.comp-del { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; width: 34px; font-size: 1.15rem; line-height: 1; cursor: pointer; }
.comp-del:hover { color: var(--ink); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.plot.lz-canvas { height: 400px; cursor: grab; touch-action: none; }
.plot.lz-graph { height: 180px; margin-top: 10px; }
@media (max-width: 600px) { .plot.lz-canvas { height: 300px; } }
.lz-quiz { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 12px 0; background: var(--surface-2); }
.lz-q { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.lz-q > span { flex: 1 1 100%; color: var(--ink); }
.lz-q .btn.sel { box-shadow: 0 0 0 2px var(--accent-1) inset; }
.lz-q .btn.right { border-color: var(--fig-green, #16a34a); box-shadow: 0 0 0 2px var(--fig-green, #16a34a) inset; }
.lz-q .btn.wrong { border-color: var(--fig-red, #dc2626); box-shadow: 0 0 0 2px var(--fig-red, #dc2626) inset; }
.plot.fd-canvas { height: 380px; }
.plot.fd-graph { height: 180px; margin-top: 10px; }
.gauss-key { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0 10px; }
.gauss-key span { display: inline-block; width: 22px; height: 5px; border-radius: 3px; margin-left: 8px; }
.gauss-key .key-out { background: var(--fig-green); margin-left: 0; }
.gauss-key .key-in { background: var(--fig-red); }
.gs-table input { width: 5.5em; }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.warn-text { color: var(--warn); }
.probe-out { min-height: 3.2em; margin-bottom: 8px; }
.ray-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .88rem; color: var(--muted); margin: 0 0 10px; }
.ray-legend span { display: inline-flex; align-items: center; gap: 6px; }
.ray-legend i { display: inline-block; width: 22px; height: 3px; border-radius: 2px; }
.ray-legend i.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 5px, transparent 5px 9px); }
#resFig .fig, #lFig .fig { overflow-x: auto; }
#resFig .fig-svg, #lFig .fig-svg { min-width: 440px; }
#resTable .fig-table th, #resTable .fig-table td { white-space: nowrap; }
@media (max-width: 520px) { .choices.with-figs { grid-template-columns: minmax(0, 1fr); } }
@media print { .fig-svg { max-width: 70%; } }
.setup .btn { margin-top: 6px; }

/* flashcards */
.flash { perspective: 1200px; max-width: 640px; height: 280px; margin: 10px auto; cursor: pointer; outline: none; }
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 28px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); font-size: 1.25rem; backface-visibility: hidden; }
.face.back { transform: rotateY(180deg); background: var(--surface-2); border-top: 5px solid var(--accent); }
.flash:focus-visible .face { outline: 3px solid var(--accent-1); }
.flash-nav { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* FRQ */
.part h3 { font-weight: 600; }
.pts { font-size: .8rem; font-weight: 700; color: var(--accent); background: var(--surface-2); border-radius: 99px; padding: 2px 8px; margin-left: 6px; white-space: nowrap; }
.guide { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 10px; }
.guide h4 { margin: 10px 0 6px; }
.rub { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.rub input { margin-top: 5px; }
.score-card { position: sticky; bottom: 10px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.score-card h2 { margin: 0; }

/* tools */
.tool-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tool-nav a { padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .92rem; }
.plot { width: 100%; height: 300px; display: block; background: var(--surface); border-radius: 10px; }
.anim { width: 100%; height: 70px; display: block; }
.readout { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; margin-top: 10px; }
.tool { scroll-margin-top: 80px; }

/* progress */
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.prog-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .94rem; }
.prog-table th, .prog-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
.prog-table td:last-child { width: 30%; }

/* support */
.tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.tier.featured { border: 2px solid var(--accent-1); }
.price { font-size: 1.8rem; font-weight: 800; margin: 0 0 8px; }
.tier ul { padding-left: 18px; }

/* ads */
.ad { margin: 0 0 18px; text-align: center; min-height: 90px; }
.ad-label { display: block; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ad-placeholder > div { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; color: var(--muted); font-size: .88rem; }
.ad-sidebar { min-height: 250px; } .ad-sidebar.ad-placeholder > div { min-height: 230px; display: grid; place-items: center; }
.footer .ad { margin-top: 18px; }

/* footer */
.footer { border-top: 1px solid var(--line); background: var(--surface); padding: 10px 0 24px; margin-top: 30px; }
.footer-cols { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 20px; padding-top: 16px; }
.footer-cols p { margin: 4px 0; color: var(--muted); font-size: .92rem; }
.footer-cols a { display: block; font-size: .92rem; }
.tm { font-size: .8rem; color: var(--muted); margin-top: 18px; }

/* responsive */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: block; }
  .mainnav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch; padding: 10px 20px; }
  .mainnav.open { display: flex; }
  .frq-types { columns: 1; }
  .eq { white-space: normal; }
  .eq-table, .eq-table tbody, .eq-table tr, .eq-table td { display: block; width: 100%; }
  .eq-table td.eq { padding-bottom: 2px; border-bottom: 0; }
}

/* print: clean equation sheets and notes */
@media print {
  .topbar, .subnav-wrap, .sidebar, .footer, .ad, .cta-row, .btn, .pager { display: none !important; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
