/* Lab page. Builds on site.css tokens: --bg --surface --band --ink --muted --line --accent --will --focus --serif --sans */
:root { --lab-red: #b3261e; --lab-viz-bg: var(--bg); --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
@media (prefers-color-scheme: dark) { :root { --lab-red: #f2857b; --lab-viz-bg: #0f141a; } }

.lab-head { padding: 2.25rem 0 1.25rem; }

/* Layout: contents rail on the left, playbooks on the right */
.lab-layout { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 2.5rem; align-items: start; padding-bottom: 3.5rem; }
.lab-toc { position: sticky; top: 1.5rem; padding-top: 0.2rem; }
.lab-toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.lab-toc a { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.5rem 0.7rem; border-left: 2px solid var(--line); color: var(--muted); font-size: 0.9rem; line-height: 1.3; text-decoration: none; }
.lab-toc a:hover { color: var(--ink); border-left-color: var(--muted); }
.lab-toc a.is-active { color: var(--ink); border-left-color: var(--accent); font-weight: 600; }
.toc-n { font: 600 0.75rem var(--mono); color: var(--accent); flex: none; }

/* Status strip */
.lab-head .lab-board { margin-top: 1.1rem; }
.lab-board { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.4rem; color: var(--muted); font-size: 0.95rem; }
.lab-board li { display: inline-flex; align-items: center; gap: 0.45rem; }
.lab-board .num { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.lab-board .lab-updated { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }

.lab-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.lab-dot.is-run { background: var(--will); animation: lab-beat 2.2s ease-out infinite; }
.lab-dot.is-test { background: var(--focus); animation: lab-blink 1.6s ease-in-out infinite; }
.lab-dot.is-ret { background: var(--muted); }
@keyframes lab-beat { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--will) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }
@keyframes lab-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* Brand marks: letter placeholders until logo files are added */
.logo { display: inline-grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 6px; flex: none; font: 700 0.68rem/1 var(--sans); color: var(--accent-ink); background: var(--accent); }
img.logo { background: none; object-fit: contain; border-radius: 6px; }
/* single-color brand glyphs sit on a white tile so they read in both themes */
img.logo.is-glyph { background: #fff; padding: 2px; box-sizing: border-box; }

/* Playbook cards */
.lab-card { scroll-margin-top: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 1.3rem 1.4rem; display: flex; flex-direction: column; gap: 1rem; transition: border-color 0.25s, box-shadow 0.25s; }
.lab-card + .lab-card { margin-top: 1.25rem; }
.lab-card:hover { border-color: var(--accent); box-shadow: 0 18px 40px -26px rgba(20, 50, 74, 0.55); }
.lab-card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 0.75rem 1rem; }
.lab-card-text { flex: 999 1 26rem; min-width: 0; }
.lab-card-text .kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.lab-card-text h3 { font-size: clamp(1.25rem, 2.2vw, 1.5rem); margin: 0.15rem 0 0.4rem; }
.lab-card-text p:not(.kicker) { margin: 0; color: var(--muted); max-width: var(--measure); font-size: 0.95rem; }
.lab-chip { display: inline-flex; align-items: center; gap: 0.35rem; letter-spacing: 0.02em; text-transform: none; }
.lab-chip .lab-dot { width: 7px; height: 7px; }
.lab-replay { font: 600 0.9rem var(--sans); color: var(--accent); background: transparent; border: 2px solid var(--accent); border-radius: 6px; padding: 0 1rem; min-height: 44px; cursor: pointer; }
.lab-replay::before { content: "\21BB"; margin-right: 0.4rem; }
.lab-replay:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lab-card-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.75rem 1.5rem; }
.lab-tools { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.lab-tools a, .lab-tool { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.6rem 0.2rem 0.25rem; border: 1px solid var(--line); border-radius: 999px; font-size: 0.78rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.lab-tools a:hover { border-color: var(--accent); color: var(--accent); }
.lab-tools .logo { width: 1.1rem; height: 1.1rem; border-radius: 50%; font-size: 0.6rem; }
.lab-links { margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; font-weight: 700; font-size: 0.95rem; }
.lab-soon { color: var(--muted); font-weight: 600; font-size: 0.85rem; }

.lab-viz { position: relative; border: 1px solid var(--line); border-radius: 12px; background: var(--lab-viz-bg); overflow: hidden; }

/* Pattern: Triage (requests checked by a model; escalations become Telegram approval cards) */
.pat-triage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1.25rem; padding: 1rem; align-items: start; }
.tri-head { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin: 0 0 0.6rem; font: 0.75rem var(--mono); color: var(--muted); }
.tri-head b { color: var(--will); }
.tri-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.tri-row { position: relative; display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-size: 0.82rem; font-weight: 600; --c: var(--will); }
.tri-row[data-v="ask"] { --c: var(--focus); }
.tri-row[data-v="always"] { --c: var(--lab-red); }
.tri-row::after { content: ""; position: absolute; inset: -1px; border-radius: inherit; border: 1.5px solid var(--will); opacity: 0; pointer-events: none; }
.tri-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tri-tag { margin-left: auto; flex: none; font-size: 0.7rem; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); border-radius: 999px; padding: 0.1rem 0.5rem; opacity: 0; }
.tri-row:not([data-v="auto"]) .tri-tag::after { content: " \2192"; }
code.tri-txt { font: 0.74rem var(--mono); font-weight: 600; }

.tg { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.tg-bar { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-bottom: 1px solid var(--line); }
.tg-bar .logo { border-radius: 50%; width: 1.6rem; height: 1.6rem; }
.tg-name { font-weight: 700; font-size: 0.85rem; }
.tg-name small { font-weight: 500; color: var(--muted); margin-left: 0.35rem; font-size: 0.72rem; }
.tg-bar .tg-app { margin-left: auto; width: 1.25rem; height: 1.25rem; }
.tg-body { display: flex; flex-direction: column; gap: 0.55rem; padding: 0.6rem; background: color-mix(in srgb, var(--accent) 6%, var(--lab-viz-bg)); }
.tg-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; padding: 0.55rem 0.7rem; font-size: 0.75rem; opacity: 0; }
.tg-title { margin: 0 0 0.3rem; font-weight: 700; line-height: 1.3; }
.tg-cmd { display: block; font: 0.72rem var(--mono); background: color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 4px; padding: 0.2rem 0.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-why { margin: 0.3rem 0 0.45rem; color: var(--muted); font-size: 0.7rem; }
.tg-act { display: grid; }
.tg-act > * { grid-area: 1 / 1; }
.tg-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem; }
.tg-btns span { position: relative; text-align: center; font-size: 0.68rem; font-weight: 600; padding: 0.22rem 0.25rem; border-radius: 6px; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); white-space: nowrap; }
.tg-btns span::after { content: ""; position: absolute; inset: 0; border-radius: 6px; border: 2px solid var(--accent); opacity: 0; }
.tg-done { align-self: center; margin: 0; text-align: center; font-weight: 700; font-size: 0.78rem; color: var(--will); opacity: 0; }
.tg-done.is-deny { color: var(--lab-red); }
/* Will's own reply: outgoing bubble on the right */
.tg-reply { justify-self: end; color: var(--ink); background: color-mix(in srgb, var(--will) 22%, var(--surface)); border-radius: 12px 12px 4px 12px; padding: 0.3rem 0.75rem; }

.pat-triage.is-run .tri-row::after { animation: lab-scan 0.8s ease-out var(--d, 0s) both; }
.pat-triage.is-run .tri-tag { animation: lab-pop 0.35s ease-out calc(var(--d, 0s) + 0.5s) both; }
.pat-triage.is-run .tg-card { animation: lab-appear 0.45s ease-out var(--cd, 0s) both; }
.pat-triage.is-run .tg-btns .is-pick { animation: lab-press 0.5s ease-out calc(var(--cd, 0s) + 1.3s) both; }
.pat-triage.is-run .tg-btns .is-pick::after { animation: lab-show 0.3s ease-out calc(var(--cd, 0s) + 1.3s) both; }
.pat-triage.is-run .tg-btns { animation: lab-hide 0.3s ease-in calc(var(--cd, 0s) + 2s) both; }
.pat-triage.is-run .tg-done { animation: lab-appear 0.35s ease-out calc(var(--cd, 0s) + 2.2s) both; }
.pat-triage.is-static .tri-tag, .pat-triage.is-static .tg-card, .pat-triage.is-static .tg-done { opacity: 1; animation: none; }
.pat-triage.is-static .tg-btns { opacity: 0; animation: none; }
@keyframes lab-scan { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; } }
@keyframes lab-pop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes lab-press { 0%, 100% { transform: none; } 45% { transform: scale(0.9); } }
@keyframes lab-show { from { opacity: 0; } to { opacity: 1; } }
@keyframes lab-hide { from { opacity: 1; } to { opacity: 0; } }

