:root {
  --bg: #07060b;
  --bg-2: #0f0d17;
  --card: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.09);
  --text: #ece9f5;
  --muted: #8f8aa3;
  --brand: #8b5cf6;
  --brand-2: #22d3ee;
  --accent: var(--brand);
  --glass: rgba(15, 13, 23, 0.72);
  --shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
  --sans: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --gutter: clamp(16px, 5vw, 72px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f4fb;
  --bg-2: #ffffff;
  --card: rgba(20, 10, 60, 0.035);
  --line: rgba(20, 10, 60, 0.12);
  --text: #16121f;
  --muted: #625c75;
  --glass: rgba(255, 255, 255, 0.78);
  --shadow: 0 30px 70px -25px rgba(40, 20, 90, 0.35);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  overflow-x: clip;
  transition: background 0.6s var(--ease), color 0.6s var(--ease);
}
body.locked { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
kbd {
  font-family: var(--mono); font-size: 0.72em;
  padding: 0.1em 0.45em; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 6px; background: var(--card);
}
::selection { background: var(--brand); color: #fff; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.eyebrow { font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.08em; color: var(--ink, var(--accent)); margin: 0 0 1rem; }
.eyebrow span { color: var(--text); }
h1, h2, h3 { line-height: 1.05; letter-spacing: -0.03em; margin: 0; font-weight: 700; }
h2 { font-size: clamp(2.2rem, 6vw, 4.8rem); margin-bottom: 1.2rem; }
section { position: relative; padding: clamp(80px, 14vh, 160px) var(--gutter); }

/* ---------- boot ---------- */
#boot {
  position: fixed; inset: 0; z-index: 1000; background: #050409;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: var(--gutter); font-family: var(--mono); color: #b9a6ff;
  transition: clip-path 0.9s var(--ease), opacity 0.4s 0.6s;
  clip-path: inset(0 0 0 0);
}
#boot.done { clip-path: inset(0 0 100% 0); opacity: 0; pointer-events: none; }
#boot-log { margin: 0 0 24px; font-size: clamp(11px, 1.6vw, 14px); line-height: 1.7; white-space: pre-wrap; min-height: 40vh; }
#boot-log .ok { color: #34d399; }
.boot-bar { height: 2px; background: rgba(255,255,255,0.08); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width 0.25s linear; }

/* ---------- chrome ---------- */
#progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%; z-index: 90;
  transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--brand), var(--brand-2), #f472b6);
}
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -2; }
.grain {
  position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain { 0% { background-position: 0 0; } 25% { background-position: -40px 30px; } 50% { background-position: 30px -50px; } 75% { background-position: -20px 45px; } }

#cursor, #cursor-dot { position: fixed; top: 0; left: 0; pointer-events: none; z-index: 999; border-radius: 50%; mix-blend-mode: difference; }
#cursor { width: 38px; height: 38px; margin: -19px 0 0 -19px; border: 1.5px solid #fff; transition: width .3s var(--ease), height .3s var(--ease), margin .3s var(--ease), background .3s; }
#cursor-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: #fff; }
#cursor.hover { width: 72px; height: 72px; margin: -36px 0 0 -36px; background: #fff; }
#cursor.text { width: 4px; height: 34px; margin: -17px 0 0 -2px; border-radius: 2px; }
@media (hover: none), (pointer: coarse) { #cursor, #cursor-dot { display: none; } }
@media (hover: hover) and (pointer: fine) { body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; } }

#nav {
  position: fixed; top: 14px; left: 50%; z-index: 80;
  transform: translateX(-50%); width: min(1180px, calc(100% - 24px));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px 10px 20px; border-radius: 18px;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  transition: transform 0.5s var(--ease), opacity .4s;
}
#nav.hidden { transform: translate(-50%, -140%); }
.logo { font-family: var(--mono); font-weight: 600; font-size: 0.95rem; white-space: nowrap; }
.nav-links { display: flex; gap: 6px; }
.nav-links a { padding: 8px 14px; border-radius: 10px; font-size: 0.92rem; color: var(--muted); transition: color .3s, background .3s; }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--card); }
.nav-actions { display: flex; gap: 8px; align-items: center; }
.chip { display: flex; gap: 3px; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); font-size: 1.1rem; transition: transform .5s var(--ease); }
.icon-btn:hover { transform: rotate(180deg); }
.burger { width: 44px; height: 38px; border-radius: 10px; background: var(--text); position: relative; }
.burger span { position: absolute; left: 13px; right: 13px; height: 2px; background: var(--bg); transition: transform .5s var(--ease), top .5s var(--ease); }
.burger span:first-child { top: 14px; } .burger span:last-child { top: 22px; }
body.menu-open .burger span:first-child { top: 18px; transform: rotate(45deg); }
body.menu-open .burger span:last-child { top: 18px; transform: rotate(-45deg); }
@media (max-width: 760px) { .nav-links, #palette-btn { display: none; } .logo { font-size: 0.82rem; } }

/* ---------- full-screen menu ---------- */
#menu { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.menu-bg { position: absolute; inset: 0; background: var(--bg-2); clip-path: circle(0% at calc(100% - 50px) 34px); transition: clip-path 0.9s var(--ease); }
body.menu-open #menu { pointer-events: auto; }
body.menu-open .menu-bg { clip-path: circle(150% at calc(100% - 50px) 34px); }
.menu-inner { position: relative; height: 100%; padding: 110px var(--gutter) 40px; display: flex; flex-direction: column; overflow-y: auto; }
.menu-label { font-family: var(--mono); color: var(--muted); margin: 0 0 10px; opacity: 0; transition: opacity .4s; }
body.menu-open .menu-label { opacity: 1; transition-delay: .35s; }
#menu-list { list-style: none; margin: 0; padding: 0; counter-reset: m; }
#menu-list li { overflow: hidden; }
#menu-list a {
  display: flex; align-items: baseline; gap: 18px; padding: 4px 0;
  font-size: clamp(1.5rem, 4.4vw, 3.2rem); font-weight: 700; letter-spacing: -0.04em; line-height: 1.1;
  transform: translateY(110%); transition: transform .8s var(--ease), color .3s, padding .4s var(--ease);
}
#menu-list a::before { counter-increment: m; content: counter(m, decimal-leading-zero); font-family: var(--mono); font-size: 0.85rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
#menu-list a:hover { color: var(--ink, var(--accent)); padding-left: 18px; }
body.menu-open #menu-list a { transform: none; }
.menu-foot { margin-top: auto; padding-top: 30px; display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; color: var(--muted); font-family: var(--mono); font-size: 0.85rem; opacity: 0; transition: opacity .4s; }
body.menu-open .menu-foot { opacity: 1; transition-delay: .6s; }
.menu-preview {
  position: absolute; right: var(--gutter); top: 50%; width: min(34vw, 420px); aspect-ratio: 4/5;
  transform: translateY(-50%) scale(.85) rotate(4deg); opacity: 0; border-radius: 24px;
  border: 1px solid var(--line); background: var(--card); padding: 30px; transition: all .6s var(--ease);
  display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; pointer-events: none;
}
.menu-preview.show { opacity: 1; transform: translateY(-50%) scale(1) rotate(0); }
.menu-preview .mp-icon { position: absolute; top: 20px; right: 26px; font-size: 7rem; opacity: .2; font-family: var(--mono); }
.menu-preview h4 { font-size: 1.7rem; margin: 0 0 8px; }
@media (max-width: 900px) { .menu-preview { display: none; } }

