/* ==========================================================================
   infixtopostfixconverter.com — instrument-panel theme
   Dark by default; light is opt-in via the header toggle ([data-theme]).
   ========================================================================== */

:root {
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype",
    Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono",
    Menlo, Consolas, "Liberation Mono", monospace;

  --max: 1180px;
  --gutter: 22px;
  --measure: 68ch;
  --column: 660px;
  --band-gap: clamp(52px, 7vw, 92px);

  --r-xs: 6px;  --r-sm: 10px; --r-md: 14px;
  --r-lg: 20px; --r-xl: 26px;

  --t-fast: .16s;
  --t-med: .3s;
  --ease: cubic-bezier(.22, .61, .36, 1);

  --glass: blur(14px) saturate(1.35);
  --glass-strong: blur(22px) saturate(1.5);

  /* ---- dark (default) ---- */
  --ground: #06070b;
  --ground-2: #0a0c12;
  --ink: #eef1f6;
  --ink-soft: #c2c9d6;
  --muted: #7e8799;
  --faint: #454d5e;

  --hairline: rgba(255, 255, 255, .13);
  --hairline-2: rgba(255, 255, 255, .06);

  --plate: rgba(255, 255, 255, .032);
  --plate-solid: #10131b;
  --plate-sunk: rgba(0, 0, 0, .26);
  --plate-hover: rgba(255, 255, 255, .058);

  --blued: #7aa2ff;
  --blued-wash: rgba(122, 162, 255, .10);
  --brass: #d4a843;
  --critical: #ff6f6f;

  --grad: linear-gradient(120deg, #6366f1 0%, #a855f7 52%, #38bdf8 100%);
  --grad-1: rgba(99, 102, 241, .30);
  --grad-2: rgba(168, 85, 247, .30);
  --grad-3: rgba(56, 189, 248, .26);

  --tok-operand: #5eead4;
  --tok-operator: #e8be5c;
  --tok-paren: #c4a5ff;

  --orb-opacity: .30;

  --shadow-plate: inset 0 1px 0 rgba(255, 255, 255, .045),
                  0 24px 60px -32px rgba(0, 0, 0, .92);
  --shadow-lift: 0 26px 60px -26px rgba(0, 0, 0, .85);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --ground: #fbfbfd;
  --ground-2: #f3f4f9;
  --ink: #10131a;
  --ink-soft: #3c4353;
  --muted: #697184;
  --faint: #b3bac7;

  --hairline: rgba(12, 18, 34, .15);
  --hairline-2: rgba(12, 18, 34, .075);

  --plate: rgba(255, 255, 255, .74);
  --plate-solid: #ffffff;
  --plate-sunk: #f5f6fa;
  --plate-hover: #ffffff;

  --blued: #4f46e5;
  --blued-wash: rgba(79, 70, 229, .07);
  --brass: #9a7614;
  --critical: #d92d2d;

  --grad: linear-gradient(120deg, #4f46e5 0%, #9333ea 52%, #0284c7 100%);
  --grad-1: rgba(99, 102, 241, .17);
  --grad-2: rgba(168, 85, 247, .17);
  --grad-3: rgba(56, 189, 248, .15);

  --tok-operand: #0b7c66;
  --tok-operator: #8a6410;
  --tok-paren: #6d28d9;

  --orb-opacity: .13;

  --shadow-plate: 0 1px 2px rgba(16, 20, 30, .05),
                  0 20px 46px -28px rgba(16, 20, 30, .32);
  --shadow-lift: 0 22px 48px -22px rgba(16, 20, 30, .30);

  color-scheme: light;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizelegibility;
}
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--blued); text-decoration-color: color-mix(in srgb, var(--blued) 40%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
::selection { background: var(--grad-1); }
:focus-visible { outline: 2px solid var(--blued); outline-offset: 3px; border-radius: var(--r-xs); }

h1, h2, h3, h4 {
  font-family: var(--serif);
  color: var(--ink);
  letter-spacing: -.02em;
  text-wrap: balance;
  overflow-wrap: break-word;
  margin: 0 0 .5em;
  font-weight: 600;
  line-height: 1.14;
}
h1 { font-size: clamp(34px, 4.8vw, 58px); letter-spacing: -.032em; font-weight: 700; line-height: 1.06; }
h2 { font-size: clamp(24px, 2.9vw, 34px); margin-top: 2.1em; }
h3 { font-size: clamp(17px, 1.7vw, 20px); margin-top: 1.9em; }
h4 { font-size: 16px; margin-top: 1.6em; }
p { margin: 0 0 1.1em; }
ul, ol { margin: 0 0 1.2em; padding-left: 1.35em; }
li { margin-bottom: .5em; }
li::marker { color: var(--faint); }
strong { color: var(--ink); font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--hairline-2); margin: 2.5rem 0; }

code, kbd, samp { font-family: var(--mono); font-size: .9em; }
:not(pre) > code {
  background: var(--plate-sunk);
  border: 1px solid var(--hairline-2);
  color: var(--ink);
  padding: .14em .42em;
  border-radius: var(--r-xs);
  white-space: nowrap;
}
kbd {
  background: var(--plate-sunk); border: 1px solid var(--hairline);
  border-bottom-width: 2px; border-radius: var(--r-xs);
  padding: .1em .42em; font-size: .82em; color: var(--ink);
}

/* ---------- Ambient field ---------- */
.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb {
  position: absolute; border-radius: 50%;
  filter: blur(120px); opacity: var(--orb-opacity);
  animation: orbFloat 24s var(--ease) infinite;
}
.orb-1 { background: var(--grad-1); width: 46vw; height: 46vw; top: -12vw; left: -8vw; }
.orb-2 { background: var(--grad-3); width: 40vw; height: 40vw; top: 32vh; right: -10vw; animation-delay: -8s; }
.orb-3 { background: var(--grad-2); width: 38vw; height: 38vw; bottom: -14vw; left: 26vw; animation-delay: -16s; }
@keyframes orbFloat {
  0%, 100% { transform: translate(0) scale(1); }
  33%      { transform: translate(4vw, -3vh) scale(1.08); }
  66%      { transform: translate(-3vw, 4vh) scale(.94); }
}

/* ---------- Layout ---------- */
.wrap { max-width: var(--max); padding-inline: var(--gutter); margin: 0 auto; }
/* A nested .prose is a reading column inside the centred .wrap. */
.prose { max-width: var(--measure); margin-inline: 0; }
/* Four pages put both roles on one element: keep the wrap centred at full
   width and cap its children instead, so the text still starts at the
   wrap's left edge and lines up with the hero above it. */
.wrap.prose { max-width: var(--max); margin-inline: auto; }
.wrap.prose > * { max-width: var(--column); }
.wrap.prose > .table-scroll, .wrap.prose > .codeblock { max-width: var(--column); }

/* Every page uses one centred reading column under a full-width header. */
.hero--center { text-align: center; }
.hero--center .hero__lede { margin-inline: auto; }

/* Structure A — .wrap and .prose on one element: the wrap stays full width
   and each child is capped and centred. The doubled class beats component
   rules further down the file that set a `margin` shorthand (.steps,
   .figure, .callout, .codeblock, .toc). */
.prose.prose--center > * { margin-inline: auto; }
.prose.prose--center > .table-scroll,
.prose.prose--center > .figure { max-width: 880px; }

/* Structure B — .prose nested inside .wrap: centre the column itself.
   Doubled selectors so these outrank .prose and .legal above. */
.prose--center:not(.wrap),
.legal.prose--center { max-width: var(--column); margin-inline: auto; }
.prose > p, .prose > ul, .prose > ol { color: var(--ink-soft); }
.section { padding-block: var(--band-gap); position: relative; }
.section + .section { border-top: 1px solid var(--hairline-2); }
.section--alt { background: var(--ground-2); border-block: 1px solid var(--hairline-2); }
.sr-only, .skip-link {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.skip-link {
  background: var(--grad); color: #fff; font: 600 13px/1 var(--sans);
  border-radius: 0 0 var(--r-sm) 0; text-decoration: none;
}
.skip-link:focus {
  position: fixed; z-index: 100; inset-inline-start: 0; top: 0;
  clip-path: none; width: auto; height: auto; padding: 14px 20px; overflow: visible;
}

/* ---------- Masthead ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--ground) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--hairline-2);
}
.site-header__inner { display: flex; align-items: center; gap: 22px; height: 76px; }
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; text-decoration: none; min-width: 0; }
.brand__mark {
  flex: none; width: 34px; height: 34px; display: block;
  filter: drop-shadow(0 8px 18px rgba(124, 58, 237, .38));
}
.brand__text {
  font-family: var(--serif); color: var(--ink);
  font-size: 19px; font-weight: 700; letter-spacing: -.01em; line-height: 1.1;
}
.brand__sub {
  display: block; margin-top: 2px;
  font-family: var(--sans); font-size: 9.5px; font-weight: 500;
  letter-spacing: .24em; text-transform: uppercase; color: var(--muted);
}
.nav { display: flex; align-items: center; gap: 30px; }
.theme-toggle {
  flex: none; width: 42px; height: 42px; margin-left: -8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--plate-sunk); border: 1px solid var(--hairline-2);
  border-radius: var(--r-sm); color: var(--muted); cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--grad-1); }
.theme-toggle svg { width: 16px; height: 16px; display: block; }
.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }
@media (max-width: 900px) {
  .site-header__inner { gap: 14px; }
  .nav { gap: 16px; }
}
@media (max-width: 620px) {
  .brand__sub { display: none; }
  .brand__text { font-size: 17px; white-space: nowrap; }
}

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { padding-top: 20px; font-size: 12px; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; list-style: none; margin: 0; padding: 0; }
.breadcrumbs li { display: flex; align-items: center; gap: 8px; margin: 0;
  font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-size: 10px; }
.breadcrumbs li + li::before { content: "/"; color: var(--faint); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--blued); }

/* ---------- Hero ---------- */
.hero { padding-block: clamp(44px, 6vw, 84px) clamp(26px, 3vw, 40px); }
.hero h1 { margin-bottom: .34em; }
.hero h1 em {
  font-style: normal;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero__lede {
  color: var(--ink-soft);
  font-size: clamp(16px, 1.35vw, 18.5px);
  max-width: 64ch; margin: 0 0 4px;
}
.eyebrow {
  display: inline-block; margin: 0 0 16px;
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- Plates ---------- */
.card {
  background: var(--plate);
  -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-plate);
  padding: clamp(22px, 2.8vw, 34px);
}
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.card__title {
  margin: 0; font-family: var(--sans); font-size: 11px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}

/* ---------- Tool ---------- */
.tool { scroll-margin-top: 90px; }
.tool__label {
  display: block; margin-bottom: 9px;
  font-size: 10px; font-weight: 600; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted);
}
.tool__inputrow { display: flex; gap: 10px; flex-wrap: wrap; }
.tool__input {
  flex: 1 1 320px; min-width: 0;
  font-family: var(--mono); font-size: 17px; letter-spacing: .02em;
  color: var(--ink); background: var(--plate-sunk);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  padding: 15px 17px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.tool__input::placeholder { color: var(--faint); }
.tool__input:focus {
  outline: none; border-color: var(--blued);
  box-shadow: 0 0 0 3px var(--blued-wash);
}
.tool__input[aria-invalid="true"] { border-color: var(--critical); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font: 600 14px/1 var(--sans); letter-spacing: -.005em;
  padding: 15px 24px; border-radius: 999px;
  border: 1px solid transparent; cursor: pointer;
  background: var(--grad); color: #fff; text-decoration: none;
  box-shadow: 0 10px 30px -12px var(--grad-2);
  transition: transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 16px 38px -12px var(--grad-2); color: #fff; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 15px; height: 15px; flex: none; display: block; }
.btn--ghost {
  background: var(--plate-sunk); color: var(--ink-soft);
  border-color: var(--hairline); box-shadow: none;
}
.btn--ghost:hover { color: var(--ink); border-color: var(--grad-1); box-shadow: none; }
.btn--sm { padding: 10px 16px; font-size: 12.5px; }

.examples { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 15px; }
.examples__label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted);
}
.chip {
  font: 500 12.5px/1 var(--mono);
  padding: 10px 14px; border-radius: 999px; cursor: pointer;
  background: var(--plate-sunk); color: var(--ink-soft);
  border: 1px solid var(--hairline-2);
  transition: border-color var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.chip:hover { border-color: var(--grad-1); color: var(--ink); transform: translateY(-1px); }

/* ---------- Error ---------- */
.error-box {
  display: flex; gap: 11px; align-items: flex-start;
  margin-top: 16px; padding: 14px 16px;
  background: color-mix(in srgb, var(--critical) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--critical) 32%, transparent);
  border-radius: var(--r-md);
  color: var(--critical); font-size: 14px; line-height: 1.6;
}
.error-box svg { width: 17px; height: 17px; flex: none; margin-top: 3px; }
.error-box strong { display: block; color: inherit; margin-bottom: 2px; }
.error-box code { background: color-mix(in srgb, var(--critical) 14%, transparent); border-color: transparent; color: inherit; }

/* ---------- Readouts ---------- */
.results { margin-top: 24px; }
.result-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 17px 20px; border-radius: var(--r-md);
  background: var(--plate-sunk); border: 1px solid var(--hairline-2);
}
.result-row + .result-row { margin-top: 8px; }
.result-row__label {
  flex: none; min-width: 96px;
  font-size: 10px; font-weight: 600; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted);
}
.result-row__value {
  flex: 1 1 auto; min-width: 0;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 19px; font-weight: 500; letter-spacing: .05em;
  color: var(--ink); word-break: break-all;
}
.result-row--primary { background: var(--blued-wash); border-color: var(--grad-1); }
.result-row--primary .result-row__label { color: var(--blued); }
.result-row--primary .result-row__value {
  font-size: clamp(22px, 3vw, 30px); font-weight: 700;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.copy-btn {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  font: 600 11px/1 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  padding: 9px 13px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--muted);
  border: 1px solid var(--hairline-2);
  transition: color var(--t-fast), border-color var(--t-fast);
}
.copy-btn:hover { color: var(--blued); border-color: var(--grad-1); }
.copy-btn[data-copied="true"] { color: var(--tok-operand); border-color: currentColor; }
.copy-btn svg { width: 13px; height: 13px; }

