/* dsa.py — styles
   Palette: cool neutral ground, ink black, "essence orange" accent,
   VS Code Dark Modern for the editor. Liquid-glass controls use an SVG
   displacement filter over a backdrop blur (see #lg-displace in index.html). */

:root {
  color-scheme: light;
  --sans: "Geist", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #eceef1;
  --bg-2: #f6f7f9;
  --ink: #0d0e10;
  --ink-2: #33363c;
  --muted: #6b7079;
  --line: rgba(13, 14, 16, 0.09);
  --line-2: rgba(13, 14, 16, 0.16);
  --panel: rgba(255, 255, 255, 0.66);
  --panel-solid: #ffffff;
  --chip-bg: rgba(13, 14, 16, 0.05);
  --accent: #ff5b14;
  --accent-soft: rgba(255, 91, 20, 0.12);
  --focus: #2f6bff;

  --glass-bg: rgba(255, 255, 255, 0.22);
  --glass-tint: rgba(255, 255, 255, 0.34);
  --glass-rim: rgba(255, 255, 255, 1);
  --glass-rim-2: rgba(255, 255, 255, 0.35);
  --glass-shadow: 0 10px 28px -10px rgba(18, 22, 30, 0.22), 0 1px 2px rgba(18, 22, 30, 0.08);
  --glass-ind: rgba(255, 255, 255, 0.78);
  --glass-hi: rgba(255, 255, 255, 0.7);

  /* visualisation */
  --v-fill: #ffffff;
  --v-stroke: #d3d7dd;
  --v-text: #15171b;
  --v-edge: #b9bec7;
  --v-head: #f1f3f5;

  /* state colours: fill / stroke / text */
  --c-active: #ff5b14;
  --c-compare-f: #ffc53d; --c-compare-s: #eea000; --c-compare-t: #2a1c00;
  --c-swap: #f43f5e;
  --c-visited-f: #cff3ec; --c-visited-s: #14b8a6; --c-visited-t: #0b4d45;
  --c-frontier-f: #dde8ff; --c-frontier-s: #3b82f6; --c-frontier-t: #1e3a8a;
  --c-done-f: #15171b; --c-done-t: #ffffff;
  --c-found: #22c55e;
  --c-path: #16a34a;
  --c-pivot: #8b5cf6;
  --c-min: #0ea5e9;
  --c-bad-f: #ffe1e4; --c-bad-s: #ef4444; --c-bad-t: #9f1239;
  --c-new-f: #d9f99d; --c-new-s: #84cc16; --c-new-t: #1a2e05;
  --c-read-f: #fff3cd; --c-read-s: #f59e0b; --c-read-t: #5c3d00;
  --c-range-f: rgba(59, 130, 246, 0.09); --c-range-s: rgba(59, 130, 246, 0.5);

  /* Big-O badges */
  --o-good-b: #dcfce7; --o-good-t: #166534;
  --o-ok-b: #d5f5ef; --o-ok-t: #115e59;
  --o-lin-b: #fdf0c8; --o-lin-t: #8a4b06;
  --o-mid-b: #ffe6d3; --o-mid-t: #9a3412;
  --o-bad-b: #ffe2e6; --o-bad-t: #9f1239;

  --blob-1: rgba(255, 110, 40, 0.30);
  --blob-2: rgba(120, 220, 120, 0.26);
  --blob-3: rgba(80, 140, 255, 0.24);

  --radius: 22px;
  --topbar-h: 68px;
  --side-w: 268px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0c0e; --bg-2: #131418; --ink: #eceef1; --ink-2: #c3c7ce; --muted: #8b9099;
    --line: rgba(255, 255, 255, 0.08); --line-2: rgba(255, 255, 255, 0.16);
    --panel: rgba(22, 24, 28, 0.66); --panel-solid: #16181c; --chip-bg: rgba(255, 255, 255, 0.07);
    --accent: #ff6a26; --accent-soft: rgba(255, 106, 38, 0.16); --focus: #7aa2ff;
    --glass-bg: rgba(255, 255, 255, 0.05); --glass-tint: rgba(255, 255, 255, 0.06);
    --glass-rim: rgba(255, 255, 255, 0.55); --glass-rim-2: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.5);
    --glass-ind: rgba(255, 255, 255, 0.16); --glass-hi: rgba(255, 255, 255, 0.28);
    --v-fill: #1b1d22; --v-stroke: #363a42; --v-text: #eceef1; --v-edge: #4a4f59; --v-head: #23262c;
    --c-compare-f: #ffc53d; --c-compare-s: #ffc53d; --c-compare-t: #221700;
    --c-visited-f: #0f3a35; --c-visited-s: #2dd4bf; --c-visited-t: #a7f3e7;
    --c-frontier-f: #16244a; --c-frontier-s: #60a5fa; --c-frontier-t: #cfe0ff;
    --c-done-f: #eceef1; --c-done-t: #0b0c0e;
    --c-bad-f: #43141b; --c-bad-s: #f87171; --c-bad-t: #fecdd3;
    --c-new-f: #2b3d0c; --c-new-s: #a3e635; --c-new-t: #e4fbb7;
    --c-read-f: #3d2c05; --c-read-s: #fbbf24; --c-read-t: #fde9b0;
    --c-range-f: rgba(96, 165, 250, 0.1); --c-range-s: rgba(96, 165, 250, 0.55);
    --o-good-b: rgba(34, 197, 94, 0.16); --o-good-t: #86efac;
    --o-ok-b: rgba(45, 212, 191, 0.15); --o-ok-t: #7eeadb;
    --o-lin-b: rgba(245, 180, 40, 0.16); --o-lin-t: #fcd57a;
    --o-mid-b: rgba(255, 120, 50, 0.17); --o-mid-t: #ffb38a;
    --o-bad-b: rgba(244, 63, 94, 0.17); --o-bad-t: #fda4b4;
    --blob-1: rgba(255, 100, 30, 0.16); --blob-2: rgba(90, 200, 90, 0.10); --blob-3: rgba(70, 120, 255, 0.16);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0c0e; --bg-2: #131418; --ink: #eceef1; --ink-2: #c3c7ce; --muted: #8b9099;
  --line: rgba(255, 255, 255, 0.08); --line-2: rgba(255, 255, 255, 0.16);
  --panel: rgba(22, 24, 28, 0.66); --panel-solid: #16181c; --chip-bg: rgba(255, 255, 255, 0.07);
  --accent: #ff6a26; --accent-soft: rgba(255, 106, 38, 0.16); --focus: #7aa2ff;
  --glass-bg: rgba(255, 255, 255, 0.05); --glass-tint: rgba(255, 255, 255, 0.06);
  --glass-rim: rgba(255, 255, 255, 0.55); --glass-rim-2: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.5);
  --glass-ind: rgba(255, 255, 255, 0.16); --glass-hi: rgba(255, 255, 255, 0.28);
  --v-fill: #1b1d22; --v-stroke: #363a42; --v-text: #eceef1; --v-edge: #4a4f59; --v-head: #23262c;
  --c-compare-f: #ffc53d; --c-compare-s: #ffc53d; --c-compare-t: #221700;
  --c-visited-f: #0f3a35; --c-visited-s: #2dd4bf; --c-visited-t: #a7f3e7;
  --c-frontier-f: #16244a; --c-frontier-s: #60a5fa; --c-frontier-t: #cfe0ff;
  --c-done-f: #eceef1; --c-done-t: #0b0c0e;
  --c-bad-f: #43141b; --c-bad-s: #f87171; --c-bad-t: #fecdd3;
  --c-new-f: #2b3d0c; --c-new-s: #a3e635; --c-new-t: #e4fbb7;
  --c-read-f: #3d2c05; --c-read-s: #fbbf24; --c-read-t: #fde9b0;
  --c-range-f: rgba(96, 165, 250, 0.1); --c-range-s: rgba(96, 165, 250, 0.55);
  --o-good-b: rgba(34, 197, 94, 0.16); --o-good-t: #86efac;
  --o-ok-b: rgba(45, 212, 191, 0.15); --o-ok-t: #7eeadb;
  --o-lin-b: rgba(245, 180, 40, 0.16); --o-lin-t: #fcd57a;
  --o-mid-b: rgba(255, 120, 50, 0.17); --o-mid-t: #ffb38a;
  --o-bad-b: rgba(244, 63, 94, 0.17); --o-bad-t: #fda4b4;
  --blob-1: rgba(255, 100, 30, 0.16); --blob-2: rgba(90, 200, 90, 0.10); --blob-3: rgba(70, 120, 255, 0.16);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--chip-bg); padding: 0.1em 0.4em; border-radius: 6px; }
