/* GraphingCalc84 design system — Concept 2 "Precision Studio Console" + Concept 3 TABLE / CALC dock.
   Pure semantic CSS, every class uses the p84- prefix. Light is the default theme. */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;
  --p84-font-sans: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --p84-font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --p84-bg: #F6F7F9;
  --p84-surface: #FFFFFF;
  --p84-surface-alt: #EDF0F4;
  --p84-canvas-bg: #FFFFFF;
  --p84-grid-major: #DCE2EA;
  --p84-grid-minor: #EEF1F6;
  --p84-axis: #1B232D;
  --p84-ink: #0F1419;
  --p84-ink-muted: #4E5A68;
  --p84-border: #D3DAE3;
  --p84-lcd-bg: #11161C;
  --p84-lcd-ink: #E8F5C8;
  --p84-lcd-dim: #8E9AA8;
  --p84-accent: #C4F02B;
  --p84-accent-ink: #11161C;
  --p84-accent-line: #8DB21A;
  --p84-accent-strong: #1A56DB;
  --p84-focus: #1A56DB;
  --p84-link: #1A56DB;
  --p84-brand-mark: #F0592A;
  --p84-glass: rgba(255, 255, 255, .86);
  --p84-glass-edge: rgba(15, 20, 25, .10);
  --p84-shadow: rgba(16, 24, 40, .20);
  --p84-hit-bg: #FFF4C7;
  --p84-hit-ink: #6B4A00;
  --p84-warn-bg: #FFE3D8;
  --p84-warn-edge: #EFB39D;
  --p84-warn-ink: #8A2300;
  --p84-key-num-bg: #FFFFFF;
  --p84-key-num-edge: #C5CDD7;
  --p84-key-op-bg: #E3E8EE;
  --p84-key-op-edge: #B9C2CD;
  --p84-key-fn-bg: #DCE6F5;
  --p84-key-fn-edge: #B3C3DC;
  --p84-key-fn-ink: #17306F;
  --p84-key-cmd-bg: #1A1F26;
  --p84-key-cmd-edge: #05070A;
  --p84-key-cmd-ink: #F2F5F8;
  --p84-y1: #0072B2;
  --p84-y2: #D55E00;
  --p84-y3: #009E73;
  --p84-y4: #CC79A7;
  --p84-y5: #B8860B;
  --p84-y6: #6D28D9;
  --p84-radius: 14px;
  --p84-radius-sm: 10px;
  --p84-safe-top: 44px;
  --p84-safe-right: 56px;
  --p84-wrap: 1240px;
  --p84-gutter: clamp(16px, 3vw, 28px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --p84-bg: #0B0E13;
  --p84-surface: #131820;
  --p84-surface-alt: #1B222D;
  --p84-canvas-bg: #0D1117;
  --p84-grid-major: #242D3B;
  --p84-grid-minor: #161C26;
  --p84-axis: #C5CED8;
  --p84-ink: #F2F5F8;
  --p84-ink-muted: #9BA7B6;
  --p84-border: #283241;
  --p84-lcd-bg: #070A0E;
  --p84-lcd-ink: #D5F772;
  --p84-lcd-dim: #7A8595;
  --p84-focus: #7AA7FF;
  --p84-link: #8AB4FF;
  --p84-glass: rgba(19, 24, 32, .84);
  --p84-glass-edge: rgba(255, 255, 255, .08);
  --p84-shadow: rgba(0, 0, 0, .6);
  --p84-hit-bg: #3A3110;
  --p84-hit-ink: #FFE27A;
  --p84-warn-bg: #3A1F17;
  --p84-warn-edge: #130805;
  --p84-warn-ink: #FFB59C;
  --p84-key-num-bg: #1B2027;
  --p84-key-num-edge: #07090C;
  --p84-key-op-bg: #252C35;
  --p84-key-op-edge: #07090C;
  --p84-key-fn-bg: #1C2740;
  --p84-key-fn-edge: #07090C;
  --p84-key-fn-ink: #B8CBFF;
  --p84-key-cmd-bg: #2A323D;
  --p84-key-cmd-edge: #07090C;
  --p84-y1: #4FA8E8;
  --p84-y2: #FF8547;
  --p84-y3: #34D399;
  --p84-y4: #F099C8;
  --p84-y5: #FACC15;
  --p84-y6: #A78BFA;
}

/* No-JS fallback: follow the OS preference when no theme attribute was chosen by script. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) { color-scheme: dark; --p84-bg: #0B0E13; --p84-surface: #131820; --p84-surface-alt: #1B222D; --p84-canvas-bg: #0D1117; --p84-grid-major: #242D3B; --p84-grid-minor: #161C26; --p84-axis: #C5CED8; --p84-ink: #F2F5F8; --p84-ink-muted: #9BA7B6; --p84-border: #283241; --p84-lcd-bg: #070A0E; --p84-lcd-ink: #D5F772; --p84-focus: #7AA7FF; --p84-link: #8AB4FF; }
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--p84-bg);
  color: var(--p84-ink);
  font: 400 16px/1.6 var(--p84-font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--p84-link); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--p84-focus); outline-offset: 2px; }
kbd { font: 600 12px var(--p84-font-mono); padding: 1px 6px; border: 1px solid var(--p84-border); border-bottom-width: 2px; border-radius: 5px; background: var(--p84-surface); color: var(--p84-ink-muted); white-space: nowrap; }
code { font: 500 .92em var(--p84-font-mono); background: var(--p84-surface-alt); padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere; }
.p84-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.p84-skip { position: absolute; left: 8px; top: 8px; z-index: 50; padding: 10px 14px; background: var(--p84-surface); border-radius: 8px; transform: translateY(-200%); }
.p84-skip:focus { transform: none; }
.p84-main { display: block; min-height: 50vh; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
#p84-workspace, .p84-prose h2[id], .p84-faq h2 { scroll-margin-top: 12px; }

/* ---------- 3. Header ---------- */
.p84-header { background: var(--p84-surface); border-bottom: 1px solid var(--p84-border); }
.p84-header__inner { max-width: var(--p84-wrap); margin: 0 auto; padding: 0 var(--p84-gutter); min-height: 60px; display: flex; align-items: center; gap: 16px; }
.p84-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--p84-ink); text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: -.015em; flex-shrink: 0; }
.p84-brand .p84-logo { width: 28px; height: 28px; }
.p84-brand__name span { color: var(--p84-brand-mark); }
.p84-nav { display: flex; gap: 2px; padding: 3px; margin: 0 auto; border-radius: 12px; background: var(--p84-surface-alt); min-width: 0; overflow-x: auto; scrollbar-width: none; }
.p84-nav::-webkit-scrollbar { display: none; }
.p84-nav a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 13px; border-radius: 9px; color: var(--p84-ink-muted); font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.p84-nav a:hover { color: var(--p84-ink); }
.p84-nav a[aria-current="page"] { background: var(--p84-surface); color: var(--p84-ink); box-shadow: 0 1px 2px var(--p84-shadow), 0 0 0 1px var(--p84-border); }
.p84-theme-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; margin-left: auto; border: 1px solid var(--p84-border); border-radius: 10px; background: var(--p84-surface); font-size: 13px; font-weight: 600; flex-shrink: 0; }
.p84-nav + .p84-theme-btn { margin-left: 0; }
:root[data-theme="dark"] .p84-theme-btn__moon, :root:not([data-theme="dark"]) .p84-theme-btn__sun { display: none; }