/* Pattern: Converge (flow chart: sources -> agent -> one digest) */
.pat-converge { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.75fr) minmax(0, 1.4fr); column-gap: 2.75rem; align-items: center; padding: 1rem 1.25rem; }
.conv-wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }
.conv-wires path { fill: none; stroke: color-mix(in srgb, var(--will) 55%, var(--line)); stroke-width: 1.5; opacity: 0; }
.conv-wires path.is-warn { stroke: var(--focus); stroke-dasharray: 4 4; }
.conv-wires path.is-out { stroke: var(--will); stroke-width: 2; }
.conv-srcs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; position: relative; z-index: 2; }
.conv-src { display: flex; align-items: center; gap: 0.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0.35rem 0.6rem 0.35rem 0.4rem; font-size: 0.8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-src.is-warn { border-color: color-mix(in srgb, var(--focus) 60%, var(--line)); }
.conv-node { position: relative; z-index: 2; text-align: center; background: var(--surface); border: 1.5px solid var(--will); border-radius: 12px; padding: 0.65rem 0.6rem; }
.conv-node b { display: block; font-size: 0.85rem; }
.conv-node span { display: block; margin-top: 0.15rem; font: 0.68rem var(--mono); color: var(--muted); }
.conv-hub { position: relative; z-index: 2; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.conv-line { margin: 0; font-size: 0.84rem; line-height: 1.35; opacity: 0; }
.conv-line:not(.conv-meta):not(.conv-warn):not(.conv-foot)::before { content: "\2022"; color: var(--will); margin-right: 0.45rem; }
.conv-meta { display: flex; justify-content: space-between; gap: 0.5rem; font: 0.72rem var(--mono); color: var(--muted); }
.conv-warn { font-size: 0.78rem; color: var(--focus); background: color-mix(in srgb, var(--focus) 14%, transparent); border-radius: 8px; padding: 0.35rem 0.55rem; }
.conv-foot { font: 0.68rem var(--mono); color: var(--muted); }
.pat-converge.is-run .conv-wires path { animation: lab-show 0.5s ease-out var(--d, 0s) both; }
.pat-converge.is-run .conv-line { animation: lab-appear 0.5s ease-out var(--d, 0s) both; }
.pat-converge.is-run .conv-node { animation: lab-glow 1.1s ease-out 1.25s both; }
.pat-converge.is-run .conv-hub { animation: lab-glow 1.2s ease-out 2.1s both; }
.pat-converge.is-static .conv-line, .pat-converge.is-static .conv-wires path { opacity: 1; animation: none; }
.conv-pulse { position: absolute; left: 0; top: 0; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--will); opacity: 0; z-index: 3; pointer-events: none; }
.conv-pulse.is-warn { background: var(--focus); }
.pat-converge.is-run .conv-pulse { animation: lab-travel 1.1s cubic-bezier(0.5, 0, 0.3, 1) var(--d, 0s) both; }
@keyframes lab-travel { 0% { transform: translate(var(--px0), var(--py0)); opacity: 0; } 12% { opacity: 1; } 85% { transform: translate(var(--px1), var(--py1)); opacity: 1; } 100% { transform: translate(var(--px1), var(--py1)); opacity: 0; } }
@keyframes lab-appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes lab-glow { 0% { box-shadow: 0 0 0 0 transparent; } 40% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--will) 22%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Shared moving token: JS sets start (--x0,--y0), stop (--x1,--y1) and optional end (--x2,--y2) */
.tok { position: absolute; left: 0; top: 0; z-index: 3; opacity: 0; will-change: transform; white-space: nowrap; }
.is-run .tok { animation: lab-path2 var(--dur, 1.4s) cubic-bezier(0.45, 0, 0.2, 1) var(--d, 0s) both; }
.is-run .tok.is-3 { animation-name: lab-path3; }
.is-static .tok { opacity: 1; transform: translate(var(--x2, var(--x1)), var(--y2, var(--y1))); }
@keyframes lab-path2 { 0% { transform: translate(var(--x0), var(--y0)); opacity: 0; } 12% { opacity: 1; } 100% { transform: translate(var(--x1), var(--y1)); opacity: 1; } }
@keyframes lab-path3 { 0% { transform: translate(var(--x0), var(--y0)); opacity: 0; } 8% { opacity: 1; } 38%, 58% { transform: translate(var(--x1), var(--y1)); opacity: 1; } 100% { transform: translate(var(--x2), var(--y2)); opacity: 1; } }
.lab-pop { opacity: 0; }
.is-run .lab-pop { animation: lab-pop 0.35s ease-out var(--d, 0s) both; }
.is-static .lab-pop { opacity: 1; }
.lab-fade { opacity: 0; }
.is-run .lab-fade { animation: lab-show 0.5s ease-out var(--d, 0s) both; }
.is-static .lab-fade { opacity: 1; }
.lab-chipbox { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; font-weight: 600; padding: 0.35rem 0.6rem; border-radius: 8px; background: var(--surface); border: 1.5px solid var(--line); color: var(--ink); }
.lab-zone { border: 1.5px dashed var(--line); border-radius: 10px; }
.lab-zone-lbl { position: absolute; font: 600 0.7rem var(--mono); color: var(--muted); letter-spacing: 0.04em; }

/* Pattern: Gate (mail passes a screen; one carrying hidden instructions is stopped) */
.pat-gate { height: 17rem; }
.gate-scan { position: absolute; left: 47%; top: 12%; bottom: 12%; width: 6%; border-radius: 10px; background: color-mix(in srgb, var(--will) 14%, transparent); border: 1.5px solid var(--will); }
.gate-scan::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--will); opacity: 0.8; }
.pat-gate.is-run .gate-scan::after { animation: lab-scanline 1.6s ease-in-out infinite; }
@keyframes lab-scanline { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(12rem); } }
.gate-scan-lbl { position: absolute; left: 50%; top: 3%; transform: translateX(-50%); font: 600 0.72rem var(--mono); color: var(--will); white-space: nowrap; }
.gate-in, .gate-out { position: absolute; top: 14%; bottom: 8%; }
.gate-in { left: 2%; width: 40%; }
.gate-out { right: 2%; width: 40%; }
.gate-in > .lab-zone-lbl, .gate-out > .lab-zone-lbl { top: -1.3rem; left: 0.2rem; }
.gate-out { border: 1.5px dashed var(--line); border-radius: 10px; }
.gate-env { font-size: 0.76rem; max-width: 30%; white-space: normal; flex-wrap: wrap; line-height: 1.25; }
.gate-env::before { content: "\2709"; color: var(--muted); }
.gate-env[data-v="bad"] { border-color: var(--lab-red); }
.gate-env small { display: block; font: 0.62rem var(--mono); color: var(--lab-red); }
.gate-env .gate-hidden { flex-basis: 100%; font: 0.62rem/1.3 var(--mono); color: var(--lab-red); white-space: normal; opacity: 0; }
.pat-gate.is-run .gate-hidden { animation: lab-show 0.4s ease-out var(--hd, 0s) both; }
.pat-gate.is-static .gate-hidden { opacity: 1; }
.gate-stamp { position: absolute; z-index: 4; font: 800 0.8rem var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--lab-red); border: 2px solid var(--lab-red); border-radius: 6px; padding: 0.1rem 0.4rem; transform: rotate(-8deg); background: var(--lab-viz-bg); }
.gate-tag { position: absolute; z-index: 4; font-size: 0.68rem; font-weight: 700; color: var(--will); }

