@import url('./tokens.css');

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scrollbar-color: var(--border-strong) var(--surface-base); }
h1, h2, h3 { text-wrap: balance; }
body { background: var(--surface-base); color: var(--text-primary); font: 16px/1.55 var(--font-sans); overflow-x: clip; -webkit-font-smoothing: antialiased; }
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(800px 600px at 80% 20%, color-mix(in oklab, var(--sig) 9%, transparent), transparent 60%),
              radial-gradient(700px 500px at 0% 90%, rgb(76 243 255 / 0.05), transparent 60%);
}
.bg-lattice {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: radial-gradient(rgb(255 255 255 / 0.07) 1px, transparent 1.2px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 70% 60% at 70% 30%, #000 20%, transparent 80%);
}
a { color: inherit; text-decoration: none; }
code { font-family: var(--font-mono); font-size: 0.88em; color: var(--sig); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
::selection { background: var(--sig); color: var(--text-inverse); }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 6px; }
.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.page { position: relative; z-index: 2; width: 100%; max-width: 100%; overflow-x: clip; }

/* ---------- nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50; height: 64px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 clamp(16px, 4vw, 40px);
  background: rgb(6 7 10 / 0.6); backdrop-filter: blur(14px) saturate(140%); border-bottom: 1px solid var(--border-subtle);
}
.brand { display: inline-flex; align-items: center; gap: var(--space-3); font-weight: 500; letter-spacing: -0.01em; }
.brand b { font-weight: 700; color: var(--sig); }
.brand-mark { width: 26px; height: 26px; fill: none; stroke: var(--sig); stroke-width: 1.8; stroke-linecap: round; }
.brand-mark path { stroke: var(--accent); }
.nav-links { display: flex; gap: var(--space-1); }
.nav-links a { position: relative; font-size: 14px; color: var(--text-secondary); padding: 8px 14px; border-radius: var(--radius-md); transition: color var(--motion-fast) var(--ease-out), background-color var(--motion-fast) var(--ease-out); }
.nav-links a:hover { color: var(--text-primary); background: var(--surface-hover); }
.nav-links a.is-active { color: var(--text-primary); }
.nav-links a.is-active::after { content: ''; position: absolute; left: 14px; right: 14px; bottom: -13px; height: 2px; background: var(--sig); border-radius: 2px; }
.nav-right { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-4); }
.nav-meter { display: inline-flex; align-items: center; gap: var(--space-2); font-size: 12px; color: var(--text-muted); }
.nav-meter b { color: var(--text-primary); font-weight: 400; min-width: 2ch; text-align: right; }
.nav-meter i { position: relative; width: 7px; height: 7px; border-radius: 99px; background: var(--state-success); }
.nav-meter i::after { content: ''; position: absolute; inset: -4px; border-radius: 99px; border: 1px solid var(--state-success); animation: ping 2.2s var(--ease-out) infinite; }
@keyframes ping { from { transform: scale(0.6); opacity: 0.8; } to { transform: scale(2.3); opacity: 0; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font: 600 15px/1 var(--font-sans); padding: 16px 26px; border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background-color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}
.btn .arrow { display: inline-block; transition: transform var(--motion-base) var(--ease-out); }
.btn-primary { background: var(--accent); color: var(--text-inverse); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-primary); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-glow); }
.btn-sm { padding: 10px 16px; font-size: 13px; }
.btn-xs { padding: 6px 10px; font-size: 12px; min-height: 28px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; padding: 4px 8px; border-radius: var(--radius-sm); white-space: nowrap; }
.badge-danger { color: var(--state-danger); background: var(--state-danger-quiet); }
.badge-success { color: var(--state-success); background: var(--state-success-quiet); }

/* ---------- hero (editorial split) ---------- */
.hero { position: relative; min-height: 100svh; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: clamp(32px, 5vw, 96px); align-items: center; padding: 120px clamp(16px, 5vw, 80px) var(--space-8); max-width: 1560px; margin: 0 auto; }
.hero-copy { max-width: 60rem; }
.hero-title { font-size: clamp(2.75rem, 4.2vw, 4.75rem); line-height: 1; letter-spacing: -0.04em; font-weight: 700; margin: 0 0 var(--space-6); }
.hero-title .line { display: block; overflow: hidden; padding-bottom: 0.06em; }
.hero-title .line-inner { display: inline-block; }
.hero-title em { font-style: normal; color: var(--sig); }
.pill-img { display: inline-block; vertical-align: middle; width: 1.8em; height: 0.8em; margin: 0 0.12em 0.14em 0; border-radius: var(--radius-full); background: var(--surface-overlay); position: relative; overflow: hidden; isolation: isolate; box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.14); }
.pill-img::before { content: ''; position: absolute; inset: 0; background: var(--img) center/cover; }
.hero-sub { max-width: 62ch; font-size: clamp(17px, 1.3vw, 19px); color: var(--text-secondary); margin: 0 0 var(--space-7); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-4); }