/* ---------- 4. Tool page frame ---------- */
.p84-tool { max-width: var(--p84-wrap); margin: 0 auto; padding: 14px var(--p84-gutter) 0; }
.p84-intro { display: grid; gap: 3px; margin-bottom: 12px; }
.p84-intro h1 { margin: 0; font-size: clamp(22px, 2.6vw, 30px); line-height: 1.15; letter-spacing: -.02em; font-weight: 700; }
.p84-intro__lede { margin: 0; color: var(--p84-ink-muted); font-size: 15px; max-width: 80ch; }
.p84-crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--p84-ink-muted); }
.p84-crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--p84-border); }
.p84-crumbs a { color: var(--p84-ink-muted); }
.p84-instrument { position: relative; border: 1px solid var(--p84-border); border-radius: var(--p84-radius); background: var(--p84-surface); overflow: hidden; box-shadow: 0 18px 40px -30px var(--p84-shadow); }
.p84-console { display: flex; flex-direction: column; min-width: 0; }

/* ---------- 5. Graph stage (Concept 2) + studio top bar ---------- */
.p84-stage { position: relative; height: clamp(340px, 52vh, 600px); background: var(--p84-canvas-bg); overflow: hidden; }
.p84-stage--plot { height: clamp(280px, 40vh, 380px); border-radius: var(--p84-radius-sm); border: 1px solid var(--p84-border); }
.p84-ssr { position: absolute; inset: 0; width: 100%; height: 100%; }
.p84-ssr path, .p84-ssr rect { vector-effect: non-scaling-stroke; }
.p84-ssr__minor { stroke: var(--p84-grid-minor); stroke-width: 1; fill: none; }
.p84-ssr__major { stroke: var(--p84-grid-major); stroke-width: 1; fill: none; }
.p84-ssr__axes { stroke: var(--p84-axis); stroke-width: 1.5; fill: none; }
.p84-ssr__curve { stroke: var(--c, var(--p84-y1)); stroke-width: 2.75; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.p84-ssr__pt { stroke-width: 11; stroke-linecap: round; fill: none; }
.p84-ssr__pt--intersect { stroke: var(--p84-ink); }
.p84-ssr__pt--trace { stroke: var(--p84-brand-mark); }
.p84-ssr__dot { stroke: var(--c, var(--p84-y1)); stroke-width: 10; stroke-linecap: round; fill: none; }
.p84-ssr__box { fill: color-mix(in srgb, var(--p84-y1) 16%, transparent); stroke: var(--p84-y1); stroke-width: 2; }
.p84-ssr__area { fill: color-mix(in srgb, var(--p84-y1) 24%, transparent); stroke: none; }
.p84-ssr__mark { stroke: var(--p84-brand-mark); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
.p84-ssr__bar { fill: var(--p84-grid-major); stroke: none; }
.p84-ssr__bar.is-on { fill: var(--p84-y1); }
.p84-ssr--resid { position: static; height: 120px; }
.p84-stage__canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
[data-p84-ready="engine"] .p84-ssr[data-p84-ssr-plot] { visibility: hidden; }
/* Window / caption text lives in a bar ABOVE the canvas (never over axis numbers). */
.p84-stage__window { margin: 0; min-width: 0; font: 500 11.5px var(--p84-font-mono); color: var(--p84-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Studio top bar: Y= ribbon on the left, angle / export / share on the right; the canvas below stays 100% clear. */
.p84-studiobar { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 10px; background: var(--p84-surface); border-bottom: 1px solid var(--p84-border); }
.p84-studiobar .p84-stage__window { flex: 0 1 auto; padding: 0 2px; }
.p84-ribbon { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 2px; overflow-x: auto; scrollbar-width: none; }
.p84-ribbon::-webkit-scrollbar { display: none; }
.p84-ribbon__label { flex-shrink: 0; padding: 0 4px 0 6px; font: 700 11px var(--p84-font-mono); letter-spacing: .14em; color: var(--p84-ink-muted); }
.p84-chip { flex-shrink: 0; display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 8px 0 2px; border-radius: 11px; background: var(--p84-bg); border: 1px solid var(--p84-border); transition: border-color .15s ease, box-shadow .15s ease; }
.p84-chip[hidden] { display: none; }
.p84-chip[hidden]:has(input:not(:placeholder-shown)) { display: flex; }
.p84-chip:focus-within { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c), 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); background: var(--p84-surface); }
.p84-chip__swatch { width: 32px; height: 36px; border: 0; background: transparent; display: grid; place-items: center; padding: 0; }
.p84-chip__swatch i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); }
.p84-chip__swatch[aria-pressed="false"] i { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }
.p84-chip label { font: 700 12px var(--p84-font-mono); color: var(--p84-ink-muted); white-space: nowrap; }
.p84-chip input { width: 136px; height: 36px; border: 0; background: transparent; color: var(--p84-ink); font: 500 15px var(--p84-font-mono); outline: none; padding: 0 0 0 4px; min-width: 0; }
.p84-chip--slot input { width: 56px; transition: width .15s ease; }
.p84-chip--slot:focus-within input { width: 136px; }
.p84-chip--err input { color: var(--p84-warn-ink); }
.p84-add-expr { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 1px dashed var(--p84-key-num-edge); border-radius: 11px; background: transparent; color: var(--p84-ink-muted); font: 700 12px var(--p84-font-mono); letter-spacing: .04em; white-space: nowrap; transition: color .15s ease, border-color .15s ease, background .15s ease; }
.p84-add-expr span { font-size: 15px; line-height: 1; }
.p84-add-expr:hover { color: var(--p84-ink); border-color: var(--p84-accent-strong); background: var(--p84-bg); }
.p84-ribbon:not(:has(.p84-chip[hidden])) .p84-add-expr, html:not(.p84-js) .p84-add-expr { display: none; }

.p84-hud { display: flex; gap: 6px; }
.p84-hud--export { flex-shrink: 0; align-items: center; }
.p84-hud--zoom { position: absolute; z-index: 2; right: 12px; top: 50%; transform: translateY(-50%); flex-direction: column; gap: 4px; padding: 4px; border-radius: 12px; background: var(--p84-glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid var(--p84-glass-edge); box-shadow: 0 12px 28px -18px var(--p84-shadow); }
.p84-hbtn { min-height: 36px; min-width: 40px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--p84-border); background: var(--p84-surface); font: 700 11.5px/1 var(--p84-font-mono); letter-spacing: .06em; white-space: nowrap; }
.p84-hbtn:hover { border-color: var(--p84-ink-muted); }
.p84-hud--zoom .p84-hbtn { width: 38px; min-width: 38px; padding: 0; font-size: 17px; }
.p84-hud--zoom .p84-hbtn--text { font-size: 10px; letter-spacing: .02em; }
.p84-hbtn--accent { background: var(--p84-accent); color: var(--p84-accent-ink); border-color: var(--p84-accent-line); }

/* Calculus bar (derivative-integral grapher, AP calc toolkit): f, f′, tangent and ∫ with inline x₀ / a / b. */
.p84-calcbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 10px; background: var(--p84-surface-alt); border-bottom: 1px solid var(--p84-border); }
.p84-calcbar__readout { flex: 1 1 520px; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font: 600 13.5px var(--p84-font-mono); }
.p84-calcbar__term { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 10px; border-radius: 8px; background: var(--p84-surface); border: 1px solid var(--p84-border); white-space: nowrap; }
.p84-calcbar__term[style]::before { content: ""; align-self: center; width: 12px; height: 3px; border-radius: 2px; background: var(--c); }
.p84-calcbar__term i { font-style: normal; color: var(--p84-ink-muted); }
.p84-calcbar__term sub, .p84-calcbar__term sup { font-size: .68em; line-height: 0; }
.p84-calcbar__term--pt { color: var(--p84-ink-muted); }
.p84-calcbar__term--int { background: var(--p84-lcd-bg); border-color: var(--p84-lcd-bg); color: var(--p84-lcd-ink); }
.p84-calcbar__term--int i { color: var(--p84-lcd-dim); }
.p84-calcbar__term--int b { color: var(--p84-accent); font-size: 15px; }
.p84-calcbar__readout:not(:has(*)) { flex: 0 1 auto; padding: 7px 12px; border-radius: 8px; background: var(--p84-lcd-bg); color: var(--p84-lcd-ink); white-space: nowrap; }
.p84-calcbar__inputs { display: flex; gap: 8px; flex-shrink: 0; margin-left: auto; }
.p84-calcbar__in { display: inline-flex; align-items: center; gap: 6px; font: 700 12px var(--p84-font-mono); color: var(--p84-ink-muted); }
.p84-instrument .p84-calcbar__in input[type="text"] { width: 64px; min-height: 34px; padding: 0 8px; border-radius: 8px; font-size: 14px; text-align: center; }