/* ---------- palette ---------- */
#palette { position: fixed; inset: 0; z-index: 95; display: grid; place-items: start center; padding: 14vh 16px 0; background: rgba(5,4,10,.55); backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity .25s; }
#palette.open { opacity: 1; pointer-events: auto; }
.palette-box { width: min(640px, 100%); border-radius: 18px; background: var(--bg-2); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; transform: translateY(-14px) scale(.97); transition: transform .35s var(--ease); }
#palette.open .palette-box { transform: none; }
#palette-input { width: 100%; padding: 20px 22px; font: inherit; font-size: 1.1rem; background: transparent; color: var(--text); border: 0; border-bottom: 1px solid var(--line); outline: none; }
#palette-list { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
#palette-list li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; cursor: pointer; }
#palette-list li .pi { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--card); font-family: var(--mono); font-size: .85rem; flex-shrink: 0; }
#palette-list li .pt { flex: 1; } #palette-list li .pk { color: var(--muted); font-family: var(--mono); font-size: .75rem; }
#palette-list li.sel { background: var(--brand); color: #fff; } #palette-list li.sel .pk { color: rgba(255,255,255,.75); }
.palette-hint { display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }

/* ---------- dots ---------- */
#dots { position: fixed; right: 18px; top: 50%; transform: translateY(-50%); z-index: 60; display: flex; flex-direction: column; gap: 10px; }
#dots a { position: relative; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--muted); transition: all .4s var(--ease); }
#dots a.active { background: var(--accent); border-color: var(--accent); transform: scale(1.4); }
#dots a span { position: absolute; right: 22px; top: 50%; transform: translate(8px,-50%); white-space: nowrap; font-family: var(--mono); font-size: .72rem; padding: 4px 9px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line); opacity: 0; pointer-events: none; transition: all .3s var(--ease); }
#dots a:hover span { opacity: 1; transform: translate(0,-50%); }
@media (max-width: 760px) { #dots { display: none; } }

/* ---------- hero ---------- */
.hero { min-height: 100svh; display: grid; place-items: center; text-align: center; overflow: hidden; }
.hero-inner { position: relative; z-index: 2; max-width: 1100px; }
.glitch {
  position: relative; font-size: clamp(3rem, 13vw, 11rem); letter-spacing: -0.06em; line-height: .92;
  background: linear-gradient(120deg, var(--text) 30%, var(--brand) 60%, var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 200% 100%;
  animation: shine 8s linear infinite;
}
@keyframes shine { to { background-position: -200% 0; } }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; background: inherit; -webkit-background-clip: text; background-clip: text; opacity: 0; }
.glitch.glitching::before { opacity: .8; color: #ff2fd6; -webkit-text-fill-color: #ff2fd6; animation: g1 .35s steps(2) both; }
.glitch.glitching::after { opacity: .8; color: #22d3ee; -webkit-text-fill-color: #22d3ee; animation: g2 .35s steps(2) both; }
@keyframes g1 { 0% { clip-path: inset(10% 0 60% 0); transform: translate(-6px, 2px); } 50% { clip-path: inset(50% 0 20% 0); transform: translate(5px,-2px); } 100% { clip-path: inset(80% 0 5% 0); transform: translate(-3px, 1px); } }
@keyframes g2 { 0% { clip-path: inset(60% 0 10% 0); transform: translate(6px,-2px); } 50% { clip-path: inset(15% 0 55% 0); transform: translate(-5px,2px); } 100% { clip-path: inset(30% 0 40% 0); transform: translate(3px,0); } }
.glitch .ch { display: inline-block; transform: translateY(110%) rotate(8deg); opacity: 0; transition: transform 1s var(--ease), opacity 1s var(--ease); }
body.ready .glitch .ch { transform: none; opacity: 1; }
.hero-sub { font-family: var(--mono); font-size: clamp(.95rem, 2vw, 1.25rem); color: var(--muted); margin: 28px auto 38px; min-height: 1.6em; }
.caret { color: var(--ink, var(--accent)); animation: blink 1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn { position: relative; display: inline-flex; align-items: center; padding: 15px 28px; border-radius: 999px; font-weight: 500; overflow: hidden; isolation: isolate; transition: transform .4s var(--ease); }
.btn span { position: relative; z-index: 1; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 10px 40px -10px var(--brand); }
.btn.ghost { border: 1px solid var(--line); }
.btn::after { content: ""; position: absolute; inset: 0; z-index: 0; border-radius: inherit; background: var(--brand-2); transform: translateY(101%); transition: transform .5s var(--ease); }
.btn:hover::after { transform: none; }
.btn.ghost:hover { color: #05040a; }
.btn.big { padding: 22px 42px; font-size: 1.15rem; }
.orbit { position: absolute; width: min(90vw, 900px); aspect-ratio: 1; border-radius: 50%; border: 1px dashed var(--line); animation: spin 60s linear infinite; z-index: 1; pointer-events: none; }
.orbit::before { content: ""; position: absolute; inset: 15%; border-radius: 50%; border: 1px solid var(--line); }
.orbit .planet { position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 14px; display: grid; place-items: center; font-family: var(--mono); font-size: .8rem; background: var(--bg-2); border: 1px solid var(--line); animation: spin 60s linear infinite reverse; box-shadow: 0 0 30px -8px var(--c); color: var(--c); }
@keyframes spin { to { transform: rotate(360deg); } }
.scroll-cue { position: absolute; bottom: 30px; left: 50%; width: 26px; height: 42px; margin-left: -13px; border: 1.5px solid var(--muted); border-radius: 14px; z-index: 2; }
.scroll-cue span { position: absolute; top: 8px; left: 50%; width: 4px; height: 8px; margin-left: -2px; background: var(--text); border-radius: 2px; animation: cue 1.8s var(--ease) infinite; }
@keyframes cue { 0% { transform: translateY(0); opacity: 1; } 80% { transform: translateY(16px); opacity: 0; } 100% { opacity: 0; } }

/* ---------- manifesto ---------- */
.manifesto { min-height: 160vh; }
.big-words { position: sticky; top: 22vh; font-size: clamp(2rem, 7vw, 6rem); font-weight: 700; letter-spacing: -0.045em; line-height: 1.05; margin: 0; max-width: 1200px; }
.big-words .w { display: inline-block; opacity: .12; transition: opacity .3s, color .3s, transform .5s var(--ease); margin-right: .22em; }
.big-words .w.on { opacity: 1; }
.big-words .w.hl.on { color: var(--brand); }

/* ---------- stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; max-width: 1200px; margin: 0 auto; }
.stat { padding: 30px 26px; border-radius: 22px; background: var(--card); border: 1px solid var(--line); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0; background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(139,92,246,.22), transparent 45%); opacity: 0; transition: opacity .4s; }
.stat:hover::before { opacity: 1; }
.stat b { display: block; font-size: clamp(2.4rem, 5vw, 3.6rem); letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-family: var(--mono); font-size: .82rem; }

/* ---------- marquee ---------- */
.marquee { overflow: hidden; border-block: 1px solid var(--line); padding: 22px 0; transform: rotate(-2deg) scale(1.04); background: var(--bg-2); }
.marquee-track { display: flex; gap: 48px; width: max-content; animation: marq 40s linear infinite; font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 700; letter-spacing: -0.03em; }
.marquee-track span { display: flex; align-items: center; gap: 48px; white-space: nowrap; }
.marquee-track span::after { content: "✦"; color: var(--brand); font-size: .6em; }
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marq { to { transform: translateX(-50%); } }

/* ---------- horizontal projects ---------- */
.projects { padding: 0; }
.pin-wrap { position: relative; }
.pin-sticky { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding: 90px 0 40px; }
.pin-head { padding: 0 var(--gutter); }
.pin-head h2 { margin-bottom: .4rem; }
.h-track { display: flex; gap: 24px; padding: 32px var(--gutter); will-change: transform; }
.pcard {
  --c: var(--brand); flex: 0 0 clamp(280px, 34vw, 440px); min-height: clamp(340px, 46vh, 460px);
  border-radius: 28px; padding: 30px; position: relative; overflow: hidden; cursor: pointer;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 18%, var(--bg-2)), var(--bg-2) 60%);
  border: 1px solid var(--line); display: flex; flex-direction: column;
  transform-style: preserve-3d; transition: transform .2s ease-out, box-shadow .4s;
}
.pcard:hover { box-shadow: 0 30px 80px -30px var(--c); }
.pcard .glare { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(500px circle at var(--gx, 50%) var(--gy, 0%), rgba(255,255,255,.14), transparent 40%); opacity: 0; transition: opacity .3s; }
.pcard:hover .glare { opacity: 1; }
.pcard .num { font-family: var(--mono); color: var(--muted); font-size: .8rem; }
.pcard .ico { position: absolute; right: 22px; top: 14px; font-size: 5.5rem; color: var(--c); opacity: .9; font-family: var(--mono); transform: translateZ(60px); line-height: 1; }
.pcard h3 { font-size: clamp(1.6rem, 2.6vw, 2.3rem); margin: auto 0 10px; transform: translateZ(40px); }
.pcard p { color: var(--muted); margin: 0 0 18px; font-size: .95rem; transform: translateZ(20px); }
.pcard .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-family: var(--mono); font-size: .7rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); }
.pcard .go { position: absolute; bottom: 26px; right: 26px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #05040a; transform: scale(0) rotate(-90deg); transition: transform .5s var(--ease); }
.pcard:hover .go { transform: none; }
.h-progress { margin: 0 var(--gutter); height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.h-progress span { display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: var(--brand); }

/* ---------- chapters ---------- */
.chapter { --accent: var(--brand); border-top: 1px solid var(--line); }
.ch-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(30px, 6vw, 90px); max-width: 1300px; margin: 0 auto; }
.ch-side { position: sticky; top: 110px; align-self: start; }
.ch-index { font-family: var(--mono); font-size: clamp(5rem, 14vw, 11rem); line-height: .8; font-weight: 700; color: transparent; -webkit-text-stroke: 1.5px var(--accent); opacity: .5; margin-bottom: 10px; }
.ch-side h2 { font-size: clamp(2.2rem, 5vw, 4rem); }
.ch-kicker { font-size: 1.2rem; color: var(--text); margin: 0 0 14px; font-weight: 500; }
.ch-sum { color: var(--muted); margin: 0 0 26px; }
.ch-links { display: flex; gap: 10px; flex-wrap: wrap; }
.ch-links .btn { padding: 11px 20px; font-size: .9rem; }
.ch-links .btn.primary { background: var(--accent); color: #05040a; box-shadow: 0 10px 40px -12px var(--accent); }
.ch-mini { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 30px; }
.ch-mini div { padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--card); }
.ch-mini b { display: block; font-size: 1.5rem; letter-spacing: -0.03em; color: var(--ink, var(--accent)); line-height: 1.1; }
.ch-mini span { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.ch-body > * + * { margin-top: 70px; }
.ch-body h3 { font-size: 1.05rem; font-family: var(--mono); font-weight: 600; letter-spacing: 0; color: var(--ink, var(--accent)); margin-bottom: 20px; display: flex; align-items: center; gap: 12px; }
.ch-body h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.steps { list-style: none; margin: 0; padding: 0; position: relative; }
.steps::before { content: ""; position: absolute; left: 19px; top: 10px; bottom: 10px; width: 2px; background: var(--line); }
.steps .fill { position: absolute; left: 19px; top: 10px; width: 2px; height: calc(100% - 20px); background: var(--accent); transform-origin: top; transform: scaleY(0); box-shadow: 0 0 14px var(--accent); }
.steps li { position: relative; padding: 0 0 30px 62px; opacity: .3; transition: opacity .5s; }
.steps li.on { opacity: 1; }
.steps li::before { counter-increment: s; content: attr(data-n); position: absolute; left: 0; top: -2px; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--bg-2); border: 1px solid var(--line); font-family: var(--mono); font-size: .8rem; transition: all .5s var(--ease); }
.steps li.on::before { background: var(--accent); color: #05040a; border-color: var(--accent); transform: rotate(-8deg) scale(1.05); }
.steps b { display: block; font-size: 1.15rem; }
.steps p { margin: 4px 0 0; color: var(--muted); }

.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.feat { padding: 20px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); position: relative; overflow: hidden; transition: transform .4s var(--ease), border-color .4s; }
.feat:hover { transform: translateY(-4px); border-color: var(--accent); }
.feat::after { content: ""; position: absolute; left: 0; top: 0; height: 3px; width: 0; background: var(--accent); transition: width .6s var(--ease); }
.feat:hover::after { width: 100%; }
.feat b { display: block; margin-bottom: 6px; }
.feat p { margin: 0; color: var(--muted); font-size: .9rem; }

.term { border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: #0b0a12; color: #e6e1f7; box-shadow: var(--shadow); }
.term-bar { display: flex; align-items: center; gap: 7px; padding: 12px 16px; background: #14121e; font-family: var(--mono); font-size: .75rem; color: #8f8aa3; }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; } .term-bar i:nth-child(2) { background: #febc2e; } .term-bar i:nth-child(3) { background: #28c840; }
.term-bar em { margin-left: auto; font-style: normal; }
.term-bar .copy { margin-left: 10px; padding: 3px 10px; border-radius: 6px; border: 1px solid rgba(255,255,255,.12); color: #ccc; font-family: var(--mono); font-size: .72rem; }
.term pre { margin: 0; padding: 20px; font-family: var(--mono); font-size: clamp(.72rem, 1.4vw, .88rem); line-height: 1.8; white-space: pre-wrap; word-break: break-word; min-height: 9em; }
.term .c { color: #6b6585; } .term .p { color: var(--accent); }

.tree { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.tree li { display: grid; grid-template-columns: minmax(140px, 2fr) 3fr; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--line); transition: background .3s; }
.tree li:first-child { border-top: 0; }
.tree li:hover { background: var(--card); }
.tree code { font-family: var(--mono); font-size: .82rem; color: var(--ink, var(--accent)); word-break: break-all; }
.tree span { color: var(--muted); font-size: .92rem; }
@media (max-width: 600px) { .tree li { grid-template-columns: 1fr; gap: 4px; } }

.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.dl div { padding: 18px 20px; border-radius: 16px; border: 1px dashed var(--line); }
.dl b { display: block; } .dl span { color: var(--muted); font-size: .88rem; }

.lbar { display: flex; height: 14px; border-radius: 8px; overflow: hidden; background: var(--line); }
.lbar i { display: block; height: 100%; width: 0; transition: width 1.4s var(--ease); }
.lkeys { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.lkeys span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--k); margin-right: 7px; }

.acc { border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.acc summary { list-style: none; cursor: pointer; padding: 18px 22px; display: flex; justify-content: space-between; align-items: center; font-weight: 500; }
.acc summary::-webkit-details-marker { display: none; }
.acc summary::after { content: "+"; font-family: var(--mono); font-size: 1.4rem; color: var(--ink, var(--accent)); transition: transform .4s var(--ease); }
.acc[open] summary::after { transform: rotate(45deg); }
.acc ul { margin: 0; padding: 0 22px 20px 42px; color: var(--muted); }
.acc li { margin-bottom: 8px; }

@media (max-width: 900px) { .ch-grid { grid-template-columns: 1fr; } .ch-side { position: relative; top: 0; } }

/* ---------- languages ---------- */
.lang-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: clamp(30px, 6vw, 80px); align-items: center; max-width: 1200px; margin: 30px auto 0; }
.donut-wrap { position: relative; max-width: 440px; width: 100%; margin: 0 auto; }
#donut { width: 100%; transform: rotate(-90deg); overflow: visible; }
#donut circle { fill: none; stroke-width: 22; transition: stroke-dasharray 1.6s var(--ease), stroke-width .3s; cursor: pointer; }
#donut circle:hover, #donut circle.hl { stroke-width: 30; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.donut-center b { display: block; font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -0.04em; line-height: 1; }
.donut-center span { font-family: var(--mono); color: var(--muted); font-size: .8rem; }
.lang-list { list-style: none; margin: 0; padding: 0; }
.lang-list li { display: grid; grid-template-columns: 130px 1fr 70px; gap: 14px; align-items: center; padding: 9px 0; font-size: .95rem; cursor: default; transition: transform .3s var(--ease); }
.lang-list li:hover, .lang-list li.hl { transform: translateX(8px); }
.lang-list .bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.lang-list .bar i { display: block; height: 100%; width: 0; border-radius: 4px; transition: width 1.4s var(--ease); }
.lang-list em { font-style: normal; font-family: var(--mono); color: var(--muted); font-size: .8rem; text-align: right; }
@media (max-width: 900px) { .lang-wrap { grid-template-columns: 1fr; } .lang-list li { grid-template-columns: 100px 1fr 60px; } }

/* ---------- timeline ---------- */
.tl { position: relative; max-width: 1000px; margin: 40px auto 0; }
.tl-line { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--line); }
.tl-line span { display: block; width: 100%; height: 100%; background: linear-gradient(var(--brand), var(--brand-2)); transform-origin: top; transform: scaleY(0); }
.tl-item { position: relative; width: 50%; padding: 0 50px 60px; }
.tl-item:nth-child(even) { margin-left: 50%; }
.tl-item:nth-child(odd) { text-align: right; }
.tl-item::before { content: ""; position: absolute; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 3px solid var(--c); box-shadow: 0 0 0 6px var(--bg), 0 0 20px var(--c); }
.tl-item:nth-child(odd)::before { right: -8px; } .tl-item:nth-child(even)::before { left: -8px; }
.tl-item time { font-family: var(--mono); font-size: .8rem; color: var(--c); }
.tl-item h4 { font-size: 1.6rem; margin: 4px 0 6px; letter-spacing: -0.03em; cursor: pointer; }
.tl-item p { margin: 0; color: var(--muted); }
@media (max-width: 760px) {
  .tl-line { left: 8px; }
  .tl-item, .tl-item:nth-child(even) { width: 100%; margin-left: 0; padding: 0 0 50px 40px; text-align: left; }
  .tl-item:nth-child(odd)::before, .tl-item:nth-child(even)::before { left: 0; right: auto; }
}

/* ---------- footer ---------- */
.footer { text-align: center; min-height: 90vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px; }
.foot-quote { font-size: clamp(2rem, 6.5vw, 5.4rem); font-weight: 700; letter-spacing: -0.045em; line-height: 1.05; max-width: 1100px; margin: 0; }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 85; pointer-events: none; }
#modal.open { pointer-events: auto; }
.modal-bg { position: absolute; inset: 0; background: rgba(4,3,8,.7); backdrop-filter: blur(10px); opacity: 0; transition: opacity .4s; }
#modal.open .modal-bg { opacity: 1; }
.modal-box {
  --accent: var(--brand); position: absolute; left: 50%; top: 50%; width: min(860px, calc(100% - 24px)); max-height: calc(100svh - 40px);
  overflow-y: auto; border-radius: 28px; background: var(--bg-2); border: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translate(-50%, -40%) scale(.92); opacity: 0; transition: transform .6s var(--ease), opacity .4s;
}
#modal.open .modal-box { transform: translate(-50%, -50%); opacity: 1; }
.m-head { padding: 40px 36px 26px; background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 25%, transparent), transparent 70%); position: relative; }
.m-head .ico { position: absolute; right: 30px; top: 20px; font-size: 6rem; font-family: var(--mono); color: var(--ink, var(--accent)); opacity: .4; line-height: 1; }
.m-head h2 { font-size: clamp(2rem, 5vw, 3.2rem); margin-bottom: .6rem; padding-right: 80px; }
.m-close { position: sticky; top: 14px; float: right; margin: 14px 14px 0 0; z-index: 2; width: 40px; height: 40px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 1.2rem; transition: transform .4s var(--ease); }
.m-close:hover { transform: rotate(90deg); }
.tabs { display: flex; gap: 4px; padding: 0 36px; border-bottom: 1px solid var(--line); overflow-x: auto; position: relative; }
.tabs button { padding: 14px 16px; color: var(--muted); white-space: nowrap; font-size: .92rem; }
.tabs button.on { color: var(--text); }
.tabs .ink { position: absolute; bottom: -1px; height: 2px; background: var(--accent); transition: left .45s var(--ease), width .45s var(--ease); }
.tab-panels { padding: 30px 36px 40px; }
.tab-panel { display: none; animation: panelIn .5s var(--ease); }
.tab-panel.on { display: block; }
@keyframes panelIn { from { opacity: 0; transform: translateY(12px); } }
@media (max-width: 600px) { .m-head, .tab-panels { padding-left: 20px; padding-right: 20px; } .tabs { padding: 0 12px; } }

/* ---------- misc ---------- */
#top-btn { position: fixed; right: 18px; bottom: 18px; z-index: 60; width: 50px; height: 50px; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 1.2rem; transform: scale(0); transition: transform .5s var(--ease); }
#top-btn.show { transform: scale(1); }
#toast { position: fixed; left: 50%; bottom: 26px; z-index: 100; transform: translate(-50%, 120px); padding: 12px 20px; border-radius: 12px; background: var(--text); color: var(--bg); font-family: var(--mono); font-size: .85rem; transition: transform .5s var(--ease); max-width: calc(100% - 32px); }
#toast.show { transform: translate(-50%, 0); }

.reveal { opacity: 0; transform: translateY(40px); transition: opacity 1s var(--ease), transform 1s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.split .wd { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
.split .wd > span { display: inline-block; transform: translateY(105%); transition: transform 1s var(--ease); }
.split.in .wd > span { transform: none; }
.stagger > * { opacity: 0; transform: translateY(30px) scale(.97); transition: opacity .8s var(--ease), transform .8s var(--ease); }
.stagger.in > * { opacity: 1; transform: none; }

body.matrix { --brand: #22ff88; --brand-2: #00ffcc; }
body.matrix .glitch { background: linear-gradient(120deg, #22ff88, #00ffcc); -webkit-background-clip: text; background-clip: text; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
  .reveal, .stagger > *, .split .wd > span, .glitch .ch { opacity: 1 !important; transform: none !important; }
}

/* ---------- chapter banners: the neck-grab ---------- */
.chapter { padding-top: 0; }
.ch-banner { position: relative; height: clamp(260px, 52vh, 520px); margin: 0 calc(var(--gutter) * -1) clamp(50px, 9vh, 100px); overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 8px; --k: 0; }
.ch-curtain { position: absolute; inset: 0; background: var(--accent); transform-origin: left; transform: scaleX(0); transition: transform 1.1s var(--ease); }
.ch-banner.hit .ch-curtain { animation: curtain 1.6s var(--ease) forwards; }
@keyframes curtain { 0% { transform: scaleX(0); transform-origin: left; } 45% { transform: scaleX(1); transform-origin: left; } 55% { transform: scaleX(1); transform-origin: right; } 100% { transform: scaleX(0); transform-origin: right; } }
.ch-giant { position: relative; white-space: nowrap; font-weight: 700; letter-spacing: -0.06em; line-height: .9; will-change: transform; }
.ch-giant span { display: inline-block; font-size: clamp(4.5rem, 16vw, 15rem); color: var(--ink, var(--accent)); text-shadow: 0 0 calc(var(--k) * 60px) color-mix(in srgb, var(--accent) 55%, transparent); }
.ch-giant.rev span { font-size: clamp(1.4rem, 4vw, 3.2rem); color: transparent; -webkit-text-stroke: 1px var(--muted); letter-spacing: -0.02em; font-weight: 500; }
.ch-banner::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, var(--bg), transparent 12%, transparent 88%, var(--bg)); }
.ch-banner .ch-giant:first-of-type { opacity: 0; transform: scale(1.25) skewX(-8deg); filter: blur(12px); transition: opacity .9s .55s var(--ease), transform 1.2s .55s var(--ease), filter 1s .55s var(--ease); }
.ch-banner.hit .ch-giant:first-of-type { opacity: 1; transform: none; filter: none; }
.ch-index { transform: translateY(calc((1 - var(--k, 1)) * 30px)); }
.steps.static li { opacity: 1; }
.steps.static::before { display: none; }

/* ---------- round two ---------- */
.spark { position: fixed; z-index: 998; width: 7px; height: 7px; border-radius: 2px; pointer-events: none; }
.feat::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 22%, transparent), transparent 50%); opacity: 0; transition: opacity .4s; }
.feat:hover::before { opacity: 1; }
.ch-banner::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: calc(var(--k) * .5);
  background: repeating-linear-gradient(0deg, transparent 0 3px, color-mix(in srgb, var(--accent) 14%, transparent) 3px 4px),
              radial-gradient(60% 80% at 50% 50%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%);
  animation: scan 6s linear infinite;
}
@keyframes scan { to { background-position: 0 120px, 0 0; } }
.pcard { transition: transform .35s var(--ease), opacity .35s, box-shadow .4s; }
.ch-index { transition: transform .3s; }