.flow { margin: 0; position: relative; }
.flow-svg { width: 100%; height: auto; max-height: 76svh; display: block; overflow: visible; }
.flow .wire { fill: none; stroke: var(--border-strong); stroke-width: 1.5; }
.flow .wire-side { stroke-dasharray: 3 5; }
.flow .node rect { fill: var(--surface-raised); stroke: var(--border-strong); stroke-width: 1; }
.flow .node text { fill: var(--text-primary); font: 500 14px var(--font-sans); text-anchor: middle; }
.flow .node-side rect { fill: var(--surface-sunken); stroke-dasharray: 3 3; }
.flow .node-side text { fill: var(--text-secondary); }
.flow .node-gate rect { stroke: var(--accent); }
.flow .node-broker rect { stroke: var(--sig); fill: color-mix(in oklab, var(--sig) 10%, var(--surface-raised)); }
.flow .node-up rect { fill: var(--surface-sunken); }
.flow .node-up text { font-family: var(--font-mono); font-size: 13px; fill: var(--text-secondary); }
.flow .lock rect, .flow .lock path { fill: none; stroke: var(--sig); stroke-width: 1.6; }
.flow .flow-label { fill: var(--text-muted); font: 11px var(--font-mono); }
.flow .packet { fill: var(--accent); opacity: 0; }
.flow .packet-2 { fill: var(--sig); }
.flow .packet-deny { fill: var(--state-danger); }
.flow .deny-flash text { fill: var(--state-danger); font: 12px var(--font-mono); opacity: 0; }
.flow .boundary { stroke: var(--sig); stroke-opacity: 0.55; stroke-dasharray: 4 6; }
.flow .boundary-label { fill: var(--sig); font: 11px var(--font-mono); }
.flow .route { fill: none; stroke: none; }
.flow figcaption { margin-top: var(--space-4); font-size: 13px; color: var(--text-muted); text-align: center; }

/* ---------- marquee ---------- */
.marquee { position: relative; overflow: hidden; border-block: 1px solid var(--border-subtle); background: var(--surface-sunken); padding: var(--space-5) 0; mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.marquee-track { display: flex; gap: var(--space-8); width: max-content; font-size: 14px; color: var(--text-muted); }
.marquee-track span { white-space: nowrap; }
.marquee-track b { color: var(--text-primary); font-weight: 400; margin-right: 8px; }

/* ---------- chapters ---------- */
.chapter { position: relative; padding: var(--space-9) clamp(16px, 5vw, 80px); max-width: 1440px; margin: 0 auto; }
.chapter-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: var(--space-5); margin-bottom: var(--space-7); }
.chapter-title { font-size: clamp(2rem, 3.4vw, 3.25rem); line-height: 1.05; letter-spacing: -0.03em; font-weight: 650; margin: 0; max-width: 54rem; }
.chapter-sub { color: var(--text-muted); font-size: 13px; margin: 0; }