/* ---------- 6. LCD readout strip ---------- */
.p84-lcd { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 8px 14px; background: var(--p84-lcd-bg); color: var(--p84-lcd-ink); font: 500 12px var(--p84-font-mono); min-width: 0; }
.p84-lcd__led { flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--p84-accent); box-shadow: 0 0 8px var(--p84-accent); }
/* Readouts scroll inside the track and fade out before the pinned TABLE / CALC pills — never sliced under them. */
/* Each readout is an atomic unit: whole readouts wrap onto a second line instead of clipping mid-number. */
.p84-lcd__track { display: flex; flex-wrap: wrap; align-items: center; row-gap: 4px; column-gap: 14px; min-width: 0; flex: 1 1 auto; overflow: visible; }
.p84-lcd__ro { display: inline-flex; flex-wrap: wrap; align-items: baseline; column-gap: 7px; max-width: 100%; line-height: 16px; white-space: nowrap; flex-shrink: 0; }
.p84-lcd__ro [data-p84-ro="ERR"] { white-space: normal; }
.p84-lcd__ro b { color: var(--p84-accent); font-size: 10px; font-weight: 700; letter-spacing: .1em; }
.p84-lcd__toggles { display: inline-flex; gap: 6px; align-self: center; flex-shrink: 0; }
.p84-lcd__btn { display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 8px; border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px; background: rgba(255, 255, 255, .04); color: var(--p84-lcd-ink); font: 700 11px/1 var(--p84-font-mono); letter-spacing: .04em; transition: background .15s ease, border-color .15s ease; }
.p84-lcd__btn::before { content: ""; width: 7px; height: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px currentColor; }
.p84-lcd__btn::after { content: "▾"; font-size: 9px; opacity: .7; transition: transform .15s ease; }
.p84-lcd__btn:hover { border-color: var(--p84-accent); }
.p84-lcd__btn[aria-pressed="true"] { background: var(--p84-accent); border-color: var(--p84-accent); color: var(--p84-accent-ink); }
.p84-lcd__btn[aria-pressed="true"]::before { background: currentColor; }
.p84-lcd__btn[aria-pressed="true"]::after { transform: rotate(180deg); }