/* ---------- Token pills ---------- */
.tok {
  display: inline-block; font-family: var(--mono); font-weight: 600;
  font-size: .92em; line-height: 1.5;
  padding: .1em .42em; border-radius: var(--r-xs); border: 1px solid transparent;
}
.tok--operand  { color: var(--tok-operand);  background: color-mix(in srgb, var(--tok-operand) 12%, transparent);  border-color: color-mix(in srgb, var(--tok-operand) 30%, transparent); }
.tok--operator { color: var(--tok-operator); background: color-mix(in srgb, var(--tok-operator) 12%, transparent); border-color: color-mix(in srgb, var(--tok-operator) 30%, transparent); }
.tok--paren    { color: var(--tok-paren);    background: color-mix(in srgb, var(--tok-paren) 12%, transparent);    border-color: color-mix(in srgb, var(--tok-paren) 30%, transparent); }
.legend {
  display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.legend .l-operand  { background: var(--tok-operand); }
.legend .l-operator { background: var(--tok-operator); }
.legend .l-paren    { background: var(--tok-paren); }

/* ---------- Tables ---------- */
.table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin-bottom: 26px;
  border: 1px solid var(--hairline-2); border-radius: var(--r-md);
  background: var(--plate-sunk);
}
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
caption {
  caption-side: top; text-align: left;
  padding: 14px 16px 10px;
  font-family: var(--sans); font-size: 10.5px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}
th, td { text-align: left; padding: 12px 16px; vertical-align: baseline; border-bottom: 1px solid var(--hairline-2); }
thead th {
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
}
tbody td { color: var(--ink-soft); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--blued-wash); }
.t-mono { font-family: var(--mono); font-size: .93em; color: var(--ink); white-space: nowrap; }
.t-num { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--brass); width: 1%; white-space: nowrap; font-size: 11px; }
.t-center { text-align: center; }

.trace-table td { white-space: nowrap; }
.trace-table .trace-action { white-space: normal; min-width: 240px; color: var(--muted); font-size: 13.5px; }
.trace-empty { color: var(--faint); font-style: italic; }
.trace-table tr.is-active td { background: var(--blued-wash); }
.trace-table tr.is-active td:first-child { box-shadow: inset 2px 0 0 var(--blued); }