kbd { font: 500 11.5px/1 var(--mono); padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--panel-solid); color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.fx-defs { position: absolute; width: 0; height: 0; }
.muted { color: var(--muted); }

.ambient { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ambient .blob { position: absolute; border-radius: 50%; filter: blur(70px); }
.ambient .b1 { width: 46vw; height: 46vw; left: -10vw; top: -14vw; background: var(--blob-1); animation: drift 26s ease-in-out infinite alternate; }
.ambient .b2 { width: 40vw; height: 40vw; right: -12vw; top: 18vh; background: var(--blob-2); animation: drift 32s ease-in-out infinite alternate-reverse; }
.ambient .b3 { width: 50vw; height: 50vw; left: 30vw; bottom: -30vw; background: var(--blob-3); animation: drift 30s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate(6vw, 4vh) scale(1.08); } }

/* ---------- liquid glass ---------- */
.lg, .lg-seg {
  position: relative;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}
.lg {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border: 0; background: transparent; color: var(--ink);
  font: 500 14px/1 var(--sans);
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  transition: transform 0.5s cubic-bezier(0.3, 1.7, 0.45, 1), box-shadow 0.3s;
}
.lg > :not(.lg-fx), .lg-seg > :not(.lg-fx):not(.lg-ind) { position: relative; z-index: 2; }
.lg:hover { transform: translateY(-1px) scale(1.035); }
.lg:active { transform: scale(0.94); transition-duration: 0.12s; }
.lg-fx { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; z-index: 0; }
.lg-blur {
  position: absolute; inset: -20px; border-radius: inherit;
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(5px) saturate(150%);
  backdrop-filter: blur(5px) saturate(150%);
  filter: url(#lg-displace);
  transform: scale(0.94);
}
.lg-tint {
  position: absolute; inset: 0; border-radius: inherit;
  background: var(--glass-tint);
  box-shadow: inset 0 1px 2px var(--glass-hi), inset 0 -1px 2px rgba(255, 255, 255, 0.06);
}
.lg-shine {
  position: absolute; inset: 0; border-radius: inherit; opacity: 0;
  background: radial-gradient(140px circle at var(--mx, 30%) var(--my, 0%), var(--glass-hi), transparent 62%);
  transition: opacity 0.35s;
}
.lg:hover .lg-shine, .lg-seg:hover > .lg-fx .lg-shine { opacity: 1; }
.lg-fx::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(110deg, var(--glass-rim-2) 0%, rgba(255, 255, 255, 0) 38%, var(--glass-rim) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

/* segmented control with a sliding liquid blob */
.lg-seg { display: inline-flex; align-items: center; padding: 4px; gap: 2px; box-shadow: var(--glass-shadow); }
.lg-seg > a, .lg-seg > button {
  border: 0; background: none; cursor: pointer;
  height: 34px; padding: 0 15px; border-radius: 999px;
  display: inline-flex; align-items: center; white-space: nowrap;
  font: 500 14px/1 var(--sans); color: var(--muted);
  transition: color 0.3s;
}
.lg-seg > a:hover, .lg-seg > button:hover { color: var(--ink); }
.lg-seg > .on { color: var(--ink); }
.lg-ind {
  position: absolute; left: 0; top: 0; z-index: 1; height: 34px; width: 0;
  border-radius: 999px; opacity: 0; pointer-events: none;
  box-shadow: 0 6px 16px -6px rgba(18, 22, 30, 0.35), 0 1px 1px rgba(18, 22, 30, 0.08);
  transform-origin: center;
}
.lg-ind .lg-tint { background: var(--glass-ind); }
.lg-ind .lg-blur { filter: url(#lg-displace); }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  pointer-events: none;
}
.topbar::before {
  content: ""; position: absolute; inset: 0 0 -24px 0; z-index: -1;
  background: linear-gradient(var(--bg) 30%, transparent);
  opacity: 0.92;
}
.topbar-inner {
  height: var(--topbar-h); display: flex; align-items: center; gap: 14px;
  padding-inline: 20px; pointer-events: auto;
}
.brand { display: inline-flex; align-items: baseline; font-weight: 700; font-size: 25px; letter-spacing: -0.045em; margin-right: 6px; }
.brand-mark { font-style: italic; transform: skewX(-6deg); display: inline-block; }
.brand-ext { font-family: var(--mono); font-weight: 500; font-size: 17px; color: var(--accent); letter-spacing: -0.02em; margin-left: 1px; }
.nav-tabs { margin-left: auto; margin-right: auto; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn { width: 40px; padding: 0; }
.search-btn { color: var(--muted); padding-right: 8px; }
.search-btn kbd { margin-left: 4px; }
.search-btn .search-label { color: var(--ink-2); }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns 0.45s cubic-bezier(0.3, 1, 0.4, 1); }
@media (min-width: 961px) {
  body.side-closed .shell, body[data-tab="home"] .shell { grid-template-columns: 0px minmax(0, 1fr); }
  .sidebar { width: var(--side-w); transition: opacity 0.3s, transform 0.45s cubic-bezier(0.3, 1, 0.4, 1); }
  body.side-closed .sidebar, body[data-tab="home"] .sidebar { opacity: 0; transform: translateX(-30px); pointer-events: none; visibility: hidden; transition: opacity 0.25s, transform 0.45s, visibility 0s 0.45s; }
  body.side-closed .main, body[data-tab="home"] .main { padding-left: 28px; }
  body.side-closed .main > *, body[data-tab="home"] .main > * { margin-inline: auto; }
}
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 30;
  padding: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 8px) 14px 14px 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.side-head { display: flex; flex-direction: column; gap: 10px; }
.side-title { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 0 12px; font: 600 14px/1 var(--sans); letter-spacing: -0.01em; }
.side-title em { font: 500 11px/1 var(--mono); font-style: normal; color: var(--muted); margin-left: 4px; }
.side-close { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--muted); display: grid; place-items: center; cursor: pointer; transition: color 0.2s, transform 0.4s cubic-bezier(0.3, 1.7, 0.5, 1); }
.side-close:hover { color: var(--ink); transform: translateX(-2px); }
.side-btn .side-fill { transition: opacity 0.3s; opacity: 0.9; }
body.side-closed .side-btn .side-fill { opacity: 0; }
body[data-tab="home"] .side-btn { display: none; }

/* dropdown menus under the top nav */
.nav-tabs > a { gap: 6px; }
.nav-tabs .chev { opacity: 0.55; transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.2s; }
.nav-tabs a.menu-open .chev { transform: rotate(180deg); opacity: 1; }
.mega { position: absolute; left: 0; right: 0; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) - 6px); display: flex; justify-content: center; padding-inline: 16px; pointer-events: none; z-index: 45; }
.mega-card {
  pointer-events: auto; width: min(1200px, 100%); max-height: min(76vh, 680px); overflow: auto;
  padding: 16px 22px 8px; border-radius: 24px;
  background: color-mix(in srgb, var(--panel-solid) 88%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(160%); backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--line); box-shadow: 0 30px 70px -24px rgba(10, 14, 22, 0.35), inset 0 1px 1px var(--glass-hi);
  transform-origin: top center;
}
.mega-card.in { animation: megaIn 0.42s cubic-bezier(0.3, 1.35, 0.45, 1); }
@keyframes megaIn { from { opacity: 0; transform: translateY(-8px) scale(0.975); } }
.mega-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.mega-head a { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 13px; color: var(--ink-2); }
.mega-head a:hover { color: var(--accent); }
.mega-cols { columns: 5 168px; column-gap: 14px; }
.mega-col { break-inside: avoid; margin-bottom: 14px; display: flex; flex-direction: column; }
.mega-col h4 { margin: 0 0 4px; padding: 4px 8px; font: 600 11px/1.2 var(--sans); text-transform: uppercase; letter-spacing: 0.09em; color: var(--accent); }
.mega-col a { padding: 5px 8px; border-radius: 9px; font-size: 14px; color: var(--ink-2); transition: background 0.2s, color 0.2s; }
.mega-col a:hover, .mega-col a:focus-visible { background: var(--chip-bg); color: var(--ink); }
.mega-col a.on { color: var(--ink); font-weight: 600; }
.filter {
  display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted);
}
.filter input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; font: 400 14px var(--sans); color: var(--ink); }
.filter:focus-within { border-color: var(--line-2); }
.side-list { overflow-y: auto; flex: 1; padding: 2px 4px 40px 0; margin-right: -6px; scrollbar-width: thin; }
.side-group { margin-bottom: 14px; }
.side-cat { font: 600 11px/1 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); padding: 8px 12px 6px; }
.side-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 12px; border-radius: 12px; font-size: 14px; color: var(--ink-2);
  transition: background 0.25s, color 0.25s, transform 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.side-item:hover { background: var(--chip-bg); color: var(--ink); transform: translateX(2px); }