/* ---------- 7. Mobile tabs (hidden on desktop) ---------- */
.p84-tabs { display: none; }
.p84-tab { min-width: 0; min-height: 40px; padding: 4px 6px; border: 0; border-radius: 9px; background: transparent; color: var(--p84-ink-muted); font: 700 12.5px/1 var(--p84-font-mono); letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p84-tab[aria-selected="true"] { background: var(--p84-lcd-bg); color: var(--p84-accent); }

/* ---------- 8. TABLE + CALC dock (Concept 3) ---------- */
.p84-dock { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px; padding: 12px; background: var(--p84-bg); border-top: 1px solid var(--p84-border); }
@media (min-width: 761px) {
  .p84-js [data-p84-show-table="false"] .p84-panel--table, .p84-js [data-p84-show-calc="false"] .p84-panel--calc { display: none; }
  .p84-js [data-p84-show-table="false"] .p84-dock:not([data-p84-tools]), .p84-js [data-p84-show-calc="false"] .p84-dock:not([data-p84-tools]) { grid-template-columns: minmax(0, 820px); }
  .p84-js [data-p84-show-table="false"][data-p84-show-calc="false"] .p84-dock:not([data-p84-tools]) { display: none; }
}
.p84-panel { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--p84-border); border-radius: var(--p84-radius-sm); background: var(--p84-surface); overflow: hidden; }
.p84-panel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--p84-border); background: var(--p84-surface-alt); }
.p84-panel__title { margin: 0; font: 700 11px var(--p84-font-mono); letter-spacing: .16em; text-transform: uppercase; }
.p84-panel__meta { font: 500 11.5px var(--p84-font-mono); color: var(--p84-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.p84-panel__note { display: flex; align-items: center; gap: 8px; margin: 0; padding: 8px 14px 10px; font-size: 12.5px; color: var(--p84-ink-muted); border-top: 1px dashed var(--p84-border); }
.p84-panel__note i { width: 10px; height: 10px; border-radius: 3px; background: var(--p84-hit-bg); box-shadow: inset 0 0 0 1px var(--p84-hit-ink); flex-shrink: 0; }
.p84-panel--table .p84-table-wrap { max-height: 300px; overflow: auto; }

.p84-table-wrap { overflow-x: auto; position: relative; max-width: 100%; -webkit-overflow-scrolling: touch; }
.p84-vtable { width: 100%; border-collapse: collapse; font: 500 13px var(--p84-font-mono); font-variant-numeric: tabular-nums; }
.p84-vtable th, .p84-vtable td { padding: 7px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--p84-grid-minor); }
.p84-vtable thead th { position: sticky; top: 0; background: var(--p84-surface); color: var(--p84-ink-muted); font-size: 11px; letter-spacing: .12em; z-index: 1; border-bottom: 1px solid var(--p84-border); }
.p84-vtable tbody th { color: var(--p84-ink-muted); font-weight: 600; }
.p84-vtable tr.is-hit th, .p84-vtable tr.is-hit td { background: var(--p84-hit-bg); color: var(--p84-hit-ink); font-weight: 700; }
.p84-vtable--kv th { text-align: left; font-family: var(--p84-font-sans); font-weight: 600; }

.p84-insp { list-style: none; margin: 0; padding: 4px 0 6px; }
.p84-insp li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 7px 14px; }
.p84-insp li + li { border-top: 1px dashed var(--p84-grid-major); }
.p84-insp__op { font: 700 12px var(--p84-font-mono); color: var(--p84-accent-strong); }
:root[data-theme="dark"] .p84-insp__op { color: var(--p84-lcd-ink); }
.p84-insp__detail { font-size: 12.5px; color: var(--p84-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p84-insp__val { font: 600 13px var(--p84-font-mono); text-align: right; white-space: nowrap; }

/* ---------- 9. Keypad (5 modules) ---------- */
.p84-keypad { padding: 8px 12px 12px; background: var(--p84-bg); border-top: 1px solid var(--p84-border); }
.p84-keypad__head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.p84-keypad__title { margin: 0; font: 700 11px var(--p84-font-mono); letter-spacing: .16em; text-transform: uppercase; white-space: nowrap; }
.p84-keypad__hint { margin: 0 auto 0 0; font-size: 12.5px; color: var(--p84-ink-muted); min-width: 0; }
.p84-ghost { min-height: 32px; padding: 0 12px; border: 1px solid var(--p84-border); border-radius: 9px; background: var(--p84-surface); font-size: 13px; font-weight: 600; white-space: nowrap; }
.p84-keypad[data-collapsed] .p84-keypad__body { display: none; }
.p84-keypad[data-collapsed] .p84-keypad__head { margin: 0; }
.p84-keypad__body { display: grid; grid-template-columns: 2.1fr 1.35fr 1.1fr .85fr .9fr; gap: 12px; align-items: stretch; }
.p84-module { min-width: 0; display: flex; flex-direction: column; padding: 8px; border-radius: var(--p84-radius); background: var(--p84-surface-alt); border: 1px solid var(--p84-border); }
.p84-module__title { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font: 700 10px var(--p84-font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--p84-ink-muted); }
.p84-module__title i { width: 6px; height: 6px; border-radius: 50%; background: var(--dot); }
.p84-keys { flex: 1; display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); grid-auto-rows: minmax(36px, 1fr); gap: 6px; }
.p84-module--classroom .p84-keys { --cols: 5; }
.p84-module--op .p84-keys, .p84-module--act .p84-keys { --cols: 2; }
.p84-key { min-width: 0; min-height: 36px; padding: 0 2px; border-radius: 10px; border: 1px solid var(--k-edge); background: var(--k-bg); color: var(--k-ink); font: 600 16px/1 var(--p84-font-sans); box-shadow: 0 2px 0 var(--k-edge), 0 4px 10px -6px var(--p84-shadow); transition: transform .06s ease, box-shadow .06s ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p84-key:active { transform: translateY(2px); box-shadow: 0 0 0 var(--k-edge); }
.p84-key--num { --k-bg: var(--p84-key-num-bg); --k-edge: var(--p84-key-num-edge); --k-ink: var(--p84-ink); font-size: 18px; }
.p84-key--op { --k-bg: var(--p84-key-op-bg); --k-edge: var(--p84-key-op-edge); --k-ink: var(--p84-ink); font-size: 17px; }
.p84-key--fn { --k-bg: var(--p84-key-fn-bg); --k-edge: var(--p84-key-fn-edge); --k-ink: var(--p84-key-fn-ink); font: 600 14px/1 var(--p84-font-mono); }
.p84-key--cmd { --k-bg: var(--p84-key-cmd-bg); --k-edge: var(--p84-key-cmd-edge); --k-ink: var(--p84-key-cmd-ink); font: 700 12px/1 var(--p84-font-mono); letter-spacing: .06em; }
.p84-module--classroom .p84-key--fn { font-size: 16px; }
.p84-key--cmd[aria-pressed="true"] { box-shadow: 0 2px 0 var(--k-edge), inset 0 -3px 0 var(--p84-accent); }
.p84-key--accent, .p84-key--enter { --k-bg: var(--p84-accent); --k-edge: var(--p84-accent-line); --k-ink: var(--p84-accent-ink); }
.p84-key--enter { grid-column: 1 / -1; font: 800 13px/1 var(--p84-font-mono); letter-spacing: .12em; }
.p84-key--warn { --k-bg: var(--p84-warn-bg); --k-edge: var(--p84-warn-edge); --k-ink: var(--p84-warn-ink); font: 700 12px/1 var(--p84-font-mono); }

/* ---------- 10. Specialized shells ---------- */
.p84-multiview { display: flex; flex-direction: column; gap: 10px; min-height: 280px; padding: 16px 18px; background: var(--p84-lcd-bg); color: var(--p84-lcd-ink); }
.p84-multiview__status { display: flex; flex-wrap: wrap; gap: 6px; font: 700 10.5px var(--p84-font-mono); letter-spacing: .12em; }
.p84-multiview__status span { padding: 3px 8px; border-radius: 6px; background: rgba(255, 255, 255, .07); color: var(--p84-accent); }
.p84-multiview__history { flex: 1; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.p84-multiview__history li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, max-content); align-items: baseline; gap: 14px; padding: 6px 0; border-bottom: 1px dashed rgba(255, 255, 255, .10); }
.p84-multiview__in { font: 500 15px var(--p84-font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--p84-lcd-dim); }
.p84-multiview__out { justify-self: end; font: 700 17px var(--p84-font-mono); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p84-multiview__out small { margin-left: 10px; font-size: 12px; font-weight: 500; color: var(--p84-lcd-dim); }
.p84-multiview__entry input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px; background: rgba(255, 255, 255, .05); color: var(--p84-lcd-ink); font: 500 16px var(--p84-font-mono); }
.p84-multiview__entry input::placeholder { color: var(--p84-lcd-dim); }

.p84-bench { display: grid; gap: 14px; padding: 16px; min-width: 0; }
.p84-bench--split { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
.p84-bench__controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.p84-bench__input { display: grid; gap: 10px; min-width: 0; }
.p84-bench__row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.p84-bench__title { margin: 0; font: 700 11px var(--p84-font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--p84-ink-muted); }
.p84-field { display: grid; gap: 4px; min-width: 0; }
.p84-field__label { font-size: 12.5px; font-weight: 600; color: var(--p84-ink-muted); }
.p84-instrument input[type="text"], .p84-instrument select, .p84-textarea, .p84-matgrid__cell {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--p84-border); border-radius: 10px; background: var(--p84-surface); color: var(--p84-ink); font: 500 15px var(--p84-font-mono); min-width: 0;
}
select { max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.p84-instrument select { padding-right: 28px; }
.p84-textarea { min-height: 180px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.p84-btn { min-height: 44px; padding: 0 16px; border: 1px solid var(--p84-border); border-radius: 10px; background: var(--p84-surface); font: 700 13px var(--p84-font-mono); letter-spacing: .04em; }
.p84-btn--accent { background: var(--p84-accent); color: var(--p84-accent-ink); border-color: var(--p84-accent-line); box-shadow: 0 2px 0 var(--p84-accent-line); }
.p84-seg { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 11px; background: var(--p84-surface-alt); border: 1px solid var(--p84-border); }
.p84-seg__btn { min-height: 38px; min-width: 44px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; font: 700 12.5px var(--p84-font-mono); color: var(--p84-ink-muted); }
.p84-seg__btn[aria-pressed="true"] { background: var(--p84-lcd-bg); color: var(--p84-accent); }
.p84-matgrid { --px: 18px; --gx: 6px; position: relative; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 76px)); gap: var(--gx); padding: 12px var(--px); border-left: 3px solid var(--p84-ink); border-right: 3px solid var(--p84-ink); border-radius: 6px; width: fit-content; max-width: 100%; }
.p84-matgrid__cell { padding: 0 4px; text-align: center; }
.p84-mat { --px: 14px; --gx: 16px; position: relative; display: inline-grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 6px var(--gx); margin: 14px; padding: 8px var(--px); font: 600 14px var(--p84-font-mono); text-align: right; border-left: 2px solid currentColor; border-right: 2px solid currentColor; border-radius: 6px; max-width: calc(100% - 28px); overflow-x: auto; }
.p84-mat--mini { --px: 10px; --gx: 12px; margin: 0; gap: 2px var(--gx); padding: 4px var(--px); font-size: 12px; color: var(--p84-ink-muted); }
/* Augmented [A | b]: dashed rule between the last two (equal-width) columns. */
.p84-mat-aug::after { content: ""; position: absolute; top: 5px; bottom: 5px; left: calc(var(--px) + (100% - 2 * var(--px) + var(--gx)) * (var(--cols) - 1) / var(--cols) - var(--gx) / 2); border-left: 1.5px dashed currentColor; opacity: .5; pointer-events: none; }
.p84-matgrid.p84-mat-aug::after { color: var(--p84-ink-muted); opacity: .8; }
.p84-step-changed { border-radius: 3px; background: color-mix(in srgb, var(--p84-accent) 30%, transparent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--p84-accent) 30%, transparent); color: var(--p84-ink); }
.p84-solution { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0 14px 12px; list-style: none; }
.p84-solution li { padding: 4px 10px; border-radius: 8px; background: var(--p84-lcd-bg); color: var(--p84-lcd-ink); font: 600 13px var(--p84-font-mono); }
.p84-rowops { list-style: none; margin: 0; padding: 6px 14px 12px; max-height: 360px; overflow: auto; }
.p84-rowops li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 0; border-bottom: 1px dashed var(--p84-grid-major); }
.p84-rowops__op { font: 700 13px var(--p84-font-mono); color: var(--p84-accent-strong); }
:root[data-theme="dark"] .p84-rowops__op { color: var(--p84-lcd-ink); }
.p84-result { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; margin: 0; padding: 14px 18px; font-family: var(--p84-font-mono); border-top: 1px solid var(--p84-border); }
.p84-result code { background: none; padding: 0; font-size: 14px; color: var(--p84-ink-muted); }
.p84-result strong { font-size: 24px; }
.p84-plotcard { min-width: 0; display: flex; flex-direction: column; border: 1px solid var(--p84-border); border-radius: var(--p84-radius-sm); background: var(--p84-surface); overflow: hidden; }
.p84-plotbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 14px; min-height: 40px; padding: 8px 12px; background: var(--p84-surface-alt); border-bottom: 1px solid var(--p84-border); }
.p84-plotbar__summary { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font: 700 13.5px var(--p84-font-mono); color: var(--p84-ink); overflow-wrap: anywhere; }
.p84-plotbar__summary::before { content: ""; flex-shrink: 0; width: 14px; height: 3px; border-radius: 2px; background: var(--p84-y2); }
.p84-plotcard .p84-stage--plot { border: 0; border-radius: 0; }
.p84-plotcard .p84-result { background: var(--p84-lcd-bg); color: var(--p84-lcd-ink); border-top: 0; }
.p84-plotcard .p84-result code { color: var(--p84-lcd-dim); }
.p84-plotcard .p84-result strong { font-size: 28px; line-height: 1.1; color: var(--p84-accent); }
.p84-plotcard .p84-result small { color: var(--p84-lcd-dim); }
.p84-seg--tail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.p84-seg--tail .p84-seg__btn { min-width: 0; padding: 0 4px; white-space: nowrap; }
/* Region pills sit right under the live Command line the engine mounts after them; the Calculate button stays last. */
.p84-console--dist .p84-tailbar { order: 1; }
.p84-console--dist .p84-tailbar + div + div, .p84-console--dist .p84-bench__params { order: 2; }
.p84-console--dist .p84-bench__input > .p84-btn { order: 3; }
.p84-result small { color: var(--p84-ink-muted); }
.p84-readout { display: grid; gap: 8px; align-content: start; min-height: 220px; padding: 18px; border-radius: var(--p84-radius); background: var(--p84-lcd-bg); color: var(--p84-lcd-ink); }
.p84-readout__label { margin: 0; font: 700 11px var(--p84-font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--p84-accent); }
.p84-readout__value { font: 700 clamp(26px, 4vw, 40px)/1.1 var(--p84-font-mono); overflow-wrap: anywhere; }
.p84-readout__extra { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 8px 0 0; }
.p84-readout__extra div { padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, .06); min-width: 0; }
.p84-readout__extra dt { font: 700 10px var(--p84-font-mono); letter-spacing: .14em; color: var(--p84-lcd-dim); }
.p84-readout__extra dd { margin: 2px 0 0; font: 600 14px var(--p84-font-mono); overflow-wrap: anywhere; }
.p84-worksteps { list-style: none; margin: 0; padding: 12px 18px 16px; display: grid; gap: 6px; counter-reset: p84step; }
.p84-worksteps li { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 8px 12px; border-radius: 10px; background: var(--p84-surface-alt); font-family: var(--p84-font-mono); font-size: 14px; }
.p84-worksteps b { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--p84-ink-muted); align-self: center; }
.p84-worksteps span { overflow-wrap: anywhere; }

