/* FrankenPandas: the home page and its figures. */

/* ---------- Entrances ---------- */
.js .reveal { opacity: 0; transform: translateY(22px); }
.js .reveal.seen { opacity: 1; transform: none; transition: opacity 0.9s var(--ease), transform 1.1s var(--ease); }
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Hero ---------- */
.hero { padding: clamp(44px, 8vw, 100px) 0 clamp(56px, 7vw, 90px); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr); gap: clamp(32px, 4.5vw, 64px); align-items: center; }
.hero-copy .lede { margin: 26px 0 0; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
@media (max-width: 1080px) { .hero-grid { grid-template-columns: 1fr; } }

/* The notebook cell */
.nb {
  position: relative;
  border-radius: 20px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(28, 24, 66, 0.92), rgba(14, 12, 36, 0.94));
  box-shadow: 0 40px 120px -40px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.02) inset, 0 0 90px -30px rgba(184, 244, 66, 0.25);
  overflow: hidden;
}
.nb::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, rgba(184, 244, 66, 0.55), transparent 35%, transparent 65%, rgba(255, 90, 168, 0.45));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.nb-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); font: 500 12.5px/1 var(--mono); color: var(--dim); }
.nb-dots { display: inline-flex; gap: 6px; }
.nb-dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(178, 170, 255, 0.18); }
.nb-dots i:first-child { background: var(--pink); }
.nb-dots i:nth-child(2) { background: var(--gold); }
.nb-dots i:last-child { background: var(--lime); }
.nb-engine { margin-left: auto; color: var(--lime); padding: 4px 8px; border-radius: 7px; background: rgba(184, 244, 66, 0.09); border: 1px solid rgba(184, 244, 66, 0.25); }
.nb-in, .nb-out { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 4px; padding: 16px 18px 6px 10px; }
.nb-out { padding-top: 8px; }
.prompt { font: 600 12.5px/1.9 var(--mono); color: var(--lime); text-align: right; padding-right: 8px; white-space: nowrap; }
.prompt.out { color: var(--pink); }
.nb-code { margin: 0; padding: 10px 14px; border-radius: 11px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.nb-code code { font-size: 1em; }
.nb-result { min-height: 168px; transition: opacity 0.3s var(--ease); }
.busy .nb-result, .busy .play-out { opacity: 0.55; }
.nb-foot { margin: 4px 18px 0 88px; font-size: 13px; color: var(--dim); line-height: 1.5; }
.nb-edit { display: inline-block; margin: 2px 18px 12px 88px; padding: 6px 0; font-size: 13.5px; color: var(--lime); }
@media (max-width: 640px) {
  .nb-in, .nb-out { grid-template-columns: 1fr; padding-left: 14px; padding-right: 14px; }
  .prompt { text-align: left; }
  .nb-foot, .nb-edit { margin-left: 14px; }
}

/* Under the hero */
.strip { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 28px; margin-top: 26px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: rgba(18, 15, 44, 0.55); }
.seg-row { display: flex; flex-wrap: wrap; gap: 8px; }
.metrics { display: flex; gap: 26px; margin: 0; }
.metrics div { display: grid; gap: 2px; }
.metrics dt { font: 600 10.5px/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.metrics dd { margin: 0; font: 600 15px/1.3 var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }

.stats { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: clamp(40px, 6vw, 72px) 0 0; padding: 0; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--line); }
.stats li { display: grid; gap: 8px; align-content: start; padding: 22px 24px; background: rgba(13, 11, 34, 0.92); }
.stats b { font-size: clamp(2rem, 3.6vw, 2.9rem); font-weight: 760; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; background: linear-gradient(100deg, var(--text), var(--lime)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stats span { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.stats.small { margin: 0 0 28px; }
.stats.small b { font-size: clamp(1.6rem, 2.6vw, 2.2rem); }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Chips and segmented controls ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: rgba(178, 170, 255, 0.05);
  font: 550 13px/1 var(--mono);
  color: var(--muted);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.chip:hover { color: var(--text); background: rgba(178, 170, 255, 0.1); }
.chip:active, .seg button:active, .tile:not(.idle):active, .cells .cell:active { transform: scale(0.97); }
.chip, .seg button, .cells .cell { transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.15s var(--ease); }
.chip[aria-pressed="true"] { color: #0c0b1f; background: var(--lime); border-color: var(--lime); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px; border-radius: 12px; border: 1px solid var(--line-2); background: rgba(0, 0, 0, 0.22); }
.seg button { min-height: 34px; padding: 0 13px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-size: 13.5px; font-weight: 580; cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: rgba(178, 170, 255, 0.16); color: var(--text); box-shadow: 0 0 0 1px rgba(178, 170, 255, 0.22) inset; }

/* ---------- Sections ---------- */
.why, .chapter { padding: clamp(72px, 10vw, 140px) 0 0; }
.chapter { scroll-margin-top: 70px; }
.ch-head { margin-bottom: clamp(28px, 4vw, 44px); }
.ch-head .lede { margin: 20px 0 0; }
.aside { margin: 22px 0 0; max-width: 78ch; color: var(--dim); font-size: 15px; }

.cards { display: grid; gap: 16px; margin-top: 22px; }
.cards.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
@media (max-width: 1100px) { .cards.four, .cards.three { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .cards.four, .cards.three, .cards.two { grid-template-columns: 1fr; } }
.card {
  position: relative;
  padding: 22px 22px 20px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 22px; top: 0; width: 34px; height: 2px; border-radius: 2px; background: var(--tone); box-shadow: 0 0 14px var(--tone); }
.card h3 { margin: 4px 0 10px; font-size: 17.5px; line-height: 1.3; letter-spacing: -0.015em; font-weight: 680; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 15.5px; }
.card p:last-child { margin-bottom: 0; }
.disc { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.disc a { display: block; padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.2); border: 1px solid var(--line); text-decoration: none; color: var(--muted); font-size: 14.5px; line-height: 1.45; }
.disc a:hover { color: var(--text); border-color: var(--line-2); }
.disc b { display: block; font: 650 12px/1.6 var(--mono); color: var(--pink); letter-spacing: 0.04em; }

/* ---------- Figures ---------- */
.fig {
  position: relative;
  padding: clamp(16px, 2.6vw, 30px);
  border-radius: 22px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(25, 21, 60, 0.75), rgba(13, 11, 33, 0.82));
  box-shadow: 0 30px 100px -50px rgba(0, 0, 0, 0.9);
}
.fig-tag { display: inline-flex; align-items: flex-start; gap: 9px; margin: 0 0 18px; font: 600 11px/1.5 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--tone); }
.pulse { flex: none; align-self: flex-start; margin-top: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 0 0 var(--tone); }
.fig.live .pulse { animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--tone) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }
.fig-note, .fig-error { margin: 0; color: var(--muted); }
.fig-error { color: var(--pink); margin-top: 12px; }
.fig-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 18px; }
.fig h3 { margin: 0 0 6px; font-size: 15.5px; font-weight: 680; letter-spacing: -0.01em; }
.fig .muted { font-size: 14px; margin: 0 0 12px; line-height: 1.55; }
.status { min-height: 1.6em; margin: 14px 0 0; font: 500 13px/1.5 var(--mono); color: var(--dim); }
.status[data-kind="ok"] { color: var(--lime-2); }
.status[data-kind="err"] { color: var(--pink); }
.status[data-kind="wait"] { color: var(--gold); }

/* ---------- Tables (engine output) ---------- */
.out { margin: 0; min-width: 0; }
.tbl { overflow: auto; max-width: 100%; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); }
.tbl table { border-collapse: collapse; font: 450 13.5px/1.35 var(--mono); font-variant-numeric: tabular-nums; min-width: 100%; }
.tbl th, .tbl td { padding: 7px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid rgba(178, 170, 255, 0.07); }
.tbl thead th { position: sticky; top: 0; background: #17143a; font-weight: 650; color: var(--text); vertical-align: bottom; }
.tbl thead small { display: block; margin-top: 2px; font-weight: 450; font-size: 11px; color: var(--sky); }
.tbl tbody tr:last-child > * { border-bottom: 0; }
.tbl tbody tr:hover { background: rgba(178, 170, 255, 0.05); }
.tbl .ix { color: var(--dim); font-weight: 550; text-align: left; }
.tbl thead .ix { color: var(--dim); }
.tbl td.n { text-align: right; color: var(--text); }
.tbl th:not(.ix) { text-align: left; }
.tbl td.na { color: var(--gold); font-style: italic; text-align: right; }
.tbl td.b { color: var(--violet); }
.out figcaption { margin-top: 8px; font: 500 12px/1.4 var(--mono); color: var(--dim); }
.out-error { padding: 14px 16px; border-radius: 12px; border: 1px solid rgba(255, 90, 168, 0.35); background: rgba(255, 90, 168, 0.07); color: #ffc2de; font: 500 13.5px/1.6 var(--mono); white-space: pre-wrap; overflow-x: auto; }
.out-scalar { display: inline-flex; align-items: baseline; gap: 10px; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.22); font: 600 22px/1 var(--mono); }
.out-scalar small { font-size: 12px; color: var(--sky); font-weight: 500; }
.out-scalar .na { color: var(--gold); }
.out-svg, .plot-svg { overflow: auto; }
.out-svg svg, .plot-svg svg { display: block; max-width: 100%; height: auto; border-radius: 12px; }

/* Highlighted pandas */
.s { color: var(--gold); }
.nu { color: var(--sky); }
.k { color: var(--pink); }
.m { color: var(--lime); }
.kw { color: var(--violet); }
.v { color: var(--text); }
.p { color: var(--dim); }

/* ---------- 01 Playground ---------- */
.editor { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 12px; padding: 10px 10px 10px 14px; border-radius: 14px; border: 1px solid var(--line-2); background: rgba(0, 0, 0, 0.32); }
.editor:focus-within { border-color: rgba(184, 244, 66, 0.55); box-shadow: 0 0 0 4px rgba(184, 244, 66, 0.1); }
.editor .prompt { padding: 0; line-height: 38px; }
.ed { position: relative; min-width: 0; }
.ed-hl, .ed-in { margin: 0; padding: 7px 0; font: 450 15px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; border: 0; letter-spacing: 0; tab-size: 4; }
.ed-hl { pointer-events: none; color: var(--text); }
.ed-in { position: absolute; inset: 0; width: 100%; resize: none; overflow: hidden; background: transparent; color: transparent; caret-color: var(--lime); outline: none; }
.ed-in::selection { background: rgba(184, 244, 66, 0.25); color: transparent; }
.editor .run { align-self: center; }
/* On a phone the Run button moves under the line, so the code gets the full width. */
@media (max-width: 640px) {
  .editor { grid-template-columns: auto minmax(0, 1fr); gap: 8px 10px; }
  .editor .run { grid-column: 1 / -1; justify-self: end; }
  .ed-hl, .ed-in { font-size: 14px; }
}
.help { margin: 8px 2px 14px; font-size: 13px; color: var(--dim); }
.play-res { margin-top: 20px; }
.trace { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; padding: 0; min-height: 30px; }
.trace li { display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px; border-radius: 9px; border: 1px solid var(--line); background: rgba(178, 170, 255, 0.05); font: 500 12.5px/1.3 var(--mono); }
.trace li code { background: none; border: 0; padding: 0; color: var(--lime); font-size: 1em; }
.trace li span { color: var(--dim); }
.trace li + li::before { content: "→"; margin: 0 4px 0 -2px; color: var(--dim); }
.trace .t-start code { color: var(--text); }
.play-out { margin-top: 12px; transition: opacity 0.3s; }
/* Notebook-style output: as wide as its columns, not stretched across the figure. */
.play-out .tbl, .data .tbl { width: fit-content; min-width: min(100%, 420px); }
.data { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.data summary { cursor: pointer; padding: 6px 0; color: var(--muted); font-weight: 560; font-size: 14.5px; }
.data[open] summary { margin-bottom: 14px; }
.data-t { margin-bottom: 18px; }
.data-name { margin: 0 0 6px; }

/* ---------- 02 Alignment ---------- */
.align-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 0.8fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .align-grid { grid-template-columns: 1fr 1fr; } .align-grid .result { grid-column: 1 / -1; } }
@media (max-width: 520px) { .align-grid { grid-template-columns: 1fr; } }
.side { min-width: 0; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.2); }
.side-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin: 0 0 10px; font-size: 13px; color: var(--dim); }
.side-name code { font-size: 14px; color: var(--text); }
table.edit { width: 100%; border-collapse: collapse; font: 450 14px/1 var(--mono); }
table.edit th { padding: 0 4px 6px; text-align: left; font: 600 10.5px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
table.edit td { padding: 3px 4px 3px 0; }
table.edit input { width: 100%; min-width: 0; height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line-2); background: rgba(0, 0, 0, 0.3); color: var(--text); font: inherit; }
table.edit input.val { text-align: right; }
table.edit input:focus { outline: none; border-color: var(--lime); box-shadow: 0 0 0 3px rgba(184, 244, 66, 0.12); }
table.edit input::placeholder { color: var(--gold); font-style: italic; opacity: 0.8; }
table.edit input[aria-invalid] { border-color: var(--pink); color: var(--pink); }
table.edit .x { width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--dim); cursor: pointer; font-size: 18px; }
table.edit .x:hover:not(:disabled) { color: var(--pink); border-color: var(--line-2); }
table.edit .x:disabled { opacity: 0.25; cursor: default; }
.side .add { margin-top: 8px; height: 34px; padding: 0 12px; border-radius: 9px; border: 1px dashed var(--line-2); background: none; color: var(--muted); font: 550 13px/1 var(--mono); cursor: pointer; }
.side .add:hover:not(:disabled) { color: var(--text); border-color: var(--lime); }
.side .add:disabled { opacity: 0.4; cursor: default; }
.result tr.r-both > th { box-shadow: 3px 0 0 var(--lime) inset; }
.result tr.r-left > th { box-shadow: 3px 0 0 var(--sky) inset; }
.result tr.r-right > th { box-shadow: 3px 0 0 var(--violet) inset; }
.align-lower { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 16px; margin-top: 16px; }
@media (max-width: 900px) { .align-lower { grid-template-columns: 1fr; } }
.plan, .ledger { min-width: 0; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.16); }
.plan small { margin-left: 6px; color: var(--dim); font-size: 11px; }
.plan .muted:last-child { margin: 12px 0 0; }
.witness { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 14px; margin: 10px 0 0; font-size: 14px; }
.witness dt { color: var(--dim); font: 600 11px/1.9 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.witness dd { margin: 0; color: var(--muted); line-height: 1.55; min-width: 0; overflow-wrap: anywhere; }
.decision { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.decision b { color: var(--lime); font-family: var(--mono); }
@media (max-width: 520px) { .witness { grid-template-columns: 1fr; gap: 2px; } .witness dd { margin-bottom: 8px; } }

/* ---------- 03 Missing ---------- */
.nulls-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 18px; }
@media (max-width: 980px) { .nulls-grid { grid-template-columns: 1fr; } }
.truth, .mask { min-width: 0; padding: 18px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.18); }
.kleene-pair { display: flex; flex-wrap: wrap; gap: 16px; }
table.kleene { border-collapse: separate; border-spacing: 4px; font: 600 13.5px/1 var(--mono); }
table.kleene th { padding: 6px 8px; color: var(--dim); font-weight: 600; text-align: center; }
table.kleene th.corner code { font-size: 13px; color: var(--text); }
table.kleene td { width: 62px; height: 42px; text-align: center; border-radius: 9px; border: 1px solid var(--line); background: rgba(178, 170, 255, 0.04); }
table.kleene td.t { color: var(--text); }
table.kleene td.f { color: var(--dim); }
table.kleene td.na { color: var(--gold); background: rgba(255, 210, 63, 0.08); border-color: rgba(255, 210, 63, 0.3); font-style: italic; }
table.kleene td.decided { color: #0c0b1f; background: var(--lime); border-color: var(--lime); }
.cells { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 520px) { .cells { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cells .cell { display: grid; gap: 4px; justify-items: center; padding: 9px 4px 7px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(178, 170, 255, 0.05); cursor: pointer; font-family: var(--mono); transition: background-color 0.2s, border-color 0.2s; }
.cells .cell:hover { border-color: rgba(178, 170, 255, 0.4); }
.cells .v { font-size: 14px; font-weight: 600; }
.cells .bit { font-size: 11px; color: var(--lime); }
.cells .cell.na { background: rgba(255, 210, 63, 0.08); border-color: rgba(255, 210, 63, 0.4); }
.cells .cell.na .v { color: var(--gold); font-style: italic; }
.cells .cell.na .bit { color: var(--pink); }
.word { display: grid; gap: 6px; margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3); }
.word-l { font: 600 10.5px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.word code { background: none; border: 0; padding: 0; white-space: normal; overflow-wrap: anywhere; font-size: 13px; letter-spacing: 0.06em; }
.word .unused { color: rgba(178, 170, 255, 0.25); }
.word .used { color: var(--lime); }
.word .hex { color: var(--sky); }
.reduce { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 0; }
.reduce div { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(178, 170, 255, 0.04); min-width: 0; }
.reduce dt { font-size: 13px; }
.reduce dd { margin: 4px 0 2px; font: 650 20px/1.2 var(--mono); overflow-wrap: anywhere; }
.reduce small { color: var(--dim); font: 400 12px/1.35 var(--sans); display: block; margin-top: 2px; }
@media (max-width: 520px) { .reduce { grid-template-columns: 1fr; } }

/* ---------- 04 Proof ---------- */
.pk-controls select { flex: 1 1 260px; min-width: 0; max-width: 520px; height: 38px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line-2); background: #141134; color: var(--text); font: 500 13.5px/1 var(--mono); }
.pk-id { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 8px; }
.pk-id code { font-size: 13.5px; }
.mode { padding: 3px 9px; border-radius: 999px; font: 650 11px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; border: 1px solid var(--line-2); color: var(--sky); }
.mode.hardened { color: var(--violet); }
.pk-opts { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.pk-opts code { font-size: 12px; color: var(--muted); }
.pk-inputs { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; }
.pk-in { min-width: 0; max-width: 100%; }
.pk-label { margin: 0 0 6px; font: 600 11px/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--dim); }
.pk-label.pandas { color: var(--pink); }
.pk-label.fp { color: var(--lime); }
.pk-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.18); }
@media (max-width: 720px) { .pk-compare { grid-template-columns: 1fr; } }
.pk-side { min-width: 0; }
.checks { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; }
.checks li { padding: 6px 10px; border-radius: 9px; font-size: 13px; border: 1px solid var(--line); background: rgba(178, 170, 255, 0.04); }
.checks li b { font-family: var(--mono); }
.checks li.ok b { color: var(--lime); }
.checks li.bad b { color: var(--pink); }
.checks li span { color: var(--dim); font-family: var(--mono); font-size: 12px; }
.board { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.board-l { margin: 0 0 10px; font: 550 13.5px/1.5 var(--mono); color: var(--muted); }
.squares { display: flex; flex-wrap: wrap; gap: 5px; }
.sq { width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--line-2); background: rgba(178, 170, 255, 0.06); cursor: pointer; padding: 0; transition: background-color 0.3s; }
.sq.ok { background: var(--lime); border-color: var(--lime); }
.sq.bad { background: var(--pink); border-color: var(--pink); }

/* ---------- 05 Speed ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; font-size: 13px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 7px; }
.lg::before { content: ""; width: 10px; height: 10px; border-radius: 50%; }
.lg.win::before { background: var(--lime); }
.lg.loss::before { background: var(--pink); }
.lg.stale::before { border: 1.5px dashed var(--gold); }
.lg.gm::before { width: 3px; height: 14px; border-radius: 2px; background: var(--sky); }
.chart-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.2); }
.speed-svg { display: block; width: 100%; min-width: 720px; height: auto; font-family: var(--mono); }
.speed-svg.narrow { min-width: 0; }
.speed-svg.narrow .cat { font-size: 15px; }
.speed-svg.narrow .cat-g { font-size: 12.5px; font-family: var(--mono); font-weight: 450; fill: var(--muted); }
.speed-svg.narrow .zone-l { font-size: 11.5px; }
.speed-svg.narrow .tick-l, .speed-svg.narrow .gm-l { font-size: 13px; }
.speed-svg.narrow .dot:hover { r: 4.5; }
.speed-svg.narrow .dot.on { r: 5.5; }
.speed-svg .slow-zone { fill: rgba(255, 90, 168, 0.06); }
.speed-svg .tick { stroke: rgba(178, 170, 255, 0.12); }
.speed-svg .tick.one { stroke: rgba(239, 238, 248, 0.5); stroke-width: 1.5; }
.speed-svg .tick-l { fill: var(--dim); font-size: 12px; text-anchor: middle; }
.speed-svg .zone-l { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.speed-svg .zone-l.slow { fill: var(--pink); text-anchor: end; }
.speed-svg .zone-l.fast { fill: var(--lime); }
.speed-svg .gm { stroke: var(--gold); stroke-dasharray: 4 4; stroke-width: 1.4; }
.speed-svg .gm-l { fill: var(--gold); font-size: 12px; font-weight: 600; }
.speed-svg .row-rule { stroke: rgba(178, 170, 255, 0.06); }
.speed-svg .cat { fill: var(--text); font-size: 13.5px; font-weight: 600; font-family: var(--sans); }
.speed-svg .cat-g { fill: var(--dim); font-size: 11.5px; }
.speed-svg .cat-gm { stroke: var(--sky); stroke-width: 3; stroke-linecap: round; }
.speed-svg .dot { fill: var(--lime); fill-opacity: 0.82; stroke: #0b0a22; stroke-width: 1; cursor: pointer; transition: r 0.2s; }
.speed-svg .dot.loss { fill: var(--pink); }
.speed-svg .dot.stale { stroke: var(--gold); stroke-width: 1.6; stroke-dasharray: 2 1.6; }
.speed-svg .dot:hover { fill-opacity: 1; r: 6.5; }
.speed-svg .dot.on { fill-opacity: 1; r: 7.5; stroke: #fff; stroke-width: 2; stroke-dasharray: none; }
.chart-wrap:focus-visible { outline-offset: 2px; }
.lane-detail { margin-top: 14px; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.18); min-height: 128px; }
.lane-detail .muted { margin: 0; }
.ld-step { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
.ld-step span { margin-right: auto; font: 500 12px/1.4 var(--mono); color: var(--dim); }
.ld-step .chip { min-height: 34px; }
.ld-step .chip:disabled { opacity: 0.35; cursor: default; }
@media (max-width: 560px) { .ld-step span { flex-basis: 100%; } }
.ld-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin: 0 0 6px; }
.ld-name code { font-size: 15px; }
.ld-name span { color: var(--dim); font-size: 13.5px; }
.ld-ratio { margin: 0 0 12px; font: 760 34px/1.1 var(--mono); letter-spacing: -0.03em; }
.ld-ratio.win { color: var(--lime); }
.ld-ratio.loss { color: var(--pink); }
.ld-ratio small { margin-left: 12px; font: 500 13px/1 var(--sans); letter-spacing: 0; color: var(--muted); }
.lane-detail dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 20px; margin: 0; }
.lane-detail dt { font: 600 10.5px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.lane-detail dd { margin: 2px 0 0; font: 550 14px/1.4 var(--mono); color: var(--text); }
.ld-note { margin: 12px 0 0; color: var(--gold); font-size: 14px; }
table.losses td, table.losses th { padding: 6px 10px; }
table.losses td.n { color: var(--pink); }
.flag { padding: 2px 7px; border-radius: 6px; font-size: 11px; color: var(--gold); border: 1px dashed rgba(255, 210, 63, 0.5); }
.card .tbl { margin: 4px 0 12px; }

/* ---------- 06 Safety ---------- */
.sliders { display: flex; flex-wrap: wrap; gap: 12px 28px; margin: 0 0 18px; }
.sliders[hidden], .slider[hidden] { display: none; }
.slider { display: grid; grid-template-columns: auto minmax(140px, 240px) 4.2em; align-items: center; gap: 12px; font-size: 13.5px; color: var(--muted); }
.slider output { font: 650 14px/1 var(--mono); color: var(--text); }
.slider input { accent-color: var(--violet); width: 100%; height: 30px; margin: 0; }
@media (max-width: 560px) { .slider { grid-template-columns: 1fr 4em; } .slider span { grid-column: 1 / -1; } }
.dec-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 980px) { .dec-grid { grid-template-columns: 1fr; } }
.dec-math, .dec-plot { min-width: 0; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.18); }
table.terms { width: 100%; border-collapse: collapse; font: 450 13px/1.3 var(--mono); margin: 8px 0 12px; }
table.terms th { text-align: left; padding: 6px 6px; font-weight: 600; font-size: 11px; color: var(--dim); border-bottom: 1px solid var(--line); }
table.terms td { padding: 7px 6px; border-bottom: 1px solid rgba(178, 170, 255, 0.06); }
table.terms td code { background: none; border: 0; padding: 0; white-space: normal; overflow-wrap: anywhere; }
table.terms td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.terms td.neg { color: var(--pink); }
table.terms td.pos { color: var(--lime); }
table.terms tr.best td { background: rgba(171, 147, 255, 0.1); }
table.terms tr.best td:first-child code { color: var(--violet); }
.eq { display: grid; gap: 4px; margin: 0 0 6px; padding: 10px 12px; border-radius: 10px; background: rgba(0, 0, 0, 0.25); font: 500 13px/1.5 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.eq b { color: var(--text); }
.dec-plot svg { display: block; width: 100%; height: auto; font-family: var(--mono); }
.dec-plot .zone { opacity: 0.12; }
.dec-plot .zone.allow, .dec-plot .ln.allow, .dec-plot .pt.allow { fill: var(--lime); stroke: var(--lime); }
.dec-plot .zone.repair, .dec-plot .ln.repair, .dec-plot .pt.repair { fill: var(--violet); stroke: var(--violet); }
.dec-plot .zone.reject, .dec-plot .ln.reject, .dec-plot .pt.reject { fill: var(--pink); stroke: var(--pink); }
.dec-plot .ln { stroke-width: 2; fill: none; }
.dec-plot .pt { stroke: #0b0a22; stroke-width: 1.5; }
.dec-plot .now { stroke: rgba(239, 238, 248, 0.7); stroke-dasharray: 3 3; }
.dec-plot .ax { fill: var(--dim); font-size: 11px; text-anchor: middle; }
.dec-plot .ax-l { fill: var(--dim); font-size: 11px; text-anchor: middle; }
.dec-plot .ln-l { font-size: 12px; font-weight: 650; }
.dec-plot .ln-l.allow { fill: var(--lime); }
.dec-plot .ln-l.repair { fill: var(--violet); }
.dec-plot .ln-l.reject { fill: var(--pink); }
.dec-plot .muted { margin: 8px 0 0; }
@media (max-width: 560px) {
  .dec-plot .ax, .dec-plot .ax-l { font-size: 15px; }
  .dec-plot .ln-l { font-size: 16px; }
}
.dec-verdict { margin-top: 16px; padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line-2); background: rgba(171, 147, 255, 0.06); }
.dec-line { margin: 0 0 6px; font-size: 16px; }
.act { padding: 2px 9px; border-radius: 8px; font: 700 14px/1.4 var(--mono); }
.act.allow { background: var(--lime); color: #0c0b1f; }
.act.repair { background: var(--violet); color: #0c0b1f; }
.act.reject { background: var(--pink); color: #0c0b1f; }
.dec-verdict .muted { margin: 6px 0 0; }
.card-text { margin: 12px 0 0; padding: 12px 14px; border-radius: 10px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.6; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 07 Formats ---------- */
.fmt-grid { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 16px; margin-top: 6px; }
.tile.idle { cursor: default; border-style: dashed; }
.tile.idle b { color: var(--muted); }
.tile.idle span, .tile.idle small { color: var(--dim); }
.tiles.running .tile.idle { animation: idle 1.1s ease-in-out infinite alternate; }
.tiles.running .tile.idle:nth-child(3n + 2) { animation-delay: 0.18s; }
.tiles.running .tile.idle:nth-child(3n) { animation-delay: 0.36s; }
@keyframes idle { from { opacity: 0.4; } to { opacity: 1; } }
@media (max-width: 900px) { .fmt-grid { grid-template-columns: 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; align-content: start; }
.tile { display: grid; gap: 3px; text-align: left; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(178, 170, 255, 0.04); cursor: pointer; transition: border-color 0.2s, background-color 0.2s; }
.tile b { font-size: 14px; font-weight: 650; }
.tile span { font: 500 12.5px/1.3 var(--mono); color: var(--muted); }
.tile small { font: 600 10.5px/1.3 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.tile.ok small { color: var(--lime); }
.tile.bad small { color: var(--pink); }
.tile:hover { border-color: var(--line-2); }
.tile[aria-selected="true"] { border-color: var(--sky); background: rgba(114, 205, 255, 0.08); }
.fmt-pane { min-width: 0; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.2); }
.fmt-pane h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.fmt-meta { font: 500 12.5px/1 var(--mono); color: var(--dim); }
.trip { color: var(--muted); font-size: 14.5px; margin: 6px 0 12px; }
.preview { margin: 0; max-height: 300px; overflow: auto; padding: 12px 14px; border-radius: 10px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.55; color: var(--text); white-space: pre; }
.preview.hex { white-space: pre-wrap; word-break: break-all; color: var(--sky); letter-spacing: 0.04em; }
.plot { margin-top: 22px; }
.plot:empty { display: none; }
.plot .seg { margin: 4px 0 14px; }
.plot-svg { max-width: 680px; padding: 10px; border-radius: 14px; background: #fff; }

/* ---------- 08 Start ---------- */
.install { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .install { grid-template-columns: 1fr; } }
.install .card h3 { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.pill { padding: 2px 8px; border-radius: 999px; font: 650 10.5px/1.5 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--pink); border: 1px solid rgba(255, 90, 168, 0.45); }
.code { position: relative; margin: 12px 0 14px; }
.code pre { margin: 0; padding: 14px 16px; padding-right: 86px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.36); overflow-x: auto; font-size: 13.5px; line-height: 1.6; color: var(--text); }
.copy { position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-2); background: #17143a; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.copy .i { width: 14px; height: 14px; }
.copy:hover { color: var(--text); }
.copy.done { color: var(--lime); border-color: var(--lime); }
.links { display: flex; flex-wrap: wrap; gap: 14px; }
.links a { color: var(--lime); }
.fit { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
@media (max-width: 900px) { .fit { grid-template-columns: 1fr; } }
.fit .card::before { display: none; }
.fit h3 { display: flex; align-items: center; gap: 10px; }
.fit .card:first-child h3 .i { color: var(--lime); }
.fit .card:last-child h3 .i { color: var(--pink); }
.fit ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 15.5px; display: grid; gap: 8px; }
.docs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
@media (max-width: 900px) { .docs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .docs { grid-template-columns: 1fr; } }
.docs a { display: grid; align-content: start; gap: 4px;padding: 16px 18px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); text-decoration: none; transition: border-color 0.2s, transform 0.4s var(--ease); }
.docs a:hover { border-color: var(--lime); transform: translateY(-2px); }
.docs b { font-weight: 680; }
.docs span { color: var(--dim); font-size: 14px; }

/* ---------- Scrollers ---------- */
/* Where the browser supports scroll-driven animation, a sideways scroller fades at an edge that has
   more content past it, so a cut-off table reads as "scroll for more" rather than as clipped. */
@property --fade-l { syntax: "<length>"; inherits: false; initial-value: 0px; }
@property --fade-r { syntax: "<length>"; inherits: false; initial-value: 0px; }
@keyframes edge-fade {
  0% { --fade-l: 0px; --fade-r: 36px; }
  6% { --fade-l: 36px; }
  94% { --fade-r: 36px; }
  100% { --fade-l: 36px; --fade-r: 0px; }
}
@supports (animation-timeline: scroll(self inline)) {
  .tbl, .chart-wrap, .code pre, .preview, .strip .seg-row, .fig .chips, .tiles {
    animation: edge-fade linear both;
    animation-timeline: scroll(self inline);
    -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
    mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  }
}

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  /* Figures reach closer to the screen edge, and their inner panels pad less, so tables get the width. */
  .fig { margin-inline: -8px; padding: 16px 12px; border-radius: 18px; }
  .side, .plan, .ledger, .truth, .mask, .dec-math, .dec-plot, .fmt-pane, .pk-compare, .lane-detail { padding: 12px; }
  /* Chip rows scroll sideways instead of stacking three or four rows above what they control. */
  .strip .seg-row, .fig .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: -12px;
    padding-inline: 12px;
    scroll-padding-inline: 12px;
  }
  .strip .seg-row::-webkit-scrollbar, .fig .chips::-webkit-scrollbar { display: none; }
  .strip .seg-row > *, .fig .chips > * { flex: none; }
  .strip { padding: 12px; }
  .strip .seg-row { margin-inline: -12px; }
  /* Format tiles become a swipeable row above their detail. */
  .tiles { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(150px, 46%); overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; }
  .tile { scroll-snap-align: start; }
}

/* ---------- 404 ---------- */
.missing-page { padding: clamp(90px, 16vw, 200px) 0 40px; }
.missing-page .lede { margin: 20px 0 0; }