/* ---------- bento: 4 cols x 2 rows, dense ----------
   zero c1 r1-2 | calls c2-4 r1 | sessions c2-3 r2 | p95 c4 r2  => 8/8 */
.bento { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(230px, auto); grid-auto-flow: dense; gap: var(--space-4); }
.cell { --mx: 50%; --my: 50%; position: relative; overflow: hidden; padding: var(--space-6); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  background: radial-gradient(420px circle at var(--mx) var(--my), color-mix(in oklab, var(--sig) calc(var(--spot, 0) * 100%), transparent), transparent 60%), var(--surface-raised);
  transition: border-color var(--motion-base) var(--ease-out); }
.cell:hover { --spot: 0.07; border-color: var(--border-strong); }
.cell p { color: var(--text-secondary); font-size: 15px; margin: var(--space-2) 0 0; position: relative; }
.cell-k { font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); margin-bottom: var(--space-4); }
.cell-zero { grid-row: span 2; display: flex; flex-direction: column; }
.cell-calls { grid-column: span 3; display: flex; flex-direction: column; }
.cell-sessions { grid-column: span 2; }
.zero { font-size: clamp(4rem, 7vw, 6rem); line-height: 0.9; letter-spacing: -0.04em; margin-bottom: var(--space-5); color: var(--sig); position: relative; z-index: 1; }
.surfaces { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.surfaces li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border-subtle); color: var(--text-secondary); }
.surfaces b { font-weight: 400; color: var(--sig); }
.cell-zero p { margin-top: auto; }
.big { font-size: clamp(2.5rem, 4vw, 3.75rem); line-height: 1; letter-spacing: -0.04em; }
.big small { font-size: 14px; letter-spacing: 0; color: var(--text-muted); }
.calls-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: var(--space-4); margin-bottom: var(--space-5); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-5); font-size: 12px; color: var(--text-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 6px; }
.k-allow { background: color-mix(in oklab, var(--accent) 70%, transparent); } .k-deny { background: var(--state-danger); }
.bars-svg { width: 100%; height: 90px; margin-top: auto; display: block; }
.bars-svg .a { fill: color-mix(in oklab, var(--accent) 55%, transparent); }
.bars-svg .d { fill: var(--state-danger); }

/* ---------- accordion ---------- */
.accordion { display: flex; gap: var(--space-2); height: 440px; }
.slice { position: relative; flex: 1 1 0; min-width: 76px; overflow: hidden; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: linear-gradient(180deg, var(--surface-raised), var(--surface-sunken)); transition: flex-grow var(--motion-slow) var(--ease-out), border-color var(--motion-base) var(--ease-out); }
.slice.is-open { flex-grow: 6; border-color: color-mix(in oklab, var(--sig) 40%, var(--border-subtle)); }
.slice::before { content: ''; position: absolute; inset: 0; background-image: radial-gradient(rgb(255 255 255 / 0.05) 1px, transparent 1.2px); background-size: 16px 16px; pointer-events: none; }
.slice-trigger { position: absolute; inset: 0 auto 0 0; z-index: 2; width: 76px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: var(--space-5) 0; background: none; border: 0; color: var(--text-primary); cursor: pointer; font: inherit; }
.slice-trigger .mono { font-size: 12px; color: var(--sig); }
.slice-label { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 18px; font-weight: 600; white-space: nowrap; }
.slice-body { position: absolute; inset: 0 0 0 76px; padding: var(--space-7); display: flex; flex-direction: column; justify-content: flex-end; gap: var(--space-4); opacity: 0; pointer-events: none; transition: opacity var(--motion-base) var(--ease-out); }
.slice.is-open .slice-body { opacity: 1; pointer-events: auto; transition-delay: 200ms; }
.slice-body h3 { font-size: clamp(1.5rem, 2.2vw, 2.1rem); letter-spacing: -0.02em; line-height: 1.1; margin: 0; }
.slice-body p { color: var(--text-secondary); margin: 0; max-width: 40rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--space-5); margin: 0; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text-primary); }