/* Interactive screener (playbook page) */
.screener { margin-top: 1rem; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 1rem; }
.screener-pick { display: flex; flex-direction: column; gap: 0.5rem; }
.screener-pick button { text-align: left; font: 600 0.88rem var(--sans); color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 0.6rem 0.8rem; cursor: pointer; min-height: 44px; }
.screener-pick button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.screener-pick small { display: block; font-weight: 500; color: var(--muted); font-size: 0.75rem; }
.screener-out { border: 1px solid var(--line); border-radius: 12px; background: var(--lab-viz-bg); padding: 1rem 1.1rem; min-height: 11rem; }
.screener-out .verdict { display: inline-block; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.8rem; padding: 0.15rem 0.55rem; border-radius: 6px; }
.screener-out .verdict.ok { color: var(--will); background: color-mix(in srgb, var(--will) 15%, transparent); }
.screener-out .verdict.warn { color: var(--focus); background: color-mix(in srgb, var(--focus) 15%, transparent); }
.screener-out .verdict.bad { color: var(--lab-red); background: color-mix(in srgb, var(--lab-red) 15%, transparent); }
.screener-out dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.8rem; margin: 0.8rem 0 0; font-size: 0.86rem; }
.screener-out dt { color: var(--muted); font-weight: 600; }
.screener-out dd { margin: 0; }
.screener-out .is-in { animation: lab-appear 0.35s ease-out both; }

