/* ==========================================================================
   API Knights — stage edition.
   Black, white and four loud colours. No borders, no rounded corners.
   The diagram is the page: the node that holds the data turns solid.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f1f1f1;
  --surface-2: #e4e4e4;
  --surface-3: #d0d0d0;
  --stage: #e6e6e6;
  --node: #ffffff;
  --panel: #f1f1f1;
  --panel-2: #ffffff;
  --ink: #0a0a0a;
  --ink-2: #333333;
  --ink-3: #666666;
  --brand: #0a0a0a;
  --on-brand: #ffffff;
  --hdr: #0a0a0a;
  --hdr-ink: #ffffff;
  --hdr-on: #ffffff;
  --hdr-on-ink: #0a0a0a;

  /* the four methods */
  --get: #0057ff;    --get-ink: #0057ff;
  --post: #00853f;   --post-ink: #00853f;
  --put: #ffb800;    --put-ink: #a85d00;
  --delete: #e5231b; --delete-ink: #d01f18;

  /* status families: 0 = no answer, 1xx … 5xx */
  --s0: #555555; --s0-ink: #555555;
  --s1: #5b6b7f; --s1-ink: #4d5c70;
  --s2: #00853f; --s2-ink: #00853f;
  --s3: #007f8f; --s3-ink: #007f8f;
  --s4: #ff6a00; --s4-ink: #c24e00;
  --s5: #d01f18; --s5-ink: #d01f18;

  --shadow: 0 14px 34px rgba(0, 0, 0, .22);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0b; --surface: #1a1a1a; --surface-2: #262626; --surface-3: #363636;
  --stage: #141414; --node: #1f1f1f; --panel: #2b2b2b; --panel-2: #3a3a3a;
  --ink: #f4f4f4; --ink-2: #c8c8c8; --ink-3: #9a9a9a; --brand: #f4f4f4; --on-brand: #0b0b0b;
  --hdr: #1f1f1f; --hdr-ink: #f4f4f4; --hdr-on: #f4f4f4; --hdr-on-ink: #0b0b0b;
  --get-ink: #6ea1ff; --post-ink: #3ddc84; --put-ink: #ffc933; --delete-ink: #ff7a72;
  --s0-ink: #bdbdbd; --s1-ink: #a9b8cc; --s2-ink: #3ddc84; --s3-ink: #4fd3e6; --s4-ink: #ff9442; --s5-ink: #ff7a72;
  --shadow: 0 14px 34px rgba(0, 0, 0, .7);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0b0b; --surface: #1a1a1a; --surface-2: #262626; --surface-3: #363636;
    --stage: #141414; --node: #1f1f1f; --panel: #2b2b2b; --panel-2: #3a3a3a;
    --ink: #f4f4f4; --ink-2: #c8c8c8; --ink-3: #9a9a9a; --brand: #f4f4f4; --on-brand: #0b0b0b;
    --hdr: #1f1f1f; --hdr-ink: #f4f4f4; --hdr-on: #f4f4f4; --hdr-on-ink: #0b0b0b;
    --get-ink: #6ea1ff; --post-ink: #3ddc84; --put-ink: #ffc933; --delete-ink: #ff7a72;
    --s0-ink: #bdbdbd; --s1-ink: #a9b8cc; --s2-ink: #3ddc84; --s3-ink: #4fd3e6; --s4-ink: #ff9442; --s5-ink: #ff7a72;
    --shadow: 0 14px 34px rgba(0, 0, 0, .7);
  }
}