.side-item.on { background: var(--panel-solid); color: var(--ink); font-weight: 600; box-shadow: 0 6px 18px -8px rgba(18, 22, 30, 0.3), inset 0 0 0 1px var(--line); }
.side-item i { font: 500 10.5px/1 var(--mono); font-style: normal; color: var(--muted); border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 6px; }
.side-empty { color: var(--muted); padding: 12px; }
.scrim { display: none; }

.main { padding: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 12px) 28px 60px 14px; min-width: 0; outline: none; }
.main > * { max-width: 1480px; }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
}
.eyebrow { font: 600 11.5px/1.2 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; display: flex; gap: 8px; align-items: center; }
.eyebrow a:hover { color: var(--accent); }

/* ---------- home ---------- */
.home { display: flex; flex-direction: column; gap: 28px; padding-top: 18px; }
.hero { padding: 18px 6px 8px; }
.hero-title { font-size: clamp(38px, 6vw, 76px); line-height: 0.98; letter-spacing: -0.05em; font-weight: 600; margin: 0 0 20px; text-wrap: balance; }
.hero-title span { color: var(--muted); }
.hero-sub { font-size: 18px; color: var(--ink-2); max-width: 62ch; margin: 0 0 26px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-lg { height: 54px; padding: 0 10px 0 24px; font-size: 16px; gap: 14px; }
.btn-lg .cnt { font: 500 13px/1 var(--mono); background: var(--ink); color: var(--bg); border-radius: 999px; padding: 9px 12px; }
.home-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.home-card { padding: 22px 24px; }
.home-card h2 { font-size: 17px; margin: 0 0 14px; letter-spacing: -0.01em; }
.cheat { width: 100%; border-collapse: collapse; font-size: 14px; }
.cheat th { text-align: left; font: 600 11px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 8px 10px 0; }
.cheat td { padding: 8px 8px 8px 0; border-top: 1px solid var(--line); vertical-align: middle; }
.cheat td:first-child { color: var(--muted); white-space: nowrap; }
.cheat td:last-child { text-align: right; }
.cheat code { background: none; padding: 0; }
.howto { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.howto li { display: flex; align-items: center; gap: 6px; }
.howto li span { margin-left: 8px; color: var(--ink-2); }

/* ---------- index pages ---------- */
.index-head { padding: 16px 4px 10px; }
.index-head h1, .topic-head h1 { font-size: clamp(30px, 3.6vw, 44px); letter-spacing: -0.04em; line-height: 1.02; margin: 0; font-weight: 600; text-wrap: balance; }
.index-group { margin-top: 26px; }
.index-group h2 { font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 0 0 12px 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column; gap: 8px; padding: 16px 18px;
  border-radius: 18px; background: var(--panel); border: 1px solid var(--line);
  transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.3s, border-color 0.3s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--glass-shadow); border-color: var(--line-2); }
.card-t { font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.card-s { color: var(--muted); font-size: 13.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-f { display: flex; gap: 8px; align-items: center; margin-top: auto; }
.vcount { font-size: 12px; color: var(--muted); }

/* ---------- topic ---------- */
.topic { display: flex; flex-direction: column; gap: 18px; container: topic / inline-size; }
.topic-head { padding: 8px 4px 0; display: flex; flex-direction: column; gap: 11px; }
.topic-head .eyebrow { margin: 0; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.variant-seg { max-width: 100%; flex-wrap: wrap; }
.summary { font-size: 16.5px; line-height: 1.55; color: var(--ink-2); margin: 0; max-width: 88ch; }
.summary code { color: var(--ink); }
.swap { animation: swapIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes swapIn { from { opacity: 0; transform: translateY(4px); filter: blur(3px); } }
.cx { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cx-item { display: inline-flex; align-items: center; gap: 8px; padding: 5px 5px 5px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.cx-lab { font: 600 11px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 0 2px 0 6px; }
.cx-lab:first-child { margin-left: 0; }
.cx-note { font-size: 13px; color: var(--muted); flex-basis: 100%; }
.obadge { font: 500 12.5px/1 var(--mono); padding: 6px 9px; border-radius: 999px; white-space: nowrap; background: var(--chip-bg); color: var(--ink-2); }
.o-good { background: var(--o-good-b); color: var(--o-good-t); }
.o-ok { background: var(--o-ok-b); color: var(--o-ok-t); }
.o-lin { background: var(--o-lin-b); color: var(--o-lin-t); }
.o-mid { background: var(--o-mid-b); color: var(--o-mid-t); }
.o-bad { background: var(--o-bad-b); color: var(--o-bad-t); }
.ops-wrap { border-radius: 18px; background: var(--panel); border: 1px solid var(--line); padding: 4px 14px 12px; }
.ops-wrap summary { cursor: pointer; font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 10px 0 8px; }
.ops { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 2px 18px; }
.op { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); min-width: 0; flex-wrap: wrap; }
.op code { background: none; padding: 0; color: var(--ink); flex: 1; min-width: 0; overflow-wrap: anywhere; }
.op-note { flex-basis: 100%; font-size: 12.5px; color: var(--muted); margin-top: -2px; }

.stage { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: 18px; align-items: start; }
.topic[data-kind="ds"] .stage { grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr); }
.viz-pane { padding: 16px 18px 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pane-title { font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.lg-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.dot { width: 11px; height: 11px; border-radius: 4px; background: var(--sf, var(--v-fill)); box-shadow: inset 0 0 0 1.5px var(--ss, var(--v-stroke)); display: inline-block; }

.inputs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-solid); flex: 1 1 180px; min-width: 0; }
.field span { font: 500 12px/1 var(--mono); color: var(--muted); }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: 500 13.5px var(--mono); color: var(--ink); }
.field:focus-within { border-color: var(--focus); }
.btn-sm { height: 38px; padding: 0 16px; font-size: 13.5px; }
.in-err { color: var(--c-bad-s); font-size: 13px; flex-basis: 100%; }
.in-err:empty { display: none; }

.viz-area { min-height: 260px; display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 14px; padding: 8px 0; }
.viz-fig { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.viz-fig figcaption { font: 500 12.5px/1.2 var(--sans); color: var(--muted); text-align: center; }
.viz-scroll { overflow-x: auto; overflow-y: hidden; padding: 4px 2px; scrollbar-width: thin; }
.viz-svg { display: block; width: 100%; height: auto; margin: 0 auto; overflow: visible; font-family: var(--mono); }

.aux { display: flex; flex-direction: column; gap: 8px; }
.aux:empty { display: none; }
.aux-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.aux-label { font: 500 12px/1 var(--mono); color: var(--muted); min-width: 64px; text-align: right; }
.aux-items { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; min-width: 0; }
.aux-end { font: 500 10.5px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 4px; }
.aux-empty { font-size: 12.5px; color: var(--muted); font-style: italic; }
.chip { font: 500 13px/1 var(--mono); padding: 7px 10px; border-radius: 9px; background: var(--sf, var(--panel-solid)); color: var(--st, var(--ink)); box-shadow: inset 0 0 0 1px var(--ss, var(--line-2)); animation: chipIn 0.3s ease-out; }
@keyframes chipIn { from { opacity: 0; transform: scale(0.85); } }

.caption { display: flex; gap: 12px; align-items: flex-start; min-height: 52px; padding: 12px 14px; border-radius: 16px; background: var(--panel-solid); border: 1px solid var(--line); font-size: 15px; line-height: 1.5; margin: 0; }
.caption.static { display: block; color: var(--ink-2); font-size: 14px; min-height: 0; }
.cap-step { font: 500 12px/1 var(--mono); color: var(--muted); padding: 5px 8px; border-radius: 999px; background: var(--chip-bg); flex-shrink: 0; margin-top: 1px; }
.cap-msg { color: var(--ink); }

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.play-btn { width: 104px; background: var(--ink); color: var(--bg); }
.play-btn .lg-tint { background: transparent; }
.play-btn .lg-blur { display: none; }
.play-btn .i-pause { display: none; }
.play-btn.playing .i-pause { display: block; }
.play-btn.playing .i-play { display: none; }
.scrub { flex: 1 1 140px; min-width: 100px; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 999px; background: linear-gradient(90deg, var(--accent) var(--p, 0%), var(--line-2) var(--p, 0%)); outline-offset: 6px; cursor: pointer; }
.scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--panel-solid); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25), inset 0 0 0 1px var(--line-2); transition: transform 0.3s cubic-bezier(0.3, 1.8, 0.5, 1); }
.scrub::-webkit-slider-thumb:hover { transform: scale(1.2); }
.scrub::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: var(--panel-solid); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.speed-btn { width: 58px; padding: 0; font: 500 13px/1 var(--mono); height: 40px; }

/* ---------- VS Code panel ---------- */
.code-pane {
  --vs-bg: #1f1f1f; --vs-bar: #181818; --vs-border: #2b2b2b; --vs-fg: #cccccc; --vs-num: #6e7681;
  display: flex; flex-direction: column; min-width: 0; container-type: inline-size;
  border-radius: var(--radius); overflow: hidden;
  background: var(--vs-bg); color: var(--vs-fg);
  box-shadow: 0 24px 50px -24px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.2);
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 8px);
}
.vs-tabs { display: flex; align-items: stretch; justify-content: space-between; background: var(--vs-bar); border-bottom: 1px solid var(--vs-border); height: 38px; }
.vs-tab { display: flex; align-items: center; gap: 7px; padding: 0 16px; font: 400 13px/1 var(--sans); color: #fff; background: var(--vs-bg); border-top: 2px solid #0078d4; border-right: 1px solid var(--vs-border); margin-bottom: -1px; }
.vs-copy { background: none; border: 1px solid #3c3c3c; color: #cccccc; font: 500 12px/1 var(--sans); border-radius: 6px; padding: 0 10px; margin: 6px 8px; cursor: pointer; transition: background 0.2s; }
.vs-copy:hover { background: #2a2d2e; }
.vs-crumbs { font: 400 12.5px/1 var(--sans); color: #a9a9a9; padding: 8px 16px 6px; }
.vs-crumbs span { color: #6e7681; margin: 0 4px; }
.vs-editor { overflow: auto; max-height: min(68vh, 660px); padding: 4px 0 14px; font: 400 12.8px/1.6 var(--mono); font-size: clamp(10.5px, calc((100cqi - 68px) / 38.6), 13px); scrollbar-color: #424242 transparent; scrollbar-width: thin; position: relative; }
.vs-lines { min-width: max-content; }
.ln { display: flex; position: relative; padding-right: 18px; cursor: text; }
.ln:hover { background: rgba(255, 255, 255, 0.03); }
.ln.sel { background: #2a2d2e; }
.gut { width: 48px; flex-shrink: 0; text-align: right; padding-right: 16px; color: var(--vs-num); user-select: none; position: relative; }
.src { white-space: pre; tab-size: 4; }
.ln.cur { background: rgba(255, 214, 0, 0.13); }
.ln.cur .gut { color: #cccccc; }
.ln.cur-first .gut::before {
  content: ""; position: absolute; left: 8px; top: 4px; width: 13px; height: 13px;
  background: #ffcc00; clip-path: polygon(0 22%, 52% 22%, 52% 0, 100% 50%, 52% 100%, 52% 78%, 0 78%);
  animation: arrowIn 0.25s ease-out;
}
@keyframes arrowIn { from { transform: translateX(-4px); opacity: 0; } }
.t-kw { color: #569cd6; } .t-kw2 { color: #c586c0; } .t-fn { color: #dcdcaa; } .t-cls { color: #4ec9b0; }
.t-str { color: #ce9178; } .t-num { color: #b5cea8; } .t-com { color: #6a9955; } .t-var, .t-prop { color: #9cdcfe; }
.t-self { color: #569cd6; font-style: italic; } .t-op { color: #d4d4d4; } .t-const { color: #4fc1ff; }
.t-br0 { color: #ffd700; } .t-br1 { color: #da70d6; } .t-br2 { color: #179fff; }
.vs-panel { border-top: 1px solid var(--vs-border); background: var(--vs-bar); }
.vs-panel-h { display: flex; justify-content: space-between; padding: 8px 16px; font: 600 11px/1 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: #bbbbbb; }
.vs-dim { color: #6e7681; font-weight: 500; text-transform: none; letter-spacing: 0; }
.vs-vars { padding: 2px 16px 12px; font: 400 13px/20px var(--mono); max-height: 150px; overflow: auto; display: grid; grid-template-columns: 1fr; }
.var { display: flex; gap: 8px; padding: 1px 6px; border-radius: 4px; min-width: 0; }
.var .vk { color: #9cdcfe; flex-shrink: 0; }
.var .vo { color: #858585; }
.var .vv { color: #ce9178; overflow-wrap: anywhere; }
.var.changed { animation: varFlash 1s ease-out; }
.var.changed .vv { color: #ffd479; }
@keyframes varFlash { from { background: rgba(255, 204, 0, 0.22); } to { background: transparent; } }
.vs-empty { color: #6e7681; font-style: italic; }
.vs-status { display: flex; gap: 18px; align-items: center; height: 24px; padding: 0 12px; font: 400 12px/1 var(--sans); color: #fff; background: #0078d4; }
.vs-status span:first-child { margin-right: auto; }
.code-pane.debugging .vs-status { background: #cc6633; }

/* ---------- notes + pager ---------- */
.notes-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 14px; }
.notes-row:empty { display: none; }
.note-card { padding: 18px 20px; }
.note-card h3 { font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); margin: 0 0 12px; }
.note-card ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; color: var(--ink-2); font-size: 14.5px; }
.note-card li::marker { color: var(--accent); }
.probs { display: flex; flex-wrap: wrap; gap: 6px; }
.prob { font-size: 13px; padding: 6px 11px; border-radius: 999px; background: var(--chip-bg); color: var(--ink-2); }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.pager-btn { height: auto; padding: 12px 22px; flex-direction: column; align-items: flex-start; gap: 5px; border-radius: 22px; max-width: 48%; }
.pager-btn.next { align-items: flex-end; text-align: right; }
.pg-dir { font: 500 11.5px/1 var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.pg-t { font-size: 15px; font-weight: 600; }

/* ---------- palette ---------- */
.palette { position: fixed; inset: 0; z-index: 80; background: rgba(10, 12, 16, 0.28); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette-card { width: min(620px, 100%); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.45); overflow: hidden; animation: palIn 0.35s cubic-bezier(0.3, 1.4, 0.5, 1); }
@keyframes palIn { from { transform: translateY(-8px) scale(0.98); opacity: 0; } }
#paletteInput { width: 100%; border: 0; outline: 0; font: 400 17px var(--sans); padding: 18px 20px; background: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.palette-list { max-height: 50vh; overflow: auto; padding: 6px; }
.pal-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; }
.pal-item em { font-style: normal; font-size: 12.5px; color: var(--muted); text-align: right; }
.pal-item.on, .pal-item:hover { background: var(--chip-bg); }
.pal-empty { padding: 14px; color: var(--muted); margin: 0; }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.palette-foot kbd { margin-right: 3px; }

/* ---------- SVG visualisation ---------- */
.viz-svg text { font-size: 14px; font-weight: 500; fill: var(--v-text); }
.viz-svg .cell > rect, .viz-svg .node > circle, .viz-svg .node > rect {
  fill: var(--sf, var(--v-fill)); stroke: var(--ss, var(--v-stroke)); stroke-width: 1.5;
  transition: fill 0.35s, stroke 0.35s;
}
.viz-svg .cell > text, .viz-svg .node > text { fill: var(--st, var(--v-text)); transition: fill 0.35s; }
.viz-svg g.cell, .viz-svg g.node, .viz-svg g.ptr, .viz-svg g.wlabel, .viz-svg g.ghost { transition: transform 0.5s cubic-bezier(0.3, 1.25, 0.5, 1), opacity 0.35s; }
.viz-svg .cell.empty > rect { fill: none; stroke-dasharray: 4 4; }
.viz-svg .kv > rect.khead { fill: var(--v-head); stroke: none; }
.viz-svg .kv > text.ktext { fill: var(--muted); font-size: 12.5px; }
.viz-svg .bar > text.bar-val { fill: var(--ink-2); }
.viz-svg .cell > text.sub { fill: var(--muted); font-size: 11px; }
.viz-svg .lcell > line.div { stroke: var(--ss, var(--v-stroke)); stroke-width: 1.5; }
.viz-svg .lcell > circle.dot { fill: var(--st, var(--v-text)); }
.viz-svg .idx { fill: var(--muted); font-size: 11px; font-weight: 400; }
.viz-svg .idx[class*=" s-"] { fill: var(--ss, var(--accent)); font-weight: 700; }
.viz-svg .row-label { fill: var(--muted); font: 500 12.5px var(--mono); }
.viz-svg .range-label { fill: var(--ss, var(--muted)); font-size: 11.5px; }
.viz-svg .null-t { fill: var(--muted); font-style: italic; font-size: 13px; }
.viz-svg .muted-t { fill: var(--muted); }
.viz-svg rect.range { fill: var(--sf); stroke: var(--ss); stroke-width: 1.5; stroke-dasharray: 5 4; transition: transform 0.5s cubic-bezier(0.3, 1.2, 0.5, 1), width 0.5s cubic-bezier(0.3, 1.2, 0.5, 1), fill 0.3s; }
.viz-svg .edge .eline { stroke: var(--se, var(--v-edge)); stroke-width: 2.2; fill: none; transition: stroke 0.35s, stroke-width 0.35s; }
.viz-svg .edge .ehead { fill: var(--se, var(--v-edge)); transition: fill 0.35s; }
.viz-svg .edge[class*=" s-"] .eline { stroke-width: 3.6; }
.viz-svg .edge.s-dim, .viz-svg .edge.s-dim .eline { stroke-width: 2; opacity: 0.35; }
.viz-svg .link.prev .eline { stroke-dasharray: 4 3; }
.viz-svg .wlabel rect { fill: var(--bg-2); stroke: var(--se, var(--v-stroke)); stroke-width: 1.2; }
.viz-svg .wlabel text { font-size: 12px; fill: var(--ink-2); }
.viz-svg .badge rect { fill: var(--ink); }
.viz-svg .badge text { fill: var(--bg); font-size: 11px; font-weight: 600; }
.viz-svg .ptr path { fill: var(--pc, var(--accent)); }
.viz-svg .ptr text, .viz-svg .ptr-t { fill: var(--pc, var(--accent)); font-weight: 700; font-size: 12.5px; }
.viz-svg .ptr.s-frontier, .viz-svg .ptr.s-min { --pc: var(--c-frontier-s); }
.viz-svg .ptr.s-visited { --pc: var(--c-visited-s); }
.viz-svg .ptr.s-compare { --pc: var(--c-compare-s); }
.viz-svg .ptr.s-pivot { --pc: var(--c-pivot); }
.viz-svg .ptr.s-found, .viz-svg .ptr.s-path { --pc: var(--c-path); }
.viz-svg .ptr.s-bad { --pc: var(--c-bad-s); }
.viz-svg .ptr.s-dim { --pc: var(--muted); }
.viz-svg .ghost rect { fill: none; stroke: var(--v-stroke); stroke-dasharray: 4 4; }
.viz-svg .ghost text { fill: var(--muted); font-size: 12.5px; font-style: italic; }
.viz-svg .tray { fill: none; stroke: var(--v-stroke); stroke-width: 2; stroke-linecap: round; }
.viz-svg .dim, .viz-svg .s-dim { opacity: 0.32; }
.viz-svg .enter { animation: vIn 0.4s ease-out; }
@keyframes vIn { from { opacity: 0; } }
.viz-svg .node.s-start > circle, .viz-svg .node.s-start > rect { stroke: var(--accent); stroke-width: 3.5; }
.viz-svg .node.s-target > circle, .viz-svg .node.s-target > rect { stroke: var(--c-path); stroke-width: 3; stroke-dasharray: 5 3; }

/* state tokens (shared by SVG, chips and legend dots) */
.s-active, .s-current { --sf: var(--c-active); --ss: var(--c-active); --st: #fff; --se: var(--c-active); }
.s-compare { --sf: var(--c-compare-f); --ss: var(--c-compare-s); --st: var(--c-compare-t); --se: var(--c-compare-s); }
.s-swap { --sf: var(--c-swap); --ss: var(--c-swap); --st: #fff; --se: var(--c-swap); }
.s-visited { --sf: var(--c-visited-f); --ss: var(--c-visited-s); --st: var(--c-visited-t); --se: var(--c-visited-s); }
.s-frontier { --sf: var(--c-frontier-f); --ss: var(--c-frontier-s); --st: var(--c-frontier-t); --se: var(--c-frontier-s); }
.s-done, .s-sorted { --sf: var(--c-done-f); --ss: var(--c-done-f); --st: var(--c-done-t); --se: var(--ink); }
.s-tree { --se: var(--ink); --sf: var(--c-done-f); --ss: var(--c-done-f); --st: var(--c-done-t); }
.s-found, .s-match { --sf: var(--c-found); --ss: var(--c-found); --st: #fff; --se: var(--c-found); }
.s-path { --sf: var(--c-path); --ss: var(--c-path); --st: #fff; --se: var(--c-path); }
.s-pivot { --sf: var(--c-pivot); --ss: var(--c-pivot); --st: #fff; --se: var(--c-pivot); }
.s-min, .s-max { --sf: var(--c-min); --ss: var(--c-min); --st: #fff; --se: var(--c-min); }
.s-bad, .s-removed { --sf: var(--c-bad-f); --ss: var(--c-bad-s); --st: var(--c-bad-t); --se: var(--c-bad-s); }
.s-new { --sf: var(--c-new-f); --ss: var(--c-new-s); --st: var(--c-new-t); --se: var(--c-new-s); }
.s-read, .s-relax { --sf: var(--c-read-f); --ss: var(--c-read-s); --st: var(--c-read-t); --se: var(--c-read-s); }
.s-range { --sf: var(--c-range-f); --ss: var(--c-range-s); --st: var(--ink); --se: var(--c-range-s); }
.s-start { --ss: var(--accent); }
.s-target { --ss: var(--c-path); }
.s-dim { --st: var(--muted); }

/* ---------- responsive ---------- */
/* code sits beside the picture until the topic column gets really narrow */
@container topic (max-width: 820px) {
  .stage, .topic[data-kind="ds"] .stage { grid-template-columns: minmax(0, 1fr); }
  .code-pane { position: relative; top: 0; }
}
@media (max-width: 1180px) {
  .home-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  :root { --topbar-h: 60px; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(310px, 86vw); height: auto;
    background: var(--bg-2); border-right: 1px solid var(--line);
    transform: translateX(-104%); transition: transform 0.45s cubic-bezier(0.3, 1.1, 0.4, 1);
    box-shadow: 20px 0 50px -20px rgba(0, 0, 0, 0.35); z-index: 60;
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
  }
  body.drawer-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(10, 12, 16, 0.3); opacity: 0; pointer-events: none; transition: opacity 0.3s; }
  body.drawer-open .scrim { opacity: 1; pointer-events: auto; }
  .main { padding-inline: 16px; }
  .search-label, .search-btn kbd { display: none; }
  .search-btn { width: 40px; padding: 0; }
  .topbar-inner { padding-inline: 16px; gap: 8px; }
  .nav-tabs > a { padding: 0 11px; font-size: 13px; }
}
@media (max-width: 640px) {
  .brand { display: none; }
  .variant-seg { border-radius: 20px; }
  .variant-seg > button { padding: 0 12px; font-size: 13px; }
  .nav-tabs > a[data-tab="home"] { display: none; }
  .nav-tabs > a { padding: 0 10px; font-size: 12.5px; }
  .summary { font-size: 16px; }
  .viz-pane { padding: 14px 12px; }
  .controls { gap: 6px; }
  .play-btn { width: auto; padding: 0 14px; }
  .scrub { flex-basis: 100%; order: 10; }
  .pager { flex-direction: column; }
  .pager-btn { max-width: none; }
  .vs-status span:nth-child(n+3) { display: none; }
  .cheat td:nth-child(2) { font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  .ambient .blob { animation: none; }
}

/* keep the player controls and caption above the picture so they stay on screen */
.viz-pane > .pane-head { order: 0; }
.viz-pane > .inputs { order: 1; }
.viz-pane > .controls { order: 2; }
.viz-pane > .caption:not(.static) { order: 3; }
.viz-pane > .viz-area { order: 4; }
.viz-pane > .aux { order: 5; }
.viz-pane > .caption.static { order: 6; }
.viz-area { min-height: 220px; }