/* ---------- Code ---------- */
.codeblock {
  position: relative; margin: 0 0 26px;
  border: 1px solid var(--hairline-2); border-radius: var(--r-md);
  background: #080a0f; overflow: hidden;
}
.codeblock__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, .022);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.codeblock__name { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #7e8799; }
.codeblock__bar .copy-btn { color: #7e8799; border-color: rgba(255, 255, 255, .1); }
.codeblock__bar .copy-btn:hover { color: #fff; border-color: rgba(255, 255, 255, .28); }
.codeblock pre { margin: 0; padding: 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.codeblock code {
  display: block; white-space: pre;
  font-family: var(--mono); font-size: 13px; line-height: 1.75; color: #dfe4ee;
}
.codeblock--plain { background: var(--plate-sunk); border-color: var(--hairline-2); }
.codeblock--plain code { color: var(--ink-soft); }

.hl-kw  { color: #c792ea; } .hl-typ { color: #7fd1e8; } .hl-str { color: #a5d66f; }
.hl-pre { color: #e8be5c; } .hl-fn  { color: #82aaff; }
.hl-num { color: #f0955f; } .hl-com { color: #5d6577; font-style: italic; }

/* ---------- Visualiser ---------- */
.viz { scroll-margin-top: 90px; }
.viz__expr {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 64px; padding: 16px; margin-bottom: 16px;
  background: var(--plate-sunk); border: 1px solid var(--hairline-2);
  border-radius: var(--r-md); font-family: var(--mono); font-size: 18px;
}
.viz__tok {
  padding: .16em .44em; border-radius: var(--r-xs);
  border: 1px solid transparent; color: var(--ink-soft);
  opacity: .42; transition: opacity var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.viz__tok.is-done { opacity: 1; }
.viz__tok.is-current {
  opacity: 1; font-weight: 700; color: var(--blued);
  background: var(--blued-wash); border-color: var(--blued);
  box-shadow: 0 0 14px -2px var(--blued);
}
.viz__grid { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(0, 1.4fr); gap: 1px; background: var(--hairline-2); border: 1px solid var(--hairline-2); border-radius: var(--r-md); overflow: hidden; }
@media (max-width: 620px) { .viz__grid { grid-template-columns: 1fr; } }
.viz__panel { background: var(--plate-sunk); padding: 16px; }
.viz__panel h3 {
  margin: 0 0 14px; font-family: var(--sans); font-size: 10px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase; color: var(--muted);
}
.viz__stack { display: flex; flex-direction: column-reverse; justify-content: flex-start; gap: 5px; min-height: 172px; }
.viz__cell {
  padding: 9px; border-radius: var(--r-xs);
  background: var(--plate-solid); border: 1px solid var(--hairline);
  font-family: var(--mono); font-size: 15px; font-weight: 600;
  color: var(--ink); text-align: center;
  animation: pop .18s var(--ease);
}
.viz__cell--top { border-color: var(--blued); color: var(--blued); box-shadow: 0 0 0 1px var(--blued-wash), 0 0 16px -4px var(--blued); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.viz__stackbase {
  margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--hairline);
  font-family: var(--mono); font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--faint); text-align: center;
}
.viz__out { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; min-height: 172px; font-family: var(--mono); }
.viz__narration {
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0 0; padding: 15px 17px; min-height: 58px;
  background: var(--blued-wash); border: 1px solid var(--grad-1);
  border-radius: var(--r-md); color: var(--ink-soft); font-size: 14.5px;
}
.step-badge {
  flex: none; font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .1em; padding: 5px 9px; border-radius: 999px;
  background: var(--grad); color: #fff;
}
.viz__controls { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.viz__progress { flex: 1 1 120px; min-width: 100px; height: 4px; border-radius: 3px; background: var(--hairline-2); overflow: hidden; }
.viz__progress i { display: block; height: 100%; background: var(--grad); border-radius: 3px; transition: width .2s var(--ease); }
.viz__count { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- FAQ ---------- */
.faq { display: flex; flex-direction: column; gap: 12px; max-width: 860px; }
.faq details {
  background: var(--plate);
  -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass);
  border: 1px solid var(--hairline-2); border-radius: var(--r-md);
  transition: border-color var(--t-fast);
}
.faq details:hover { border-color: var(--hairline); }
.faq details[open] { border-color: var(--grad-1); }
.faq summary {
  display: flex; align-items: center; gap: 16px;
  padding: 19px clamp(18px, 2vw, 26px);
  font-family: var(--serif); font-size: clamp(15.5px, 1.6vw, 17.5px);
  font-weight: 600; letter-spacing: -.01em; color: var(--ink);
  cursor: pointer; list-style: none;
  transition: color var(--t-fast);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { color: var(--blued); }
.faq summary::after {
  content: ""; flex: none; margin-inline-start: auto;
  width: 8px; height: 8px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform var(--t-med), border-color var(--t-fast);
}
.faq details[open] summary::after { border-color: var(--blued); transform: rotate(225deg) translate(-2px, -2px); }
.faq__body { padding: 0 clamp(18px, 2vw, 26px) 22px; color: var(--ink-soft); font-size: 15px; }
.faq__body > *:last-child { margin-bottom: 0; }

/* ---------- Callouts ---------- */
.callout {
  margin: 0 0 26px; padding: 4px 0 4px 20px;
  border-inline-start: 2px solid transparent;
  border-image: var(--grad) 1;
  color: var(--ink-soft); font-size: 15px;
}
.callout > *:last-child { margin-bottom: 0; }
.callout__title {
  margin-bottom: 5px; font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.callout--warn { border-image: linear-gradient(180deg, var(--brass), color-mix(in srgb, var(--brass) 30%, transparent)) 1; }
.callout--warn .callout__title { background: none; color: var(--brass); }

/* ---------- Steps ---------- */
.steps { list-style: none; counter-reset: step; margin: 0 0 26px; padding: 0; }
.steps > li {
  position: relative; counter-increment: step;
  padding-inline-start: 40px; margin-bottom: 20px;
  color: var(--ink-soft); font-size: 15.5px;
}
.steps > li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute; inset-inline-start: 0; top: 5px;
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: .06em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.steps > li > strong:first-child { display: block; margin-bottom: 2px; color: var(--ink); }
.steps > li > *:last-child { margin-bottom: 0; }

/* ---------- Link cards ---------- */
.cardgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(258px, 1fr)); }
.linkcard {
  display: flex; flex-direction: column; gap: 8px;
  padding: 24px; text-decoration: none; color: inherit;
  background: var(--plate);
  -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass);
  border: 1px solid var(--hairline-2); border-radius: var(--r-md);
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.linkcard:hover { border-color: var(--grad-1); background: var(--plate-hover); transform: translateY(-2px); }
.linkcard__title {
  font-family: var(--serif); font-size: 17.5px; font-weight: 600;
  letter-spacing: -.015em; color: var(--ink);
  display: flex; align-items: baseline; gap: 8px;
}
.linkcard__title::after { content: "\2192"; color: var(--blued); transition: transform var(--t-fast); }
.linkcard:hover .linkcard__title::after { transform: translateX(3px); }
.linkcard p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }

/* ---------- TOC ---------- */
.toc {
  margin-bottom: 34px; padding: 20px 24px;
  background: var(--plate-sunk); border: 1px solid var(--hairline-2); border-radius: var(--r-md);
}
.toc h2 {
  margin: 0 0 12px !important; font-family: var(--sans);
  font-size: 10px !important; font-weight: 700; letter-spacing: .22em;
  text-transform: uppercase; color: var(--muted);
}
.toc ol { margin: 0; padding-inline-start: 20px; font-size: 14px; }
.toc li { margin-bottom: 6px; }
.toc li::marker { font-family: var(--mono); font-size: 11px; color: var(--brass); }
.toc a { color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--blued); text-decoration: underline; }

/* ---------- Legal / prose pages ---------- */
.legal { max-width: var(--measure); margin-inline: 0; }
.legal h2 { font-size: clamp(20px, 2.2vw, 25px); margin-top: 2.4em; }
.legal h3 { font-size: 17px; }
.legal__updated {
  display: inline-block; margin-bottom: 30px; padding: 8px 14px;
  border: 1px solid var(--hairline-2); border-radius: 999px;
  background: var(--plate-sunk);
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--muted);
}

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block; margin-bottom: 8px;
  font-size: 10px; font-weight: 600; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted);
}
.field input, .field select, .field textarea {
  width: 100%; font-family: var(--sans); font-size: 15px; color: var(--ink);
  padding: 13px 15px; background: var(--plate-sunk);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.field textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--blued); box-shadow: 0 0 0 3px var(--blued-wash);
}
.field--mono input { font-family: var(--mono); }
.field__hint { margin: 8px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--muted); }

/* ---------- Sitemap page ---------- */
.sitemap-group { margin-bottom: 40px; }
.sitemap-group > h2 {
  margin: 0 0 18px; font-family: var(--sans); font-size: 10.5px; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase; color: var(--muted);
}
.sitemap-list { list-style: none; margin: 0; padding: 0; }
.sitemap-list li { position: relative; margin-bottom: 18px; padding-inline-start: 22px; }
.sitemap-list li::before {
  content: ""; position: absolute; inset-inline-start: 2px; top: 12px;
  width: 8px; height: 2px; border-radius: 2px; background: var(--grad);
}
.sitemap-list a { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: -.015em; color: var(--ink); text-decoration: none; }
.sitemap-list a:hover { color: var(--blued); }
.sitemap-list p { margin: 3px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--hairline-2);
  background: var(--ground-2);
  padding-block: clamp(48px, 6vw, 76px) 40px;
  margin-top: clamp(48px, 6vw, 80px);
  font-size: 14px;
}
.site-footer__grid {
  display: grid; gap: clamp(28px, 4vw, 60px);
  grid-template-columns: minmax(0, 1.7fr) repeat(3, minmax(0, 1fr));
  padding-bottom: 40px; border-bottom: 1px solid var(--hairline-2);
}
@media (max-width: 900px) { .site-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .site-footer__grid { grid-template-columns: minmax(0, 1fr); } }
.site-footer h2 {
  margin: 0 0 14px; font-family: var(--sans); font-size: 10px; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase; color: var(--muted);
}
.site-footer p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.6; max-width: 42ch; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.site-footer li { margin: 0; }
.site-footer a { color: var(--ink-soft); font-size: 13.5px; text-decoration: none; transition: color var(--t-fast); }
.site-footer a:hover { color: var(--blued); }
.site-footer__bottom {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: 14px 26px; margin-top: 30px; padding-top: 26px;
  border-top: 1px solid var(--hairline-2);
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--faint);
}
.footer-email {
  display: inline-block; align-self: start;
  font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere;
  color: var(--ink-soft); text-decoration: none;
  border-bottom: 1px solid var(--hairline-2); padding-bottom: 1px;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.footer-email:hover { color: var(--blued); border-color: var(--grad-1); }

.footer-legal { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.footer-legal a {
  font-family: var(--sans); font-size: 12.5px; letter-spacing: 0;
  color: var(--muted); text-decoration: none;
}
.footer-legal a:hover { color: var(--blued); }

/* ---------- Utilities ---------- */
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* Inline code must not force the page wide on a phone. It stays on one line
   where there is room, and breaks rather than overflowing where there is not. */
@media (max-width: 700px) {
  :not(pre) > code { white-space: normal; overflow-wrap: anywhere; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
@media print {
  .ambient, .site-header, .theme-toggle, .viz__controls { display: none !important; }
  body { background: #fff; color: #000; }
}

/* ---------- Diagrams ---------- */
.figure { margin: 0 0 30px; display: flex; flex-direction: column; gap: 14px; }
.figure-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
.figure svg { display: block; width: 100%; height: auto; }
.figure figcaption { color: var(--muted); font-size: 13.5px; line-height: 1.6; max-width: var(--measure); }
.figure figcaption b { color: var(--ink-soft); font-weight: 600; }

/* shared diagram primitives */
.d-surface   { fill: var(--plate-sunk); stroke: var(--hairline-2); }
.d-plate     { fill: var(--plate-solid); stroke: var(--hairline); }
.d-hair      { stroke: var(--hairline); fill: none; }
.d-wire      { stroke: var(--faint); fill: none; }
.d-arrow     { fill: var(--faint); }
.d-text      { fill: var(--ink); font-family: var(--mono); font-size: 15px; }
.d-text-sans { fill: var(--ink); font-family: var(--sans); font-size: 13px; font-weight: 600; }
.d-muted     { fill: var(--muted); font-family: var(--sans); font-size: 11.5px; }
.d-tag       { fill: var(--muted); font-family: var(--mono); font-size: 9.5px; letter-spacing: .16em; }
.d-brass     { fill: var(--brass); font-family: var(--mono); font-size: 10px; letter-spacing: .12em; }
.d-accent    { fill: var(--blued); }
.d-accent-s  { stroke: var(--blued); fill: none; }
.d-operand   { fill: var(--tok-operand); font-family: var(--mono); font-size: 15px; font-weight: 600; }
.d-operator  { fill: var(--tok-operator); font-family: var(--mono); font-size: 15px; font-weight: 600; }
.d-paren     { fill: var(--tok-paren); font-family: var(--mono); font-size: 15px; font-weight: 600; }
.d-operand-c  { fill: color-mix(in srgb, var(--tok-operand) 13%, transparent);  stroke: color-mix(in srgb, var(--tok-operand) 40%, transparent); }
.d-operator-c { fill: color-mix(in srgb, var(--tok-operator) 13%, transparent); stroke: color-mix(in srgb, var(--tok-operator) 40%, transparent); }
.d-accent-c   { fill: var(--blued-wash); stroke: var(--blued); }
.figure svg text { font-family: var(--mono); }
.figure svg text.d-muted, .figure svg text.d-text-sans { font-family: var(--sans); }
.d-mid { text-anchor: middle; }
.d-end { text-anchor: end; }

/* ---------- Site search ---------- */
.search-btn {
  flex: none; width: 42px; height: 42px; margin-left: -4px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--plate-sunk); border: 1px solid var(--hairline-2);
  border-radius: var(--r-sm); color: var(--muted); cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.search-btn:hover { color: var(--ink); border-color: var(--grad-1); }
.search-btn svg { width: 16px; height: 16px; display: block; }

.search-veil {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(3, 5, 9, .62);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.search-panel {
  position: fixed; z-index: 61; top: 84px; left: 50%; transform: translateX(-50%);
  width: min(620px, calc(100vw - 28px));
  background: var(--plate-solid); border: 1px solid var(--hairline);
  border-radius: var(--r-md); box-shadow: var(--shadow-plate), var(--shadow-lift);
  display: flex; flex-direction: column; overflow: hidden;
}
.search-box { display: flex; align-items: center; gap: 11px; padding: 4px 14px; border-bottom: 1px solid var(--hairline-2); }
.search-box .search-glyph { color: var(--muted); flex: none; width: 17px; height: 17px; }
.search-panel input[type="search"] {
  flex: 1; min-width: 0; appearance: none; -webkit-appearance: none;
  background: none; border: 0; outline: none;
  font-family: var(--sans); font-size: 16px; color: var(--ink); padding: 15px 0;
}
.search-panel input::placeholder { color: var(--faint); }
.search-panel input::-webkit-search-cancel-button { display: none; }
.search-hint {
  flex: none; font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  color: var(--faint); border: 1px solid var(--hairline-2);
  border-radius: 5px; padding: 3px 6px;
}
.search-results { list-style: none; margin: 0; padding: 6px; max-height: min(56vh, 420px); overflow-y: auto; }
.search-results li { margin: 0; }
.search-results a {
  display: block; padding: 10px 12px; border-radius: var(--r-sm);
  text-decoration: none; color: inherit;
}
.search-results a:hover, .search-results a.is-active { background: var(--blued-wash); }
.search-results a.is-active { box-shadow: inset 2px 0 0 var(--blued); }
.sr-title { font-size: 14.5px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.sr-page {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--brass); margin-top: 3px;
}
.sr-snip {
  font-size: 12.5px; color: var(--muted); line-height: 1.5; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sr-title mark, .sr-snip mark { background: none; color: var(--blued); font-weight: 600; }
.search-empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.search-foot {
  display: flex; gap: 16px; padding: 9px 14px; border-top: 1px solid var(--hairline-2);
  font-family: var(--mono); font-size: 10px; letter-spacing: .06em; color: var(--faint);
}
@media (max-width: 620px) {
  .search-panel { top: 62px; }
  .search-hint, .search-foot { display: none; }
}

/* ---------- Practice quiz ---------- */
.quiz-bar {
  position: sticky; top: 76px; z-index: 20;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 26px; padding: 14px 18px;
  background: var(--plate); -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass);
  border: 1px solid var(--hairline-2); border-radius: var(--r-md);
}
.quiz-bar__stat { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.quiz-bar__stat b { color: var(--ink); font-size: 15px; }
.quiz-bar__track { flex: 1 1 120px; min-width: 90px; height: 5px; border-radius: 3px; background: var(--hairline-2); overflow: hidden; }
.quiz-bar__track i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 3px; transition: width .25s var(--ease); }

.quiz-list { list-style: none; margin: 0 0 30px; padding: 0; }
.quiz-q {
  margin-bottom: 14px; padding: 18px 20px;
  background: var(--plate); -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass);
  border: 1px solid var(--hairline-2); border-radius: var(--r-md);
  transition: border-color var(--t-fast);
}
.quiz-q[data-state="right"] { border-color: color-mix(in srgb, var(--tok-operand) 55%, transparent); }
.quiz-q[data-state="wrong"] { border-color: color-mix(in srgb, var(--critical) 45%, transparent); }
.quiz-ask { margin: 0 0 12px; font-size: 15px; color: var(--ink); }
.quiz-ask b { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; color: var(--brass); margin-right: 8px; }
.quiz-form { display: flex; gap: 9px; flex-wrap: wrap; }
.quiz-input {
  flex: 1 1 240px; min-width: 0;
  font-family: var(--mono); font-size: 15px; color: var(--ink);
  padding: 11px 14px; background: var(--plate-sunk);
  border: 1px solid var(--hairline); border-radius: var(--r-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.quiz-input::placeholder { color: var(--faint); }
.quiz-input:focus { outline: none; border-color: var(--blued); box-shadow: 0 0 0 3px var(--blued-wash); }
.quiz-verdict {
  margin: 12px 0 0; padding: 10px 13px; border-radius: var(--r-sm);
  font-size: 13.5px; font-family: var(--mono);
}
.quiz-verdict--right { color: var(--tok-operand); background: color-mix(in srgb, var(--tok-operand) 10%, transparent); }
.quiz-verdict--wrong { color: var(--critical);    background: color-mix(in srgb, var(--critical) 10%, transparent); }
.quiz-verdict--idle  { color: var(--muted);       background: var(--plate-sunk); }
.quiz-q details { margin-top: 12px; }
.quiz-q summary {
  cursor: pointer; font-size: 13px; color: var(--muted); list-style: none;
  font-family: var(--sans);
}
.quiz-q summary::-webkit-details-marker { display: none; }
.quiz-q summary:hover { color: var(--blued); }
.quiz-q summary::before { content: "▸ "; }
.quiz-q details[open] summary::before { content: "▾ "; }
@media (max-width: 620px) { .quiz-bar { top: 66px; } }

/* ---------- Navigation ---------- */
.nav-top {
  display: inline-flex; align-items: center;
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  padding: 8px 2px; transition: color var(--t-fast);
}
.nav-top:hover { color: var(--ink); }
.nav-top[aria-current="page"] { color: var(--blued); }

.nav-burger {
  display: none; width: 42px; height: 42px; flex: none;
  align-items: center; justify-content: center;
  background: var(--plate-sunk); border: 1px solid var(--hairline-2);
  border-radius: var(--r-sm); color: var(--ink); cursor: pointer;
}
.nav-burger:hover { border-color: var(--grad-1); }
.nav-burger svg { width: 18px; height: 18px; }

/* Below 860px the links move into a panel — none of them are dropped,
   which the previous nav used to do. */
@media (max-width: 860px) {
  .nav-burger { display: inline-flex; }
  .nav { gap: 8px; }
  .nav > .nav-top { display: none; }
  .nav.is-open {
    position: absolute; top: 72px; right: var(--gutter); left: var(--gutter);
    flex-direction: column; align-items: stretch; gap: 2px; padding: 10px;
    background: var(--plate-solid); border: 1px solid var(--hairline);
    border-radius: var(--r-md); box-shadow: var(--shadow-plate), var(--shadow-lift);
  }
  .nav.is-open > .nav-top {
    display: block; width: 100%; padding: 12px;
    border-radius: var(--r-sm); font-size: 15px;
  }
  .nav.is-open > .nav-top:hover { background: var(--blued-wash); }
  .nav.is-open .search-btn, .nav.is-open .theme-toggle { display: none; }
}

/* ---------- Video ---------- */
.video-wrap {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-plate);
  border: 1px solid var(--hairline);
  background: #000;
}
.video-player {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--r-lg);
}

/* ---------- Expression history ---------- */
.history-tray {
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--plate);
  -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-md);
  animation: fadeSlideIn .25s var(--ease);
}
.history-tray__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.history-tray__label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.history-tray__clear {
  background: none; border: 0; cursor: pointer;
  font-family: var(--sans); font-size: 12px; color: var(--faint);
  transition: color var(--t-fast);
}
.history-tray__clear:hover { color: var(--critical); }
.history-tray__list {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.history-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--plate-sunk);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  cursor: pointer;
  font-family: var(--mono); font-size: 12.5px;
  color: var(--ink-soft);
  transition: border-color var(--t-fast), background var(--t-fast);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-chip:hover {
  border-color: var(--blued);
  background: var(--blued-wash);
}
.history-chip__infix { color: var(--ink); }
.history-chip__arrow { color: var(--faint); font-size: 11px; }
.history-chip__postfix { color: var(--tok-operand); }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Expression tree ---------- */
.tree-wrap {
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--plate);
  -webkit-backdrop-filter: var(--glass); backdrop-filter: var(--glass);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-md);
}
.tree-wrap__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.tree-wrap__title {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
  margin: 0;
}
.tree-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.tree-svg line {
  stroke: var(--hairline);
  stroke-width: 1.5;
}
.tree-svg circle {
  transition: fill .2s var(--ease), stroke .2s var(--ease);
}
.tree-svg text {
  font-family: var(--mono);
  font-size: 13px;
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.tree-legend {
  display: flex; gap: 16px; margin-top: 10px;
  font-size: 11px; color: var(--muted); font-family: var(--sans);
}
.tree-legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  margin-right: 5px; vertical-align: -1px;
}
.tree-legend .tl-operand { background: var(--tok-operand); }
.tree-legend .tl-operator { background: var(--tok-operator); }

/* ---------- Print ---------- */
@media print {
  /* Hide everything non-essential */
  .ambient, .skip-link, .site-header, .site-footer,
  .breadcrumbs, .nav, .search-btn, .theme-toggle, .nav-burger,
  .search-veil, .search-panel,
  .examples, .error-box, .copy-btn, #clear-btn,
  .history-tray, .video-wrap, video,
  .quiz-bar, .quiz-form, .quiz-verdict,
  .btn, .btn--ghost, .chip,
  .callout, .toc,
  .section--alt, .linkcard,
  .cardgrid, [hidden] { display: none !important; }

  /* Reset backgrounds and colors */
  :root, :root[data-theme="light"] {
    --ground: #fff;
    --ground-2: #fff;
    --ink: #000;
    --ink-soft: #222;
    --muted: #555;
    --faint: #999;
    --hairline: #ccc;
    --hairline-2: #ddd;
    --plate: transparent;
    --plate-solid: #fff;
    --plate-sunk: #f5f5f5;
    --blued: #0044cc;
    --tok-operand: #006644;
    --tok-operator: #884400;
    --tok-paren: #4400aa;
    --orb-opacity: 0;
    color-scheme: light;
  }

  body {
    background: #fff; color: #222;
    font-size: 11pt; line-height: 1.5;
  }

  .wrap { max-width: 100%; padding-inline: 0; }
  .card { border: 1px solid #ddd; box-shadow: none; }

  /* Tables should be readable on paper */
  table { border-collapse: collapse; width: 100%; page-break-inside: avoid; }
  th, td { border: 1px solid #ccc; padding: 4px 8px; font-size: 10pt; }
  thead { background: #f0f0f0; }

  /* Code blocks */
  pre, code { font-size: 9pt; }
  pre { border: 1px solid #ccc; padding: 8px; page-break-inside: avoid; }

  /* Page breaks */
  h2, h3 { page-break-after: avoid; }
  .trace-table { page-break-inside: auto; }
  .trace-table tr { page-break-inside: avoid; }

  /* Don't underline links */
  a { color: #000; text-decoration: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #666; }
  a[href^="/"]::after { content: none; }
}

/* ---------- Floating copy buttons on bare code blocks ---------- */
pre.has-copy { position: relative; }
.copy-float {
  position: absolute; top: 8px; right: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast);
}
pre.has-copy:hover .copy-float,
pre.has-copy:focus-within .copy-float { opacity: 1; pointer-events: auto; }
/* Touch devices get no hover, so keep it visible there. */
@media (hover: none) {
  .copy-float { opacity: .85; pointer-events: auto; }
}

/* ---------- Back to top ---------- */
.to-top {
  position: fixed; right: clamp(12px, 2.5vw, 26px); bottom: clamp(12px, 2.5vw, 26px);
  z-index: 40; width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--plate-solid); color: var(--ink);
  border: 1px solid var(--hairline-2); border-radius: 50%;
  box-shadow: var(--shadow-lift); cursor: pointer;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast), border-color var(--t-fast);
}
.to-top.is-on { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { border-color: var(--grad-1); }
.to-top svg { width: 18px; height: 18px; }
@media print { .to-top, .copy-float { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  .to-top { transition: opacity var(--t-fast), visibility var(--t-fast); transform: none; }
}

/* ---------- Keyboard hint badges ---------- */
.kbd-hint {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.6em; margin-left: 8px; padding: 2px 5px;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.4; font-weight: 500;
  color: var(--faint); background: var(--plate-sunk);
  border: 1px solid var(--hairline-2); border-radius: 4px;
  white-space: nowrap;
}
.btn .kbd-hint { color: inherit; opacity: .62; background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.22); }
.btn--ghost .kbd-hint { background: var(--plate-sunk); border-color: var(--hairline-2); }
.search-btn { position: relative; }
.kbd-hint--search { position: absolute; right: calc(100% + 6px); margin: 0; }
/* Hide the badges wherever they would crowd the control. */
@media (max-width: 1100px) { .kbd-hint--search { display: none; } }
@media (max-width: 560px) { .kbd-hint { display: none; } }
@media (hover: none) { .kbd-hint { display: none; } }
@media print { .kbd-hint { display: none !important; } }

/* ---------- Reveal on appear ---------- */
@keyframes ipc-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.results:not([hidden]),
.tree-wrap:not([hidden]),
.history-tray:not([hidden]) { animation: ipc-rise .28s cubic-bezier(.22,.61,.36,1) both; }
.trace-table tbody tr { animation: ipc-rise .22s ease-out both; }
.trace-table tbody tr:nth-child(1) { animation-delay: .01s; }
.trace-table tbody tr:nth-child(2) { animation-delay: .03s; }
.trace-table tbody tr:nth-child(3) { animation-delay: .05s; }
.trace-table tbody tr:nth-child(4) { animation-delay: .07s; }
.trace-table tbody tr:nth-child(5) { animation-delay: .09s; }
.trace-table tbody tr:nth-child(n+6) { animation-delay: .11s; }
@media (prefers-reduced-motion: reduce) {
  .results:not([hidden]), .tree-wrap:not([hidden]),
  .history-tray:not([hidden]), .trace-table tbody tr { animation: none; }
}
@media print { .trace-table tbody tr, .results, .tree-wrap { animation: none !important; } }

/* ---------- Compare all three notations ---------- */
.compare {
  margin-top: 18px; padding: 16px 18px;
  background: var(--plate); border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.compare__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.compare__title { font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--ink); }
.compare__body { margin-top: 16px; }
.compare-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .compare-grid { grid-template-columns: 1fr; } }
.compare-col {
  position: relative; min-width: 0; padding: 12px 14px;
  background: var(--plate-sunk); border: 1px solid var(--hairline-2);
  border-radius: var(--r-sm);
}
.compare-col--lead { border-color: var(--blued); }
.compare-col__label {
  display: block; font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 7px;
}
.compare-col__note { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--faint); }
.compare-col__value {
  display: block; font-family: var(--mono); font-size: 15px; color: var(--ink);
  overflow-wrap: anywhere; padding-right: 60px; min-height: 1.4em;
}
.compare-col .copy-btn { position: absolute; top: 10px; right: 10px; }
.compare-eval { margin: 12px 0 0; }
.compare-steps { margin-top: 14px; }
.compare-steps summary {
  cursor: pointer; font-family: var(--sans); font-size: 13px; color: var(--blued);
}
.compare-steps__list { margin: 10px 0 0; padding-left: 20px; font-size: 13.5px; color: var(--ink-soft); }
.compare-steps__list li { margin-bottom: 7px; }
.compare-steps__list .mono {
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  overflow-wrap: anywhere;
}
@media print { .compare__head .btn { display: none !important; } }

/* ---------- Timed drill ---------- */
.drill {
  margin: 18px 0 26px; padding: 18px 20px;
  background: var(--plate); border: 1px solid var(--blued);
  border-radius: var(--r-md);
}
.drill__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.drill__title { margin: 0; font-size: 17px; }
.drill__durations { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 16px; }
.drill__durations .chip.is-on { border-color: var(--blued); color: var(--ink); background: var(--blued-wash); }
.drill__meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.drill__clock {
  font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.drill__clock.is-low { color: #e0574a; }
.drill__score { font-size: 13px; color: var(--muted); }
.drill__track { flex: 1 1 120px; height: 5px; min-width: 90px; background: var(--plate-sunk); border-radius: 3px; overflow: hidden; }
.drill__track i { display: block; height: 100%; width: 0; background: var(--grad-1); transition: width 1s linear; }
.drill__ask { font-size: 16px; margin: 0 0 12px; color: var(--ink); }
.drill__form { display: flex; gap: 8px; flex-wrap: wrap; }
.drill__form .quiz-input { flex: 1 1 240px; min-width: 0; }
.drill__verdict { margin: 12px 0 0; font-size: 14px; font-family: var(--mono); }
.drill__verdict.is-right { color: #2f9e6d; }
.drill__verdict.is-wrong { color: #e0574a; }
.drill__final { font-size: 17px; color: var(--ink); margin: 0 0 12px; }
.drill__missed { margin: 8px 0 18px; padding-left: 20px; font-size: 13.5px; line-height: 1.9; }
@media (max-width: 520px) {
  .drill { padding: 14px; }
  .drill__clock { font-size: 19px; }
}
@media print { .drill, #drill-start { display: none !important; } }

/* ---------- Classroom / exam mode (?mode=exam) ---------- */
.exam-mode .site-header,
.exam-mode .site-footer,
.exam-mode .breadcrumbs,
.exam-mode .ambient,
.exam-mode .to-top,
.exam-mode .compare,
.exam-mode .history-tray,
.exam-mode .section,
.exam-mode .cardgrid,
.exam-mode .toc,
.exam-mode .faq,
.exam-mode .linkcard { display: none !important; }
/* Keep the tool, its results and the hero heading. */
.exam-mode .hero { padding-block: 26px 10px; }
.exam-mode .hero .eyebrow { display: none; }
.exam-mode .tool { margin-bottom: 40px; }
.exam-mode .examples { opacity: .8; }

.exam-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px clamp(14px, 4vw, 28px);
  background: var(--blued-wash); border-bottom: 1px solid var(--hairline);
  font-family: var(--sans); font-size: 12.5px; color: var(--muted);
}
.exam-bar__exit { color: var(--blued); text-decoration: none; font-weight: 600; }
.exam-bar__exit:hover { text-decoration: underline; }
@media print { .exam-bar { display: none !important; } }

/* ---------- Cheat sheet ---------- */
.cheat-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.cheat { display: grid; gap: 16px; padding-bottom: 40px; }
.cheat-card {
  padding: 20px 22px;
  background: var(--plate); border: 1px solid var(--hairline);
  border-radius: var(--r-md);
}
.cheat-card h2 { margin: 0 0 12px; font-size: 17px; }
.cheat-card .trace-table { margin-top: 10px; }
.cheat-rules { margin: 0; padding-left: 22px; line-height: 1.85; color: var(--ink-soft); }
.cheat-rules li { margin-bottom: 6px; }
.cheat-rules b, .cheat-mistakes b { color: var(--ink); }
.cheat-mistakes { margin: 0; padding-left: 22px; line-height: 1.8; color: var(--ink-soft); }
.cheat-mistakes li { margin-bottom: 9px; }
.cheat-examples code { white-space: nowrap; }
.cheat-foot { text-align: center; margin: 6px 0 0; }

/* The whole point of this page is that it prints well. */
@media print {
  .cheat-actions, #cheat-print { display: none !important; }
  .cheat { gap: 10px; }
  .cheat-card {
    padding: 10px 12px; border: 1px solid #ccc;
    break-inside: avoid; page-break-inside: avoid;
  }
  .cheat-card h2 { font-size: 12pt; margin-bottom: 6px; }
  .cheat-rules, .cheat-mistakes { line-height: 1.45; font-size: 9.5pt; }
  .cheat-rules li, .cheat-mistakes li { margin-bottom: 2px; }
  .hero { padding-block: 0 8px !important; }
  .hero h1 { font-size: 17pt; }
  .hero__lede { font-size: 9.5pt; }
}

/* ---------- Guided walkthrough ---------- */
.tour-on { overflow: hidden; }
.tour-veil {
  position: fixed; inset: 0; z-index: 90;
  /* A huge spread shadow around the cut-out is what dims everything else. */
  background: transparent;
  box-shadow: 0 0 0 9999px rgba(4, 6, 10, .74);
  border-radius: 10px;
  top: var(--y, 0); left: var(--x, 0);
  width: var(--w, 0); height: var(--h, 0);
  inset: auto;
  outline: 2px solid var(--grad-1);
  transition: top .22s ease, left .22s ease, width .22s ease, height .22s ease;
  pointer-events: none;
}
.tour-box {
  position: fixed; z-index: 91; width: min(360px, calc(100vw - 20px));
  padding: 18px 20px;
  background: var(--plate-solid); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: var(--r-md);
  box-shadow: var(--shadow-plate), var(--shadow-lift);
}
.tour-step {
  margin: 0 0 6px; font-family: var(--sans); font-size: 11px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase; color: var(--faint);
}
.tour-title { margin: 0 0 8px; font-size: 17px; line-height: 1.25; }
.tour-text { margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: var(--ink-soft); }
.tour-text b { color: var(--ink); font-family: var(--mono); font-size: 13.5px; }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-actions .btn:disabled { opacity: .4; cursor: not-allowed; }
.tour-skip {
  margin-left: auto; background: none; border: 0; cursor: pointer;
  font-family: var(--sans); font-size: 12.5px; color: var(--faint);
}
.tour-skip:hover { color: var(--ink); text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .tour-veil { transition: none; } }
@media print { .tour-veil, .tour-box, #tour-start { display: none !important; } }

/* ---------- Lazy rendering of off-screen sections ----------
   The browser skips layout and paint for sections below the fold until they
   are near the viewport. contain-intrinsic-size supplies a placeholder height
   so the scrollbar does not jump as they are realised. Only applied to blocks
   that are always long and always below the first screen. */
.section,
.faq details,
.cheat-card,
.codeblock {
  content-visibility: auto;
}
.section { contain-intrinsic-size: auto 600px; }
.faq details { contain-intrinsic-size: auto 60px; }
.cheat-card { contain-intrinsic-size: auto 320px; }
.codeblock { contain-intrinsic-size: auto 400px; }

/* The hero, the tool and anything on the first screen must render immediately,
   and printing must never skip content. */
.hero, .tool, .site-header { content-visibility: visible; }
@media print {
  .section, .faq details, .cheat-card, .codeblock { content-visibility: visible; }
}

/* ---------- Page date ---------- */
.breadcrumbs { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-date {
  margin: 0; flex: none;
  font-family: var(--sans); font-size: 12px; color: var(--faint);
}
.page-date time { color: var(--muted); }
@media (max-width: 520px) { .page-date { font-size: 11.5px; } }

/* ---------- Sharing ----------
   Brand glyphs are CSS masks rather than <img>, so they take currentColor and
   work in both themes without shipping two copies of every icon. No platform
   SDK is loaded: these are plain links. */
.share {
  margin: 46px auto 8px;
  padding-top: 26px;
  border-top: 1px solid var(--hairline);
}
.share__title {
  margin: 0 0 14px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  color: var(--muted);
}
.share__row { display: flex; flex-wrap: wrap; gap: 8px; }
.share__btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--muted); text-decoration: none;
  background: var(--plate-sunk);
  border: 1px solid var(--hairline-2); border-radius: var(--r-sm);
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.share__btn:hover { color: var(--ink); border-color: var(--grad-1); }
.share__btn svg { width: 15px; height: 15px; flex: none; }
.share__icon {
  width: 15px; height: 15px; flex: none;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-size: contain; mask-size: contain;
}
.share__btn--copy.is-done { color: var(--blued); border-color: var(--blued); }
.share__btn--native { order: -1; }

@media (max-width: 520px) {
  .share__name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .share__btn--copy .share__name, .share__btn--native span { position: static; width: auto; height: auto; clip: auto; }
  .share__btn { padding: 10px 13px; }
}
@media print { .share { display: none !important; } }

.share__icon[data-icon="x"] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M18.9%201.2h3.7l-8%209.2L24%2022.8h-7.4l-5.8-7.6-6.6%207.6H.5l8.6-9.8L0%201.2h7.6l5.2%206.9%206.1-6.9Zm-1.3%2019.4h2L6.5%203.3H4.3l13.3%2017.3Z%22%2F%3E%3C%2Fsvg%3E"); mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M18.9%201.2h3.7l-8%209.2L24%2022.8h-7.4l-5.8-7.6-6.6%207.6H.5l8.6-9.8L0%201.2h7.6l5.2%206.9%206.1-6.9Zm-1.3%2019.4h2L6.5%203.3H4.3l13.3%2017.3Z%22%2F%3E%3C%2Fsvg%3E"); }
.share__icon[data-icon="whatsapp"] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M17.5%2014.4c-.3-.1-1.8-.9-2-1-.3-.1-.5-.1-.7.1-.2.3-.7%201-.9%201.2-.2.2-.3.2-.6.1-.3-.1-1.2-.5-2.3-1.4-.9-.8-1.4-1.7-1.6-2-.2-.3%200-.5.1-.6l.5-.5c.1-.2.2-.3.3-.5%200-.2%200-.4%200-.5%200-.1-.7-1.6-.9-2.2-.2-.6-.5-.5-.7-.5h-.6c-.2%200-.5.1-.8.4-.3.3-1%201-1%202.5s1.1%202.9%201.2%203.1c.1.2%202.1%203.2%205.1%204.5.7.3%201.3.5%201.7.6.7.2%201.4.2%201.9.1.6-.1%201.8-.7%202-1.5.3-.7.3-1.4.2-1.5-.1-.1-.3-.2-.6-.3zM12%200C5.4%200%200%205.4%200%2012c0%202.1.6%204.2%201.6%206L0%2024l6.2-1.6c1.7%201%203.7%201.5%205.8%201.5%206.6%200%2012-5.4%2012-12S18.6%200%2012%200zm0%2021.8c-1.9%200-3.7-.5-5.3-1.5l-.4-.2-3.7%201%201-3.6-.2-.4c-1-1.6-1.6-3.5-1.6-5.5C1.8%206.4%206.4%201.8%2012%201.8S22.2%206.4%2022.2%2012%2017.6%2021.8%2012%2021.8z%22%2F%3E%3C%2Fsvg%3E"); mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M17.5%2014.4c-.3-.1-1.8-.9-2-1-.3-.1-.5-.1-.7.1-.2.3-.7%201-.9%201.2-.2.2-.3.2-.6.1-.3-.1-1.2-.5-2.3-1.4-.9-.8-1.4-1.7-1.6-2-.2-.3%200-.5.1-.6l.5-.5c.1-.2.2-.3.3-.5%200-.2%200-.4%200-.5%200-.1-.7-1.6-.9-2.2-.2-.6-.5-.5-.7-.5h-.6c-.2%200-.5.1-.8.4-.3.3-1%201-1%202.5s1.1%202.9%201.2%203.1c.1.2%202.1%203.2%205.1%204.5.7.3%201.3.5%201.7.6.7.2%201.4.2%201.9.1.6-.1%201.8-.7%202-1.5.3-.7.3-1.4.2-1.5-.1-.1-.3-.2-.6-.3zM12%200C5.4%200%200%205.4%200%2012c0%202.1.6%204.2%201.6%206L0%2024l6.2-1.6c1.7%201%203.7%201.5%205.8%201.5%206.6%200%2012-5.4%2012-12S18.6%200%2012%200zm0%2021.8c-1.9%200-3.7-.5-5.3-1.5l-.4-.2-3.7%201%201-3.6-.2-.4c-1-1.6-1.6-3.5-1.6-5.5C1.8%206.4%206.4%201.8%2012%201.8S22.2%206.4%2022.2%2012%2017.6%2021.8%2012%2021.8z%22%2F%3E%3C%2Fsvg%3E"); }
.share__icon[data-icon="reddit"] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M24%2011.8a3.4%203.4%200%200%200-5.8-2.4%2016.7%2016.7%200%200%200-9-2.9l1.5-7.2%205%201.1a2.4%202.4%200%201%200%20.3-1.7l-5.6-1.2a.9.9%200%200%200-1%20.7L7.7%206.5a16.7%2016.7%200%200%200-9%202.9A3.4%203.4%200%201%200%202.2%2015a6.7%206.7%200%200%200-.1%201c0%205%205.8%209.1%2013%209.1s13-4.1%2013-9.1a6.7%206.7%200%200%200-.1-1%203.4%203.4%200%200%200%201.9-3.1zM6.7%2014.2a2.4%202.4%200%201%201%202.4%202.4%202.4%202.4%200%200%201-2.4-2.4zm10.8%205.1a8.6%208.6%200%200%201-5.5%201.7%208.6%208.6%200%200%201-5.5-1.7.7.7%200%200%201%20.9-1%207.2%207.2%200%200%200%204.6%201.3%207.2%207.2%200%200%200%204.6-1.3.7.7%200%201%201%20.9%201zm-.6-2.7a2.4%202.4%200%201%201%202.4-2.4%202.4%202.4%200%200%201-2.4%202.4z%22%2F%3E%3C%2Fsvg%3E"); mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M24%2011.8a3.4%203.4%200%200%200-5.8-2.4%2016.7%2016.7%200%200%200-9-2.9l1.5-7.2%205%201.1a2.4%202.4%200%201%200%20.3-1.7l-5.6-1.2a.9.9%200%200%200-1%20.7L7.7%206.5a16.7%2016.7%200%200%200-9%202.9A3.4%203.4%200%201%200%202.2%2015a6.7%206.7%200%200%200-.1%201c0%205%205.8%209.1%2013%209.1s13-4.1%2013-9.1a6.7%206.7%200%200%200-.1-1%203.4%203.4%200%200%200%201.9-3.1zM6.7%2014.2a2.4%202.4%200%201%201%202.4%202.4%202.4%202.4%200%200%201-2.4-2.4zm10.8%205.1a8.6%208.6%200%200%201-5.5%201.7%208.6%208.6%200%200%201-5.5-1.7.7.7%200%200%201%20.9-1%207.2%207.2%200%200%200%204.6%201.3%207.2%207.2%200%200%200%204.6-1.3.7.7%200%201%201%20.9%201zm-.6-2.7a2.4%202.4%200%201%201%202.4-2.4%202.4%202.4%200%200%201-2.4%202.4z%22%2F%3E%3C%2Fsvg%3E"); }
.share__icon[data-icon="linkedin"] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M20.4%2020.5h-3.6v-5.6c0-1.3%200-3-1.9-3s-2.1%201.4-2.1%202.9v5.7H9.4V9h3.4v1.6h.1a3.8%203.8%200%200%201%203.4-1.9c3.6%200%204.3%202.4%204.3%205.5v6.3zM5.3%207.4a2.1%202.1%200%201%201%202.1-2.1%202.1%202.1%200%200%201-2.1%202.1zm1.8%2013.1H3.5V9h3.6v11.5zM22.2%200H1.8A1.8%201.8%200%200%200%200%201.8v20.4A1.8%201.8%200%200%200%201.8%2024h20.4a1.8%201.8%200%200%200%201.8-1.8V1.8A1.8%201.8%200%200%200%2022.2%200z%22%2F%3E%3C%2Fsvg%3E"); mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M20.4%2020.5h-3.6v-5.6c0-1.3%200-3-1.9-3s-2.1%201.4-2.1%202.9v5.7H9.4V9h3.4v1.6h.1a3.8%203.8%200%200%201%203.4-1.9c3.6%200%204.3%202.4%204.3%205.5v6.3zM5.3%207.4a2.1%202.1%200%201%201%202.1-2.1%202.1%202.1%200%200%201-2.1%202.1zm1.8%2013.1H3.5V9h3.6v11.5zM22.2%200H1.8A1.8%201.8%200%200%200%200%201.8v20.4A1.8%201.8%200%200%200%201.8%2024h20.4a1.8%201.8%200%200%200%201.8-1.8V1.8A1.8%201.8%200%200%200%2022.2%200z%22%2F%3E%3C%2Fsvg%3E"); }
.share__icon[data-icon="facebook"] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M24%2012.07C24%205.4%2018.63%200%2012%200S0%205.4%200%2012.07C0%2018.1%204.39%2023.1%2010.13%2024v-8.44H7.08v-3.49h3.05V9.41c0-3.02%201.79-4.69%204.53-4.69%201.31%200%202.68.24%202.68.24v2.97h-1.51c-1.49%200-1.96.93-1.96%201.89v2.25h3.33l-.53%203.49h-2.8V24C19.61%2023.1%2024%2018.1%2024%2012.07z%22%2F%3E%3C%2Fsvg%3E"); mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M24%2012.07C24%205.4%2018.63%200%2012%200S0%205.4%200%2012.07C0%2018.1%204.39%2023.1%2010.13%2024v-8.44H7.08v-3.49h3.05V9.41c0-3.02%201.79-4.69%204.53-4.69%201.31%200%202.68.24%202.68.24v2.97h-1.51c-1.49%200-1.96.93-1.96%201.89v2.25h3.33l-.53%203.49h-2.8V24C19.61%2023.1%2024%2018.1%2024%2012.07z%22%2F%3E%3C%2Fsvg%3E"); }
.share__icon[data-icon="email"] { -webkit-mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M20%204H4a2%202%200%200%200-2%202v12a2%202%200%200%200%202%202h16a2%202%200%200%200%202-2V6a2%202%200%200%200-2-2Zm0%204.2-8%205-8-5V6l8%205%208-5Z%22%2F%3E%3C%2Fsvg%3E"); mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20d%3D%22M20%204H4a2%202%200%200%200-2%202v12a2%202%200%200%200%202%202h16a2%202%200%200%200%202-2V6a2%202%200%200%200-2-2Zm0%204.2-8%205-8-5V6l8%205%208-5Z%22%2F%3E%3C%2Fsvg%3E"); }

