/* How AI Works — animated lab. Loaded after the shared site styles; the site
   theme styles bare `button` and `a` with !important, hence the overrides. */
:root {
  --lab-bg: #020813;
  --lab-panel: rgba(4, 17, 34, 0.86);
  --lab-line: rgba(74, 151, 242, 0.34);
  --lab-line-hot: rgba(61, 208, 255, 0.72);
  --lab-text: #eef7fb;
  --lab-muted: #a9c0cf;
  --lab-dim: #6f8da3;
  --lab-cyan: #39cfff;
  --lab-gold: #e6bd67;
  --lab-green: #84e37a;
  --lab-rose: #ff7f9c;
  --lab-violet: #9d86ff;
  --lab-orange: #ffb060;
  --lab-ink: #020812;
  --lab-shadow: 0 24px 70px rgba(0,0,0,0.42);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--lab-bg); }
body {
  position: relative; margin: 0; min-height: 100vh; overflow-x: hidden;
  color: var(--lab-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 4%, rgba(57,207,255,0.16), transparent 28%),
    radial-gradient(circle at 88% 8%, rgba(230,189,103,0.12), transparent 26%),
    linear-gradient(180deg, #020813 0%, #051427 52%, #020813 100%);
}
body::before, body::after { content: ""; position: fixed; pointer-events: none; z-index: 0; }
body::before {
  inset: -8vh -18vw -14vh;
  background:
    linear-gradient(90deg, rgba(2,7,17,0.82), rgba(2,7,17,0.02) 17%, rgba(2,7,17,0.0) 84%, rgba(2,7,17,0.82)),
    linear-gradient(180deg, rgba(2,7,17,0.62), rgba(2,7,17,0.02) 24%, rgba(2,7,17,0.18) 70%, rgba(2,7,17,0.84)),
    url("../assets/galaxy-home-20260702.webp") center 42% / cover no-repeat;
  opacity: 0.96; filter: saturate(1.28) contrast(1.08);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  animation: galaxy-drift 28s ease-in-out infinite alternate;
}
body::after {
  inset: -38vmax -42vmax;
  background:
    linear-gradient(90deg, rgba(1,4,12,0.52), rgba(1,4,12,0.0) 17%, rgba(1,4,12,0.0) 83%, rgba(1,4,12,0.52)),
    radial-gradient(ellipse at 50% 50%, rgba(255,255,255,0.08), transparent 34%),
    url("../assets/galaxy-home-20260702.webp") center 50% / cover no-repeat;
  opacity: 0.3; filter: saturate(1.22) contrast(1.06) blur(0.4px); mix-blend-mode: screen;
  transform-origin: 50% 50%; animation: galaxy-slow-turn 210s linear infinite;
  -webkit-mask-image: radial-gradient(ellipse at 50% 50%, #000 0 43%, rgba(0,0,0,0.72) 58%, transparent 83%);
  mask-image: radial-gradient(ellipse at 50% 50%, #000 0 43%, rgba(0,0,0,0.72) 58%, transparent 83%);
}
.ai-lab::before {
  content: ""; position: fixed; inset: -8vh -18vw -14vh; z-index: -2; pointer-events: none;
  background:
    linear-gradient(90deg, rgba(2,7,17,0.8), rgba(2,7,17,0.0) 16%, rgba(2,7,17,0.0) 84%, rgba(2,7,17,0.8)),
    linear-gradient(180deg, rgba(2,7,17,0.76), rgba(2,7,17,0.0) 24%, rgba(2,7,17,0.18) 72%, rgba(2,7,17,0.86)),
    url("../assets/galaxy-home-20260702.webp") center 42% / cover no-repeat;
  opacity: 0.96; filter: saturate(1.28) contrast(1.08);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  animation: galaxy-drift 28s ease-in-out infinite alternate;
}
.ai-lab [data-space-fx] { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
@keyframes galaxy-slow-turn { from { transform: rotate(-1deg) scale(1.03); } to { transform: rotate(359deg) scale(1.03); } }
@keyframes galaxy-drift { from { transform: translate3d(-1.5%, -1%, 0) scale(1.02); } to { transform: translate3d(1.5%, 1%, 0) scale(1.08); } }

.ai-lab { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; padding: 24px clamp(14px, 3vw, 40px) 80px; }
.ai-lab button, .ai-lab textarea, .ai-lab input, .ai-lab select { font: inherit; }
.ai-lab em { font-style: italic; color: #e9f6ff; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lab-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 22px; align-items: start; }
.lab-main { min-width: 0; }

/* ---------- rail ---------- */
.lab-rail {
  position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow-y: auto; padding: 16px;
  border: 1px solid var(--lab-line); border-radius: 14px;
  background: linear-gradient(160deg, rgba(8,28,48,0.94), rgba(3,12,24,0.96)); box-shadow: var(--lab-shadow);
}
.rail-brand { display: block; padding-bottom: 12px; text-decoration: none; }
.rail-brand strong { display: block; color: #f8ecd8; font: 800 1.3rem/1.05 Georgia, serif; }
.rail-brand span { display: block; margin-top: 6px; color: var(--lab-muted); font-size: 12px; }
.rail-progress { height: 4px; border-radius: 99px; background: rgba(255,255,255,0.09); overflow: hidden; }
.rail-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--lab-gold), var(--lab-cyan)); transition: width .5s ease; }
.lab-nav { display: grid; gap: 3px; margin-top: 12px; }
.nav-group { margin: 10px 0 4px; color: var(--lab-dim); font-size: 10.5px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.ai-lab .lab-nav a {
  display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 6px 9px;
  border: 1px solid transparent; border-radius: 8px; color: #cfe2ec !important;
  text-decoration: none; font-size: 13px; font-weight: 650; transition: background .2s, border-color .2s;
}
.lab-nav a b { color: var(--lab-dim); font: 700 11px var(--mono); }
.ai-lab .lab-nav a:hover { background: rgba(57,207,255,0.09); color: #fff !important; }
.ai-lab .lab-nav a.active { border-color: var(--lab-line-hot); background: rgba(57,207,255,0.13); color: #fff !important; }
.lab-nav a.active b { color: var(--lab-gold); }
.motion-box { display: grid; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.speed-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.motion-box .lab-button { min-height: 32px; padding: 5px 8px; font-size: 12px; }

/* ---------- hero ---------- */
.lab-hero {
  position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) minmax(200px, 320px); gap: 18px; align-items: center;
  padding: clamp(22px, 4vw, 44px); border: 1px solid var(--lab-line); border-radius: 18px;
  background:
    linear-gradient(115deg, rgba(2,8,19,0.98) 0%, rgba(5,18,34,0.92) 46%, rgba(8,25,45,0.62) 100%),
    url("../assets/home-cards/ai-explainer.jpg?v=neural-network-20260526") center/cover;
  box-shadow: var(--lab-shadow);
}
.hero-copy { position: relative; z-index: 1; }
.hero-canvas { display: block; width: 100%; height: 260px; }
.kicker { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--lab-gold); font-size: 12px; font-weight: 900; letter-spacing: 0.13em; text-transform: uppercase; }
.lab-hero .kicker::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--lab-green); box-shadow: 0 0 18px rgba(132,227,122,0.8); animation: pulse-dot 2.2s ease-in-out infinite; }
@keyframes pulse-dot { 50% { transform: scale(1.5); opacity: .55; } }
.ch-num { font: 800 12px var(--mono); font-style: normal; color: #10202b; background: var(--lab-gold); padding: 2px 6px; border-radius: 5px; letter-spacing: 0; }
.ai-lab h1, .ai-lab h2, .ai-lab h3 { margin: 0; color: #f8ecd8; font-family: Georgia, "Times New Roman", serif; letter-spacing: 0; }
.ai-lab h1 { font-size: clamp(2.5rem, 6.4vw, 5rem); line-height: 0.96; }
.hero-copy p { max-width: 620px; margin: 16px 0 0; color: #c9dae5; font-size: clamp(1rem, 1.6vw, 1.12rem); line-height: 1.6; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* ---------- buttons ---------- */
.ai-lab .lab-button, .ai-lab .hero-actions a {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 13px;
  border: 1px solid rgba(86,163,232,0.42) !important; border-radius: 8px !important;
  color: var(--lab-text) !important; background: rgba(255,255,255,0.06) !important;
  text-decoration: none; font-weight: 750; font-size: 13.5px; line-height: 1.2; cursor: pointer;
  transition: background .18s, border-color .18s, transform .12s;
}
.ai-lab .lab-button:hover, .ai-lab .lab-button.active, .ai-lab .hero-actions a:hover {
  border-color: var(--lab-line-hot) !important; background: rgba(57,207,255,0.16) !important; color: #fff !important;
}
.ai-lab .lab-button:active { transform: translateY(1px); }
.ai-lab .lab-button.primary, .ai-lab .hero-actions a.primary {
  color: #10202b !important; border-color: rgba(230,189,103,0.8) !important;
  background: linear-gradient(135deg, var(--lab-gold), #ff8b74) !important;
}
.ai-lab .lab-button:disabled { opacity: .4; cursor: default; }
.ai-lab :focus-visible { outline: 2px solid var(--lab-cyan); outline-offset: 2px; }
.control-row, .preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-row { margin-bottom: 14px; }
.control-row { margin-top: 12px; }

/* ---------- cards ---------- */
.lab-card {
  margin-top: 22px; border: 1px solid var(--lab-line); border-radius: 14px;
  background: linear-gradient(145deg, var(--lab-panel), rgba(2,10,22,0.93));
  box-shadow: 0 18px 50px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.04); scroll-margin-top: 18px;
}
.lab-card-header { display: flex; justify-content: space-between; gap: 18px; padding: 22px 22px 0; }
.lab-card h2 { font-size: clamp(1.5rem, 3vw, 2.15rem); }
.lab-card h3 { font-size: 1.12rem; }
.lab-card-header p { max-width: 760px; margin: 10px 0 0; color: var(--lab-muted); line-height: 1.6; font-size: 15px; }
.status-pill {
  flex: 0 0 auto; align-self: start; padding: 6px 10px; border: 1px solid rgba(132,227,122,0.36); border-radius: 999px;
  color: #caffc3; background: rgba(132,227,122,0.08); font-size: 11px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap;
}
.lab-card-body { padding: 20px 22px 22px; }
.sub-block { margin-top: 26px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,0.08); }
.sub-block.first { margin-top: 0; padding-top: 0; border-top: 0; }
.sub-block > p, .two-col p { margin: 8px 0 14px; color: var(--lab-muted); line-height: 1.55; font-size: 14.5px; max-width: 760px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.mini-panel { padding: 16px; border: 1px solid rgba(110,159,205,0.24); border-radius: 10px; background: rgba(255,255,255,0.035); }
.mini-panel p { margin: 8px 0 0; color: var(--lab-muted); line-height: 1.5; font-size: 13.5px; }
.mini-panel p.tight { font-size: 12.5px; }
.trace-note {
  margin-top: 14px; padding: 12px 14px; border: 1px solid rgba(230,189,103,0.28); border-radius: 10px;
  color: #f5e3bf; background: rgba(230,189,103,0.06); font-size: 14px; line-height: 1.55; min-height: 46px;
}
.trace-note strong { color: #fff; }
.ch-foot { display: grid; gap: 10px; margin-top: 22px; }
.key-idea { padding: 14px 16px; border-left: 4px solid var(--lab-green); border-radius: 0 10px 10px 0; background: rgba(132,227,122,0.07); color: #e3ffe0; line-height: 1.55; font-size: 15px; }
.key-idea b { display: block; margin-bottom: 4px; color: var(--lab-green); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.fine-print { color: var(--lab-dim); font-size: 12.5px; line-height: 1.55; }
.fine-print::before { content: "How honest is this picture? "; color: var(--lab-muted); font-weight: 800; }
.stage { display: block; width: 100%; border: 1px solid rgba(86,163,232,0.26); border-radius: 12px; background: var(--lab-ink); }
.stage-journey { height: 470px; }
.stage-emb { height: 470px; }
.stage-stack { height: 440px; }
.stage-train { height: 400px; cursor: crosshair; }
.stage-prompt { height: 290px; }
.metric-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.metric-row.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { padding: 10px; border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; background: rgba(255,255,255,0.035); }
.metric > span { display: block; color: var(--lab-dim); font-size: 10.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.metric strong { display: block; margin-top: 4px; color: #fff; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.meter { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,0.08); margin-top: 8px; }
.meter span { display: block; height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, var(--lab-green), var(--lab-cyan), var(--lab-gold)); transition: width .45s ease; }
.meter.risk span { background: linear-gradient(90deg, var(--lab-gold), var(--lab-rose)); }
.ai-lab input[type="range"] { width: 100%; accent-color: var(--lab-cyan); }
.ai-lab textarea {
  width: 100%; min-height: 84px; resize: vertical; padding: 12px; border: 1px solid rgba(110,159,205,0.34); border-radius: 8px;
  color: var(--lab-text); background: rgba(2,8,18,0.92); line-height: 1.5;
}
.ai-lab .lab-select { padding: 7px 9px; border: 1px solid rgba(110,159,205,0.4); border-radius: 8px; color: var(--lab-text); background: #06162a; color-scheme: dark; }

/* ---------- 01 journey ---------- */
.journey-steps { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; counter-reset: js; }
.journey-steps li {
  counter-increment: js; padding: 9px 8px; border: 1px solid rgba(110,159,205,0.22); border-radius: 9px; background: rgba(255,255,255,0.03);
  cursor: pointer; transition: border-color .25s, background .25s, transform .25s;
}
.journey-steps li::before { content: counter(js); display: block; color: var(--lab-dim); font: 800 11px var(--mono); }
.journey-steps b { display: block; margin-top: 3px; color: #fff; font-size: 13px; }
.journey-steps span { display: block; margin-top: 2px; color: var(--lab-muted); font-size: 11px; line-height: 1.3; }
.journey-steps li.done { border-color: rgba(132,227,122,0.34); background: rgba(132,227,122,0.06); }
.journey-steps li.active { border-color: var(--lab-gold); background: rgba(230,189,103,0.14); transform: translateY(-3px); box-shadow: 0 10px 26px rgba(230,189,103,0.14); }
.journey-steps li.active::before { color: var(--lab-gold); }

/* ---------- 02 tokens ---------- */
.tok-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 18px; align-items: start; }
.tok-stage { display: flex; flex-wrap: wrap; gap: 6px 9px; min-height: 96px; align-content: start; margin-top: 14px; padding: 14px; border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; background: rgba(0,0,0,0.26); }
.tok-word { display: inline-flex; gap: 2px; }
.tok { display: inline-block; padding: 5px 6px; border: 1px solid rgba(255,255,255,0.14); border-radius: 6px; color: #dcf8ff; font: 13px/1.15 var(--mono); white-space: pre; }
.tok.raw { color: var(--lab-muted); background: rgba(255,255,255,0.04); padding-inline: 4px; }
.c0 { background: rgba(57,207,255,0.17); border-color: rgba(57,207,255,0.5); }
.c1 { background: rgba(230,189,103,0.17); border-color: rgba(230,189,103,0.5); }
.c2 { background: rgba(132,227,122,0.16); border-color: rgba(132,227,122,0.5); }
.c3 { background: rgba(255,127,156,0.16); border-color: rgba(255,127,156,0.5); }
.c4 { background: rgba(157,134,255,0.19); border-color: rgba(157,134,255,0.55); }
.c5 { background: rgba(255,176,96,0.17); border-color: rgba(255,176,96,0.5); }
.tok.pop { animation: tok-pop .34s cubic-bezier(.2,1.6,.4,1); box-shadow: 0 0 0 2px #fff, 0 0 18px rgba(255,255,255,0.5); color: #fff; }
@keyframes tok-pop { from { transform: scale(1.5); } to { transform: scale(1); } }
.tok-ids { margin-top: 12px; }
.tok-ids span { display: block; color: var(--lab-dim); font-size: 10.5px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.tok-ids code { display: block; margin-top: 5px; padding: 10px; border-radius: 8px; background: rgba(0,0,0,0.3); color: var(--lab-gold); font: 12.5px/1.5 var(--mono); word-break: break-word; }
.tok-rules { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.tok-rules li { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; color: var(--lab-muted); font-size: 12px; }
.tok-rules b { width: 26px; color: var(--lab-dim); font: 700 11px var(--mono); }
.tok-rules i { margin-left: auto; color: var(--lab-dim); font: normal 11px var(--mono); }
.tok-rules .tok { padding: 3px 5px; font-size: 12px; }

/* ---------- 03 embeddings ---------- */
.emb-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
.strip-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 4px 8px; align-items: center; margin-top: 12px; }
.strip-row b { color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.strip-tag { grid-column: 2; color: var(--lab-green); font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.strip-tag.far { color: var(--lab-rose); }
.vstrip { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; height: 20px; }
.vstrip i { border-radius: 2px; transition: background .5s ease; }
.sim { color: var(--lab-gold); font: 700 12px var(--mono); }
.hit { color: var(--lab-rose); }
.analogy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--lab-muted); font: 700 18px var(--mono); }
.pos-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.pos-col { display: grid; gap: 5px; padding: 12px; border: 1px solid rgba(110,159,205,0.22); border-radius: 10px; background: rgba(255,255,255,0.03); }
.pos-col b { color: #fff; font: 700 15px var(--mono); }
.pos-op { color: var(--lab-dim); font-size: 11px; font-weight: 800; }
.vstrip.pos i { border-radius: 50%; }
.vstrip.sum { height: 26px; outline: 1px solid rgba(157,134,255,0.6); outline-offset: 2px; border-radius: 2px; }

/* ---------- 04 attention ---------- */
.att-controls .preset-row { margin-bottom: 8px; }
.att-scroll { overflow-x: auto; margin-top: 6px; padding: 0 6px 8px; scrollbar-width: thin; scrollbar-color: rgba(57,207,255,0.4) transparent; }
.att-stage { position: relative; min-width: 610px; }
.att-arcs { display: block; height: 120px; overflow: visible; }
.att-arc { fill: none; stroke: var(--lab-gold); stroke-linecap: round; }
.att-arc.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: att-draw .55s ease-out forwards; }
@keyframes att-draw { to { stroke-dashoffset: 0; } }
.att-self { fill: var(--lab-gold); }
.att-row { position: relative; display: flex; justify-content: space-between; gap: 5px; }
.ai-lab .att-tok {
  --w: 0; flex: 1 1 0; min-width: 0; padding: 8px 2px 6px; cursor: pointer; text-align: center;
  border: 1px solid rgba(230,189,103, calc(var(--w) * 0.8 + 0.2)) !important; border-radius: 8px !important;
  background: rgba(230,189,103, calc(var(--w) * 0.62 + 0.03)) !important; color: #fff !important;
  transition: background .4s, border-color .4s, transform .2s;
}
.att-tok span { display: block; font: 700 13.5px var(--mono); overflow: hidden; text-overflow: ellipsis; }
.att-tok em { display: block; margin-top: 3px; color: #f5e3bf; font: normal 700 10.5px var(--mono); }
.ai-lab .att-tok.query { border-color: var(--lab-cyan) !important; box-shadow: 0 0 0 2px rgba(57,207,255,0.35), 0 8px 22px rgba(57,207,255,0.2); transform: translateY(-3px); }
.ai-lab .att-tok.future { border-style: dashed !important; border-color: rgba(255,255,255,0.16) !important; background: transparent !important; color: var(--lab-dim) !important; }
.att-tok.future em { color: var(--lab-dim); }
.ai-lab .att-tok.swap span { text-decoration: underline dotted var(--lab-rose); text-underline-offset: 3px; }
.att-grid { display: grid; grid-template-columns: 58px repeat(11, minmax(0, 1fr)); gap: 2px; max-width: 430px; }
.att-grid i { --w: 0; aspect-ratio: 1; border-radius: 3px; background: rgba(230,189,103, calc(var(--w) * 0.95 + 0.05)); cursor: pointer; transition: background .4s; }
.att-grid i.on { outline: 1px solid var(--lab-cyan); }
.att-grid i.masked { cursor: default; background: repeating-linear-gradient(45deg, rgba(255,255,255,0.07) 0 2px, transparent 2px 5px); }
.att-colh { height: 52px; writing-mode: vertical-rl; transform: rotate(180deg); color: var(--lab-dim); font: 10px var(--mono); text-align: left; overflow: hidden; justify-self: center; }
.att-rowh { align-self: center; color: var(--lab-dim); font: 10.5px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-rowh.on { color: var(--lab-cyan); font-weight: 800; }
.qkv { display: grid; gap: 7px; }
.qkv-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 9px; padding: 8px 10px; border: 1px solid rgba(255,255,255,0.08); border-radius: 9px; background: rgba(0,0,0,0.22); }
.qkv-row > b { min-width: 52px; color: #fff; font: 700 13px var(--mono); }
.qkv-q { border-color: rgba(57,207,255,0.5); background: rgba(57,207,255,0.07); }
.qkv-tag { color: var(--lab-dim); font-size: 9.5px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.nums { display: inline-flex; gap: 2px; }
.nums i { display: grid; place-items: center; width: 36px; height: 22px; border-radius: 4px; color: #fff; font: normal 700 10.5px var(--mono); text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.qkv-hint { flex: 1 1 160px; color: var(--lab-muted); font-size: 12px; }
.qkv-calc { flex: 1 1 100%; color: var(--lab-muted); font: 11.5px var(--mono); }
.qkv-calc strong { color: var(--lab-gold); }
.qkv-bar { flex: 1 1 130px; display: flex; align-items: center; gap: 7px; }
.qkv-bar span { display: block; height: 10px; width: 0; border-radius: 99px; background: var(--lab-gold); transition: width .7s cubic-bezier(.2,.8,.2,1) var(--d, 0ms); }
.qkv-bar em { color: var(--lab-gold); font: normal 700 12px var(--mono); }
.qkv-val { display: inline-flex; align-items: center; gap: 6px; }
.qkv-calc, .qkv-bar, .qkv-val, .qkv-out { opacity: 0; transition: opacity .45s ease var(--d, 0ms); }
.qkv:not([data-step="0"]) .qkv-calc { opacity: 1; }
.qkv[data-step="2"] .qkv-bar, .qkv[data-step="3"] .qkv-bar { opacity: 1; }
.qkv[data-step="2"] .qkv-bar span, .qkv[data-step="3"] .qkv-bar span { width: calc(var(--p) * 100%); }
.qkv[data-step="3"] .qkv-val, .qkv[data-step="3"] .qkv-out { opacity: 1; }
.qkv-out { border-color: rgba(132,227,122,0.5); background: rgba(132,227,122,0.07); }

/* ---------- 05 layers ---------- */
.neuron-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: center; }
.neuron-svg { display: block; width: 100%; height: auto; border: 1px solid rgba(86,163,232,0.26); border-radius: 12px; background: var(--lab-ink); }
.n-num { fill: #fff; font: 700 13px var(--mono); text-anchor: middle; }
.n-cap { fill: #9fb8c9; font: 700 9.5px var(--mono); text-anchor: middle; text-transform: uppercase; letter-spacing: .06em; }
.n-lab { fill: #cfe2ec; font: 11px var(--mono); }
.n-edge { fill: none; stroke-linecap: round; opacity: .85; }
.n-edge.flow { stroke-dasharray: 7 9; animation: edge-flow .9s linear infinite; }
@keyframes edge-flow { to { stroke-dashoffset: -16; } }
.neuron-sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.neuron-sliders label { display: grid; gap: 2px; color: var(--lab-muted); font-size: 12px; }
.neuron-sliders label span { display: flex; justify-content: space-between; }
.neuron-sliders output, .dial output { color: var(--lab-gold); font: 700 12px var(--mono); }
.neuron-sliders label:nth-of-type(7), .neuron-sliders .lab-button { grid-column: 1 / -1; }
.stack-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 18px; align-items: start; }
.slider-row { align-items: center; }
.inline-range { display: flex; flex: 1 1 200px; align-items: center; gap: 10px; color: var(--lab-muted); font-size: 13px; font-weight: 700; }
.lens-bars { display: grid; gap: 8px; margin-top: 12px; }
.lens-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) 36px; gap: 8px; align-items: center; font: 13px var(--mono); color: #d8eaf2; animation: rise .35s ease both; }
.lens-row .bar { height: 10px; border-radius: 99px; background: rgba(255,255,255,0.07); overflow: hidden; }
.lens-row .bar i { display: block; height: 100%; border-radius: inherit; background: var(--lab-rose); animation: grow .5s ease both; transform-origin: left; }
.lens-row em { color: var(--lab-muted); font: normal 12px var(--mono); text-align: right; }
.lens-row.hit { color: var(--lab-gold); font-weight: 800; }
.lens-row.hit .bar i { background: var(--lab-gold); }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.scale-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
.scale-card { padding: 16px; border: 1px solid rgba(110,159,205,0.24); border-radius: 10px; background: rgba(255,255,255,0.035); }
.scale-card > span { color: var(--lab-gold); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.scale-card dl { display: grid; gap: 6px; margin: 10px 0 0; }
.scale-card dl div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-bottom: 1px dashed rgba(255,255,255,0.08); padding-bottom: 5px; }
.scale-card dt { color: var(--lab-muted); font-size: 13px; }
.scale-card dd { margin: 0; color: #fff; font: 700 1.05rem var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- 06 sampling ---------- */
.samp-text { padding: 14px 16px; border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; background: rgba(0,0,0,0.3); font: 600 clamp(1.05rem, 2.4vw, 1.45rem)/1.5 Georgia, serif; color: #cfe2ec; min-height: 62px; }
.samp-text .ctx { color: #fff; text-decoration: underline 2px var(--lab-cyan); text-underline-offset: 6px; }
.samp-text .new { color: var(--lab-gold); animation: tok-pop .4s cubic-bezier(.2,1.6,.4,1); display: inline-block; }
.caret { color: var(--lab-cyan); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.samp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 20px; margin-top: 16px; align-items: start; }
.samp-head, .samp-row { display: grid; grid-template-columns: 88px 46px minmax(0, 1fr) 92px 34px; gap: 8px; align-items: center; }
.samp-head { color: var(--lab-dim); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.samp-bars { display: grid; gap: 5px; }
.samp-row { font: 13px var(--mono); color: #e6f3f9; transition: opacity .3s; }
.samp-row .w { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.samp-row .w i { color: var(--lab-muted); font-weight: 400; }
.samp-row .s { color: var(--lab-dim); font-size: 11.5px; }
.samp-row .bar { position: relative; height: 13px; border-radius: 99px; background: rgba(255,255,255,0.06); }
.samp-row .bar i { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: linear-gradient(90deg, #ff5f86, var(--lab-rose)); }
.samp-row .bar b { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 6px #fff; }
.samp-row em { color: var(--lab-muted); font: normal 12px var(--mono); }
.samp-row .n { color: var(--lab-dim); font-size: 11px; text-align: right; }
.samp-row.cut { opacity: .36; }
.samp-row.cut .w { text-decoration: line-through; }
.samp-row.cut em { color: var(--lab-rose); font-size: 10.5px; }
.samp-row.picked { color: var(--lab-gold); }
.samp-row.picked .bar i { background: var(--lab-gold); box-shadow: 0 0 14px rgba(230,189,103,.6); }
.samp-strip { position: relative; height: 36px; margin-top: 16px; border-radius: 9px; overflow: hidden; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12); }
.samp-strip .seg { position: absolute; top: 0; bottom: 0; display: grid; place-items: center; overflow: hidden; border: 0; border-right: 1px solid var(--lab-ink); color: #fff; font: 700 11px var(--mono); transition: left .35s ease, width .35s ease; }
.samp-strip .seg.picked { box-shadow: inset 0 0 0 2px #fff; }
.needle { position: absolute; top: 0; bottom: 0; left: 0; width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 10px #fff; opacity: 0; transition: left .09s linear; z-index: 2; }
.needle.on { opacity: 1; }
.strip-cap { margin: 8px 0 0; color: var(--lab-dim); font-size: 12px; line-height: 1.45; }
.samp-side { display: grid; gap: 12px; align-content: start; }
.dial { display: grid; gap: 3px; color: #dbeaf2; font-size: 13px; font-weight: 700; }
.dial span { display: flex; justify-content: space-between; }
.dial small { color: var(--lab-dim); font-weight: 400; font-size: 11.5px; }
.samp-side .control-row { margin-top: 0; }
.samp-side .lab-button { flex: 1 1 auto; }

/* ---------- 07 training ---------- */
.train-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 18px; align-items: start; }
.scope-callout { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; margin-top: 18px; padding: 16px 18px; border: 1px solid rgba(230,189,103,0.42); border-radius: 12px; background: linear-gradient(135deg, rgba(230,189,103,0.13), rgba(57,207,255,0.07)); }
.scope-callout p { margin: 6px 0 0; color: var(--lab-muted); line-height: 1.5; font-size: 14px; }

/* ---------- 08 context ---------- */
.context-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end; }
.context-controls .control-row { margin: 0; }
.range-label { display: block; margin-bottom: 4px; color: var(--lab-muted); font-size: 13px; font-weight: 700; }
.range-label strong { color: var(--lab-gold); }
.ctx-frame { margin-top: 16px; padding: 12px; border: 2px solid rgba(57,207,255,0.5); border-radius: 12px; background: rgba(0,0,0,0.28); }
.ctx-cap { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--lab-muted); font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.ctx-cap strong { color: #fff; }
.ctx-bar { display: flex; height: 54px; border-radius: 8px; overflow: hidden; background: repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 8px, transparent 8px 16px); }
.ctx-blk { flex: 0 0 auto; width: 0; height: 100%; overflow: hidden; display: grid; place-items: center; white-space: nowrap; color: #06121d; font: 800 10px var(--mono); border-right: 2px solid var(--lab-ink); transition: width .65s cubic-bezier(.2,.8,.2,1), opacity .4s; }
.ctx-blk.gone { opacity: 0; border-right-width: 0; }
.ctx-blk.sys { background: #7f9bb0; } .ctx-blk.mem { background: var(--lab-violet); } .ctx-blk.sum { background: var(--lab-gold); }
.ctx-blk.user { background: var(--lab-cyan); } .ctx-blk.ai { background: var(--lab-green); }
.ctx-blk.key { box-shadow: inset 0 0 0 3px #fff; }
.context-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.legend-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid rgba(255,255,255,0.1); border-radius: 999px; color: var(--lab-muted); background: rgba(255,255,255,0.035); font-size: 12px; font-weight: 800; }
.legend-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--pill-color, var(--lab-cyan)); }
.ctx-probe { margin-top: 14px; padding: 12px 14px; border-radius: 10px; border: 1px solid; font-size: 14px; line-height: 1.55; transition: background .4s, border-color .4s; }
.ctx-probe b { display: block; margin-bottom: 3px; color: #fff; }
.ctx-probe.ok { border-color: rgba(132,227,122,0.5); background: rgba(132,227,122,0.08); color: #dfffe0; }
.ctx-probe.warn { border-color: rgba(230,189,103,0.5); background: rgba(230,189,103,0.08); color: #f5e3bf; }
.ctx-probe.bad { border-color: rgba(255,127,156,0.55); background: rgba(255,127,156,0.09); color: #ffd9e1; }
.context-stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.context-item { display: grid; grid-template-columns: 128px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid rgba(110,159,205,0.2); border-radius: 8px; background: rgba(255,255,255,0.035); color: var(--lab-muted); font-size: 12.5px; transition: opacity .4s, border-color .4s, color .4s; }
.context-item[hidden] { display: none; }
.context-item strong { font-size: 12px; }
.context-item.key strong::after { content: " \2605"; color: var(--lab-gold); }
.context-item.visible { border-color: rgba(132,227,122,0.42); color: #dfffe0; }
.context-item.summary { border-color: rgba(230,189,103,0.38); color: #f4dfb5; opacity: 0.8; }
.context-item.memory { border-color: rgba(157,134,255,0.6); color: #e8e1ff; }
.context-item.dropped { color: #73879a; opacity: 0.42; text-decoration: line-through; }
.context-state { font-size: 10.5px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; }

/* ---------- 09 prompts ---------- */
.prompt-build { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 12px 16px; margin-top: 14px; align-items: start; }
.part-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.prompt-output { min-height: 86px; padding: 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.08); background: rgba(0,0,0,0.26); color: #d8eaf2; line-height: 1.7; font-size: 15px; }
.prompt-output .part { padding: 2px 5px; border-radius: 5px; animation: rise .35s ease both; }
.p-goal { --pc: 57,207,255; } .p-scope { --pc: 132,227,122; } .p-constraints { --pc: 230,189,103; } .p-verify { --pc: 255,127,156; } .p-format { --pc: 157,134,255; }
.prompt-output .part { background: rgba(var(--pc), 0.16); box-shadow: inset 0 -2px 0 rgba(var(--pc), 0.8); }
.ai-lab .part-row .lab-button.active { border-color: rgb(var(--pc)) !important; background: rgba(var(--pc), 0.2) !important; }
.metric.hit strong { font-size: 1.5rem; color: var(--lab-green); }

/* ---------- 10 agents ---------- */
.agent-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 18px; align-items: start; }
.ag-head, .ag-lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
.ag-head span { padding: 7px; border-radius: 8px 8px 0 0; text-align: center; font-size: 11px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: #fff; background: rgba(255,255,255,0.07); }
.ag-head span:nth-child(1) { box-shadow: inset 0 -3px 0 var(--lab-cyan); } .ag-head span:nth-child(2) { box-shadow: inset 0 -3px 0 var(--lab-gold); } .ag-head span:nth-child(3) { box-shadow: inset 0 -3px 0 var(--lab-orange); }
.ag-lanes {
  height: 430px; overflow-y: auto; align-content: start; padding: 12px 0; border: 1px solid rgba(255,255,255,0.08); border-top: 0; border-radius: 0 0 10px 10px;
  background:
    linear-gradient(90deg, transparent calc(33.33% - 1px), rgba(255,255,255,0.07) calc(33.33% - 1px) 33.33%, transparent 33.33% calc(66.66% - 1px), rgba(255,255,255,0.07) calc(66.66% - 1px) 66.66%, transparent 66.66%),
    rgba(0,0,0,0.3);
}
.ag-msg { --kc: 57,207,255; margin: 0 10px; padding: 9px 11px; border: 1px solid rgba(var(--kc), 0.55); border-radius: 10px; background: linear-gradient(90deg, rgba(var(--kc), 0.2), rgba(var(--kc), 0.07)); animation: ag-right .45s cubic-bezier(.2,.8,.2,1) both; }
.ag-msg.d-left { background: linear-gradient(270deg, rgba(var(--kc), 0.2), rgba(var(--kc), 0.07)); animation-name: ag-left; }
.ag-msg.d-self { animation-name: rise; border-style: dashed; }
@keyframes ag-right { from { opacity: 0; transform: translateX(-34px); } }
@keyframes ag-left { from { opacity: 0; transform: translateX(34px); } }
.ag-tag { display: block; margin-bottom: 4px; color: rgb(var(--kc)); font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.ag-msg.d-left .ag-tag { text-align: right; }
.ag-msg p { margin: 0; color: #eef7fb; font-size: 13.5px; line-height: 1.45; }
.ag-msg code { display: block; color: #f3f8fb; font: 12px/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; }
.k-plan { --kc: 230,189,103; } .k-call { --kc: 255,176,96; } .k-result { --kc: 132,227,122; } .k-answer { --kc: 57,207,255; } .k-guess { --kc: 255,127,156; } .k-ask { --kc: 157,134,255; }
.agent-side { display: grid; gap: 12px; }
.agent-ring { display: block; width: 100%; max-width: 190px; margin: 0 auto; }
.ring-lab { fill: #9fb8c9; font: 700 9px var(--mono); text-anchor: middle; text-transform: uppercase; }
.ring-lab.on { fill: #fff; }
.ring-mid { fill: #9fb8c9; font: 700 9px var(--mono); text-anchor: middle; text-transform: uppercase; letter-spacing: .1em; }
.ring-num { fill: #fff; font: 800 18px var(--mono); text-anchor: middle; }
.ring-on { animation: ring-pulse 1s ease-in-out infinite; }
@keyframes ring-pulse { 50% { opacity: .55; } }
.agent-side .lab-button { flex: 1 1 auto; }
.ai-lab .lab-button.toggle { margin-left: auto; border-color: rgba(132,227,122,0.6) !important; }
.ai-lab .lab-button.toggle:not(.active) { border-color: rgba(255,127,156,0.7) !important; color: #ffd9e1 !important; }

/* ---------- 11 systems ---------- */
.system-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.system-tile { padding: 16px; border-radius: 10px; border: 1px solid rgba(110,159,205,0.24); background: rgba(255,255,255,0.035); transition: border-color .25s, background .25s, transform .25s, box-shadow .25s; }
.system-tile:nth-child(1) { border-color: rgba(132,227,122,0.34); } .system-tile:nth-child(2) { border-color: rgba(57,207,255,0.34); }
.system-tile:nth-child(3) { border-color: rgba(157,134,255,0.34); } .system-tile:nth-child(4) { border-color: rgba(230,189,103,0.34); }
.system-tile h3 { font-size: 1rem; }
.system-tile p { margin: 8px 0 0; color: var(--lab-muted); font-size: 13px; line-height: 1.45; }
.system-tile.active { border-color: var(--lab-gold); background: rgba(230,189,103,0.12); transform: translateY(-5px); box-shadow: 0 16px 36px rgba(230,189,103,0.16); }
.builder-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; }
.builder-options { display: grid; gap: 8px; }
.builder-option { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid rgba(110,159,205,0.24); border-radius: 10px; background: rgba(255,255,255,0.035); cursor: pointer; }
.builder-option input { margin-top: 3px; accent-color: var(--lab-cyan); }
.builder-option strong { display: block; color: #fff; font-size: 14px; }
.builder-option span span { display: block; margin-top: 3px; color: var(--lab-muted); font-size: 12px; line-height: 1.4; }
.builder-output { display: grid; align-content: start; gap: 12px; padding: 16px; border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; background: var(--lab-ink); }
.stack-visual { display: grid; gap: 6px; }
.stack-layer { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid rgba(57,207,255,0.2); border-left: 4px solid var(--layer-color, var(--lab-cyan)); border-radius: 9px; background: rgba(255,255,255,0.035); }
.stack-layer.in { animation: drop-in .45s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes drop-in { from { opacity: 0; transform: translateY(-22px) scale(.96); } }
.stack-layer strong { color: #fff; font-size: 13px; }
.stack-layer span { color: var(--lab-muted); font-size: 12.5px; line-height: 1.35; }
.builder-output .metric-row { margin-top: 0; }
.builder-summary { min-height: 70px; padding: 12px 14px; border: 1px solid rgba(230,189,103,0.28); border-radius: 10px; color: #f5e3bf; background: rgba(230,189,103,0.055); line-height: 1.5; font-size: 14px; }

/* ---------- 12 failure ---------- */
.failure-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.failure-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: center; padding: 16px; border: 1px solid rgba(255,127,156,0.3); border-radius: 10px; background: rgba(255,127,156,0.055); }
.failure-card h3 { color: #ffe3e9; }
.failure-card p { margin: 8px 0 0; color: #f3c8d1; line-height: 1.55; font-size: 14.5px; }
.fv { min-height: 150px; display: grid; align-content: center; gap: 8px; padding: 14px; border-radius: 10px; background: var(--lab-ink); border: 1px solid rgba(255,255,255,0.08); animation: rise .4s ease both; }
.fv-q { color: #fff; font: 600 15px Georgia, serif; margin-bottom: 4px; }
.fv-bar { display: grid; grid-template-columns: 112px minmax(0, 1fr) 36px; gap: 8px; align-items: center; font: 12.5px var(--mono); color: #e6f3f9; }
.fv-bar i { height: 10px; border-radius: 99px; background: var(--lab-rose); width: calc(var(--p) * 2.6); max-width: 100%; animation: grow .7s ease both; transform-origin: left; }
.fv-bar em { color: var(--lab-muted); font-style: normal; }
.fv-bar.good { color: var(--lab-green); } .fv-bar.good i { background: var(--lab-green); }
.fv-time { position: relative; height: 96px; }
.fv-time .known, .fv-time .gap { position: absolute; top: 34px; height: 26px; display: grid; place-items: center; font: 700 10.5px var(--mono); border-radius: 6px 0 0 6px; }
.fv-time .known { left: 0; width: 62%; background: rgba(57,207,255,0.25); color: #dcf8ff; }
.fv-time .gap { left: 62%; width: 34%; border-radius: 0 6px 6px 0; color: var(--lab-rose); background: repeating-linear-gradient(45deg, rgba(255,127,156,0.2) 0 4px, transparent 4px 9px); }
.fv-time b { position: absolute; top: 12px; font: 700 10px var(--mono); color: var(--lab-gold); transform: translateX(-50%); white-space: nowrap; }
.fv-time b::after { content: ""; position: absolute; left: 50%; top: 14px; width: 2px; height: 42px; background: var(--lab-gold); }
.fv-time .cut { left: 62%; } .fv-time .now { left: 96%; transform: translateX(-90%); } .fv-time .now::after { left: 90%; }
.fv-time .ask { position: absolute; left: 80%; top: 68px; transform: translateX(-50%); padding: 2px 7px; border-radius: 99px; background: var(--lab-rose); color: #10202b; font: normal 800 10px var(--mono); white-space: nowrap; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, -5px); } }
.fv-win { display: flex; gap: 5px; padding: 8px; border: 2px solid rgba(57,207,255,0.5); border-radius: 9px; }
.fv-win span { flex: 1; padding: 14px 4px; border-radius: 6px; background: rgba(57,207,255,0.2); color: #dcf8ff; font: 700 10.5px var(--mono); text-align: center; }
.fv-win .hole { background: transparent; border: 2px dashed var(--lab-rose); color: var(--lab-rose); animation: blink 1.4s ease-in-out infinite; }
.fv-fan { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; }
.fv-fan b { grid-row: span 4; color: #fff; font: 600 15px Georgia, serif; }
.fv-fan span { padding: 5px 9px; border-left: 3px solid var(--lab-rose); background: rgba(255,127,156,0.1); color: #ffd9e1; font-size: 12.5px; animation: ag-right .5s ease both; }
.fv-fan span:nth-of-type(2) { animation-delay: .1s; } .fv-fan span:nth-of-type(3) { animation-delay: .2s; } .fv-fan span:nth-of-type(4) { animation-delay: .3s; }
.fv-tools { display: grid; gap: 6px; }
.fv-tools span { padding: 8px 10px; border-radius: 8px; font-size: 12.5px; border: 1px solid; }
.fv-tools .no { border-color: rgba(255,127,156,0.5); color: #ffd9e1; background: rgba(255,127,156,0.08); }
.fv-tools .no::before { content: "\2717  "; } .fv-tools .yes::before { content: "\2713  "; }
.fv-tools .yes { border-color: rgba(132,227,122,0.5); color: #dfffe0; background: rgba(132,227,122,0.08); }
.fv-gate { position: relative; height: 70px; border-bottom: 2px dashed rgba(255,255,255,0.2); }
.fv-gate .gate { position: absolute; left: 56%; bottom: -2px; height: 62px; padding: 0 6px; display: grid; place-items: center; border-left: 4px solid var(--lab-gold); color: var(--lab-gold); font: 800 10px var(--mono); text-transform: uppercase; }
.fv-gate .dest { position: absolute; right: 0; bottom: 8px; color: var(--lab-muted); font: 700 11px var(--mono); }
.fv-gate .pkt { position: absolute; left: 0; bottom: 6px; width: 22px; height: 22px; border-radius: 6px; background: var(--lab-cyan); box-shadow: 0 0 14px var(--lab-cyan); animation: to-gate 2.6s ease-in-out infinite; }
@keyframes to-gate { 0% { left: 0; } 45%, 100% { left: calc(56% - 30px); } 55%, 70% { left: calc(56% - 36px); } }
.quiz-card { display: grid; gap: 10px; padding: 16px; border: 1px solid rgba(230,189,103,0.32); border-radius: 10px; background: rgba(230,189,103,0.055); margin-top: 16px; }
.quiz-card p { margin: 0; color: #fff; font: 600 15px Georgia, serif; }
.quiz-card .preset-row, .quiz-card .control-row { margin: 0; }
.quiz-result { min-height: 46px; color: #f5e3bf; line-height: 1.5; font-size: 14px; }

/* ---------- 13 glossary ---------- */
.concept-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.ai-lab .concept-chip { padding: 7px 12px; border: 1px solid rgba(110,159,205,0.3) !important; border-radius: 999px !important; background: rgba(255,255,255,0.04) !important; color: #dbeaf2 !important; font-size: 13px; font-weight: 700; cursor: pointer; }
.ai-lab .concept-chip.active, .ai-lab .concept-chip:hover { border-color: var(--lab-line-hot) !important; background: rgba(57,207,255,0.16) !important; color: #fff !important; }
.concept-detail { margin-top: 14px; padding: 18px; border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; background: var(--lab-ink); }
.concept-detail h3 { font-size: 1.35rem; }
.concept-detail p { margin: 10px 0 0; color: var(--lab-muted); line-height: 1.6; max-width: 820px; }
.concept-example { margin-top: 14px; padding: 12px 14px; border: 1px solid rgba(132,227,122,0.26); border-radius: 10px; color: #dfffe0; background: rgba(132,227,122,0.055); font-size: 14px; line-height: 1.5; }
.concept-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.concept-pair div { padding: 12px; border: 1px solid rgba(230,189,103,0.22); border-radius: 10px; background: rgba(230,189,103,0.045); }
.concept-pair strong { display: block; color: #fff; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.concept-pair span { display: block; margin-top: 6px; color: #f5ddb0; font-size: 13.5px; line-height: 1.4; }
.concept-detail .see { margin-top: 14px; }

.ai-lab footer { margin-top: 38px; padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.08); color: var(--lab-muted); font-size: 13px; text-align: center; }
.mobile-tour-bar { display: none; }

/* ---------- motion preferences ---------- */
.lab-paused .ai-lab *, .lab-paused .ai-lab *::before, .lab-paused .ai-lab *::after { animation-play-state: paused !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body::before, body::after, .ai-lab::before { animation: none; }
  .ai-lab *, .ai-lab *::before, .ai-lab *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .lab-shell { grid-template-columns: 1fr; }
  .lab-rail { position: static; max-height: none; }
  .lab-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nav-group { grid-column: 1 / -1; }
  .motion-box { grid-template-columns: 1fr 1fr; align-items: center; }
}
@media (max-width: 860px) {
  .tok-layout, .emb-layout, .neuron-layout, .stack-layout, .samp-layout, .train-layout, .agent-layout, .builder-grid, .two-col, .failure-card { grid-template-columns: 1fr; }
  .journey-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .system-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-side { grid-template-columns: 150px minmax(0, 1fr); align-items: center; }
  .agent-side .control-row { grid-column: 1 / -1; }
  .context-stack { grid-template-columns: 1fr; }
  .lab-hero { grid-template-columns: 1fr; }
  .hero-canvas { height: 150px; }
}
@media (max-width: 680px) {
  .ai-lab { padding: 14px 12px 96px; }
  .lab-hero { padding: 22px; }
  .lab-rail { padding: 12px; }
  .rail-brand { padding-bottom: 8px; }
  .rail-brand strong { display: inline; font-size: 1.05rem; }
  .rail-brand span { display: inline; margin-left: 8px; }
  .lab-nav { display: flex; overflow-x: auto; gap: 6px; padding-bottom: 6px; scrollbar-width: thin; }
  .nav-group { display: none; }
  .ai-lab .lab-nav a { flex: 0 0 auto; border-color: rgba(96,156,216,0.28); white-space: nowrap; }
  .motion-box { grid-template-columns: 1fr 1fr; margin-top: 8px; padding-top: 10px; }
  .lab-card-header { display: block; padding: 18px 16px 0; }
  .lab-card-body { padding: 16px; }
  .status-pill { display: inline-flex; margin-top: 12px; }
  .mobile-tour-bar {
    position: sticky; top: 8px; z-index: 20; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; margin: 12px 0 0; padding: 8px;
    border: 1px solid rgba(86,163,232,0.34); border-radius: 12px; background: rgba(3,13,26,0.94); backdrop-filter: blur(12px);
  }
  .mobile-tour-bar span { color: #fff; font-size: 12.5px; font-weight: 800; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lab-card { scroll-margin-top: 70px; }
  .stage-journey { height: 450px; } .stage-emb { height: 400px; } .stage-stack { height: 400px; } .stage-train { height: 320px; } .stage-prompt { height: 250px; }
  .journey-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-row, .metric-row.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .system-strip, .scale-grid, .concept-pair, .pos-row, .context-controls, .prompt-build, .scope-callout { grid-template-columns: 1fr; }
  .samp-head, .samp-row { grid-template-columns: 70px minmax(0, 1fr) 62px 30px; }
  .samp-head span:nth-child(2), .samp-row .s { display: none; }
  .context-item { grid-template-columns: 1fr auto; } .context-item span:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .stack-layer { grid-template-columns: 1fr; gap: 2px; }
  .ag-msg { grid-column: 1 / -1 !important; margin: 0 8px; }
  .ag-msg.d-right { margin-right: 26px; } .ag-msg.d-left { margin-left: 26px; }
  .ag-lanes { background: rgba(0,0,0,0.3); height: 400px; }
  .ag-head { display: none; }
  .ai-lab .lab-button.toggle { margin-left: 0; }
  .att-grid { grid-template-columns: 44px repeat(11, minmax(0, 1fr)); }
}

/* =====================================================================
   v2: the shared prompt, the real model's views, live training, the chat
   chapter, predict-first questions, and the phone accordion
   ===================================================================== */
.fine { margin: 10px 0 0; color: var(--lab-dim); font-size: 12.5px; line-height: 1.55; }
.unk-note { color: #ffc2cf; }
.ai-lab .link-btn { padding: 0 !important; border: 0 !important; background: none !important; color: var(--lab-cyan) !important; font-size: 11.5px; text-decoration: underline; cursor: pointer; }

/* ---------- prompt bar ---------- */
.prompt-card { border-color: rgba(230,189,103,0.5); background: linear-gradient(145deg, rgba(40,30,8,0.55), rgba(2,10,22,0.93)); }
.prompt-card .kicker { margin-bottom: 10px; cursor: pointer; }
.prompt-row { display: flex; gap: 10px; margin-bottom: 12px; }
.ai-lab .prompt-input { flex: 1 1 auto; min-width: 0; padding: 11px 13px; border: 1px solid rgba(230,189,103,0.5); border-radius: 9px; color: #fff; background: rgba(2,8,18,0.92); font: 600 1.05rem/1.3 Georgia, serif; }
.prompt-tokens { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.tok.unk { border: 1px solid var(--lab-rose) !important; background: rgba(255,127,156,0.12); color: #ffd9e1; box-shadow: 0 0 0 1px var(--lab-rose); }
.tok.marker { color: var(--lab-dim); font-style: italic; }
.vocab-box { margin-top: 10px; color: var(--lab-muted); font-size: 13px; }
.vocab-box summary { cursor: pointer; font-weight: 700; }
.vocab-box .concept-chips { margin-top: 10px; }
.vocab-box .concept-chip { padding: 4px 9px; font-size: 12px; }
.rail-prompt { display: grid; gap: 4px; margin-top: 12px; color: var(--lab-dim); font-size: 10.5px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.ai-lab .rail-prompt input { width: 100%; padding: 7px 9px; border: 1px solid rgba(230,189,103,0.45); border-radius: 7px; color: #fff; background: rgba(2,8,18,0.9); font: 600 13px/1.3 Georgia, serif; letter-spacing: 0; text-transform: none; }
.predict-score { margin: 2px 0 0; color: var(--lab-muted); font-size: 11.5px; line-height: 1.4; }

/* ---------- chapter 1: steps are real buttons ---------- */
.journey-steps li { padding: 0; }
.ai-lab .journey-steps li > button { display: block; width: 100%; height: 100%; padding: 9px 8px; text-align: left; border: 0 !important; background: none !important; color: inherit !important; cursor: pointer; }
.journey-steps li::before { padding: 9px 8px 0; }
.ai-lab .journey-steps li > button { padding-top: 3px; }

/* ---------- chapter 3 ---------- */
.stage-toy { height: 400px; }
.inline-pick { display: inline-flex; align-items: center; gap: 8px; color: var(--lab-muted); font-size: 13px; font-weight: 700; }
.vstrip.wide { height: 22px; }
.pos-col .vstrip i { min-width: 0; }

/* ---------- chapter 4 ---------- */
.ai-lab .att-tok.marker span { font-style: italic; color: var(--lab-muted); font-weight: 500; }
.ai-lab .att-tok.unknown { border-color: var(--lab-rose) !important; }
.att-guess { display: inline-block; margin-top: 6px; color: #cfe2ec; }
.att-guess b { color: var(--lab-gold); }
.att-controls .lab-button b { color: var(--lab-gold); font-weight: 800; }
.att-grid { max-width: 440px; }

/* ---------- chapter 5 ---------- */
.scale-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.scale-card.mine { border-color: rgba(230,189,103,0.55); background: rgba(230,189,103,0.07); }

/* ---------- chapter 6 ---------- */
.samp-text .gen { color: var(--lab-gold); }
.samp-side > a.lab-button { text-align: center; }

/* ---------- chapter 7: live training ---------- */
.start-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.start-grid .lab-button { min-height: 32px; padding: 5px 6px; font-size: 12px; }
.tr-controls { margin-top: 0; margin-bottom: 14px; }
.tr-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tr-loss { height: 210px; }
.tr-map { height: 380px; margin-top: 16px; }
.tr-samples { min-height: 210px; }
.tr-line { margin: 10px 0 0 !important; padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,0.3); font: 13.5px/1.45 var(--mono); color: var(--lab-gold) !important; word-break: break-word; }
.tr-line b { color: #fff; font-weight: 700; }

/* ---------- chapter 8: a chat is one string ---------- */
.chat-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.chat-cap { margin-bottom: 6px; color: var(--lab-dim); font-size: 10.5px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.chat-cap strong { color: var(--lab-gold); }
.chat-bubbles, .chat-raw { height: 340px; overflow-y: auto; margin: 0; padding: 12px; border: 1px solid rgba(255,255,255,0.09); border-radius: 12px; background: rgba(0,0,0,0.3); }
.chat-bubbles { display: flex; flex-direction: column; gap: 9px; }
.cb { max-width: 88%; padding: 9px 12px; border-radius: 14px; animation: rise .35s ease both; }
.cb p { margin: 0; color: #f1f8fb; font-size: 14px; line-height: 1.45; min-height: 1.45em; }
.cb-who { display: block; margin-bottom: 3px; font-size: 9.5px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.cb-system { align-self: center; max-width: 100%; border: 1px dashed rgba(157,134,255,0.6); background: rgba(157,134,255,0.08); }
.cb-system .cb-who { color: var(--lab-violet); } .cb-system p { color: #dcd4ff; font-size: 13px; }
.cb-user { align-self: flex-end; background: rgba(57,207,255,0.18); border: 1px solid rgba(57,207,255,0.45); border-bottom-right-radius: 4px; }
.cb-user .cb-who { color: var(--lab-cyan); }
.cb-assistant { align-self: flex-start; background: rgba(132,227,122,0.13); border: 1px solid rgba(132,227,122,0.4); border-bottom-left-radius: 4px; }
.cb-assistant .cb-who { color: var(--lab-green); }
.cb.ghost { opacity: .55; border-style: dashed; }
.cb.ghost .cb-who { color: var(--lab-rose); }
.chat-raw { font: 12.5px/1.75 var(--mono); white-space: pre-wrap; word-break: break-word; color: #dbeaf2; }
.chat-raw .mk { padding: 1px 5px; border-radius: 5px; font-weight: 800; font-size: 11.5px; }
.chat-raw .r-system { --rc: 157,134,255; } .chat-raw .r-user { --rc: 57,207,255; } .chat-raw .r-assistant { --rc: 132,227,122; }
.chat-raw .mk { color: rgb(var(--rc)); background: rgba(var(--rc), 0.16); }
.chat-raw .tx { background: rgba(var(--rc), 0.07); box-shadow: inset 0 -1px 0 rgba(var(--rc), 0.4); padding: 1px 2px; }
.chat-raw .mk.hot { outline: 2px solid var(--lab-gold); color: var(--lab-gold); animation: ring-pulse 1.1s ease-in-out 3; }
.chat-raw .ghost { opacity: .6; }
.chat-raw .mk.ghost, .chat-raw .tx.ghost { --rc: 255,127,156; }
.chat-raw.resend { animation: resend .9s ease; }
@keyframes resend { 0% { box-shadow: inset 0 0 0 2px var(--lab-gold); background: rgba(230,189,103,0.16); } 100% { box-shadow: inset 0 0 0 0 transparent; } }

/* ---------- predict first ---------- */
.predict { margin-bottom: 18px; padding: 14px 16px; border: 1px solid rgba(157,134,255,0.5); border-radius: 12px; background: linear-gradient(135deg, rgba(157,134,255,0.13), rgba(57,207,255,0.05)); }
.predict-tag { display: inline-block; padding: 3px 8px; border-radius: 99px; background: var(--lab-violet); color: #10102b; font-size: 10.5px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.predict-q, .quiz-def { margin: 9px 0 10px; color: #fff; font: 600 15.5px/1.45 Georgia, serif; }
.predict-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.predict-fb { margin: 0; color: #e3ddff; font-size: 14px; line-height: 1.55; }
.predict.done .predict-fb, .concept-detail .predict-fb:not(:empty) { margin-top: 10px; }
.predict-fb .lab-button { margin: 8px 8px 0 0; }
.ai-lab .lab-button.right { border-color: var(--lab-green) !important; background: rgba(132,227,122,0.2) !important; opacity: 1; color: #fff !important; }
.ai-lab .lab-button.wrong { border-color: var(--lab-rose) !important; background: rgba(255,127,156,0.16) !important; opacity: 1; text-decoration: line-through; }

/* ---------- chapter 12: where the text travels ---------- */
.sys-diagram { display: block; width: 100%; height: auto; max-height: 230px; margin-bottom: 14px; border: 1px solid rgba(86,163,232,0.26); border-radius: 12px; background: var(--lab-ink); }
.sd-t { font: 800 11px var(--mono); text-anchor: middle; text-transform: uppercase; letter-spacing: .08em; }
.sd-m { font: 700 10.5px var(--mono); text-anchor: middle; }

/* ---------- chapter 13: live failures ---------- */
.fv { position: relative; }
.fv-live { justify-self: start; padding: 2px 8px; border-radius: 99px; background: var(--lab-green); color: #06200a; font-size: 9.5px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-left: 2px; border-radius: 50%; background: var(--lab-green); box-shadow: 0 0 8px var(--lab-green); }
.fv-bar i { width: var(--p); }
.fv-bar.dim i { opacity: .55; }
.fv-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fv-two .fv-bar { grid-template-columns: 62px minmax(0, 1fr) 34px; }
.fv-two .fv-q { font-size: 13px; }
.fv-two s { color: var(--lab-rose); }
.fv-cap { margin: 4px 0 0; color: var(--lab-gold); font: 13px/1.45 var(--mono); }

/* ---------- chapter 14 ---------- */
.glossary-tools { display: flex; gap: 10px; margin-bottom: 12px; }
.glossary-tools .prompt-input { font: 14px/1.3 Inter, system-ui, sans-serif; border-color: rgba(110,159,205,0.4); }

/* ---------- phones: one chapter open at a time ---------- */
.ai-lab .ch-toggle { display: none; }
.lab-acc .lab-card-header { cursor: pointer; }
.lab-acc .ai-lab .ch-toggle { display: inline-flex; margin-top: 10px; min-height: 30px; padding: 4px 12px; font-size: 12px; }
.lab-acc .chapter.collapsed .lab-card-body { display: none; }
.lab-acc .chapter.collapsed .lab-card-header { padding-bottom: 14px; }
.lab-acc .chapter.collapsed .lab-card-header p, .lab-acc .chapter.collapsed .status-pill { display: none; }
.lab-acc .chapter.collapsed h2 { font-size: 1.25rem; }
.lab-acc .lab-card.chapter { margin-top: 12px; }

@media (max-width: 860px) {
  .tr-grid, .chat-layout, .scale-grid.three { grid-template-columns: 1fr; }
  .chat-bubbles, .chat-raw { height: 260px; }
}
@media (max-width: 680px) {
  .prompt-row, .glossary-tools { flex-direction: column; }
  .rail-prompt { display: none; }
  .stage-toy { height: 340px; }
  .tr-map { height: 320px; }
  .fv-two { grid-template-columns: 1fr; }
  .predict-opts .lab-button { flex: 1 1 100%; justify-content: flex-start; text-align: left; }
}

/* ---------- v3: the hero is a full-width feed-forward network, with the words under it ---------- */
.lab-hero.net-hero {
  display: block; padding: 0;
  background:
    radial-gradient(120% 90% at 78% 0%, rgba(34,104,180,0.2), transparent 60%),
    linear-gradient(180deg, #020914 0%, #04101e 58%, #071a2e 100%);
}
.net-hero .hero-canvas { height: clamp(360px, 40vw, 490px); touch-action: pan-y; cursor: grab; outline: none; -webkit-user-select: none; user-select: none; }
.net-hero .hero-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--lab-line-hot); border-radius: 17px 17px 0 0; }
.net-hero .hero-copy { padding: clamp(18px, 2.6vw, 30px) clamp(20px, 3.6vw, 44px) clamp(22px, 3.4vw, 40px); border-top: 1px solid rgba(74,151,242,0.16); }
.net-hero .hero-copy p { max-width: 760px; }
@media (max-width: 680px) {
  .net-hero .hero-canvas { height: 340px; }
}

/* ---------- v4: the hero network is trained, and you can draw on it ---------- */
.net-stage { position: relative; }
.net-hero .net-in, .net-hero .net-out { position: absolute; bottom: 12px; z-index: 1; padding: 8px 10px 10px; border: 1px solid rgba(74,151,242,0.24); border-radius: 10px; background: rgba(3,11,22,0.8); }
.net-hero .net-in { left: 14px; }
.net-hero .net-out { right: 14px; }
.net-cap { display: block; margin-bottom: 7px; color: var(--lab-muted); font: 700 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.net-pad { display: grid; grid-template-columns: repeat(var(--n, 8), var(--cell, 14px)); gap: 2px; touch-action: none; }
.ai-lab .net-cell {
  width: var(--cell, 14px); height: var(--cell, 14px); min-width: 0 !important; min-height: 0 !important; padding: 0 !important; margin: 0 !important;
  border: 1px solid rgba(132,227,122,0.3) !important; border-radius: 3px !important; box-shadow: none !important;
  background: rgba(132,227,122,var(--v, 0.05)) !important; cursor: crosshair; transform: none !important;
}
.ai-lab .net-cell:focus-visible { outline: 2px solid var(--lab-gold); outline-offset: 1px; }
.net-outs { display: grid; grid-template-columns: repeat(3, 58px); gap: 3px; }
.net-o { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 3px 6px; border: 1px solid transparent; border-radius: 5px; background: rgba(157,134,255,calc(0.1 + 0.6 * var(--v, 0))); color: var(--lab-text); font: 600 11px var(--mono); }
.net-o span { font-size: 13px; line-height: 1; }
.net-o b { font-weight: 700; }
.net-o.hot { background: rgba(230,189,103,calc(0.25 + 0.7 * var(--v, 0))); border-color: var(--lab-gold); color: #10202b; }
.net-bar { display: grid; gap: 10px; padding: 12px clamp(14px, 3.6vw, 44px) 14px; border-top: 1px solid rgba(74,151,242,0.16); }
.net-note, .net-status { margin: 0; color: #d6e6f0; font-size: 14px; line-height: 1.5; }
.net-note { min-height: 21px; }
.net-note strong, .net-status strong { color: #fff; }
.net-status { color: var(--lab-muted); font-size: 13px; }
.net-shapes, .net-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-lab .net-bar [hidden] { display: none !important; }
.ai-lab .net-bar .lab-button { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.ai-lab .net-shape span { font-size: 14px; margin-right: 2px; }
.net-neuron { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; align-items: start; padding: 12px 14px; border: 1px solid rgba(230,189,103,0.28); border-radius: 10px; background: rgba(230,189,103,0.06); }
.net-neuron[hidden] { display: none; }
.net-neuron canvas { width: 96px; height: 96px; border: 1px solid rgba(86,163,232,0.3); border-radius: 6px; background: var(--lab-ink); }
.net-neuron canvas[hidden] { display: none; }
.net-neuron canvas[hidden] + p { grid-column: 1 / -1; }
.net-neuron p { margin: 0; color: #f5e3bf; font-size: 13.5px; line-height: 1.55; }
.net-neuron strong { color: #fff; }
.net-math { font-family: var(--mono); font-size: 12.5px; color: #cfe6f5; }
@media (max-width: 680px) {
  /* on a phone the pad and the answer sit under the network, so the network gets the whole canvas */
  .net-stage { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 0 12px 12px; }
  .net-stage .hero-canvas { grid-column: 1 / -1; margin: 0 -12px; width: calc(100% + 24px); }
  .net-hero .net-in, .net-hero .net-out { position: static; }
  .net-hero .net-out { justify-self: end; }
  .net-hero .net-in, .net-hero .net-out { padding: 8px; }
  .net-pad { --cell: 13px; }
  .net-outs { grid-template-columns: repeat(3, 48px); }
  .net-o { padding: 3px 4px; gap: 2px; font-size: 10px; }
  .net-o span { font-size: 12px; }
  /* title and intro come straight after the network; the controls follow them */
  .lab-hero.net-hero { display: flex; flex-direction: column; }
  .net-hero .hero-copy { order: 2; border-top: 0; padding-top: 6px; }
  .net-hero .net-bar { order: 3; }
  .net-neuron { grid-template-columns: 72px minmax(0, 1fr); gap: 10px; }
  .net-neuron canvas { width: 72px; height: 72px; }
}

/* ---------- v5: the training page's hero, and the 3D feed-forward step in the Layers chapter ---------- */
.net-px { display: block; width: var(--cell, 14px); height: var(--cell, 14px); border: 1px solid rgba(132,227,122,0.3); border-radius: 3px; background: rgba(132,227,122,var(--v, 0.05)); }
.net-acc { display: block; width: 170px; height: 62px; }
.net-acc-text { display: block; margin-top: 4px; color: var(--lab-gold); font: 700 11px var(--mono); }
.stage-ff { height: clamp(300px, 36vw, 430px); margin-top: 14px; touch-action: pan-y; cursor: grab; outline: none; -webkit-user-select: none; user-select: none; }
.stage-ff:focus-visible { box-shadow: inset 0 0 0 2px var(--lab-line-hot); }
@media (max-width: 680px) {
  .net-acc { width: 150px; height: 52px; }
}

/* ---------- v6: hero extras (tour, why, break it, gallery, teach, share) and the Training chapter's side-by-side ---------- */
.net-more { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.07); }
.net-more .net-cap { margin: 0 4px 0 0; }
.net-tour { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 9px 12px; border: 1px solid rgba(230,189,103,0.5); border-radius: 10px; background: rgba(230,189,103,0.1); color: #fbeccb; font-size: 14px; line-height: 1.45; }
.net-tour b { flex: none; padding: 2px 8px; border-radius: 99px; background: var(--lab-gold); color: #10202b; font: 800 10.5px var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.net-tour span { flex: 1 1 260px; min-width: 0; }
.net-tour em, .net-panel em { color: #fff; font-style: normal; font-weight: 700; }
.ai-lab .net-cue { outline: 2px solid var(--lab-gold) !important; outline-offset: 3px; border-radius: 6px; animation: net-cue 1.5s ease-in-out infinite; }
@keyframes net-cue { 50% { outline-color: rgba(230,189,103,0.25); } }
.net-why { margin: 0; padding: 10px 13px; border: 1px solid rgba(230,189,103,0.28); border-radius: 10px; background: rgba(230,189,103,0.06); color: #f5e3bf; font-size: 13.5px; line-height: 1.55; }
.net-why strong { color: #fff; }
.ai-lab .net-cell[data-why="for"] { border-color: var(--lab-gold) !important; box-shadow: 0 0 0 1.5px rgba(230,189,103,var(--k, 1)) !important; }
.ai-lab .net-cell[data-why="against"] { border-color: var(--lab-rose) !important; box-shadow: 0 0 0 1.5px rgba(255,127,156,var(--k, 1)) !important; }
.ai-lab .net-cell.flipped { border-color: var(--lab-rose) !important; border-style: dashed !important; }
.net-panel { display: grid; gap: 12px; padding: 13px 14px; border: 1px solid rgba(86,163,232,0.28); border-radius: 10px; background: rgba(57,207,255,0.045); }
.net-panel p { margin: 0; color: #d6e6f0; font-size: 13.5px; line-height: 1.55; max-width: 820px; }
.net-panel strong { color: #fff; }
.net-dials { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 22px; max-width: 640px; }
.net-dials input[type="range"] { width: 100%; }
.ai-lab .net-panel > .lab-button { justify-self: start; }
.net-gallery { grid-template-columns: minmax(0, 432px) minmax(0, 1fr); align-items: start; gap: 16px; }
.net-gallery canvas { display: block; width: 100%; aspect-ratio: 1; border-radius: 6px; background: var(--lab-ink); cursor: pointer; }
.net-gallery-side { display: grid; gap: 10px; align-content: start; justify-items: start; }
.net-teach-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.net-thumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.net-thumbs canvas { width: 40px; height: 40px; border: 1px solid rgba(132,227,122,0.35); border-radius: 4px; background: var(--lab-ink); }
.net-name { display: inline-flex; align-items: center; gap: 8px; color: #dbeaf2; font-size: 13px; font-weight: 700; }
.ai-lab .net-name input, .ai-lab .net-share input {
  min-height: 32px; padding: 4px 9px; border: 1px solid rgba(86,163,232,0.4); border-radius: 7px; background: var(--lab-ink); color: #fff; font: 600 13px var(--mono);
}
.ai-lab .net-name input { width: 15ch; }
.net-share { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0; color: var(--lab-muted); font-size: 13px; }
.ai-lab .net-share input { flex: 1 1 260px; min-width: 0; max-width: 520px; font-size: 12px; }

.loop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.loop-col { padding: 14px 16px; border: 1px solid rgba(110,159,205,0.24); border-radius: 10px; background: rgba(255,255,255,0.035); }
.loop-col h4 { margin: 0 0 10px; color: #fff; font-size: 15px; }
.loop-col[data-loop="shape"] h4 { color: var(--lab-cyan, #39cfff); }
.loop-col[data-loop="text"] h4 { color: var(--lab-gold); }
.loop-col dl { display: grid; grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); gap: 7px 14px; margin: 0; align-items: center; }
.loop-col dt { color: var(--lab-dim); font-size: 10.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.loop-col dd { margin: 0; min-height: 22px; color: #e8f2f8; font: 600 13.5px var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.loop-col dd:first-of-type { min-height: 74px; display: flex; align-items: center; }
.loop-col dd canvas { width: 72px; height: 72px; border: 1px solid rgba(132,227,122,0.3); border-radius: 5px; background: var(--lab-ink); }
.loop-col dd small { color: var(--lab-dim); font-size: 11.5px; }
.loop-col dd strong { color: #fff; }
.loop-col dd.ok { color: #a9ee9f; }
.loop-col dd.no { color: #ffb3c4; }
.loop-col dd.loop-text { display: block; min-height: 0; font-size: 14.5px; line-height: 1.6; }
.loop-blank { display: inline-block; min-width: 2.2ch; padding: 0 6px; border: 1.5px dashed var(--lab-gold); border-radius: 5px; color: var(--lab-gold); text-align: center; }
.stage-loop { height: 220px; margin-top: 12px; }
@media (max-width: 860px) {
  .net-gallery { grid-template-columns: 1fr; }
  .net-gallery canvas { max-width: 432px; }
}
@media (max-width: 680px) {
  .net-dials, .loop-grid { grid-template-columns: 1fr; }
  .loop-col { padding: 12px; }
  .loop-col dl { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 7px 10px; }
  .stage-loop { height: 190px; }
  .net-tour { font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) { .ai-lab .net-cue { animation: none; } }

/* ---------- v7: follow the signal, fool it, and the gallery's layer tabs ---------- */
.net-o { cursor: pointer; }
.net-o:hover { border-color: rgba(230,189,103,0.6); }
.net-o:focus-visible { outline: 2px solid var(--lab-gold); outline-offset: 1px; }
.net-o.traced { box-shadow: 0 0 0 2px var(--lab-gold); }
.net-trace { border-style: dashed; }
.ai-lab .net-cell[data-path] { position: relative; }
.ai-lab .net-cell[data-path]::after { content: ""; position: absolute; left: 50%; top: 50%; width: 34%; height: 34%; min-width: 4px; min-height: 4px; transform: translate(-50%, -50%); border-radius: 50%; background: var(--lab-gold); box-shadow: 0 0 0 1.5px #10202b; pointer-events: none; }
.ai-lab .net-cell.moved { border-color: #fff !important; border-style: dashed !important; }
.net-panel a { color: var(--lab-gold); }
.net-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