/* ---------- plate ---------- */
.plate { margin: 0; position: relative; border-radius: var(--radius-xl); overflow: hidden; aspect-ratio: 16 / 7; border: 1px solid var(--border-subtle); }
.plate-img { position: absolute; inset: -8% 0; background: var(--img) left center/cover; }
.plate::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, rgb(6 7 10 / 0.96) 0%, rgb(6 7 10 / 0.6) 45%, transparent 75%); }
.plate figcaption { position: absolute; z-index: 2; left: var(--space-7); right: var(--space-7); bottom: var(--space-7); display: flex; flex-direction: column; gap: var(--space-3); }
.plate figcaption span { font-size: 13px; color: var(--sig); }
.plate figcaption strong { font-size: clamp(1.25rem, 2.3vw, 2.25rem); line-height: 1.3; letter-spacing: -0.02em; font-weight: 600; max-width: 48rem; }

/* ---------- card stacking ---------- */
.stack-section { padding: var(--space-9) clamp(16px, 5vw, 80px); max-width: 1100px; margin: 0 auto; }
.stack-head { margin-bottom: var(--space-8); }
.stack { display: flex; flex-direction: column; gap: 12vh; padding-bottom: 12vh; }
.stack-card { position: sticky; top: calc(120px + var(--i, 0) * 18px); min-height: 280px; padding: var(--space-7); border-radius: var(--radius-xl); border: 1px solid var(--border-strong);
  background: linear-gradient(160deg, var(--surface-overlay), var(--surface-raised)); box-shadow: 0 -6px 16px rgb(0 0 0 / 0.45); transform-origin: 50% 0; }
.stack-card:nth-child(1) { --i: 0; } .stack-card:nth-child(2) { --i: 1; } .stack-card:nth-child(3) { --i: 2; } .stack-card:nth-child(4) { --i: 3; }
.stack-n { display: inline-block; margin-top: var(--space-5); font-size: 13px; color: var(--sig); }
.stack-card h3 { font-size: clamp(1.5rem, 2.8vw, 2.5rem); line-height: 1.1; letter-spacing: -0.025em; margin: 0 0 var(--space-4); max-width: 36ch; }
.stack-card p { color: var(--text-secondary); margin: 0; max-width: 52ch; }

/* ---------- tables ---------- */
.table-wrap { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow-x: auto; background: var(--surface-base); }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
thead th { position: sticky; top: 0; text-align: left; font: 500 11px/1 var(--font-mono); text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); background: var(--surface-raised); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
tbody td, tbody th { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border-subtle); font-size: 14px; white-space: nowrap; text-align: left; font-weight: 400; }
tbody tr { transition: background-color var(--motion-fast) var(--ease-out); }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody tr.is-selected { background: color-mix(in oklab, var(--sig) 9%, transparent); }
tbody tr.is-selected td:nth-child(4) { color: var(--sig); }
.empty { margin: 0; padding: var(--space-6) var(--space-5); text-align: center; color: var(--text-secondary); font-size: 14px; }
.num { text-align: right !important; }
.c { text-align: center !important; }
.tool { color: var(--text-primary); }
.scope { font-size: 12px; padding: 3px 8px; border-radius: var(--radius-sm); background: var(--accent-quiet); color: var(--accent-text); }
.scope-write { background: color-mix(in oklab, var(--sig) 14%, transparent); color: var(--sig); }
.roles { display: flex; gap: 6px; }
.roles span { font-size: 12px; padding: 3px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-full); color: var(--text-secondary); }