/* ---------- round three ---------- */
#tint {
  position: fixed; inset: 0; z-index: -3; pointer-events: none; opacity: .13;
  transition: background-color 1.2s var(--ease);
  -webkit-mask: radial-gradient(70% 60% at 70% 40%, #000, transparent 75%);
  mask: radial-gradient(70% 60% at 70% 40%, #000, transparent 75%);
}
:root[data-theme="light"] #tint { opacity: .09; }
.live-pill { display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: .72rem; letter-spacing: 0; opacity: 0; transform: translateY(6px); transition: opacity .6s var(--ease), transform .6s var(--ease); vertical-align: middle; }
.live-pill.on { opacity: 1; transform: none; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 0 #34d399; animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.pcard::after { content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%; pointer-events: none; background: linear-gradient(100deg, transparent, rgba(255,255,255,.16), transparent); transform: skewX(-18deg); }
.pcard:hover::after { animation: sweep .9s var(--ease); }
@keyframes sweep { to { left: 130%; } }

/* ---------- round four: demos ---------- */
.demo { border: 1px solid var(--line); border-radius: 20px; padding: 20px; background: var(--card); position: relative; overflow: hidden; }
.demo::before { content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; background: conic-gradient(from var(--ang, 0deg), transparent 70%, var(--accent), transparent); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: ang 5s linear infinite; pointer-events: none; }
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes ang { to { --ang: 360deg; } }
.demo-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.demo-btn { padding: 9px 18px; font-size: .85rem; }
.demo-btn:disabled { opacity: .6; }
.demo-note { margin: 12px 0 0; font-size: .78rem; color: var(--muted); }
.demo-label { display: block; font-family: var(--mono); font-size: .78rem; color: var(--muted); margin-bottom: 8px; }
.cf-code { margin: 0; padding: 16px; border-radius: 12px; background: #0b0a12; color: #e6e1f7; font-family: var(--mono); font-size: clamp(.68rem, 1.3vw, .82rem); line-height: 1.9; white-space: pre-wrap; word-break: break-word; }
.cf-code span { display: inline; color: #ff8b8b; transition: color .4s; }
.cf-code span.new { color: #7dffb2; }
#nl-in { width: 100%; resize: vertical; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font: inherit; outline: none; transition: border-color .3s; }
#nl-in:focus { border-color: var(--accent); }
.nl-out { position: relative; margin-top: 12px; padding: 14px; border-radius: 12px; background: #0b0a12; color: var(--accent); font-family: var(--mono); font-size: .82rem; line-height: 1.5; word-break: break-all; min-height: 4em; max-height: 11em; overflow: hidden; }
.nl-out::after { content: attr(data-total); position: absolute; right: 10px; bottom: 6px; font-size: .7rem; color: #8f8aa3; background: #0b0a12; padding-left: 6px; }
.nl-out span { display: inline-block; animation: digitIn .5s var(--ease) both; }
@keyframes digitIn { from { opacity: 0; transform: translateY(-8px) scale(1.6); color: #fff; } }
.da-drop { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 28px 16px; border: 2px dashed var(--line); border-radius: 14px; cursor: pointer; transition: border-color .3s, background .3s, transform .3s var(--ease); }
.da-drop:hover, .da-drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.da-drop.over { transform: scale(1.02); }
.da-drop span { color: var(--muted); font-size: .85rem; }
.da-out:not(:empty) { margin-top: 14px; }
.da-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: .88rem; animation: panelIn .5s var(--ease) both; }
.da-row:nth-child(2) { animation-delay: .06s; } .da-row:nth-child(3) { animation-delay: .12s; } .da-row:nth-child(4) { animation-delay: .18s; } .da-row:nth-child(5) { animation-delay: .24s; } .da-row:nth-child(6) { animation-delay: .3s; }
.da-row span { color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.da-row b { font-weight: 500; word-break: break-all; }
.da-row .mono { font-family: var(--mono); font-size: .76rem; }
.ent { display: inline-block; vertical-align: middle; width: 90px; height: 6px; margin-left: 8px; border-radius: 3px; background: var(--line); overflow: hidden; }
.ent i { display: block; height: 100%; background: var(--accent); }
@media (max-width: 600px) { .da-row { grid-template-columns: 1fr; gap: 2px; } }

/* ---------- round five: more demos ---------- */
.fm-grid { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 12px; align-items: stretch; }
.fm-side { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.fm-side b { font-family: var(--mono); color: var(--ink, var(--accent)); }
.fm-side input, #av-path { padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-size: .9rem; outline: none; width: 100%; }
.fm-side input:focus, #av-path:focus { border-color: var(--accent); }
.fm-plain { margin: 0; font-size: 1.05rem; }
.fm-wire { display: flex; flex-direction: column; gap: 6px; justify-content: center; padding: 14px; border-radius: 14px; background: #0b0a12; overflow: hidden; }
.fm-wire span { font-family: var(--mono); font-size: .7rem; color: #8f8aa3; }
.fm-wire code { font-family: var(--mono); font-size: .7rem; color: #ff8bd8; word-break: break-all; line-height: 1.5; }
.fm-wire code.fly { animation: fly .7s var(--ease); }
@keyframes fly { from { transform: translateX(-60%); opacity: 0; filter: blur(4px); } }
.fm-code { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 12px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--line); font-family: var(--mono); font-size: .82rem; }
.fm-code span { color: var(--muted); } .fm-code b { color: var(--ink, var(--accent)); letter-spacing: .08em; }
@media (max-width: 700px) { .fm-grid { grid-template-columns: 1fr; } }
.oc-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.oc-pick label { display: flex; flex-direction: column; gap: 6px; font-family: var(--mono); font-size: .75rem; color: var(--muted); }
.oc-pick select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font: inherit; font-size: .88rem; }
.oc-row { display: grid; grid-template-columns: 50px 150px 1fr; gap: 10px; align-items: baseline; padding: 10px 0; border-top: 1px solid var(--line); animation: panelIn .4s var(--ease); }
.oc-row span { font-family: var(--mono); font-size: .72rem; color: var(--muted); }
.oc-row p { margin: 0; color: var(--muted); font-size: .88rem; }
.oc-verdict { margin-top: 10px; padding: 14px 16px; border-radius: 12px; font-weight: 700; font-size: 1.1rem; animation: pop .5s var(--ease); }
.oc-verdict small { display: block; font-weight: 400; font-size: .82rem; opacity: .8; }
.oc-verdict.oc-ok { background: color-mix(in srgb, #34d399 18%, transparent); }
.oc-verdict.oc-warn { background: color-mix(in srgb, #facc15 18%, transparent); }
.oc-verdict.oc-no { background: color-mix(in srgb, #f87171 18%, transparent); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
@media (max-width: 600px) { .oc-row { grid-template-columns: 1fr; gap: 2px; } }
.wt-mode { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.wt-mode b { color: var(--ink, var(--accent)); }
.wt-in { animation: panelIn .5s var(--ease) both; }
.av-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 12px; font-family: var(--mono); font-size: .78rem; }
.av-get { padding: 2px 8px; border-radius: 6px; background: var(--accent); color: #05040a; font-weight: 600; }
.av-ok { margin-left: auto; color: #34d399; }
.av-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.av-json, .av-res { margin: 0; padding: 12px; border-radius: 12px; background: #0b0a12; color: #e6e1f7; font-family: var(--mono); font-size: .74rem; line-height: 1.55; max-height: 300px; overflow: auto; }
.av-res { margin-top: 10px; min-height: 4em; transition: color .3s; }
.av-res.ok { color: #7dffb2; } .av-res.err { color: #ff8b8b; }
.av-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.av-chips button { font-family: var(--mono); font-size: .68rem; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); transition: border-color .3s, color .3s; }
.av-chips button:hover { border-color: var(--accent); color: var(--ink, var(--accent)); }
@media (max-width: 700px) { .av-grid { grid-template-columns: 1fr; } }
.ht-dev { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.ht-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--card); font-size: 1.3rem; }
.ht-dev div { display: flex; flex-direction: column; } .ht-dev div span { color: var(--muted); font-size: .8rem; }
.ht-sw { margin-left: auto; display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .85rem; }
.ht-sw input { position: absolute; opacity: 0; }
.ht-sw i { width: 42px; height: 24px; border-radius: 12px; background: var(--line); position: relative; transition: background .3s; }
.ht-sw i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .4s var(--ease); }
.ht-sw input:checked + i { background: var(--accent); }
.ht-sw input:checked + i::after { transform: translateX(18px); }
.ht-sw input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.ht-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.ht-btns button { padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); font-size: .85rem; transition: border-color .3s, transform .3s var(--ease); }
.ht-btns button:hover { border-color: var(--accent); transform: translateY(-2px); }
.ht-log span.c { color: #6b6585; } .ht-log span.bad { color: #ff8b8b; }


/* ---------- light mode polish ---------- */
:root[data-theme="light"], :root[data-theme="light"] [style*="--accent"] { --ink: color-mix(in srgb, var(--accent) 62%, #000); }
:root[data-theme="light"] { --brand: #7c3aed; --brand-2: #0891b2; }
:root[data-theme="light"] .glitch { background-image: linear-gradient(120deg, var(--text) 30%, #7c3aed 60%, #0891b2); }
:root[data-theme="light"] .grain { opacity: .035; }
:root[data-theme="light"] .ch-giant span { text-shadow: none; }
:root[data-theme="light"] .ch-giant.rev span { -webkit-text-stroke-color: #b5afc8; }
:root[data-theme="light"] .ch-index { -webkit-text-stroke-color: var(--ink); }
:root[data-theme="light"] .pcard { background: linear-gradient(160deg, color-mix(in srgb, var(--c) 22%, #fff), #fff 65%); }
:root[data-theme="light"] .pcard .ico { color: color-mix(in srgb, var(--c) 70%, #000); }
:root[data-theme="light"] .stat, :root[data-theme="light"] .feat, :root[data-theme="light"] .demo { background: #fff; box-shadow: 0 10px 30px -18px rgba(40, 20, 90, .25); }
:root[data-theme="light"] .marquee { background: #fff; }
:root[data-theme="light"] #tint { opacity: .18; }
:root[data-theme="light"] .tl-item::before { box-shadow: 0 0 0 6px var(--bg); }
:root[data-theme="light"] .menu-preview { background: #fff; }
:root[data-theme="light"] .oc-verdict.oc-ok { background: #d1fae5; } :root[data-theme="light"] .oc-verdict.oc-warn { background: #fef3c7; } :root[data-theme="light"] .oc-verdict.oc-no { background: #fee2e2; }
:root[data-theme="light"] .av-ok { color: #059669; }

/* sun / moon switch */
.theme-sw { position: relative; width: 64px; height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); padding: 0; overflow: hidden; }
.theme-sw .knob { position: absolute; top: 4px; left: 4px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--bg); transition: transform .6s var(--ease), background .6s, color .6s; }
:root[data-theme="light"] .theme-sw .knob { transform: translateX(26px) rotate(360deg); }
.theme-sw svg { width: 16px; height: 16px; }
.theme-sw .sun, :root[data-theme="light"] .theme-sw .moon { display: none; }
:root[data-theme="light"] .theme-sw .sun { display: block; }
.theme-sw .stars { position: absolute; inset: 0; pointer-events: none; }
.theme-sw .stars i { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: var(--text); opacity: .7; transition: opacity .5s, transform .6s var(--ease); }
.theme-sw .stars i:nth-child(1) { right: 12px; top: 10px; } .theme-sw .stars i:nth-child(2) { right: 20px; top: 22px; } .theme-sw .stars i:nth-child(3) { right: 9px; top: 26px; }
:root[data-theme="light"] .theme-sw .stars i { opacity: 0; transform: translateY(8px); }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

/* ---------- round six: explorer + dice ---------- */
.ex-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 20px; max-width: 1300px; margin: 0 auto; }
.dice-btn { margin-bottom: 1.2rem; }
.dice-btn:hover span { display: inline-block; animation: wobble .6s var(--ease); }
@keyframes wobble { 30% { transform: rotate(-8deg) scale(1.08); } 60% { transform: rotate(6deg); } }
.ex-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; max-width: 1300px; margin: 10px auto 26px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); font-size: .86rem; color: var(--muted); transition: all .35s var(--ease); }
.chip-btn sup { font-family: var(--mono); font-size: .65rem; margin-left: 5px; opacity: .7; }
.chip-btn:hover { color: var(--text); border-color: var(--muted); }
.chip-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; transform: translateY(-2px); box-shadow: 0 8px 24px -10px var(--brand); }
#ex-search { flex: 0 1 260px; min-width: 0; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-size: .9rem; outline: none; transition: border-color .3s, flex-basis .4s var(--ease); }
#ex-search:focus { border-color: var(--brand); flex-basis: 340px; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; max-width: 1300px; margin: 0 auto; }
.ex-tile { position: relative; overflow: hidden; text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 20px; border-radius: 20px; border: 1px solid var(--line); background: var(--card); min-height: 190px; transition: border-color .35s, transform .35s var(--ease), box-shadow .35s; }
.ex-tile[hidden] { display: none; }
.ex-tile::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 0%), color-mix(in srgb, var(--c) 26%, transparent), transparent 60%); opacity: 0; transition: opacity .35s; }
.ex-tile:hover { border-color: var(--c); transform: translateY(-4px); box-shadow: 0 20px 40px -24px var(--c); }
.ex-tile:hover::before { opacity: 1; }
.ex-ico { font-family: var(--mono); font-size: 1.8rem; color: var(--c); line-height: 1; margin-bottom: 6px; transition: transform .5s var(--ease); }
.ex-tile:hover .ex-ico { transform: rotate(-10deg) scale(1.2); }
.ex-tile b { font-size: 1.15rem; letter-spacing: -0.02em; }
.ex-k { color: var(--muted); font-size: .86rem; line-height: 1.45; }
.ex-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; padding-top: 8px; }
.ex-tags i { font-style: normal; font-family: var(--mono); font-size: .62rem; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
:root[data-theme="light"] .ex-tile { background: #fff; }
:root[data-theme="light"] .ex-ico { color: color-mix(in srgb, var(--c) 65%, #000); }
.ex-empty { text-align: center; margin-top: 30px; }

#slot { position: fixed; inset: 0; z-index: 96; display: grid; place-items: center; background: rgba(5,4,10,.6); backdrop-filter: blur(8px); opacity: 0; pointer-events: none; transition: opacity .3s; }
#slot.open { opacity: 1; pointer-events: auto; }
.slot-box { padding: 24px 28px; border-radius: 24px; background: var(--bg-2); border: 1px solid var(--line); box-shadow: var(--shadow); text-align: center; transform: scale(.9); transition: transform .4s var(--ease); }
#slot.open .slot-box { transform: none; }
.slot-win { position: relative; height: 64px; width: min(80vw, 460px); overflow: hidden; border-radius: 14px; background: var(--card); -webkit-mask: linear-gradient(transparent, #000 25%, #000 75%, transparent); mask: linear-gradient(transparent, #000 25%, #000 75%, transparent); }
.slot-reel div { height: 64px; display: flex; align-items: center; justify-content: center; gap: 12px; font-size: clamp(1.2rem, 4vw, 1.8rem); font-weight: 700; letter-spacing: -0.03em; white-space: nowrap; }
.slot-reel div span { font-family: var(--mono); }
.slot-reel div.win { animation: winPop .6s var(--ease); }
@keyframes winPop { 40% { transform: scale(1.18); text-shadow: 0 0 24px currentColor; } }

/* ---------- round seven: shell + chapter ring ---------- */
.term-btn { font-family: var(--mono); font-size: .8rem; font-weight: 600; }
.ch-ring { position: relative; width: 38px; height: 38px; display: grid; place-items: center; opacity: 0; transform: scale(.6); transition: opacity .4s, transform .5s var(--ease); --accent: var(--brand); }
.ch-ring.on { opacity: 1; transform: none; }
.ch-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ch-ring circle { fill: none; stroke-width: 3; }
.ch-ring .bg { stroke: var(--line); }
.ch-ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .3s, stroke .6s; }
.ch-ring span { font-family: var(--mono); font-size: .5rem; letter-spacing: -0.02em; }
@media (max-width: 760px) { .ch-ring, .term-btn { display: none; } }
#shell {
  position: fixed; left: 50%; top: 0; z-index: 97; width: min(860px, calc(100% - 24px)); height: min(460px, 70svh);
  display: flex; flex-direction: column; border-radius: 0 0 20px 20px; overflow: hidden;
  background: rgba(8, 7, 14, .94); color: #e6e1f7; border: 1px solid rgba(255,255,255,.1); border-top: 0;
  box-shadow: 0 40px 100px -20px rgba(0,0,0,.8); backdrop-filter: blur(14px);
  transform: translate(-50%, -105%); transition: transform .55s var(--ease);
  font-family: var(--mono); font-size: .82rem;
}
#shell.open { transform: translate(-50%, 0); }
.sh-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; background: #14121e; color: #8f8aa3; font-size: .72rem; }
.sh-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; } .sh-bar i:nth-child(2) { background: #febc2e; } .sh-bar i:nth-child(3) { background: #28c840; }
.sh-bar em { font-style: normal; margin-left: 8px; }
.sh-bar button { margin-left: auto; color: #8f8aa3; font-size: .9rem; }
.sh-out { flex: 1; overflow-y: auto; padding: 14px 16px 4px; white-space: pre-wrap; word-break: break-word; line-height: 1.6; }
.sh-l { animation: shIn .25s ease-out; }
@keyframes shIn { from { opacity: 0; transform: translateY(4px); } }
.sh-l.err { color: #ff8b8b; } .sh-l .dim, .sh-l.dim { color: #6b6585; } .sh-l b { color: #fff; }
.sh-l.cmd { margin-top: 6px; }
.sh-ps { color: #a78bfa; margin-right: 8px; white-space: nowrap; }
.sh-line { display: flex; align-items: center; padding: 8px 16px 14px; }
#sh-in { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: #fff; font: inherit; caret-color: #a78bfa; }


/* ---------- round nine: project globe ---------- */
.orbit { animation: none; border: 0; pointer-events: none; }
.orbit::before { inset: 8%; border: 1px dashed var(--line); animation: spin 90s linear infinite; }
.orbit .planet {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: 0; border-radius: 14px;
  display: grid; place-items: center; pointer-events: auto; cursor: pointer; animation: none;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--c); font-family: var(--mono); font-size: .8rem;
  box-shadow: 0 0 30px -8px var(--c); will-change: transform, opacity; transition: border-color .3s, box-shadow .3s;
}
:root[data-theme="light"] .orbit .planet { color: color-mix(in srgb, var(--c) 65%, #000); }
.orbit .planet:hover { border-color: var(--c); box-shadow: 0 0 40px -4px var(--c); }
.orbit .planet em {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translate(-50%, -4px); white-space: nowrap;
  font-style: normal; font-family: var(--sans); font-size: .78rem; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s var(--ease);
}
.orbit .planet:hover em, .orbit .planet:focus-visible em { opacity: 1; transform: translate(-50%, 0); }
.hero.spinning { cursor: grabbing; }
@media (max-width: 760px) { .orbit .planet { width: 36px; height: 36px; border-radius: 11px; font-size: .7rem; } }

.glitch .word { display: inline-block; white-space: nowrap; background: inherit; -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- final pass: small screens ---------- */
/* grid and flex children may shrink below their longest word */
.ch-grid > *, .lang-wrap > *, .av-grid > *, .fm-grid > *, .ex-grid > * { min-width: 0; }
/* long repo names like usb-overclock-kit wrap instead of pushing past the edge */
.ch-side h2, .ch-side .eyebrow, .pcard h3, .ex-tile b, .tl-item h4, .m-head h2, .ch-mini b, .tree code, .dl b, .dl span, .feat b, .demo-head span { overflow-wrap: anywhere; }
@media (max-width: 400px) {
  .ch-mini { grid-template-columns: 1fr 1fr; gap: 8px; }
  .ch-mini div { padding: 12px; }
  .ch-mini b { font-size: 1.15rem; }
  .ch-links .btn { padding: 10px 14px; font-size: .82rem; }
  .pcard { padding: 22px; }
  .logo { font-size: .76rem; }
}
/* the text links live in the ☰ menu and ⌘K too, so drop them before the bar runs out of room */
@media (max-width: 960px) { .nav-links { display: none; } }
.nav-actions > * { flex-shrink: 0; }
.logo { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* headings shrink with narrow screens so names like FreeMessenger stay whole */
.ch-side h2 { font-size: min(clamp(2.2rem, 5vw, 4rem), 10vw); }
.ch-side h2, .m-head h2 { overflow-wrap: break-word; }