/* ---------- 11. Ad slots (below the instrument only, zero CLS) ---------- */
.p84-slot[hidden] { display: none; }
.p84-slot[data-state="reserved"] { display: block; min-height: var(--p84-slot-h, 90px); margin: 20px auto; max-width: 970px; contain: layout; }

/* ---------- 12. Content ---------- */
.p84-content { max-width: var(--p84-wrap); margin: 0 auto; padding: 28px var(--p84-gutter) 56px; }
.p84-prose { max-width: 780px; min-width: 0; }
.p84-content .p84-prose { margin: 0 auto 0 0; }
.p84-content__main { min-width: 0; }
.p84-rail { display: none; }
.p84-rail__card { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--p84-border); border-radius: var(--p84-radius-sm); background: var(--p84-surface); }
.p84-rail__title { margin: 0; font: 700 11px var(--p84-font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--p84-ink-muted); }
.p84-rail__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.p84-rail__list a { display: block; padding: 5px 9px; border-radius: 7px; color: var(--p84-ink-muted); font-size: 13.5px; line-height: 1.35; text-decoration: none; }
.p84-rail__list a:hover { background: var(--p84-surface-alt); color: var(--p84-ink); }
.p84-rail__back { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; border-radius: 10px; background: var(--p84-lcd-bg); color: var(--p84-accent); font: 700 12.5px var(--p84-font-mono); letter-spacing: .02em; text-decoration: none; }
.p84-rail__back:hover { box-shadow: inset 0 0 0 1px var(--p84-accent); }
@media (min-width: 1180px) {
  .p84-content--rail { display: grid; grid-template-columns: minmax(0, 780px) 260px; justify-content: space-between; gap: 48px; align-items: start; }
  .p84-content--rail .p84-rail { display: block; position: sticky; top: 16px; }
}
.p84-load-row { display: flex; flex-wrap: wrap; gap: 8px; }
.p84-load-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px; border: 1px solid color-mix(in srgb, var(--p84-accent-line) 55%, var(--p84-border)); border-radius: 10px; background: color-mix(in srgb, var(--p84-accent) 16%, var(--p84-surface)); color: var(--p84-ink); font: 600 13.5px var(--p84-font-mono); text-align: left; box-shadow: 0 2px 0 color-mix(in srgb, var(--p84-accent-line) 35%, transparent); }
.p84-load-btn:hover { border-color: var(--p84-accent-line); background: color-mix(in srgb, var(--p84-accent) 28%, var(--p84-surface)); }
html:not(.p84-js) .p84-load-row { display: none; }
.p84-load-note { flex: 1 1 260px; align-self: center; margin: 0; font-size: 14px; line-height: 1.45; color: var(--p84-ink-muted); }
/* Keyboard-scrollable regions (tabindex="0"): inset ring so overflow:hidden parents never clip it. */
.p84-table-wrap:focus-visible, .p84-rowops:focus-visible, .p84-calcbar__readout:focus-visible, .p84-multiview__history:focus-visible, .p84-math-scroll:focus-visible { outline-offset: -2px; }
.p84-math-scroll { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; border-radius: 6px; }
.p84-prose .p84-math-scroll > .katex-display, .p84-math-scroll > .katex-display { overflow: visible; }
.p84-prose .p84-hub__title { margin: 1.5em 0 .6em; padding-bottom: 6px; border-bottom: 1px solid var(--p84-border); font: 700 12px var(--p84-font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--p84-ink-muted); }
.p84-prose .p84-related__grid { padding: 0; }
.p84-prose .p84-related__grid li { margin: 0; }
.p84-prose > * + * { margin-top: 1em; }
.p84-prose h2 { margin: 2em 0 .5em; font-size: clamp(21px, 2.3vw, 26px); line-height: 1.2; letter-spacing: -.015em; }
.p84-prose h3 { margin: 1.6em 0 .4em; font-size: 18px; line-height: 1.3; }
.p84-prose p, .p84-prose li { color: var(--p84-ink); }
.p84-prose ul, .p84-prose ol { padding-left: 1.3em; }
.p84-prose li + li { margin-top: .35em; }
.p84-prose table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.p84-prose th, .p84-prose td { padding: 9px 12px; border-bottom: 1px solid var(--p84-border); text-align: left; vertical-align: top; }
.p84-prose thead th { background: var(--p84-surface-alt); font-weight: 700; font-size: 13px; }
.p84-prose td code, .p84-prose th code { white-space: nowrap; }
.p84-prose .p84-table-wrap { border: 1px solid var(--p84-border); border-radius: var(--p84-radius-sm); background: var(--p84-surface); }
.p84-prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.p84-section { padding-top: 4px; }
.p84-callout { padding: 14px 16px; border-radius: var(--p84-radius-sm); border: 1px solid var(--p84-border); border-left: 4px solid var(--p84-accent-strong); background: var(--p84-surface); }
.p84-callout--warn { border-left-color: var(--p84-brand-mark); background: color-mix(in srgb, var(--p84-warn-bg) 45%, var(--p84-surface)); }
.p84-callout--tip { border-left-color: var(--p84-accent-line); }
.p84-callout > :first-child { margin-top: 0; }
.p84-callout > :last-child { margin-bottom: 0; }