/* ---------- CTA + footer ---------- */
.cta { position: relative; text-align: center; padding: var(--space-10) clamp(16px, 5vw, 80px); display: flex; flex-direction: column; align-items: center; gap: var(--space-7); }
.cta::before { content: ''; position: absolute; inset: 15% 10%; z-index: -1; background: radial-gradient(ellipse at center, color-mix(in oklab, var(--sig) 13%, transparent), transparent 65%); }
.cta-title { font-size: clamp(3rem, 6.4vw, 6rem); line-height: 0.98; letter-spacing: -0.04em; font-weight: 750; margin: 0; max-width: 76rem; }
.cta-title em { font-style: normal; color: var(--sig); }
.snippet { width: min(520px, 100%); text-align: left; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-sunken); overflow: hidden; }
.snippet-bar { display: flex; justify-content: space-between; align-items: center; padding: var(--space-2) var(--space-2) var(--space-2) var(--space-5); border-bottom: 1px solid var(--border-subtle); font-size: 12px; color: var(--text-muted); }
.snippet pre { margin: 0; padding: var(--space-5); font-size: 14px; color: var(--text-primary); overflow-x: auto; }
.footer { display: flex; flex-wrap: wrap; gap: var(--space-4); justify-content: space-between; align-items: center; padding: var(--space-6) clamp(16px, 5vw, 80px) var(--space-7); border-top: 1px solid var(--border-subtle); color: var(--text-muted); font-size: 13px; }
.footer-links { display: flex; gap: var(--space-5); }
.footer-links a { color: var(--text-secondary); transition: color var(--motion-fast) var(--ease-out); }
.footer-links a:hover { color: var(--accent-text); }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 99px; background: var(--state-success); margin-right: 6px; vertical-align: middle; }

/* ---------- app: audit + grants ---------- */
.app { padding-top: 64px; }
.app-head { position: relative; display: flex; justify-content: space-between; align-items: end; gap: var(--space-5); padding: var(--space-8) clamp(16px, 4vw, 40px) var(--space-6); border-bottom: 1px solid var(--border-subtle); }
.crumbs { font-size: 13px; color: var(--text-muted); margin: 0 0 var(--space-3); }
.app-title { font-size: clamp(2rem, 3.6vw, 3.25rem); letter-spacing: -0.035em; line-height: 1; margin: 0 0 var(--space-4); }
.app-meta { font-size: 13px; color: var(--text-muted); margin: 0; }
.scan { position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; overflow: hidden; }
.scan i { position: absolute; inset: 0 auto 0 0; width: 30%; background: linear-gradient(90deg, transparent, var(--sig), transparent); }
.live-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--state-success); box-shadow: 0 0 0 3px var(--state-success-quiet); }
[data-live][aria-pressed="false"] .live-dot { background: var(--text-muted); box-shadow: none; }

.audit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--space-6); padding: var(--space-7) clamp(16px, 4vw, 40px); max-width: 1480px; margin: 0 auto; align-items: start; }
.audit-main { min-width: 0; }
.block-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.block-title { font-size: 20px; letter-spacing: -0.015em; font-weight: 600; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { font: 500 13px/1 var(--font-sans); padding: 8px 12px; min-height: 32px; border-radius: var(--radius-full); border: 1px solid var(--border-strong); background: transparent; color: var(--text-secondary); cursor: pointer; transition: background-color var(--motion-fast) var(--ease-out), color var(--motion-fast) var(--ease-out), border-color var(--motion-fast) var(--ease-out); }
.chip b { font-weight: 400; margin-left: 4px; color: var(--text-muted); }
.chip:hover { background: var(--surface-hover); color: var(--text-primary); }
.chip.is-on { background: color-mix(in oklab, var(--sig) 14%, transparent); border-color: color-mix(in oklab, var(--sig) 50%, transparent); color: var(--text-primary); }
.audit-table tbody tr { cursor: pointer; }
.audit-table tbody tr.is-new { background: color-mix(in oklab, var(--accent) 10%, transparent); }

.drawer { position: sticky; top: 88px; padding: var(--space-6); background: var(--surface-raised); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); display: flex; flex-direction: column; gap: var(--space-5); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer .cell-k { margin-bottom: calc(var(--space-3) * -1); }
.kv-tight { font-size: 12px; }
.json { margin: 0; padding: var(--space-4); background: var(--surface-sunken); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); font-size: 12.5px; line-height: 1.7; color: var(--text-secondary); overflow-x: auto; }
.redacted { color: var(--sig); background: color-mix(in oklab, var(--sig) 12%, transparent); border-radius: 3px; padding: 0 3px; }