/* Colour hooks: --c = fill, --c-ink = text on a surface, --on-c = text on the fill */
.m-get { --c: var(--get); --c-ink: var(--get-ink); --on-c: #fff; }
.m-post { --c: var(--post); --c-ink: var(--post-ink); --on-c: #fff; }
.m-put { --c: var(--put); --c-ink: var(--put-ink); --on-c: #140d00; }
.m-delete { --c: var(--delete); --c-ink: var(--delete-ink); --on-c: #fff; }
.s0 { --c: var(--s0); --c-ink: var(--s0-ink); --on-c: #fff; }
.s1 { --c: var(--s1); --c-ink: var(--s1-ink); --on-c: #fff; }
.s2 { --c: var(--s2); --c-ink: var(--s2-ink); --on-c: #fff; }
.s3 { --c: var(--s3); --c-ink: var(--s3-ink); --on-c: #fff; }
.s4 { --c: var(--s4); --c-ink: var(--s4-ink); --on-c: #140d00; }
.s5 { --c: var(--s5); --c-ink: var(--s5-ink); --on-c: #fff; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.5; color: var(--ink); background: var(--bg); min-height: 100vh; overflow-x: hidden; }
h1, h2, h3 { line-height: 1.1; margin: 0 0 .5em; letter-spacing: -.02em; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
code, kbd, pre { font-family: var(--mono); }
code { font-size: .88em; background: var(--surface-3); padding: .1em .4em; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--c, var(--ink)); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.ico { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; vertical-align: -.2em; }
.ico.fill { fill: currentColor; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--brand); color: var(--on-brand); padding: 10px 16px; text-decoration: none; }
.skip:focus { top: 10px; }
.eyebrow { display: block; font: 700 .8rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 14px; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--hdr); color: var(--hdr-ink); }
.site-header .bar { display: flex; align-items: center; gap: 14px; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; text-decoration: none; margin-right: auto; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; background: var(--hdr-on); color: var(--hdr-on-ink); font: 800 .85rem var(--mono); letter-spacing: 0; }
.nav ol { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.nav a { display: block; padding: 10px 16px; text-decoration: none; font-weight: 700; font-size: .95rem; white-space: nowrap; opacity: .66; transition: opacity .2s, background .2s, color .2s; }
.nav a:hover { opacity: 1; background: rgba(127, 127, 127, .28); }
.nav a[aria-current="page"] { opacity: 1; background: var(--hdr-on); color: var(--hdr-on-ink); }
.tools { display: flex; align-items: center; gap: 8px; }
.mode-pill { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; background: rgba(127, 127, 127, .28); font-size: .85rem; font-weight: 700; transition: background .2s; }
.mode-pill:hover { background: rgba(127, 127, 127, .45); }
.mode-pill i { width: 9px; height: 9px; background: #3ddc84; }
.mode-pill[data-state="practice"] i { background: #ffb800; }
.mode-pill[data-state="fallback"] i { background: #ff5a50; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; background: rgba(127, 127, 127, .28); transition: background .2s; }
.icon-btn:hover { background: rgba(127, 127, 127, .45); }
@media (max-width: 960px) {
  .nav { order: 3; width: 100%; overflow-x: auto; margin: 0 -20px; padding: 0 20px 6px; scrollbar-width: thin; }
  .nav ol { width: max-content; }
}

/* ---------- Layout ---------- */
main.wrap { padding-top: 22px; padding-bottom: 40px; }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.controls .hint { color: var(--ink-3); font-weight: 600; margin: 0; }
.controls .grow { flex: 1; }
.card { background: var(--surface); padding: 18px; }
.note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: color-mix(in srgb, var(--c, var(--ink)) 12%, var(--bg)); box-shadow: inset 5px 0 0 var(--c, var(--ink)); font-size: .98rem; }
.note > .ico { margin-top: .22em; color: var(--c-ink, var(--ink)); font-size: 1.15em; }
.note p { margin: 0; }
.note.danger { --c: var(--delete); --c-ink: var(--delete-ink); }
.note.good { --c: var(--post); --c-ink: var(--post-ink); }

/* ---------- Buttons + tabs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; padding: 10px 24px; background: var(--surface-2); color: var(--ink); font-weight: 700; text-decoration: none; transition: background .2s, transform .15s; }
.btn:hover:not(:disabled) { background: var(--surface-3); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover:not(:disabled) { background: var(--ink-2); }
.btn--method { background: var(--c); color: var(--on-c, #fff); }
.btn--method:hover:not(:disabled) { background: color-mix(in srgb, var(--c) 85%, #000); }
.btn--danger { --c: var(--delete); --on-c: #fff; background: var(--c); color: #fff; }
.btn--danger:hover:not(:disabled) { background: color-mix(in srgb, var(--c) 85%, #000); }
.btn--sm { min-height: 40px; padding: 6px 16px; font-size: .92rem; }
.btn--lg { min-height: 58px; padding-inline: 34px; font-size: 1.12rem; }
.btn--block { width: 100%; }
.btn .ico { font-size: 1.1em; }

.seg { display: inline-flex; gap: 2px; background: var(--surface-2); padding: 3px; flex-wrap: wrap; }
.seg button { padding: 10px 20px; font-weight: 700; color: var(--ink-3); min-height: 44px; transition: background .2s, color .2s; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: .92rem; font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 42px; height: 24px; background: var(--surface-3); position: relative; cursor: pointer; margin: 0; flex: none; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: var(--ink-3); transition: transform .2s, background .2s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); background: var(--on-brand); }

.tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; margin-bottom: 10px; }
.tab { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; padding: 14px 18px; min-height: 76px; text-align: left; background: var(--surface); transition: background .2s, color .2s, transform .15s; }
.tab:hover { background: var(--surface-2); transform: translateY(-2px); }
.tab .nm { display: flex; align-items: center; gap: 10px; font: 800 1.45rem/1.1 var(--mono); color: var(--c-ink); transition: color .2s; }
.tab .nm .ico { font-size: .9em; }
.tab .rl { font-size: .92rem; font-weight: 600; color: var(--ink-3); transition: color .2s; }
.tab--text .nm { font-family: var(--font); font-size: 1.15rem; letter-spacing: -.01em; }
.tab[aria-selected="true"] { background: var(--c); color: var(--on-c, #fff); }
.tab[aria-selected="true"] .nm, .tab[aria-selected="true"] .rl { color: inherit; }

/* ---------- Badges ---------- */
.mbadge { display: inline-block; font: 800 .74rem/1 var(--mono); color: var(--on-c, #fff); background: var(--c); padding: 6px 9px; min-width: 3.6em; text-align: center; }
.spill { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; font-size: .86rem; padding: 4px 11px; color: var(--c-ink); background: color-mix(in srgb, var(--c) 16%, var(--bg)); white-space: nowrap; }
.spill::before { content: ""; width: 8px; height: 8px; background: var(--c); }
.src { display: inline-block; font-size: .76rem; font-weight: 800; padding: 4px 10px; background: var(--surface-3); color: var(--ink-2); letter-spacing: .03em; text-transform: uppercase; }
.src.live { color: var(--post-ink); }
.src.practice { color: var(--put-ink); }
.tile { display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); font-weight: 800; flex: none; }

/* ---------- The scheme ---------- */
.scheme { --lane: 38px; background: var(--stage); padding: 24px; position: relative; }
.scheme-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.scheme-bar h3 { margin: 0; font: 800 .85rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.slowmo { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 20px; background: var(--node); color: var(--ink); font-weight: 800; transition: background .2s, color .2s; }
.slowmo:hover { background: var(--surface-3); }
.slowmo[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.scheme-grid { display: grid; grid-template-columns: minmax(210px, 1.05fr) minmax(90px, .5fr) minmax(190px, .95fr) minmax(90px, .5fr) minmax(250px, 1.4fr); align-items: stretch; }

.node { background: var(--node); color: var(--ink); padding: 16px; display: flex; flex-direction: column; gap: 14px; min-height: 300px; min-width: 0; transition: opacity .35s, transform .35s, box-shadow .35s, background .3s, color .3s; }
.scheme[data-busy="true"] .node:not(.is-active) { opacity: .42; }
.node.is-active { background: var(--ink); color: var(--bg); box-shadow: var(--shadow); transform: translateY(-5px); }
.node-head { display: flex; align-items: center; gap: 12px; }
.node-ico { width: 42px; height: 42px; display: grid; place-items: center; background: var(--ink); color: var(--bg); flex: none; font-size: 1.2rem; transition: background .3s, color .3s; }
.node.is-active .node-ico { background: var(--bg); color: var(--ink); }
.node-head b { font-size: 1.15rem; line-height: 1.15; letter-spacing: -.01em; }

.db { flex: 1; background: var(--panel); color: var(--ink); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.db-title { font: 800 .68rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); display: flex; align-items: center; gap: 6px; padding-bottom: 2px; }
.db-rows { display: flex; flex-direction: column; gap: 6px; }
.db-row { display: flex; align-items: center; gap: 10px; padding: 7px 9px; background: var(--panel-2); font-size: .88rem; line-height: 1.25; transition: background .3s, box-shadow .3s; overflow: hidden; }
.db-row .tile { width: 30px; height: 30px; font-size: .85rem; }
.db-row b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-row small { color: var(--ink-3); display: block; font-size: .74rem; }
.db-row > span:last-child { min-width: 0; }
.db-row.is-read { background: color-mix(in srgb, var(--get) 18%, var(--panel-2)); box-shadow: inset 5px 0 0 var(--get); }
.db-row.is-new { background: color-mix(in srgb, var(--post) 18%, var(--panel-2)); box-shadow: inset 5px 0 0 var(--post); animation: row-in .5s cubic-bezier(.2, .8, .2, 1); }
.db-row.is-update { background: color-mix(in srgb, var(--put) 28%, var(--panel-2)); box-shadow: inset 5px 0 0 var(--put); animation: flash .7s ease; }
.db-row.is-gone { background: color-mix(in srgb, var(--delete) 18%, var(--panel-2)); box-shadow: inset 5px 0 0 var(--delete); animation: row-out .6s .15s ease forwards; }
@keyframes row-in { from { opacity: 0; transform: translateY(-12px); max-height: 0; } to { opacity: 1; transform: none; max-height: 60px; } }
@keyframes row-out { to { opacity: 0; transform: translateX(28px); max-height: 0; padding-top: 0; padding-bottom: 0; margin-top: -6px; } }
@keyframes flash { 30% { transform: scale(1.03); } }

.hand { flex: 1; display: flex; flex-direction: column; background: var(--panel); color: var(--ink); min-height: 150px; }
.hand-tag { font: 800 .7rem var(--mono); letter-spacing: .14em; text-transform: uppercase; padding: 10px 12px 0; color: var(--ink-3); min-height: 1.9em; }
.hand pre { margin: 0; padding: 6px 12px 12px; flex: 1; max-height: 240px; overflow: hidden; font-size: .78rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.hand pre:empty::before { content: "—"; color: var(--ink-3); }
.hand.fresh { animation: pop .5s ease; }
@keyframes pop { from { background: color-mix(in srgb, var(--post) 30%, var(--panel)); } }

.link { display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 0 6px; position: relative; min-width: 0; }
.lane { position: relative; height: var(--lane); flex: none; --lc: var(--ink-2); }
.lane[data-dir="toScreen"] { --lc: var(--post-ink); }
.lane::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; opacity: .55; background: repeating-linear-gradient(90deg, var(--lc) 0 8px, transparent 8px 16px); background-size: 16px 4px; animation: flow-r 1.3s linear infinite; }
.lane[data-dir="toServer"]::before { animation-name: flow-l; }
.lane::after { content: ""; position: absolute; top: 50%; width: 0; height: 0; transform: translateY(-50%); }
.lane[data-dir="toScreen"]::after { right: -3px; border-left: 13px solid var(--lc); border-top: 8px solid transparent; border-bottom: 8px solid transparent; }
.lane[data-dir="toServer"]::after { left: -3px; border-right: 13px solid var(--lc); border-top: 8px solid transparent; border-bottom: 8px solid transparent; }
.lane-name { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); font: 800 .62rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); background: var(--stage); padding: 0 5px; z-index: 1; }
@keyframes flow-r { to { background-position: 16px 0; } }
@keyframes flow-l { to { background-position: -16px 0; } }
.scheme[data-busy="true"] .lane::before { opacity: 1; }

.packet { position: absolute; z-index: 6; white-space: nowrap; font: 800 .86rem/1 var(--mono); padding: 10px 14px; background: var(--c, var(--ink)); color: var(--on-c, var(--bg)); box-shadow: 0 8px 22px rgba(0, 0, 0, .3); display: flex; align-items: center; gap: 7px; pointer-events: none; will-change: transform, opacity; max-width: 240px; }
.packet[data-tone="get"] { --c: var(--get); --on-c: #fff; }
.packet[data-tone="post"] { --c: var(--post); --on-c: #fff; }
.packet[data-tone="put"] { --c: var(--put); --on-c: #140d00; }
.packet[data-tone="delete"] { --c: var(--delete); --on-c: #fff; }
.packet[data-tone="neutral"] { --c: var(--ink); --on-c: var(--bg); }
.packet[data-tone="s0"] { --c: var(--s0); --on-c: #fff; }
.packet[data-tone="s1"] { --c: var(--s1); --on-c: #fff; }
.packet[data-tone="s2"] { --c: var(--s2); --on-c: #fff; }
.packet[data-tone="s3"] { --c: var(--s3); --on-c: #fff; }
.packet[data-tone="s4"] { --c: var(--s4); --on-c: #140d00; }
.packet[data-tone="s5"] { --c: var(--s5); --on-c: #fff; }

.browser { flex: 1; background: var(--panel-2); color: var(--ink); display: flex; flex-direction: column; min-height: 0; }
.browser-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--panel); }
.browser-bar .d { width: 8px; height: 8px; background: var(--ink-3); opacity: .5; flex: none; }
.browser-url { flex: 1; min-width: 0; margin-left: 6px; font: .74rem var(--mono); background: var(--panel-2); padding: 3px 10px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen { padding: 14px; flex: 1; overflow: auto; min-height: 180px; max-height: 380px; font-size: .94rem; }

.steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 18px 0 0; padding: 0; list-style: none; counter-reset: st; }
.steps li { position: relative; padding: 12px 10px 12px 44px; background: var(--node); color: var(--ink-3); font-size: .9rem; font-weight: 700; line-height: 1.2; counter-increment: st; transition: background .3s, color .3s; min-height: 50px; display: flex; align-items: center; }
.steps li::before { content: counter(st); position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; display: grid; place-items: center; font: 800 .76rem var(--mono); background: var(--surface-2); color: var(--ink-2); transition: background .3s, color .3s; }
.steps li.is-active { background: var(--ink); color: var(--bg); }
.steps li.is-active::before { background: var(--bg); color: var(--ink); }
.steps li.is-done { color: var(--ink); }
.steps li.is-done::before { content: "✓"; background: var(--post); color: #fff; }

@media (max-width: 1100px) and (min-width: 900px) { .steps { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 899px) {
  .scheme { padding: 14px; }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .scheme-grid { grid-template-columns: 1fr; }
  .node { min-height: 0; }
  .link { flex-direction: row; justify-content: center; align-items: stretch; gap: min(30vw, 150px); padding: 6px 0; }
  .lane { width: var(--lane); height: 74px; }
  .lane::before { left: 50%; right: auto; top: 0; bottom: 0; width: 4px; height: auto; margin: 0 0 0 -2px; background: repeating-linear-gradient(180deg, var(--lc) 0 8px, transparent 8px 16px); background-size: 4px 16px; animation-name: flow-d; }
  .lane[data-dir="toServer"]::before { animation-name: flow-u; }
  .lane::after { left: 50% !important; right: auto !important; top: auto; transform: translateX(-50%); border: 0; }
  .lane[data-dir="toScreen"]::after { bottom: -3px; border-top: 13px solid var(--lc); border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 0; }
  .lane[data-dir="toServer"]::after { top: -3px; bottom: auto; border-bottom: 13px solid var(--lc); border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 0; }
  .lane-name { display: none; }
  .hand { min-height: 90px; }
  .hand pre { max-height: 140px; }
  .screen { max-height: none; }
  @keyframes flow-d { to { background-position: 0 16px; } }
  @keyframes flow-u { to { background-position: 0 -16px; } }
}

/* ---------- Code colours (the frontend's request and response) ---------- */
.j-key { color: var(--get-ink); }
.j-str { color: var(--post-ink); }
.j-num { color: var(--put-ink); }
.j-kw { color: var(--delete-ink); font-weight: 700; }
.j-cm { color: var(--ink-3); font-style: italic; }
.tok-method { font-weight: 800; color: var(--c-ink); }

/* ---------- The little app on the screen ---------- */
.app-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; margin-bottom: 12px; }
.app-head small { color: var(--ink-3); font-weight: 600; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-bottom: 12px; font-size: .9rem; line-height: 1.35; background: color-mix(in srgb, var(--c) 14%, var(--panel-2)); box-shadow: inset 5px 0 0 var(--c); animation: slide-down .35s ease; }
.banner b { color: var(--c-ink); }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } }
.pets { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.pet { position: relative; text-align: center; padding: 14px 8px 10px; background: var(--surface); animation: pet-in .45s cubic-bezier(.2, .8, .2, 1) backwards; transition: background .3s, box-shadow .3s; min-width: 0; }
.pet.still { animation: none; }
.pet .tile { width: 44px; height: 44px; margin: 0 auto 8px; font-size: 1.3rem; background: var(--panel-2); }
.pet b { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pet small { display: block; color: var(--ink-3); font-size: .72rem; }
.pet .st { display: inline-block; margin-top: 6px; font-size: .7rem; font-weight: 800; padding: 2px 8px; background: color-mix(in srgb, var(--c) 18%, var(--bg)); color: var(--c-ink); }
.pet s { color: var(--ink-3); font-weight: 500; }
.pet.is-new { background: color-mix(in srgb, var(--post) 18%, var(--surface)); box-shadow: inset 0 5px 0 var(--post); }
.pet.is-update { background: color-mix(in srgb, var(--put) 28%, var(--surface)); box-shadow: inset 0 5px 0 var(--put); animation: flash .8s ease; }
.pet.is-gone { background: color-mix(in srgb, var(--delete) 18%, var(--surface)); box-shadow: inset 0 5px 0 var(--delete); animation: poof .65s ease forwards; }
.pet .tag { position: absolute; top: 0; right: 0; font: 800 .62rem var(--mono); letter-spacing: .06em; background: var(--c); color: var(--on-c, #fff); padding: 3px 7px; }
@keyframes pet-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes poof { 60% { transform: scale(.92); opacity: .5; } to { transform: scale(.6); opacity: 0; } }
.empty { text-align: center; color: var(--ink-3); padding: 30px 8px; font-size: .92rem; }

.form { display: grid; gap: 10px; }
.field { display: grid; gap: 4px; }
.field label { font-weight: 700; font-size: .82rem; color: var(--ink-2); }
.field input, .field select { width: 100%; min-height: 44px; padding: 8px 12px; border: 0; background: var(--surface); color: var(--ink); }
.field input:focus, .field select:focus { outline: 3px solid var(--ink); outline-offset: 0; }
.field small { color: var(--ink-3); font-size: .76rem; line-height: 1.3; }
.check { display: flex; gap: 8px; align-items: center; font-size: .86rem; color: var(--ink-2); }
.result-card { text-align: center; padding: 18px 10px; background: color-mix(in srgb, var(--c, var(--post)) 14%, var(--panel-2)); box-shadow: inset 0 5px 0 var(--c, var(--post)); animation: pet-in .45s ease; }
.result-card .ico { display: block; margin: 0 auto 8px; font-size: 2rem; color: var(--c-ink, var(--post-ink)); }
.result-card b { display: block; }
.result-card small { color: var(--ink-3); }
.row-list { display: grid; gap: 6px; }
.row-list .r { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface); animation: pet-in .4s ease backwards; }
.row-list .tile { width: 32px; height: 32px; font-size: .9rem; background: var(--panel-2); }
.row-list b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-screen { text-align: center; padding: 16px 6px; animation: pet-in .45s ease; }
.status-screen .big { font: 800 4rem/1 var(--mono); color: var(--c-ink); letter-spacing: -.05em; }
.status-screen h4 { margin: 8px 0 4px; font-size: 1.15rem; }
.status-screen p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.confirm { display: grid; gap: 8px; padding: 12px; background: color-mix(in srgb, var(--delete) 12%, var(--panel-2)); box-shadow: inset 5px 0 0 var(--delete); }
.confirm .btns { display: flex; gap: 8px; }

/* ---------- Status codes ---------- */
.groups { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
@media (max-width: 960px) { .groups { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .groups { grid-template-columns: 1fr; } }
.group { background: var(--surface); }
.group-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; background: var(--c); color: var(--on-c, #fff); }
.group-head b { font: 800 1.7rem/1 var(--mono); letter-spacing: -.03em; }
.group-head span { font-weight: 800; }
.group-body { display: grid; gap: 4px; padding: 6px; }
.chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 46px; background: var(--surface-2); text-align: left; font-weight: 700; transition: background .2s, color .2s, transform .15s; }
.chip b { font-family: var(--mono); color: var(--c-ink); transition: color .2s; }
.chip span { font-size: .88rem; color: var(--ink-3); font-weight: 600; transition: color .2s; }
.chip:hover { transform: translateX(3px); background: var(--surface-3); }
.chip[aria-pressed="true"] { background: var(--c); color: var(--on-c, #fff); }
.chip[aria-pressed="true"] b, .chip[aria-pressed="true"] span { color: inherit; }

/* ---------- Quiz + Game ---------- */
.stage { max-width: 860px; margin: 0 auto; }
.panel { background: var(--surface); padding: clamp(20px, 4vw, 38px); }
.progress { height: 8px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .5s cubic-bezier(.2, .8, .2, 1); }
.q-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; font: 800 .85rem var(--mono); letter-spacing: .06em; color: var(--ink-3); margin-bottom: 10px; text-transform: uppercase; }
.q-text { font-size: clamp(1.5rem, 3.4vw, 2.1rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin: 22px 0; animation: pet-in .4s ease; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; padding: 14px 16px; background: var(--surface-2); font-weight: 700; min-height: 60px; transition: background .2s, transform .15s; animation: pet-in .4s ease backwards; }
.opt .k { width: 32px; height: 32px; display: grid; place-items: center; background: var(--surface-3); font: 800 .85rem var(--mono); color: var(--ink-2); flex: none; transition: background .2s, color .2s; }
.opt:hover:not(:disabled) { background: var(--surface-3); transform: translateX(4px); }
.opt:disabled { cursor: default; }
.opt.is-right { background: color-mix(in srgb, var(--post) 20%, var(--surface)); box-shadow: inset 5px 0 0 var(--post); }
.opt.is-right .k { background: var(--post); color: #fff; }
.opt.is-wrong { background: color-mix(in srgb, var(--delete) 18%, var(--surface)); box-shadow: inset 5px 0 0 var(--delete); animation: shake .4s ease; }
.opt.is-wrong .k { background: var(--delete); color: #fff; }
.opt.is-dim { opacity: .5; }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
.explain { margin-top: 14px; min-height: 56px; }
.explain .note { animation: pet-in .35s ease; }
.nav-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.score-big { font: 800 clamp(4rem, 12vw, 7rem)/1 var(--mono); letter-spacing: -.06em; margin: 6px 0 14px; }
.score-bar { height: 10px; background: var(--surface-3); max-width: 420px; margin: 0 auto 18px; }
.score-bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width 1.1s cubic-bezier(.2, .8, .2, 1); }
.big-ico { display: block; margin: 0 auto 14px; font-size: 3.4rem; color: var(--ink); }
.stars { display: flex; justify-content: center; gap: 8px; font-size: 2.2rem; margin: 6px 0 12px; }
.stars .off { color: var(--surface-3); }
.stars .on { color: var(--put); fill: currentColor; animation: star-in .5s cubic-bezier(.2, 1.4, .4, 1) backwards; }
@keyframes star-in { from { transform: scale(0); } }
.review { text-align: left; margin-top: 22px; display: grid; gap: 6px; }
.review .r { padding: 10px 14px; background: var(--surface-2); font-size: .92rem; }
.review .r b { display: block; }

.hud { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.hearts { display: flex; gap: 6px; font-size: 2rem; color: var(--delete); }
.heart { transition: transform .3s, color .3s; display: inline-flex; }
.heart .ico { fill: currentColor; font-size: 1em; }
.heart.lost { color: var(--surface-3); }
.heart.lost .ico { fill: none; }
.heart.breaking { animation: heart-break .7s ease; }
@keyframes heart-break { 0% { transform: scale(1); } 30% { transform: scale(1.5) rotate(-12deg); color: var(--delete); } 55% { transform: scale(.7) rotate(10deg); } 100% { transform: scale(1); } }
.hud .stat { font-weight: 800; display: flex; align-items: center; gap: 8px; color: var(--ink-3); }
.hud .stat b { color: var(--ink); font-size: 1.25rem; }
.arena { position: relative; padding: 18px; background: var(--surface-2); overflow: hidden; }
.arena-scene { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.castle { font-size: 2.8rem; color: var(--ink); display: grid; place-items: center; gap: 2px; text-align: center; transition: color .3s; }
.castle small { font: 800 .64rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.castle.hit { animation: shake .45s ease; color: var(--delete-ink); }
.castle.safe { color: var(--post-ink); animation: pulse .6s ease; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.scroll { flex: 1; background: var(--surface); padding: 16px 20px; animation: scroll-in .55s cubic-bezier(.2, .9, .3, 1); }
.scroll .lbl { font: 800 .68rem var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.scroll p { margin: 4px 0 0; font-size: clamp(1.2rem, 2.6vw, 1.6rem); font-weight: 800; letter-spacing: -.01em; line-height: 1.25; }
.scroll p:focus { outline: none; }
@keyframes scroll-in { from { opacity: 0; transform: translateX(-50px); } }
.timer { height: 8px; background: var(--surface-3); overflow: hidden; margin-bottom: 14px; }
.timer > i { display: block; height: 100%; width: 100%; background: var(--ink); transform-origin: left; }
.choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 700px) { .choices { grid-template-columns: repeat(2, 1fr); } }
.choice { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 8px; background: var(--surface); font: 800 1.1rem var(--mono); color: var(--c-ink); transition: background .2s, color .2s, transform .15s; min-height: 124px; position: relative; }
.choice small { font-family: var(--font); font-weight: 700; color: var(--ink-3); font-size: .8rem; text-align: center; line-height: 1.2; }
.choice:hover:not(:disabled) { transform: translateY(-4px); background: color-mix(in srgb, var(--c) 14%, var(--surface)); }
.choice:disabled { cursor: default; }
.choice .kbd { position: absolute; top: 8px; left: 10px; font: 800 .72rem var(--mono); color: var(--ink-3); }
.choice.is-right { background: var(--post); color: #fff; animation: pulse .5s ease; }
.choice.is-right small, .choice.is-right .kbd { color: #fff; }
.choice.is-right .shield { background: #fff; color: var(--post); }
.choice.is-wrong { background: var(--delete); color: #fff; animation: shake .4s ease; }
.choice.is-wrong small, .choice.is-wrong .kbd { color: #fff; }
.choice.is-wrong .shield { background: #fff; color: var(--delete); }
.choice.is-dim { opacity: .45; }
.choice.codechoice { min-height: 100px; }
.choice.codechoice .num { font-size: 1.9rem; }
.shield { width: 46px; height: 54px; flex: none; display: grid; place-items: start center; padding-top: 11px; color: var(--on-c, #fff); background: var(--c); clip-path: polygon(0 0, 100% 0, 100% 62%, 50% 100%, 0 62%); transition: background .25s, color .25s; }
.shield .ico { font-size: 22px; stroke-width: 2.4; }
.feedback { margin-top: 14px; min-height: 64px; }
.feedback .note { animation: pet-in .3s ease; }
.start-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 22px 0; text-align: left; }
@media (max-width: 700px) { .start-grid { grid-template-columns: 1fr; } }
.start-grid .card { background: var(--surface-2); padding: 16px; }
.start-grid .card b { display: flex; align-items: center; gap: 10px; }
.combo { color: var(--put-ink); font-weight: 800; }

/* ---------- Toasts + motion ---------- */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: var(--bg); padding: 12px 22px; font-weight: 700; font-size: .92rem; box-shadow: var(--shadow); animation: toast 3.2s ease forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(14px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.slowmo em { font: 800 .72rem var(--mono); font-style: normal; padding: 3px 7px; background: var(--surface-2); color: var(--ink-2); }
.slowmo[aria-pressed="true"] em { background: var(--bg); color: var(--ink); }