/* Practice card: independent timed self-check (partials/practice-card.njk, driven by client/practice.ts). */
.p84-practice { --p84-ok: #0B7A55; --p84-practice-line: color-mix(in srgb, var(--p84-ink-muted) 70%, var(--p84-surface)); min-width: 0; border: 1px solid var(--p84-border); border-radius: var(--p84-radius); background: var(--p84-surface); }
:root[data-theme="dark"] .p84-practice { --p84-ok: #34D399; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .p84-practice { --p84-ok: #34D399; } }
.p84-prose .p84-practice { margin: 1.75em 0; }
.p84-practice [hidden] { display: none !important; }
.p84-practice__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--p84-border); border-radius: calc(var(--p84-radius) - 1px) calc(var(--p84-radius) - 1px) 0 0; background: var(--p84-surface-alt); box-shadow: inset 0 3px 0 var(--p84-accent); }
.p84-practice .p84-practice__eyebrow { margin: 0; font: 700 11.5px/1.3 var(--p84-font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--p84-ink-muted); }
.p84-practice__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.p84-practice .p84-practice__start { min-height: 36px; padding: 0 12px; font-size: 12px; }
.p84-practice__clock { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 10px; border-radius: 8px; background: var(--p84-lcd-bg); color: var(--p84-lcd-ink); font: 600 14px var(--p84-font-mono); font-variant-numeric: tabular-nums; }
.p84-practice__clock-k { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--p84-lcd-dim); }
.p84-practice__timer { min-width: 4ch; text-align: right; }
.p84-practice__score { display: inline-flex; align-items: center; min-height: 36px; max-width: 100%; padding: 6px 10px; border: 1px solid var(--p84-border); border-radius: 8px; background: var(--p84-surface); color: var(--p84-ink); font: 600 12.5px/1.3 var(--p84-font-mono); font-variant-numeric: tabular-nums; }
.p84-practice__body { display: grid; gap: 12px; min-width: 0; padding: 16px 18px 18px; }
.p84-practice .p84-practice__prompt { margin: 0; font-size: 17px; line-height: 1.5; font-weight: 500; color: var(--p84-ink); overflow-wrap: anywhere; }
.p84-practice__form { min-width: 0; }
.p84-practice__label { display: block; margin-bottom: 4px; font-size: 12.5px; font-weight: 600; color: var(--p84-ink-muted); }
.p84-practice__controls { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; min-width: 0; }
.p84-practice__field { display: flex; flex: 1 1 220px; align-items: center; gap: 8px; min-width: 0; }
.p84-practice__input { flex: 1 1 auto; width: 100%; min-width: 0; min-height: 44px; padding: 0 12px; border: 1px solid var(--p84-practice-line); border-radius: 10px; background: var(--p84-surface); color: var(--p84-ink); font: 500 16px var(--p84-font-mono); }
.p84-practice__input::placeholder { color: var(--p84-ink-muted); opacity: 1; }
.p84-practice__input[aria-invalid="true"] { border-color: var(--p84-warn-ink); }
.p84-practice__input[readonly] { background: var(--p84-surface-alt); }
.p84-practice__unit { flex: none; font: 600 14px var(--p84-font-mono); color: var(--p84-ink-muted); }
.p84-practice__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.p84-practice .p84-btn { color: var(--p84-ink); }
.p84-practice .p84-btn--accent { color: var(--p84-accent-ink); }
.p84-practice .p84-btn:not(.p84-btn--accent):hover:not(:disabled) { background: var(--p84-surface-alt); border-color: var(--p84-practice-line); }
.p84-practice .p84-btn--accent:hover:not(:disabled) { background: color-mix(in srgb, var(--p84-accent) 86%, var(--p84-accent-line)); }
.p84-practice [data-p84-practice-hint-btn][aria-expanded="true"] { background: var(--p84-surface-alt); border-color: var(--p84-practice-line); }
.p84-practice button:disabled { cursor: not-allowed; opacity: .55; box-shadow: none; }
.p84-practice .p84-practice__hint { margin: 0; padding: 10px 14px; border-left: 3px solid var(--p84-focus); border-radius: 10px; background: var(--p84-surface-alt); color: var(--p84-ink); font: 500 14px/1.6 var(--p84-font-mono); overflow-wrap: anywhere; }
.p84-practice__feedback { padding: 10px 14px; border: 1px solid var(--p84-border); border-left: 4px solid var(--p84-ink-muted); border-radius: 10px; background: var(--p84-surface); color: var(--p84-ink); font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.p84-practice__feedback:empty { display: none; }
.p84-practice__feedback[data-status="correct"] { border-left-color: var(--p84-ok); background: color-mix(in srgb, var(--p84-ok) 10%, var(--p84-surface)); }
.p84-practice__feedback[data-status="trap"] { border-left-color: var(--p84-brand-mark); background: color-mix(in srgb, var(--p84-warn-bg) 55%, var(--p84-surface)); }
.p84-practice .p84-practice__solution { margin: 0; padding-left: 14px; border-left: 2px solid var(--p84-border); color: var(--p84-ink); font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.p84-practice .p84-load-btn { min-height: 44px; }
html:not(.p84-js) .p84-practice__meta, html:not(.p84-js) .p84-practice__form { display: none; }
@media (max-width: 760px), (pointer: coarse) {
  .p84-practice .p84-practice__start, .p84-practice__clock, .p84-practice__score { min-height: 44px; }
}
@media (max-width: 560px) {
  .p84-practice__bar { padding: 10px 14px; }
  .p84-practice .p84-practice__eyebrow { flex: 1 1 100%; }
  .p84-practice__body { padding: 14px; }
  .p84-practice__field { flex-basis: 100%; }
  .p84-practice__actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .p84-practice__actions .p84-btn { padding: 0 10px; }
  .p84-practice__actions [data-p84-practice-check] { grid-column: 1 / -1; }
  .p84-practice .p84-load-btn { width: 100%; }
}
@media print {
  .p84-practice__meta, .p84-practice__form, .p84-practice__reveal, .p84-practice__feedback { display: none !important; }
}
.p84-steps { list-style: none; padding: 0; counter-reset: p84s; }
.p84-steps > li { position: relative; padding: 12px 14px 12px 52px; border: 1px solid var(--p84-border); border-radius: var(--p84-radius-sm); background: var(--p84-surface); counter-increment: p84s; }
.p84-steps > li::before { content: counter(p84s); position: absolute; left: 14px; top: 12px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--p84-lcd-bg); color: var(--p84-accent); font: 700 13px var(--p84-font-mono); }
.p84-links { list-style: none; padding: 0; display: grid; gap: 8px; }
.p84-links a { font-weight: 600; }
.p84-meta { margin: 0; font-size: 13.5px; color: var(--p84-ink-muted); }

.p84-faq { max-width: 780px; margin-top: 40px; }
.p84-faq h2 { font-size: clamp(21px, 2.3vw, 26px); letter-spacing: -.015em; margin: 0 0 12px; }
.p84-faq__item { border: 1px solid var(--p84-border); border-radius: var(--p84-radius-sm); background: var(--p84-surface); }
.p84-faq__item + .p84-faq__item { margin-top: 8px; }
.p84-faq__item summary { min-height: 48px; padding: 12px 16px; font-weight: 700; cursor: pointer; list-style-position: outside; }
.p84-faq__a { padding: 0 16px 14px; color: var(--p84-ink); }
.p84-faq__a > :first-child { margin-top: 0; }

.p84-related { margin-top: 44px; }
.p84-related h2 { font-size: clamp(21px, 2.3vw, 26px); letter-spacing: -.015em; margin: 0 0 14px; }
.p84-related__grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 10px; }
.p84-related__card { display: grid; gap: 4px; height: 100%; padding: 14px 16px; border: 1px solid var(--p84-border); border-radius: var(--p84-radius-sm); background: var(--p84-surface); color: var(--p84-ink); text-decoration: none; transition: border-color .15s ease, transform .15s ease; }
.p84-related__card:hover { border-color: var(--p84-accent-strong); transform: translateY(-1px); }
.p84-related__cat { font: 700 10.5px var(--p84-font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--p84-ink-muted); }
.p84-related__name { font-weight: 700; line-height: 1.3; }