.grants { padding: var(--space-4) clamp(16px, 4vw, 40px) var(--space-9); max-width: 1480px; margin: 0 auto; }
.grant { position: relative; width: 40px; height: 24px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface-sunken); cursor: pointer; transition: background-color var(--motion-base) var(--ease-out), border-color var(--motion-base) var(--ease-out); }
.grant::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 99px; background: var(--text-muted); transition: transform var(--motion-base) var(--ease-out), background-color var(--motion-base) var(--ease-out); }
.grant.is-on { background: color-mix(in oklab, var(--sig) 22%, var(--surface-sunken)); border-color: color-mix(in oklab, var(--sig) 60%, transparent); }
.grant.is-on::after { transform: translateX(16px); background: var(--sig); }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 140%); opacity: 0; transition: opacity 400ms var(--ease), transform 400ms var(--ease); padding: 12px 18px; font-size: 13px; background: var(--surface-overlay); border: 1px solid var(--border-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-md); color: var(--text-primary); max-width: calc(100vw - 32px); }
.toast b { color: var(--sig); font-weight: 400; }

/* ---------- icons: one authored stroke family ---------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 1em; height: 1em; vertical-align: -0.14em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.badge .i { width: 1.1em; height: 1.1em; }

/* ---------- motion layer ----------
   Press feedback 160ms ease-out; hover colour 150ms ease; on-screen morphs use
   --ease-in-out; any hover-driven movement is gated to fine pointers. */
.btn { transition: background-color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease), scale var(--motion-press) var(--ease-out); }
.chip, .icon-btn { transition: background-color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease), scale var(--motion-press) var(--ease-out); }
/* `scale` composes with GSAP's inline magnetic transform instead of fighting it */
.btn:active, .chip:active, .icon-btn:active { scale: 0.97; }
.btn .arrow, .link-arrow span { display: inline-block; transition: transform var(--motion-base) var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover .arrow, .link-arrow:hover span { transform: translateX(4px); }
  .stack-card:hover { border-color: color-mix(in oklab, var(--sig) 40%, var(--border-strong)); }
}

/* horizontal accordion: the slice morphs on screen, its content arrives after */
.slice { transition: flex-grow var(--motion-slow) var(--ease-in-out), border-color var(--motion-base) var(--ease); }
.slice-body { transition: opacity var(--motion-base) var(--ease-out); }
.slice.is-open .slice-body { transition-delay: 180ms; }
.slice-body > *, .slice-content > * { opacity: 0; transform: translateY(8px); transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out); }
.slice.is-open .slice-body > *, .slice.is-open .slice-content > * { opacity: 1; transform: none; }
.slice.is-open .slice-body > :nth-child(1), .slice.is-open .slice-content > :nth-child(1) { transition-delay: 220ms; }
.slice.is-open .slice-body > :nth-child(2), .slice.is-open .slice-content > :nth-child(2) { transition-delay: 270ms; }
.slice.is-open .slice-body > :nth-child(3), .slice.is-open .slice-content > :nth-child(3) { transition-delay: 320ms; }
.slice.is-open .slice-body > :nth-child(4), .slice.is-open .slice-content > :nth-child(4) { transition-delay: 370ms; }
.slice.is-open .slice-body > :nth-child(5), .slice.is-open .slice-content > :nth-child(5) { transition-delay: 420ms; }

/* reading progress under the nav: state, scrubbed linearly */
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--sig); transform-origin: 0 50%; transform: scaleX(0); pointer-events: none; }