/* ---------- Table of contents as a sidebar ----------
   The markup does not change: the same nav.toc that reads inline on a phone
   moves into the margin when the viewport can hold it without squeezing the
   measure. 1240px is where 660px of prose plus a 230px rail plus gutters fit
   with room to spare; below that it stays exactly as it was. */
@media (min-width: 1240px) {
  /* Three tracks, with equal side tracks, so the reading column lands in
     exactly the same place as on a page that has no TOC. The rail sits in the
     left margin rather than pushing the text across. */
  .wrap.prose.prose--center:has(> .toc) {
    display: grid;
    grid-template-columns: 1fr minmax(0, var(--column)) 1fr;
    column-gap: 0;
    max-width: none;
  }
  .wrap.prose.prose--center:has(> .toc) > * {
    grid-column: 2;
    margin-inline: 0;
    max-width: var(--column);
  }
  .wrap.prose.prose--center > .toc {
    grid-column: 1;
    grid-row: 1 / -1;          /* span the article so sticky has room to travel */
    justify-self: end;
    align-self: start;
    position: sticky;
    top: 88px;
    width: 232px;
    margin-right: 48px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin-bottom: 0;
    padding: 4px 4px 4px 18px;
    background: none;
    border: 0;
    border-left: 1px solid var(--hairline-2);
    border-radius: 0;
  }
  .toc ol { font-size: 13px; }
  .toc li { margin-bottom: 9px; line-height: 1.45; }

  /* Scroll-spy state, set by toc.js. */
  .toc a.is-current { color: var(--blued); font-weight: 600; }
  .toc li:has(> a.is-current)::marker { color: var(--blued); }

  .wrap.prose.prose--center > .toc::-webkit-scrollbar { width: 6px; }
  .wrap.prose.prose--center > .toc::-webkit-scrollbar-thumb {
    background: var(--hairline-2); border-radius: 3px;
  }
}