/* Trust / prose pages */
.p84-page { max-width: 860px; margin: 0 auto; padding: 22px var(--p84-gutter) 64px; }
.p84-page__head { display: grid; gap: 8px; padding: 18px 0 22px; border-bottom: 1px solid var(--p84-border); margin-bottom: 8px; }
.p84-page__head h1 { margin: 0; font-size: clamp(28px, 4vw, 40px); line-height: 1.1; letter-spacing: -.025em; }
.p84-eyebrow { margin: 0; font: 700 11px var(--p84-font-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--p84-brand-mark); }
.p84-lede { margin: 0; font-size: 18px; color: var(--p84-ink-muted); max-width: 64ch; }
.p84-spec { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; padding: 0; list-style: none; }
.p84-spec li { padding: 14px; border-radius: var(--p84-radius-sm); background: var(--p84-surface); border: 1px solid var(--p84-border); margin: 0; }
.p84-spec b { display: block; font: 700 11px var(--p84-font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--p84-ink-muted); margin-bottom: 4px; }

/* ---------- 13. Footer ---------- */
.p84-footer { margin-top: 24px; background: var(--p84-surface); border-top: 1px solid var(--p84-border); }
.p84-footer__inner { max-width: var(--p84-wrap); margin: 0 auto; padding: 36px var(--p84-gutter) 20px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.6fr) minmax(0, .8fr); gap: 28px; }
.p84-footer__brand p { margin: 10px 0 0; color: var(--p84-ink-muted); font-size: 14px; max-width: 36ch; }
.p84-footer__col h2 { margin: 0 0 10px; font: 700 11px var(--p84-font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--p84-ink-muted); }
.p84-footer__col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.p84-footer__col[aria-label="Calculators"] ul { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); column-gap: 18px; }
.p84-footer__col a { color: var(--p84-ink); text-decoration: none; font-size: 14px; }
.p84-footer__col a:hover { color: var(--p84-link); text-decoration: underline; }
.p84-footer__disclaimer, .p84-footer__legal { max-width: var(--p84-wrap); margin: 0 auto; padding: 0 var(--p84-gutter); font-size: 13px; color: var(--p84-ink-muted); }
.p84-footer__disclaimer { padding-top: 16px; border-top: 1px solid var(--p84-border); font-weight: 600; }
.p84-footer__legal { padding-top: 6px; padding-bottom: 28px; }