/* one-shot clip reveal for chapter titles (marketing surfaces only; JS adds .reveal) */
.reveal { clip-path: inset(0 0 100% 0); transition: clip-path var(--motion-slow) var(--ease-in-out); }
.reveal.is-visible { clip-path: inset(0 0 -10% 0); }

@media (prefers-reduced-motion: reduce) {
  /* fewer and gentler, not zero: keep fades and colour, drop movement and loops */
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-property: opacity, color, background-color, border-color, box-shadow !important; }
  .btn:active, .chip:active, .icon-btn:active { scale: none; }
  .slice-body > *, .slice-content > * { transform: none; }
  .reveal { clip-path: none; }
  .scrub .w { opacity: 1; }
}

.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.grant::after { transition: transform 200ms var(--ease-out), background-color var(--motion-fast) var(--ease); }
.grant:active::after { transform: scale(0.85); }
.grant.is-on:active::after { transform: translateX(16px) scale(0.85); }
.grants-table tbody tr.is-changed th { color: var(--sig); }
.grants-table tbody th { transition: color 600ms var(--ease); }
.live-count { font-size: 11px; color: var(--text-inverse); background: var(--accent); border-radius: 99px; padding: 2px 7px; margin-left: 2px; opacity: 0; transform: scale(0.9); transition: opacity var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out); }
.live-count.is-on { opacity: 1; transform: none; }
.drawer > * { transition: opacity 150ms var(--ease); }
.drawer.is-swapping > * { opacity: 0.35; }

.flow .node rect { transition: stroke 300ms var(--ease), fill 300ms var(--ease); }
.flow .node-gate.is-deny rect { stroke: var(--state-danger); fill: var(--state-danger-quiet); }
.flow .node-gate.is-pass rect { stroke: var(--accent-hover); }
.flow .node-broker.is-minting rect { fill: color-mix(in oklab, var(--sig) 24%, var(--surface-raised)); }

/* ---------- responsive ---------- */
@media (min-width: 1025px) { .hero-title .line-inner { white-space: nowrap; } }
@media (max-width: 1024px) {
  .nav { grid-template-columns: 1fr auto; height: auto; row-gap: var(--space-2); padding-block: var(--space-3) var(--space-2); }
  .nav-links { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; scrollbar-width: none; margin-inline: -14px; }
  .nav-links a.is-active { background: var(--surface-hover); }
  .nav-links a.is-active::after { display: none; }
  .app { padding-top: 104px; }
  .drawer { top: auto; }
  .hero { grid-template-columns: minmax(0, 1fr); padding-top: 160px; }
  .flow { max-width: 460px; margin: 0 auto; }
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cell-zero { grid-row: span 1; grid-column: span 2; }
  .cell-calls { grid-column: span 2; }
  .cell-sessions { grid-column: span 1; }
  .accordion { flex-direction: column; height: auto; }
  .slice { flex: none; min-height: 68px; }
  .slice-trigger { position: relative; width: 100%; flex-direction: row; justify-content: flex-start; gap: var(--space-4); padding: var(--space-5); }
  .slice-label { writing-mode: horizontal-tb; transform: none; }
  .slice-body { position: relative; inset: auto; display: none; padding: 0 var(--space-5) var(--space-5); }
  .slice.is-open .slice-body { display: flex; }
  .audit-layout { grid-template-columns: minmax(0, 1fr); }
  .drawer { position: static; }
}
@media (max-width: 640px) {
  .nav-meter { display: none; }
  .bento { grid-template-columns: minmax(0, 1fr); }
  .cell-zero, .cell-calls, .cell-sessions { grid-column: span 1; }
  .plate { aspect-ratio: 4 / 5; }
  .plate figcaption { left: var(--space-5); right: var(--space-5); bottom: var(--space-5); }
  .stack-card { padding: var(--space-5); }
  .app-head { flex-direction: column; align-items: start; }
}