/* Pattern: Lanes (agents collide on one inbox, then each takes its own lane) */
.pat-lanes { height: 16rem; }
.lanes-rows { position: absolute; inset: 8% 3% 8% 3%; display: grid; grid-template-rows: repeat(3, 1fr); gap: 0.5rem; }
.lane { border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, transparent); border: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; padding-right: 0.9rem; font-size: 0.8rem; font-weight: 700; color: var(--muted); }
.lane b { color: var(--ink); }
.lanes-inbox { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; }
.pat-lanes.is-run .lanes-inbox { animation: lab-hide 0.4s ease-in 2.3s both; }
.pat-lanes.is-static .lanes-inbox { opacity: 0; }
.lanes-bang { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); z-index: 4; font-size: 0.75rem; font-weight: 800; color: var(--lab-red); background: color-mix(in srgb, var(--lab-red) 14%, var(--lab-viz-bg)); border-radius: 6px; padding: 0.15rem 0.5rem; opacity: 0; white-space: nowrap; }
.pat-lanes.is-run .lanes-bang { animation: lab-flash 1.1s ease-out 1.25s both; }
@keyframes lab-flash { 0% { opacity: 0; } 20%, 70% { opacity: 1; } 100% { opacity: 0; } }
.pat-lanes.is-run .lane { animation: lab-show 0.5s ease-out 2.4s both; }
.pat-lanes .lane { opacity: 0; }
.pat-lanes.is-static .lane { opacity: 1; }
.lanes-agent { border-color: var(--accent); }
.pat-lanes.is-run .lanes-agent { animation-name: lab-path3; animation-duration: 3.6s; }