/* ---------- 14. Responsive ---------- */
/* 1440x900: graph + LCD + full 5-module keypad above the fold (functions in 5 columns = 4 key rows max). */
@media (min-width: 1101px) {
  .p84-console--graphing .p84-stage { height: clamp(330px, calc(100vh - 525px), 640px); height: clamp(330px, calc(100svh - 525px), 640px); }
  .p84-tool:has(.p84-crumbs) .p84-console--graphing .p84-stage { height: clamp(330px, calc(100vh - 548px), 640px); height: clamp(330px, calc(100svh - 548px), 640px); }
  .p84-intro__lede { max-width: none; }
  .p84-keypad__body { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) minmax(0, 1.6fr) minmax(0, 1.1fr) minmax(0, 1.15fr); }
  .p84-module--fn .p84-keys { --cols: 5; }
  .p84-console--graphing .p84-module--classroom .p84-keys { --cols: 3; }
  .p84-console--graphing .p84-module--classroom .p84-key:first-child, .p84-console--graphing .p84-module--classroom .p84-key:last-child { grid-column: span 2; }
}
@media (min-width: 761px) and (max-width: 1000px) {
  .p84-studiobar .p84-stage__window { display: none; }
}
/* Scientific: MathPrint screen + LCD on the left, the full keypad on the right. */
@media (min-width: 1024px) {
  .p84-console--scientific { display: grid; grid-template-columns: minmax(0, 44fr) minmax(0, 56fr); align-items: stretch; }
  .p84-console--scientific .p84-sci-screen { display: flex; flex-direction: column; min-width: 0; }
  .p84-console--scientific .p84-multiview { flex: 1 1 auto; min-height: 300px; }
  .p84-console--scientific .p84-multiview__history { flex: 0 1 auto; margin-top: auto; max-height: 220px; overflow-y: auto; justify-content: flex-start; scrollbar-width: thin; }
  .p84-console--scientific .p84-keypad { border-top: 0; border-left: 1px solid var(--p84-border); }
  .p84-console--scientific .p84-keypad__body { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
  .p84-console--scientific .p84-module--classroom { grid-column: 1 / -1; }
  .p84-console--scientific .p84-module--fn, .p84-console--scientific .p84-module--num, .p84-console--scientific .p84-module--op, .p84-console--scientific .p84-module--act { grid-column: span 3; }
  .p84-console--scientific .p84-module--fn .p84-keys { --cols: 3; }
  .p84-console--scientific .p84-module--op .p84-keys, .p84-console--scientific .p84-module--act .p84-keys { --cols: 4; }
}
/* Matrix: entries + rref() side by side, LCD and Gauss-Jordan steps full width below. */
@media (min-width: 960px) {
  .p84-console--matrix { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); grid-template-areas: "bench rref" "lcd lcd" "steps steps"; align-items: start; }
  .p84-console--matrix > .p84-bench { grid-area: bench; }
  .p84-console--matrix > .p84-lcd { grid-area: lcd; }
  .p84-console--matrix > .p84-dock { display: contents; }
  .p84-console--matrix .p84-panel--rref { grid-area: rref; margin: 16px 16px 16px 0; }
  .p84-console--matrix .p84-panel--steps { grid-area: steps; margin: 12px; }
  .p84-console--matrix .p84-rowops { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); column-gap: 24px; max-height: none; }
}
@media (max-width: 1100px) {
  .p84-keypad__body { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .p84-module--classroom { grid-column: 1 / -1; }
  .p84-module--fn { grid-column: span 3; }
  .p84-module--num { grid-column: span 3; }
  .p84-module--op, .p84-module--act { grid-column: span 3; }
  .p84-module--op .p84-keys, .p84-module--act .p84-keys { --cols: 4; }
  .p84-footer__inner { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .p84-footer__brand { grid-column: 1 / -1; }
  .p84-nav { padding-right: 28px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
}

@media (max-width: 760px) {
  .p84-header__inner { flex-wrap: wrap; gap: 8px 12px; padding-top: 8px; padding-bottom: 8px; }
  .p84-nav { order: 3; flex: 1 0 100%; margin: 0; }
  .p84-theme-btn, .p84-nav + .p84-theme-btn { margin-left: auto; }
  .p84-tool { padding-top: 8px; }
  .p84-intro { gap: 2px; margin-bottom: 10px; }
  .p84-intro h1 { font-size: 21px; }
  .p84-intro__lede { font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
  .p84-instrument { margin-left: calc(-1 * var(--p84-gutter) + 4px); margin-right: calc(-1 * var(--p84-gutter) + 4px); border-radius: 12px; }
  .p84-stage { height: 42vh; min-height: 280px; max-height: 400px; }
  .p84-stage--plot { height: 230px; min-height: 0; }
  /* Studio bar: Y= ribbon on row 1, slim utility row (window + PNG/SVG/Share) on row 2; the canvas stays clean. */
  .p84-studiobar { flex-wrap: wrap; gap: 6px 8px; padding: 6px 8px; }
  .p84-ribbon { flex: 1 0 100%; order: -1; }
  .p84-ribbon__label { display: none; }
  .p84-chip { height: 38px; }
  .p84-chip input { width: 116px; font-size: 16px; }
  .p84-chip--slot:focus-within input { width: 116px; }
  .p84-add-expr { height: 38px; padding: 0 10px; }
  .p84-studiobar .p84-stage__window { flex: 1 1 0; font-size: 11px; }
  .p84-hud--export { margin-left: auto; gap: 4px; }
  .p84-hud--export .p84-hbtn { min-height: 34px; min-width: 0; padding: 0 10px; font-size: 11px; }
  .p84-hud--zoom { top: auto; bottom: 10px; right: 10px; transform: none; gap: 3px; padding: 3px; border-radius: 11px; background: color-mix(in srgb, var(--p84-surface) 70%, transparent); }
  .p84-hud--zoom .p84-hbtn { width: 36px; min-width: 36px; height: 36px; min-height: 36px; border-radius: 8px; font-size: 16px; }
  .p84-hud--zoom .p84-hbtn--text { font-size: 9px; }
  .p84-calcbar { gap: 8px; padding: 8px; }
  .p84-calcbar__readout { flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; font-size: 12.5px; }
  .p84-calcbar__readout::-webkit-scrollbar { display: none; }
  .p84-calcbar__inputs { flex: 1 0 100%; }
  .p84-calcbar__in { flex: 1 1 0; }
  .p84-instrument .p84-calcbar__in input[type="text"] { width: 100%; font-size: 16px; }
  .p84-lcd { padding: 6px 12px; gap: 10px; }
  .p84-lcd__track { row-gap: 2px; column-gap: 12px; }
  .p84-lcd__ro { line-height: 14px; }
  .p84-lcd__toggles { display: none; }
  .p84-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 6px; background: var(--p84-surface-alt); border-bottom: 1px solid var(--p84-border); }
  .p84-dock { grid-template-columns: minmax(0, 1fr); padding: 8px; }
  .p84-keypad { padding: 8px; }
  .p84-keypad__head { display: none; }
  .p84-keypad[data-collapsed] .p84-keypad__body { display: grid; }
  .p84-keypad__body { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 8px; }
  .p84-module { padding: 8px; }
  .p84-module__title { display: none; }
  .p84-module--classroom, .p84-module--fn, .p84-module--act { grid-column: 1 / -1; }
  .p84-module--num, .p84-module--op { grid-column: auto; }
  .p84-module--fn .p84-keys { --cols: 5; }
  .p84-console--scientific .p84-module--fn .p84-keys { --cols: 3; }
  .p84-module--classroom .p84-key--fn { font-size: 18px; }
  .p84-module--op .p84-keys { --cols: 2; }
  .p84-module--act .p84-keys { --cols: 4; }
  .p84-key--enter { grid-column: span 2; }
  .p84-keys { grid-auto-rows: minmax(46px, 1fr); gap: 6px; }
  .p84-key { min-height: 46px; }
  .p84-key--cmd { font-size: 11px; letter-spacing: .02em; }
  .p84-insp li { grid-template-columns: 84px minmax(0, 1fr); }
  .p84-insp__detail { grid-column: 1 / -1; grid-row: 2; }
  .p84-insp__val { text-align: right; }
  .p84-bench { padding: 12px; }
  .p84-bench--split { grid-template-columns: minmax(0, 1fr); }
  .p84-matgrid { --px: 10px; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); width: 100%; padding: 8px var(--px); }
  .p84-console--stats .p84-textarea { height: 108px; min-height: 108px; }
  .p84-plotcard .p84-result strong { font-size: 24px; }
  /* Distribution on phones: the card opens up (display: contents) so the worked steps can drop below the inputs.
     Order: caption → 175px curve → live answer → region + μ/σ/bounds + Calculate → mode pickers → steps. */
  .p84-console--dist .p84-bench--split { row-gap: 0; }
  .p84-console--dist .p84-plotcard { display: contents; }
  .p84-console--dist .p84-plotbar { order: -3; min-height: 32px; padding: 6px 12px; border: 1px solid var(--p84-border); border-radius: var(--p84-radius-sm) var(--p84-radius-sm) 0 0; }
  .p84-console--dist .p84-stage--plot { order: -2; height: 175px; border: 1px solid var(--p84-border); border-width: 0 1px; border-radius: 0; }
  .p84-console--dist .p84-result { order: -1; row-gap: 2px; padding: 8px 12px; border-radius: 0 0 var(--p84-radius-sm) var(--p84-radius-sm); }
  .p84-console--dist .p84-result code { font-size: 13px; }
  .p84-console--dist .p84-bench__input { gap: 8px; margin-top: 12px; }
  .p84-console--dist .p84-bench__input > .p84-field:first-child, .p84-console--dist .p84-tailbar + div { order: 4; }
  .p84-console--dist .p84-worksteps { order: 1; margin-top: 12px; padding: 0; }
  /* Scientific: compact screen (last two results, one line each) so 4-5 key rows sit above the fold. */
  .p84-console--scientific .p84-multiview { min-height: 0; max-height: 145px; overflow: hidden; gap: 6px; padding: 8px 12px; }
  .p84-console--scientific .p84-multiview:has(.p84-seg) { max-height: none; }
  .p84-console--scientific .p84-multiview__status { gap: 4px; font-size: 9.5px; }
  .p84-console--scientific .p84-multiview__status span { padding: 2px 6px; }
  .p84-console--scientific .p84-multiview__history li { padding: 3px 0; }
  .p84-console--scientific .p84-multiview__history li:nth-last-child(n+3) { display: none; }
  .p84-console--scientific .p84-multiview__in { font-size: 13px; }
  .p84-console--scientific .p84-multiview__out { font-size: 15px; }
  .p84-console--scientific .p84-multiview__entry input { min-height: 42px; font-size: 16px; }
  .p84-worksteps li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .p84-footer__inner { grid-template-columns: minmax(0, 1fr); }
  .p84-slot[data-state="reserved"] { min-height: var(--p84-slot-h-m, 100px); }

  /* Tabbed console (JS present): show only the active pane group. */
  .p84-js [data-p84-deck] [data-p84-pane] { display: none; }
  .p84-js [data-p84-deck][data-p84-active-tab="keypad"] [data-p84-pane="keypad"],
  .p84-js [data-p84-deck][data-p84-active-tab="functions"] [data-p84-pane="functions"],
  .p84-js [data-p84-deck][data-p84-active-tab="table"] [data-p84-pane="table"],
  .p84-js [data-p84-deck][data-p84-active-tab="calc"] [data-p84-pane="calc"] { display: flex; }
  .p84-js [data-p84-deck][data-p84-active-tab="table"] .p84-keypad,
  .p84-js [data-p84-deck][data-p84-active-tab="calc"] .p84-keypad { display: none; }
  .p84-js [data-p84-deck][data-p84-active-tab="keypad"] .p84-dock,
  .p84-js [data-p84-deck][data-p84-active-tab="functions"] .p84-dock { display: none; }
  .p84-js [data-p84-deck][data-p84-active-tab="table"] .p84-dock,
  .p84-js [data-p84-deck][data-p84-active-tab="calc"] .p84-dock { display: grid; grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .p84-crumbs { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

@media print {
  .p84-header, .p84-footer, .p84-keypad, .p84-tabs, .p84-hud, .p84-slot, .p84-theme-btn, .p84-rail, .p84-load-row, .p84-add-expr { display: none !important; }
  body { background: #fff; color: #000; }
}
