/* ============================================================
   The Agent-Run Company · base.css
   Loads after tokens.css. Layout, typography, the chapter chrome and every
   device the tutorial uses: callouts, prompt blocks, code, terminals, Q&A,
   steps, cards, stats, rules, crew cards, timelines, tabs, tables, mocks,
   the flow-animation frame, and the reveal / typing animations.
   ============================================================ */

/* ---- reset & rhythm ---- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 17px; line-height: 1.6; color: var(--ink); background: var(--bg); }
img, svg { max-width: 100%; }
a { color: var(--blue-mid); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--navy); }
b, strong { font-weight: 650; }
h1, h2, h3, h4 { font-family: var(--display); color: var(--navy); line-height: 1.15; letter-spacing: -.015em; margin: 0 0 .4em; }
h1 { font-size: clamp(1.9rem, 3.6vw, 2.75rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 2.4vw, 1.85rem); font-weight: 650; }
h3 { font-size: 1.15rem; font-weight: 650; color: var(--ink); }
h4 { font-size: .98rem; font-weight: 650; color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
ul, ol { padding-left: 1.3em; margin: 0 0 1em; }
li { margin: .25em 0; }
.wrap { width: min(1100px, 92vw); margin: 0 auto; }
.wrap-narrow { width: min(780px, 92vw); margin: 0 auto; }
.prose p, .prose li { max-width: 68ch; }
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 64ch; }
.tiny { font-size: .82rem; color: var(--muted); }
.small { font-size: .9rem; }
.accent { color: var(--cyan-deep); }
.hero h1 .accent { background: linear-gradient(120deg, var(--cyan-deep), var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent; }
code { font-family: var(--mono); font-size: .88em; background: var(--neutral-soft); padding: .08em .4em; border-radius: 4px; color: var(--ink); }
kbd { font-family: var(--mono); font-size: .8em; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: .05em .45em; background: #fff; }
hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
mark { background: linear-gradient(180deg, transparent 0 6%, hsl(190 70% 86%) 6% 94%, transparent 94%); color: inherit; padding: 0 .14em; border-radius: 2px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
mark.amber { background-image: linear-gradient(180deg, transparent 0 6%, hsl(35 90% 84%) 6% 94%, transparent 94%); }
mark.good { background-image: linear-gradient(180deg, transparent 0 6%, hsl(150 50% 84%) 6% 94%, transparent 94%); }
mark.bad { background-image: linear-gradient(180deg, transparent 0 6%, hsl(0 70% 88%) 6% 94%, transparent 94%); }
mark.ink { background: var(--navy); color: #fff; padding: .04em .32em; border-radius: 3px; font-weight: 600; }
.center { text-align: center; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mt { margin-top: 18px; } .mb { margin-bottom: 18px; }

/* ---- topbar ---- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--navy-deep); color: #fff; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; }
.topbar .brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; font-family: var(--display); font-weight: 650; letter-spacing: -.01em; }
.topbar .brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--navy); display: grid; place-items: center; }
.topbar .brand small { display: block; font-family: var(--font); font-weight: 500; font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: hsl(190 85% 62%); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: hsl(210 30% 86%); text-decoration: none; font-size: .9rem; padding: 7px 12px; border-radius: 8px; white-space: nowrap; }
.topbar nav a:hover, .topbar nav a.on { background: hsl(215 60% 30%); color: #fff; }
.topbar nav a.cta { background: var(--cyan); color: var(--navy-deep); font-weight: 600; }
.topbar nav a.cta:hover { background: hsl(190 85% 55%); }

/* ---- chapter navigation ---- */
.chapnav { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 58px; z-index: 29; }
.chapnav .wrap { display: flex; gap: 6px; align-items: center; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.chapnav .wrap::-webkit-scrollbar { display: none; }
.chapnav a { display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px 6px 7px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-size: .86rem; white-space: nowrap; border: 1px solid transparent; }
.chapnav a .n { font-family: var(--mono); font-size: .72rem; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--neutral-soft); color: var(--navy); font-weight: 600; }
.chapnav a:hover { background: var(--bg-2); }
.chapnav a.on { background: var(--navy); color: #fff; }
.chapnav a.on .n { background: var(--cyan); color: var(--navy-deep); }
.chapnav a.extra { margin-left: auto; border-color: var(--line-2); padding-left: 13px; }
.chapnav a.extra + a.extra { margin-left: 0; }
.chapnav a.extra::before { content: "▶"; font-size: .62rem; color: var(--cyan-deep); }

/* ---- hero ---- */
.hero { padding: clamp(26px, 4vw, 52px) 0 clamp(18px, 2.4vw, 30px); background: linear-gradient(180deg, #fff, var(--bg)); }
.hero .chapter { font-family: var(--mono); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan-deep); display: block; margin-bottom: 10px; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: .9rem; color: var(--muted); }
.hero .meta b { color: var(--ink-2); font-weight: 600; margin-right: 6px; }

/* ---- story strip ---- */
.story { background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.story .wrap { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; padding: 18px 0 20px; }
.story .tag { font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; color: var(--cyan-deep); display: block; margin-bottom: 5px; }
.story p { font-size: 1rem; color: var(--ink-2); }
.story .now { border-left: 3px solid var(--cyan); padding-left: 16px; }
.story .time { display: inline-flex; gap: 6px; align-items: center; font-family: var(--mono); font-size: .74rem; color: var(--muted); margin-top: 8px; }
.story .time::before { content: "◔"; color: var(--cyan); }

/* ---- sections ---- */
section.block { padding: clamp(26px, 3.6vw, 48px) 0; }
section.block.tint { background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
section.block.dark { background: var(--navy-deep); color: var(--on-dark); }
section.block.dark h2, section.block.dark h3 { color: #fff; }
section.block.dark p { color: var(--on-dark); }
section.block.dark a { color: hsl(190 85% 66%); }
section.block.dark code { background: hsl(215 50% 24%); color: #fff; }
.sec-head { margin-bottom: 18px; }
.sec-head p { color: var(--ink-2); max-width: 66ch; }
.sec-head .kicker { font-family: var(--mono); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan-deep); display: block; margin-bottom: 6px; }
section.block.dark .sec-head p { color: var(--on-dark-muted); }

/* ---- callouts ---- */
.callout { border-left: 5px solid var(--cyan); background: var(--accent-soft); border-radius: var(--radius-lg); padding: 15px 20px 15px 18px; margin: 18px 0; }
.callout .tag { font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em; font-size: .7rem; font-weight: 600; display: block; margin-bottom: 6px; color: var(--cyan-deep); }
.callout p { max-width: none; }
.callout p + p { margin-top: .5em; }
.callout.note { border-color: var(--cyan); background: var(--accent-soft); }
.callout.decide { border-color: var(--navy); background: var(--info-soft); } .callout.decide .tag { color: var(--navy); }
.callout.watch { border-color: var(--amber); background: var(--warn-soft); } .callout.watch .tag { color: var(--amber); }
.callout.good { border-color: var(--good); background: var(--good-soft); } .callout.good .tag { color: var(--good); }
.callout.risk { border-color: var(--bad); background: var(--bad-soft); } .callout.risk .tag { color: var(--bad); }
.callout.story { border-color: var(--ink-2); background: var(--neutral-soft); } .callout.story .tag { color: var(--ink-2); }
.callout.founder { border-color: var(--violet); background: var(--violet-soft); } .callout.founder .tag { color: var(--violet); }
.callout.dark { border-color: var(--cyan); background: var(--navy-deep); color: var(--on-dark); } .callout.dark .tag { color: var(--cyan); } .callout.dark p { color: var(--on-dark); }
.callout.big { padding: 22px 26px 22px 24px; font-size: 1.1rem; line-height: 1.5; }
.callouts { display: grid; gap: 12px; } .callouts.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.callouts .callout { margin: 0; }

/* ---- prompt block ---- */
.prompt { margin: 18px 0; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow); overflow: hidden; }
.prompt .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px 8px 14px; background: linear-gradient(90deg, var(--info-soft), var(--accent-soft)); border-bottom: 1px solid var(--line); }
.prompt .head .label { font-family: var(--mono); font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--navy); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.prompt .head .label::before { content: "✎"; color: var(--cyan-deep); }
.prompt pre { margin: 0; padding: 16px 18px; background: transparent; color: var(--ink); font-family: var(--mono); font-size: .9rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.prompt pre code { background: none; padding: 0; font-size: inherit; color: inherit; }

/* ---- code block ---- */
pre { position: relative; background: var(--term-bg); color: var(--term-ink); border-radius: var(--radius-lg); padding: 16px 18px; overflow-x: auto; font-family: var(--mono); font-size: .86rem; line-height: 1.55; margin: 16px 0; }
pre code { background: none; padding: 0; font-size: inherit; color: inherit; white-space: pre; }
.codewrap { margin: 16px 0; }
.codewrap pre { margin: 0; border-top-left-radius: 0; }
.codewrap .file { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: .76rem; color: var(--term-dim); background: var(--term-bar); padding: 6px 12px; border-radius: var(--radius) var(--radius) 0 0; }
.codewrap .file::before { content: "▤"; color: var(--term-cyan); }
.copy { position: absolute; top: 8px; right: 8px; font: 600 .72rem var(--font); letter-spacing: .04em; color: var(--term-ink); background: hsl(215 40% 24%); border: 1px solid hsl(215 30% 34%); border-radius: 6px; padding: 4px 9px; cursor: pointer; opacity: .85; }
.copy:hover { opacity: 1; background: hsl(215 40% 30%); }
.copy.done { background: var(--good); border-color: var(--good); color: #fff; }
.prompt .copy { position: static; color: var(--navy); background: #fff; border-color: var(--line-2); }
.prompt .copy.done { color: #fff; }
.hl { color: var(--term-cyan); } .k { color: var(--term-amber); } .s { color: var(--term-green); } .c { color: var(--term-dim); font-style: italic; }

/* ---- terminal ---- */
.term { margin: 18px 0; background: var(--term-bg); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); font-family: var(--mono); font-size: .86rem; line-height: 1.6; color: var(--term-ink); }
.term .bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--term-bar); color: var(--term-dim); font-size: .74rem; }
.term .bar .dots { display: inline-flex; gap: 6px; margin-right: 6px; }
.term .bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: hsl(0 70% 60%); display: block; }
.term .bar .dots i:nth-child(2) { background: hsl(40 90% 60%); } .term .bar .dots i:nth-child(3) { background: hsl(150 60% 50%); }
.term .body { padding: 14px 16px 16px; overflow-x: auto; }
.term .line { white-space: pre-wrap; word-break: break-word; min-height: 1.6em; }
.term .line.cmd { color: #fff; }
.term .line.cmd::before { content: "$ "; color: var(--term-green); }
.term .line.out { color: var(--term-ink); }
.term .line.dim { color: var(--term-dim); }
.term .line.ok { color: var(--term-green); }
.term .line.warn { color: var(--term-amber); }
.term .line.err { color: var(--term-red); }
.term .line.agent { color: var(--term-cyan); }
.term .line.gap { min-height: .8em; }
.term:not(.static) .line { visibility: hidden; }
.term:not(.static) .line.shown { visibility: visible; }
.term .line.typing::after { content: "▍"; color: var(--term-cyan); animation: blink 1s steps(2) infinite; }
@keyframes blink { to { opacity: 0; } }
.term .replay { float: right; font: 600 .7rem var(--font); color: var(--term-dim); background: transparent; border: 1px solid hsl(215 30% 30%); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.term .replay:hover { color: #fff; }

/* ---- Q&A ---- */
.qas { display: grid; gap: 10px; margin: 16px 0; }
.qa { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.qa summary { cursor: pointer; list-style: none; padding: 14px 18px 14px 46px; position: relative; font-weight: 600; color: var(--navy); }
.qa summary::-webkit-details-marker { display: none; }
.qa summary::before { content: "Q"; position: absolute; left: 14px; top: 13px; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--cyan-deep); font-family: var(--mono); font-size: .78rem; font-weight: 700; display: grid; place-items: center; }
.qa summary::after { content: "+"; position: absolute; right: 16px; top: 11px; font-size: 1.3rem; color: var(--muted); transition: transform .2s var(--ease); }
.qa[open] summary::after { transform: rotate(45deg); }
.qa[open] summary { border-bottom: 1px solid var(--line); }
.qa .a { padding: 14px 18px 16px 46px; color: var(--ink-2); font-size: .98rem; position: relative; }
.qa .a::before { content: "A"; position: absolute; left: 14px; top: 13px; width: 24px; height: 24px; border-radius: 50%; background: var(--navy); color: #fff; font-family: var(--mono); font-size: .78rem; font-weight: 700; display: grid; place-items: center; }
.qa .a p { max-width: none; }

/* ---- grid children must be allowed to shrink so a long code line scrolls inside its block instead of widening the page ---- */
.steps > li, .cards > *, .callouts > *, .split > *, .grid2 > *, .grid3 > *, .crew > *, .stats > *, .qas > *, .tabs .panel, .qa .a { min-width: 0; }

/* ---- steps ---- */
.steps { list-style: none; padding: 0; margin: 18px 0; counter-reset: step; display: grid; gap: 12px; }
.steps > li { counter-increment: step; position: relative; padding: 14px 18px 14px 62px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.steps > li::before { content: counter(step); position: absolute; left: 16px; top: 14px; width: 32px; height: 32px; border-radius: 50%; background: var(--navy); color: #fff; font-family: var(--display); font-weight: 700; display: grid; place-items: center; }
.steps > li > b { display: block; margin-bottom: 4px; color: var(--navy); font-family: var(--display); font-size: 1.05rem; }
.steps > li p { color: var(--ink-2); margin-bottom: .6em; }
.steps > li pre, .steps > li .term, .steps > li .prompt, .steps > li .codewrap { margin: 10px 0 4px; }

/* ---- cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 16px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow); }
.card .ico { font-size: 1.4rem; display: block; margin-bottom: 6px; }
.card b, .card h3 { display: block; color: var(--navy); margin-bottom: 4px; }
.card p { color: var(--ink-2); font-size: .95rem; }
a.card { text-decoration: none; color: inherit; transition: transform .2s var(--ease), border-color .2s; }
a.card:hover { transform: translateY(-2px); border-color: var(--cyan); }
.card .go { display: inline-block; margin-top: 8px; color: var(--cyan-deep); font-weight: 600; font-size: .9rem; }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--cyan); border-radius: var(--radius-lg); padding: 14px 16px 13px; box-shadow: var(--shadow); min-width: 0; }
.stat .n { font-family: var(--display); font-weight: 700; font-size: clamp(1.5rem, 2.8vw, 2.1rem); letter-spacing: -.025em; line-height: 1; font-variant-numeric: tabular-nums; color: var(--navy); }
.stat .l { font-family: var(--mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-top: 8px; }
.stat .d { font-size: .85rem; color: var(--ink-2); margin-top: 3px; }
.stat.good { border-top-color: var(--good); } .stat.good .n { color: var(--good); }
.stat.warn { border-top-color: var(--amber); } .stat.warn .n { color: var(--amber); }
.stat.bad { border-top-color: var(--bad); } .stat.bad .n { color: var(--bad); }
.stat.dark { background: var(--navy-deep); border-color: var(--navy-deep); } .stat.dark .n { color: #fff; } .stat.dark .l { color: var(--on-dark-muted); } .stat.dark .d { color: var(--on-dark); }

/* ---- rules ---- */
.rules { display: grid; gap: 10px; margin: 16px 0; }
.rule { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.rule .n { font-family: var(--display); font-weight: 700; font-size: 1.6rem; color: var(--cyan); line-height: 1; padding-top: 2px; grid-column: 1; grid-row: 1 / span 2; }
.rule b, .rule > span:not(.n) { grid-column: 2; }
.rule b { display: block; } .rule span { color: var(--ink-2); font-size: .95rem; display: block; margin-top: 2px; }

/* ---- crew ---- */
.crew { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin: 16px 0; }
.agent { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0 0 14px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.agent .top { height: 6px; background: var(--ac, var(--cyan)); }
.agent .head { display: flex; gap: 12px; align-items: center; padding: 14px 16px 6px; }
.agent .av { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--ac, var(--cyan)); color: #fff; font-family: var(--display); font-weight: 700; font-size: 1.15rem; flex: 0 0 auto; }
.agent .name { font-family: var(--display); font-weight: 700; font-size: 1.15rem; color: var(--navy); line-height: 1.1; }
.agent .role { font-size: .84rem; color: var(--muted); }
.agent .bio { padding: 4px 16px 0; color: var(--ink-2); font-size: .93rem; }
.agent .tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; margin-top: auto; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: .7rem; letter-spacing: .04em; padding: 3px 8px; border-radius: 999px; background: var(--neutral-soft); color: var(--ink-2); white-space: nowrap; }
.badge.model { background: var(--info-soft); color: var(--navy); }
.badge.tool { background: var(--accent-soft); color: var(--cyan-deep); }
.badge.gate { background: var(--violet-soft); color: var(--violet); }
.badge.good { background: var(--good-soft); color: var(--good); } .badge.warn { background: var(--warn-soft); color: var(--amber); } .badge.bad { background: var(--bad-soft); color: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px 1px 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2); font-size: .88em; font-weight: 600; color: var(--ink); white-space: nowrap; vertical-align: baseline; text-decoration: none; }
.chip .dot { width: 18px; height: 18px; border-radius: 50%; background: var(--ac, var(--cyan)); color: #fff; font-family: var(--display); font-size: .68rem; font-weight: 700; display: grid; place-items: center; }

/* ---- people ---- */
.people { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin: 16px 0; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: grid; grid-template-columns: 40px 1fr; gap: 4px 12px; align-items: center; }
.person .av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--navy); font-weight: 700; font-family: var(--display); grid-row: span 2; }
.person b { display: block; line-height: 1.2; }
.person .r { font-size: .84rem; color: var(--muted); line-height: 1.3; }
.person.exec .av { background: var(--navy); color: #fff; }

/* ---- timeline ---- */
.tl { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); position: relative; margin: 20px 0; }
.tl::before { content: ""; position: absolute; left: 7px; right: 7px; top: 9px; height: 2px; background: var(--line-2); }
.tl .e { position: relative; padding: 26px 14px 0 0; }
.tl .e::before { content: ""; position: absolute; left: 0; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--cyan); box-sizing: border-box; }
.tl .e.done::before { background: var(--cyan); }
.tl .e.now::before { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 4px var(--warn-soft); }
.tl .e.future::before { border-style: dashed; border-color: var(--line-2); }
.tl .e .d { font-family: var(--mono); font-size: .74rem; color: var(--cyan-deep); }
.tl .e.now .d { color: var(--amber); font-weight: 700; }
.tl .e b { display: block; margin: 2px 0 1px; font-size: .95rem; line-height: 1.25; }
.tl .e span { font-size: .84rem; color: var(--muted); display: block; line-height: 1.35; }

/* ---- tabs ---- */
.tabs { margin: 16px 0; }
.tabs .tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs .tabbar button { font: 600 .9rem var(--font); color: var(--muted); background: transparent; border: 0; border-bottom: 3px solid transparent; padding: 9px 14px; cursor: pointer; margin-bottom: -1px; }
.tabs .tabbar button.on { color: var(--navy); border-bottom-color: var(--cyan); }
.tabs .panel { display: none; padding-top: 12px; }
.tabs .panel.on { display: block; }

/* ---- split / aside ---- */
.split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 22px; align-items: start; }
.aside { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; }
.aside h3, .aside h4 { margin-top: 0; }

/* ---- comparison table ---- */
table.cmp { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 16px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
table.cmp th, table.cmp td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.cmp th { background: var(--surface-2); font-family: var(--display); font-weight: 650; color: var(--navy); font-size: .86rem; }
table.cmp tr:last-child td { border-bottom: 0; }
table.cmp td.yes { color: var(--good); font-weight: 600; } table.cmp td.no { color: var(--bad); } table.cmp td.part { color: var(--amber); }
.tablewrap { overflow-x: auto; }

/* ---- mock window (a fake screen) ---- */
.mock { margin: 18px 0; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.mock .bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: .74rem; color: var(--muted); }
.mock .bar .dots { display: inline-flex; gap: 6px; } .mock .bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); display: block; }
.mock .bar .url { margin-left: 6px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 2px 10px; flex: 1; }
.mock .screen { padding: 16px 18px; font-size: .92rem; }
.figure { margin: 18px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; box-shadow: var(--shadow); }
.figure figcaption, .figure .cap { font-size: .84rem; color: var(--muted); margin-top: 8px; }

/* ---- flow animation frame (viz.js) ---- */
.viz { margin: 18px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.viz svg { display: block; width: 100%; height: auto; }
.viz .node rect { fill: #fff; stroke: var(--line-2); stroke-width: 1.5; rx: 10; }
.viz .node.on rect { stroke: var(--nc, var(--cyan)); stroke-width: 3; filter: drop-shadow(0 4px 10px hsl(215 50% 15% / .15)); }
.viz .node .lbl { font: 600 15px var(--display); fill: var(--navy); }
.viz .node .sub { font: 12px var(--font); fill: var(--muted); }
.viz .node .badge { fill: var(--nc, var(--cyan)); }
.viz .node .badge-t { font: 700 11px var(--display); fill: #fff; }
.viz .edge { fill: none; stroke: var(--line-2); stroke-width: 2; }
.viz .edge.on { stroke: var(--cyan); stroke-dasharray: 6 6; animation: dash 1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -24; } }
.viz .edge-lbl { font: 11px var(--mono); fill: var(--muted); }
.viz .packet { fill: var(--cyan); stroke: #fff; stroke-width: 2; }
.viz .ctrl { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.viz .ctrl button { font: 600 .8rem var(--font); color: var(--navy); background: #fff; border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 11px; cursor: pointer; }
.viz .ctrl button:hover { border-color: var(--cyan); }
.viz .ctrl .cap { flex: 1; font-size: .9rem; color: var(--ink-2); min-width: 200px; }
.viz .ctrl .cap b { color: var(--navy); }
.viz .ctrl .idx { font-family: var(--mono); font-size: .74rem; color: var(--muted); }

/* ---- reveal & motion ---- */
.reveal { opacity: 0; transform: translateY(10px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.pulse { animation: pulse 2.2s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 hsl(190 85% 45% / .35); } 50% { box-shadow: 0 0 0 10px hsl(190 85% 45% / 0); } }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } .viz .edge.on { animation: none; } .term:not(.static) .line { visibility: visible; } }

/* ---- chapter footer ---- */
.chapfoot { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 34px 0 10px; }
.chapfoot a { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: var(--radius-lg); text-decoration: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.chapfoot a small { font-family: var(--mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.chapfoot a b { font-family: var(--display); font-size: 1.05rem; color: var(--navy); }
.chapfoot a.next { background: var(--navy); border-color: var(--navy); color: #fff; text-align: right; }
.chapfoot a.next small, .chapfoot a.next .tiny { color: hsl(210 30% 80%); } .chapfoot a.next b { color: #fff; }
.chapfoot a:hover { border-color: var(--cyan); }
.footer { padding: 18px 0 40px; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--line); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px; background: var(--navy); color: #fff; text-decoration: none; font-weight: 600; border: 0; cursor: pointer; font-family: var(--font); font-size: .95rem; }
.btn:hover { background: var(--navy-soft); color: #fff; }
.btn.cyan { background: var(--cyan); color: var(--navy-deep); } .btn.cyan:hover { background: hsl(190 85% 52%); }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line-2); } .btn.ghost:hover { border-color: var(--cyan); background: #fff; }
.btn.sm { padding: 6px 12px; font-size: .84rem; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .story .wrap, .split, .grid2, .grid3, .callouts.g2, .chapfoot { grid-template-columns: 1fr; }
  .topbar nav a:not(.cta):not(.on) { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { padding-top: 22px; }
  .steps > li { padding-left: 54px; } .steps > li::before { left: 12px; width: 28px; height: 28px; }
  pre, .term { font-size: .8rem; }
}
@media print {
  .topbar, .chapnav, .chapfoot, .copy, .viz .ctrl, .term .replay { display: none !important; }
  .term:not(.static) .line { visibility: visible; }
  body { background: #fff; }
  section.block.dark { background: #fff; color: var(--ink); border-top: 2px solid var(--navy); }
  section.block.dark h2, section.block.dark p { color: var(--ink); }
}