/* Pattern: Fan-out (lead sends bounded tasks to workers and checks each return) */
.pat-fanout { height: 16.5rem; }
.fan-lead { position: absolute; left: 3%; top: 50%; transform: translateY(-50%); width: 24%; z-index: 2; text-align: center; padding: 0.7rem 0.5rem; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--accent); }
.fan-lead b, .fan-w b { display: block; font-size: 0.82rem; }
.fan-lead span, .fan-w span { display: block; font-size: 0.7rem; color: var(--muted); }
.fan-ws { position: absolute; right: 3%; top: 6%; bottom: 6%; width: 38%; display: flex; flex-direction: column; justify-content: space-between; }
.fan-w { position: relative; z-index: 2; padding: 0.5rem 0.7rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.fan-w .fan-st { position: absolute; right: 0.5rem; top: 50%; margin-top: -0.6rem; font-size: 0.68rem; font-weight: 700; padding: 0.1rem 0.45rem; border-radius: 999px; color: var(--will); background: color-mix(in srgb, var(--will) 15%, transparent); }
.fan-w .fan-st.is-back { color: var(--focus); background: color-mix(in srgb, var(--focus) 15%, transparent); }
.pat-fanout.is-run .fan-tok { animation-name: lab-path2-out; }
.pat-fanout.is-static .fan-tok { opacity: 0; }
@keyframes lab-path2-out { 0% { transform: translate(var(--x0), var(--y0)); opacity: 0; } 12% { opacity: 1; } 88% { transform: translate(var(--x1), var(--y1)); opacity: 1; } 100% { transform: translate(var(--x1), var(--y1)); opacity: 0; } }
.fan-tok { width: 1.4rem; height: 1.4rem; margin: -0.7rem 0 0 -0.7rem; border-radius: 50%; display: grid; place-items: center; font-size: 0.7rem; font-weight: 800; color: var(--accent-ink); background: var(--accent); }
.fan-tok.is-ok { background: var(--will); }
.fan-tok.is-back { background: var(--focus); }

/* Pattern: Policy fork (a failure meets the repair policy: allowed fixes vs ask Will) */
.pat-fork { height: 19rem; }
.fork-src { position: absolute; left: 50%; top: 5%; transform: translateX(-50%); font: 600 0.72rem var(--mono); color: var(--muted); }
.fork-gate { position: absolute; left: 30%; right: 30%; top: 24%; height: 2.6rem; border-radius: 999px; border: 1.5px dashed var(--accent); display: grid; place-items: center; font: 600 0.78rem var(--mono); color: var(--accent); background: var(--lab-viz-bg); }
.fork-out { position: absolute; bottom: 5%; width: 42%; height: 44%; border-radius: 10px; padding: 0.5rem 0.7rem; --c: var(--will); background: color-mix(in srgb, var(--c) 12%, transparent); }
.fork-out b { color: var(--c); font-size: 0.85rem; display: block; }
.fork-out span { color: var(--muted); font-size: 0.72rem; }
.fork-out.is-left { left: 3%; }
.fork-out.is-right { right: 3%; --c: var(--focus); }
.fork-tok { font-size: 0.74rem; max-width: 40%; white-space: normal; line-height: 1.25; }
.fork-tok[data-to="right"] { border-color: var(--focus); }
.fork-tok[data-to="left"] { border-color: var(--will); }

/* Pattern: Funnel (listings checked live, gated, then ranked or stretch) */
.pat-funnel { height: 21rem; }
.fun-layer { position: absolute; left: 3%; right: 3%; height: 0; border-top: 1.5px dashed var(--line); }
.fun-layer span { position: absolute; left: 0; top: -1.15rem; font: 600 0.68rem var(--mono); color: var(--muted); }
.fun-bins { position: absolute; left: 3%; right: 3%; bottom: 4%; height: 32%; display: grid; grid-template-columns: 1.6fr 1fr; gap: 3%; }
.fun-bin { border-radius: 10px; padding: 0.4rem 0.6rem; --c: var(--will); background: color-mix(in srgb, var(--c) 12%, transparent); }
.fun-bin b { display: block; font-size: 0.8rem; color: var(--c); }
.fun-bin[data-bin="stretch"] { --c: var(--accent); }
.fun-item { font-size: 0.68rem; padding: 0.25rem 0.5rem; }
.fun-item::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: var(--lab-red); opacity: 0; transform: rotate(-4deg); }
.pat-funnel.is-run .fun-item.is-cut::after { animation: lab-show 0.25s ease-out var(--cd, 0s) both; }
.pat-funnel.is-static .fun-item.is-cut::after { opacity: 1; }
.pat-funnel.is-run .fun-item.is-cut { animation-name: lab-path2-dim; }
.pat-funnel.is-static .fun-item.is-cut { opacity: 0.55; }
@keyframes lab-path2-dim { 0% { transform: translate(var(--x0), var(--y0)); opacity: 0; } 12% { opacity: 1; } 80% { transform: translate(var(--x1), var(--y1)); opacity: 1; } 100% { transform: translate(var(--x1), var(--y1)); opacity: 0.55; } }