/* Browsers without :has() simply keep the inline TOC, which is why the rules
   above are scoped to it rather than restructuring the markup. */
@media print {
  .toc { position: static !important; max-height: none !important; }
}

/* ---------- Consent ----------
   A bar at the bottom rather than a modal: it must be impossible to miss and
   equally possible to ignore, and it must never cover the tool. Allow and
   Decline are the same size, because a choice weighted towards one answer is
   not really a choice. */
.consent {
  position: fixed; inset: auto 0 0 0; z-index: 80;
  background: var(--plate-solid);
  border-top: 1px solid var(--hairline);
  box-shadow: 0 -8px 30px rgba(0,0,0,.28);
  animation: ipc-rise .3s cubic-bezier(.22,.61,.36,1) both;
}
.consent__inner {
  max-width: 1100px; margin: 0 auto;
  padding: 16px clamp(14px, 4vw, 28px);
  display: flex; align-items: center; gap: clamp(14px, 3vw, 34px);
  flex-wrap: wrap;
}
.consent__text { flex: 1 1 420px; min-width: 0; }
.consent__title {
  margin: 0 0 4px; font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--ink);
}
.consent__text p:last-child {
  margin: 0; font-size: 13px; line-height: 1.55; color: var(--muted);
}
.consent__text a { color: var(--blued); }
.consent__actions { display: flex; gap: 10px; flex: none; }
.consent__actions .btn { min-width: 104px; justify-content: center; }
/* Both answers are styled identically. A coloured Allow beside a plain Decline
   is the standard nudge, and it makes the choice less than free. */
.consent__btn { background: var(--plate-sunk); border-color: var(--hairline-2); color: var(--ink); }
.consent__btn:hover { border-color: var(--grad-1); }
.consent:focus { outline: none; }
.consent:focus-visible { outline: 2px solid var(--blued); outline-offset: -2px; }
@media (max-width: 560px) {
  .consent__inner { padding: 14px; gap: 12px; }
  .consent__actions { width: 100%; }
  .consent__actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .consent { animation: none; } }
@media print { .consent { display: none !important; } }

/* The footer link that reopens it. */
.site-footer__bottom [data-consent-open] {
  color: var(--muted); text-decoration: none; margin-left: 14px;
}
.site-footer__bottom [data-consent-open]:hover { color: var(--ink); text-decoration: underline; }