/* Pattern: Meter (usage fills by model family; content never stored) */
.pat-meter { padding: 1.25rem 1.25rem 1rem; }
.meter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; font: 0.72rem var(--mono); color: var(--muted); }
.meter-bar { display: flex; height: 2.2rem; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.meter-seg { flex: var(--w) 0 0; transform-origin: left center; transform: scaleX(0); background: color-mix(in srgb, var(--c) 70%, var(--surface)); }
.pat-meter.is-run .meter-seg { animation: lab-grow 0.8s cubic-bezier(0.3, 0, 0.2, 1) var(--d, 0s) both; }
.pat-meter.is-static .meter-seg { transform: none; }
@keyframes lab-grow { from { transform: scaleX(0); } to { transform: none; } }
.meter-legend { list-style: none; margin: 0.8rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; font-size: 0.8rem; }
.meter-legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.meter-legend i { width: 0.7rem; height: 0.7rem; border-radius: 3px; background: color-mix(in srgb, var(--c) 70%, var(--surface)); }
.meter-locks { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.meter-lock { font-size: 0.76rem; font-weight: 600; padding: 0.3rem 0.6rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.meter-lock::before { content: "\1F512"; margin-right: 0.35rem; }
.meter-lock.is-kept::before { content: "\2713"; color: var(--will); }

@media (max-width: 40rem) {
  .pat-gate { height: 19rem; }
  .gate-env { font-size: 0.66rem; padding: 0.25rem 0.4rem; }
  .gate-scan-lbl { font-size: 0.64rem; }
  .screener { grid-template-columns: minmax(0, 1fr); }
  .lane { font-size: 0.7rem; padding-right: 0.5rem; }
  .fan-lead { width: 30%; }
  .fan-ws { width: 52%; }
  .fan-w .fan-st { position: static; display: inline-block; margin: 0.2rem 0 0; }
  .pat-fanout { height: 19rem; }
  .fork-gate { left: 18%; right: 18%; }
  .fork-out { width: 46%; }
  .fork-tok { font-size: 0.66rem; }
  .fun-item { font-size: 0.6rem; padding: 0.2rem 0.35rem; }
}

/* Playbook pages */
.lab-demo .lab-viz { margin-top: 0.25rem; }
.lab-layer { margin-top: 2rem; }
.lab-layer h3 { margin-bottom: 0.25rem; }
.lab-layer > p { color: var(--muted); max-width: var(--measure); margin-top: 0; }
.lab-code { position: relative; margin: 0.75rem 0 1.25rem; }
.lab-code pre { margin: 0; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--lab-viz-bg); font: 0.8rem/1.55 var(--mono); overflow-x: auto; white-space: pre; }
.lab-code.is-wrap pre { white-space: pre-wrap; }
.lab-copy { position: absolute; top: 0.5rem; right: 0.5rem; font: 600 0.75rem var(--sans); color: var(--accent); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 0.3rem 0.6rem; cursor: pointer; }
.lab-copy:hover { border-color: var(--accent); }
.lab-steps { padding-left: 1.25rem; max-width: var(--measure); }
.lab-steps > li { margin-bottom: 1rem; }
.lab-steps > li::marker { font-weight: 700; color: var(--accent); }
.lab-stats { border-collapse: collapse; width: 100%; max-width: 44rem; font-size: 0.92rem; margin: 0.5rem 0 1rem; }
.lab-stats th, .lab-stats td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); }
.lab-stats th { font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.lab-stats td:not(:first-child), .lab-stats th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.lab-note { color: var(--muted); font-size: 0.9rem; max-width: var(--measure); }

/* Coming next */
.lab-main > section { padding-top: 0; padding-bottom: 0; }
.lab-main > .lab-next { padding-top: 2.25rem; }
.lab-next h2 { margin-bottom: 0.25rem; }
.lab-next-sub { margin: 0 0 1rem; }
.lab-next-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.lab-next-grid .card { position: relative; border-style: dashed; padding: 0.9rem 1rem; }
.lab-next-grid .card > .kicker, .lab-next-grid .card > h3 { padding-right: 2.25rem; }
.lab-next-logo { position: absolute; top: 0.85rem; right: 0.85rem; width: 1.75rem; height: 1.75rem; border-radius: 8px; }
.lab-next-logo.is-glyph { padding: 4px; }
.lab-next-grid .kicker { color: var(--will); margin-bottom: 0.2rem; }
.lab-next-grid h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.lab-next-grid p:not(.kicker) { margin: 0; font-size: 0.85rem; color: var(--muted); }

.lab-more .card { border-style: solid; transition: border-color 0.2s; }
.lab-more .card:hover { border-color: var(--accent); }
.lab-more .kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.lab-more h3 a { color: var(--ink); text-decoration: none; }
.lab-more h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.lab-more h3 a:hover { color: var(--accent); }
.lab-more h3 a:focus-visible { outline: none; }
.lab-more .card:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Lessons log: each entry wipes from what I tried to what I learned */
.lab-main > .lab-lessons { padding-top: 2.75rem; }
.pat-wipe { border: 0; background: none; overflow: visible; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.wipe { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0.85rem 1rem; }
.wipe p { margin: 0; }
.wipe-before { font-size: 0.85rem; color: var(--muted); }
.wipe-before b { font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.45rem; margin-right: 0.35rem; }
.wipe-after { margin-top: 0.45rem !important; font-size: 0.92rem; font-weight: 600; color: var(--ink); padding-left: 0.8rem; border-left: 3px solid var(--will); }
.wipe::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--will) 18%, transparent); transform: scaleX(0); transform-origin: left; pointer-events: none; }
.pat-wipe.is-run .wipe::after { animation: lab-wipe 0.9s ease-in-out var(--d, 0s) both; }
.pat-wipe.is-run .wipe-after { animation: lab-show 0.4s ease-out calc(var(--d, 0s) + 0.45s) both; }
.pat-wipe .wipe-after { opacity: 0; }
.pat-wipe.is-static .wipe-after { opacity: 1; }
@keyframes lab-wipe { 0% { transform: scaleX(0); transform-origin: left; } 50% { transform: scaleX(1); transform-origin: left; } 50.1% { transform: scaleX(1); transform-origin: right; } 100% { transform: scaleX(0); transform-origin: right; } }
@media (max-width: 40rem) { .pat-wipe { grid-template-columns: minmax(0, 1fr); } }

/* Skills shelf: terminal cards (reuses .tool from site.css); hover or tap types the invocation */
.lab-skills { padding-top: 2.25rem; }
.shelf-install { margin: 0 0 1rem; }
.shelf { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; list-style: none; margin: 0; padding: 0; }
.shelf .tool { padding: 1rem 1.1rem; gap: 0.5rem; cursor: default; }
.shelf .tool h3 { font-size: 1rem; font-family: var(--mono); }
.shelf-term { margin: 0; min-height: 2.9rem; font: 0.78rem/1.45 var(--mono); color: #c9d1d9; background: #161b22; border: 1px solid #30363d; border-radius: 6px; padding: 0.4rem 0.6rem; }
.shelf-term .p { color: #3fb950; }
.shelf-term .r { display: block; color: #79c0ff; }
.shelf-term .cur { display: inline-block; width: 0.5em; height: 1em; vertical-align: text-bottom; background: #c9d1d9; animation: lab-blink 1s steps(1) infinite; }
@media (max-width: 40rem) { .shelf { grid-template-columns: minmax(0, 1fr); } }

@media (max-width: 56rem) {
  .lab-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .lab-toc { position: static; }
  .lab-toc .kicker { display: none; }
  .lab-toc ol { flex-direction: row; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.25rem; }
  .lab-toc a { border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem 0.75rem; white-space: nowrap; font-size: 0.82rem; }
  .lab-toc a.is-active { border-color: var(--accent); }
  .lab-next-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 40rem) {
  .lab-head { padding: 1.75rem 0 1rem; }
  .lab-card { padding: 1.1rem; }
  .pat-triage { grid-template-columns: minmax(0, 1fr); padding: 0.75rem; gap: 0.9rem; }
  .tri-row { font-size: 0.76rem; padding: 0.35rem 0.5rem; }
  /* commands wrap rather than truncate at phone width */
  code.tri-txt { white-space: normal; overflow-wrap: anywhere; font-size: 0.7rem; }
  .pat-converge { grid-template-columns: minmax(0, 1fr); row-gap: 1.75rem; padding: 1rem; }
  .conv-srcs { flex-direction: row; flex-wrap: wrap; gap: 0.4rem; }
  .conv-src { font-size: 0.74rem; padding: 0.25rem 0.5rem 0.25rem 0.3rem; }
  .conv-src .logo { width: 1.05rem; height: 1.05rem; font-size: 0.6rem; }
  .conv-node { justify-self: center; padding: 0.5rem 1rem; }
  .lab-next-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .lab-dot.is-run, .lab-dot.is-test { animation: none !important; }
  .lab-card { transition: none; }
}

/* Playbook card with several initiatives, each with its own status */
.lab-sub { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.lab-sub li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.85rem; font-weight: 600; color: var(--ink); }

/* Live now: one playbook at a time, thumbnails below. The box fits the slide being shown. */
.lab-sec-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.lab-sec-head h2 { margin: 0; }
.lab-nav-btns { display: flex; align-items: center; gap: 0.5rem; }
.lab-arrow { font: 700 1.1rem var(--sans); width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--accent); background: var(--surface); color: var(--accent); cursor: pointer; }
.lab-arrow:hover { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.lab-count { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.5rem; text-align: center; }
.lab-stage > .lab-slide { margin: 0; }
.lab-carousel.is-ready .lab-slide:not(.is-active) { display: none; }
.lab-carousel.is-ready .lab-slide.is-active { animation: lab-slide-in 0.35s ease-out; }
.lab-carousel:not(.is-ready) .lab-slide + .lab-slide { margin-top: 1.25rem; }
@keyframes lab-slide-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.lab-thumbs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; margin-top: 0.75rem; }
.lab-thumb { width: 100%; height: 100%; min-height: 44px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 0.5rem; align-items: center; text-align: left; padding: 0.5rem 0.6rem; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font: 600 0.78rem/1.25 var(--sans); cursor: pointer; transition: border-color 0.2s, color 0.2s; }
.lab-thumb .logo { grid-row: 1 / 3; width: 1.5rem; height: 1.5rem; border-radius: 6px; }
.lab-thumb .logo.is-glyph { padding: 3px; }
.lab-thumb .toc-n { color: var(--will); font-size: 0.72rem; letter-spacing: 0.06em; }
.lab-thumb:hover { color: var(--ink); border-color: var(--muted); }
.lab-thumb.is-active { color: var(--ink); border-color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.lab-thumb:focus-visible, .lab-arrow:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.lab-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 56rem) { .lab-thumbs { grid-template-columns: repeat(5, minmax(9.5rem, 1fr)); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 0.25rem; } .lab-thumb { scroll-snap-align: start; } }
@media (max-width: 40rem) { .lab-two { grid-template-columns: minmax(0, 1fr); } .lab-count { display: none; } }
@media (prefers-reduced-motion: reduce) { .lab-carousel.is-ready .lab-slide.is-active { animation: none; } }
