/* ─── design-system tokens (lifted from s46) ────────────────────────── */
:root {
    --paper: #fbfbf2;
    --ink: #121213;
    --signal: #2b5fff;
    --signal-soft: color-mix(in oklab, var(--signal) 12%, var(--paper));
    --signal-highlighter: color-mix(in oklab, var(--signal) 30%, white);
    --signal-shadow: color-mix(in oklab, var(--signal) 60%, transparent);
    --cta-bg: #2b5fff;
    --cta-hover-bg: color-mix(in oklab, #2b5fff 80%, black);
    --accent: #d33a4e;
    --accent-soft: color-mix(in oklab, #d33a4e 22%, var(--paper));
    --accent-ink: #8a1f2d;
    --ok: #1f8a5b;
    --ok-soft: color-mix(in oklab, var(--ok) 16%, var(--paper));
    --btn-bg: var(--cta-bg);
    --btn-fg: #ffffff;
    --btn-border: var(--cta-bg);
    --btn-hover-bg: var(--cta-hover-bg);
    --btn-hover-border: var(--btn-hover-bg);
    --steel: #55564f;
    --rule: #deded0;
    --rule-strong: #b9baa8;
    --shadow-dither: radial-gradient(circle at 1px 1px, var(--rule-strong) 0 1px, transparent 1.1px);
    --hash-strip: repeating-linear-gradient(90deg, var(--rule-strong) 0 1px, transparent 1px 6px);
    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --sans: "Diatype", "ABC Diatype", "Inter", -apple-system, system-ui, sans-serif;
    --gutter: clamp(20px, 4vw, 56px);
    --col-max: 1480px;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --paper: #121213;
    --ink: #f7f7ec;
    --signal: #6b8aff;
    --signal-highlighter: color-mix(in oklab, var(--signal) 60%, white);
    --cta-bg: #6b8aff;
    --cta-hover-bg: color-mix(in oklab, #6b8aff 80%, white);
    --accent: #ff6a7d;
    --accent-soft: color-mix(in oklab, #ff6a7d 22%, var(--paper));
    --accent-ink: #ffb8c1;
    --ok: #5fd0a0;
    --ok-soft: color-mix(in oklab, var(--ok) 22%, var(--paper));
    --btn-fg: #0b0d18;
    --steel: #a0a294;
    --rule: #282a25;
    --rule-strong: #4d5143;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track {
    background: var(--paper);
    background-image: var(--shadow-dither);
    background-size: 4px 4px;
    border-left: 1px solid var(--rule);
}
::-webkit-scrollbar-thumb { background: var(--ink); min-height: 32px; }
::-webkit-scrollbar-thumb:hover { background: var(--signal); }
a { color: inherit; text-decoration: none; }
::selection { background: var(--signal); color: var(--btn-fg); }

.mono {
    font-family: var(--mono);
    font-feature-settings: "ss01", "cv11";
}

.dot {
    width: 4px; height: 4px;
    background: var(--rule-strong);
    display: inline-block;
}
.spec {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--steel);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
}
.spec .num { color: var(--ink); }

a:focus-visible, button:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 3px;
}

/* ═══ app layout ════════════════════════════════════════════════════════ */
.app {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    min-height: 100vh;
}

/* ─── topbar ────────────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in oklab, var(--paper) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--rule);
}
.topbar-inner {
    max-width: var(--col-max);
    margin: 0 auto;
    padding: 12px var(--gutter);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
}
.wordmark {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-shrink: 0;
}
.wordmark .mark {
    width: 14px; height: 14px;
    background: var(--signal);
    display: inline-block;
    transform: translateY(2px);
}
.wordmark .name {
    font-family: var(--mono);
    font-weight: 600;
    font-size: 17px;
    letter-spacing: -0.01em;
}
.wordmark .domain {
    font-family: var(--mono);
    color: var(--steel);
    font-size: 12px;
}
.topbar-crumbs {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--steel);
    min-width: 0;
    overflow: hidden;
}
.crumb-muted { color: var(--steel); }
.crumb-slash { color: var(--rule-strong); }
.crumb-id { color: var(--ink); font-weight: 500; }
.status-finished {
    border: 1px solid var(--rule-strong);
    padding: 2px 7px;
    color: var(--steel);
    font-size: 10px;
    letter-spacing: 0.1em;
}
.live-pulse {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--accent);
    background: var(--accent-soft);
    padding: 2px 8px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--accent-ink);
}
.live-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 var(--accent);
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 60%, transparent); }
    70% { box-shadow: 0 0 0 8px color-mix(in oklab, var(--accent) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--accent) 0%, transparent); }
}
.viewers {
    border: 1px solid var(--rule);
    padding: 2px 7px;
    font-size: 10px;
    color: var(--steel);
    letter-spacing: 0.06em;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ghost-btn {
    appearance: none;
    background: transparent;
    border: 1px solid var(--rule);
    color: var(--steel);
    font-family: var(--mono);
    font-size: 12px;
    padding: 9px 12px;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.ghost-btn:hover {
    border-color: var(--ink);
    color: var(--ink);
}
.topbar-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-family: var(--mono);
    font-weight: 500;
    padding: 9px 14px;
    font-size: 13px;
    letter-spacing: 0.02em;
    border: 1px solid var(--btn-border);
    cursor: pointer;
    transition: background 0.15s, transform 0.12s;
}
.topbar-cta:hover { background: var(--btn-hover-bg); }
.topbar-cta:active { transform: translateY(1px); }
.topbar-cta .arrow { transition: transform 0.15s; }
.topbar-cta:hover .arrow { transform: translateX(3px); }

/* ─── hero strip ────────────────────────────────────────────────────── */
.hero-strip {
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
    position: relative;
}
.hs-inner {
    max-width: var(--col-max);
    margin: 0 auto;
    padding: 24px var(--gutter) 22px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "spec spec"
        "body stats";
    gap: 14px 40px;
    align-items: end;
}
.hs-spec { grid-area: spec; }
.hs-vis {
    border: 1px solid var(--rule-strong);
    padding: 2px 6px;
    color: var(--steel);
    font-size: 10px;
}
.hs-layout { color: var(--steel); }
.hs-body { grid-area: body; min-width: 0; }
.hs-title {
    font-family: var(--sans);
    font-weight: 500;
    letter-spacing: -0.025em;
    line-height: 1;
    font-size: clamp(28px, 3.4vw, 44px);
    margin: 0 0 14px;
    text-wrap: balance;
}
.hs-prompt {
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 90ch;
    color: var(--steel);
    font-size: 14px;
    line-height: 1.5;
}
.hs-prompt-tag {
    flex: 0 0 auto;
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--accent-ink);
    background: var(--accent-soft);
    border: 1px solid color-mix(in oklab, var(--accent) 30%, var(--rule));
    padding: 2px 6px;
    margin-top: 1px;
}
.hs-prompt-body { color: var(--ink); }

.hs-stats {
    grid-area: stats;
    margin: 0;
    display: flex;
    gap: 24px;
    align-items: end;
}
.hs-stats > div {
    border-left: 1px solid var(--rule);
    padding-left: 14px;
}
.hs-stats > div:first-child { border-left: 0; padding-left: 0; }
.hs-stats dt {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--steel);
    margin: 0 0 4px;
}
.hs-stats dd {
    margin: 0;
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.hs-stat-sub {
    color: var(--steel);
    font-size: 11px;
    font-weight: 400;
    margin-left: 4px;
}
.hs-lane dd { display: inline-flex; align-items: center; gap: 6px; }
.lane-mark {
    display: inline-block;
    width: 8px; height: 8px;
    background: var(--signal);
}

@media (max-width: 900px) {
    .hs-inner {
        grid-template-columns: 1fr;
        grid-template-areas: "spec" "body" "stats";
    }
    .hs-stats {
        flex-wrap: wrap;
        gap: 16px;
    }
    .topbar-inner {
        grid-template-columns: auto 1fr;
        grid-template-areas: "wm acts" "crumbs crumbs";
        row-gap: 10px;
    }
    .topbar-crumbs { grid-area: crumbs; }
    .topbar-actions { grid-area: acts; flex-wrap: wrap; justify-content: flex-end; }
    .ghost-btn { padding: 7px 10px; font-size: 11px; }
    .topbar-cta { padding: 7px 11px; font-size: 12px; }
}

/* ═══ layouts ═══════════════════════════════════════════════════════════ */
.layout {
    max-width: var(--col-max);
    width: 100%;
    margin: 0 auto;
    border-left: 1px solid var(--rule);
    border-right: 1px solid var(--rule);
    min-height: 0;
}

/* ── reader ───────────────────────────────────────────────────────── */
.reader-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    min-height: 100%;
}
.reader-wrap .feed {
    padding: 36px clamp(20px, 5vw, 64px);
    border-right: 1px solid var(--rule);
    max-width: 86ch;
    margin: 0 auto;
    width: 100%;
}
.reader-aside {
    border-left: 1px solid var(--rule);
    background: color-mix(in oklab, var(--paper) 96%, var(--ink));
}
@media (max-width: 1100px) {
    .reader-wrap { grid-template-columns: 1fr; }
    .reader-aside { display: none; }
}

/* ── split ──────────────────────────────────────────────────────────── */
.split-wrap {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 320px;
    min-height: 100%;
}
.split-center {
    border-left: 1px solid var(--rule);
    border-right: 1px solid var(--rule);
    min-width: 0;
    overflow: hidden;
}
.split-center .feed {
    padding: 28px 28px 60px;
}
@media (max-width: 1200px) {
    .split-wrap { grid-template-columns: 1fr; }
    .rail--timeline, .rail--meta { display: none; }
}

/* ── ide ────────────────────────────────────────────────────────────── */
.ide-wrap {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 260px;
    height: calc(100vh - 220px);
    min-height: 600px;
}
.ide-center {
    display: grid;
    grid-template-rows: 1fr 280px;
    border-left: 1px solid var(--rule);
    border-right: 1px solid var(--rule);
    min-width: 0;
    overflow: hidden;
}
.ide-editor {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.ide-tabs {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--rule);
    background: color-mix(in oklab, var(--paper) 94%, var(--ink));
    overflow-x: auto;
    flex-shrink: 0;
}
.ide-tab {
    appearance: none;
    background: transparent;
    border: 0;
    border-right: 1px solid var(--rule);
    padding: 10px 14px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--steel);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.ide-tab:hover { color: var(--ink); }
.ide-tab.is-on {
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 1px 0 0 var(--paper);
    position: relative;
    z-index: 1;
}
.ide-tab.is-on::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 2px;
    background: var(--signal);
}
.ide-tab-sp { flex: 1; border-right: 1px solid var(--rule); }
.ide-editor-meta {
    padding: 10px 14px;
    color: var(--steel);
    font-size: 11px;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}
.ide-editor-body {
    overflow: auto;
    background: var(--paper);
    min-height: 0;
}
.ide-file-pre {
    margin: 0;
    padding: 14px 18px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.55;
    color: var(--ink);
    white-space: pre;
}
.ide-terminal {
    border-top: 1px solid var(--ink);
    background: var(--ink);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.ide-term-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid color-mix(in oklab, var(--paper) 14%, transparent);
    color: color-mix(in oklab, var(--paper) 60%, transparent);
    font-size: 11px;
    letter-spacing: 0.06em;
    background: var(--ink);
    flex-shrink: 0;
}
.ide-term-head span:nth-child(2) { flex: 1; }
.ide-term-meta { color: color-mix(in oklab, var(--paper) 60%, transparent); }
.ide-term-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    min-height: 0;
}
.ide-term-body .terminal-stream {
    border: 0;
    flex: 1;
    margin: 0;
}
.ide-term-body .terminal-stream .ts-head { display: none; }
.ide-term-body .ts-body { padding: 12px 14px; }

.ide-stepbar {
    border-left: 1px solid var(--rule);
    background: color-mix(in oklab, var(--paper) 96%, var(--ink));
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.ide-stepbar > .rail-head { flex-shrink: 0; }
.ide-steplist {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
    border-bottom: 1px solid var(--rule);
}
.ide-step {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
    font-size: 11px;
    color: var(--steel);
    transition: background 0.1s, color 0.1s;
}
.ide-step:hover { background: var(--paper); color: var(--ink); }
.ide-step.is-current {
    background: var(--signal-soft);
    color: var(--ink);
    border-left: 3px solid var(--signal);
    padding-left: 9px;
}
.ide-step.is-past .ide-step-k { color: var(--ink); }
.ide-step-n { color: var(--rule-strong); font-size: 10px; }
.ide-step.is-past .ide-step-n,
.ide-step.is-current .ide-step-n { color: var(--ink); }
.ide-step-k {
    letter-spacing: 0.04em;
    text-transform: lowercase;
}
.ide-step--user .ide-step-k { color: var(--accent-ink); }
.ide-step--bash .ide-step-k { color: var(--ink); font-weight: 500; }
.ide-step--edit .ide-step-k { color: var(--signal); }
.ide-step--summary .ide-step-k { color: var(--ok); }
.ide-step-t { color: var(--rule-strong); font-size: 10px; }
.ide-step.is-current .ide-step-t,
.ide-step.is-past .ide-step-t { color: var(--steel); }

.ide-meta-compact {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
}

@media (max-width: 1200px) {
    .ide-wrap { grid-template-columns: 1fr; height: auto; }
    .rail--tree, .ide-stepbar { display: none; }
    .ide-center { border: 0; grid-template-rows: 1fr 300px; height: 100vh; }
}

/* ═══ feed (turns) ═══════════════════════════════════════════════════════ */
.feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    height: 100%;
}
.split-center .feed,
.reader-wrap .feed {
    overflow-y: auto;
    max-height: calc(100vh - 220px);
}

/* generic turn frame */
.turn {
    border: 1px solid var(--rule);
    background: var(--paper);
    transition: border-color 0.12s, transform 0.12s;
    cursor: default;
}
.turn:hover { border-color: var(--rule-strong); }
.turn.is-current {
    border-color: var(--ink);
    box-shadow: 0 0 0 1px var(--ink);
}
.turn-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--rule);
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--steel);
    flex-wrap: wrap;
}
.turn-num { color: var(--ink); font-weight: 500; }
.turn-kind { color: var(--steel); }
.turn-author { color: var(--accent-ink); margin-left: 4px; }
.turn-t { color: var(--rule-strong); margin-left: auto; font-size: 10px; }
.turn-t-sub { color: var(--rule-strong); margin-left: 4px; }
.turn-body { padding: 14px 16px; min-width: 0; overflow: hidden; }

/* user turn */
.turn--user {
    border: 1px solid var(--ink);
    background: var(--paper);
    position: relative;
}
.turn--user .turn-head {
    border-bottom: 1px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
}
.turn--user .turn-num { color: var(--paper); }
.turn--user .turn-kind {
    color: var(--ink);
    background: var(--paper);
    padding: 1px 7px;
    font-weight: 500;
    letter-spacing: 0.12em;
}
.turn--user .turn-author { color: color-mix(in oklab, var(--paper) 70%, transparent); }
.turn--user .turn-t { color: color-mix(in oklab, var(--paper) 50%, transparent); }
.user-quote {
    margin: 0;
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.5;
    color: var(--ink);
    max-width: 70ch;
}
.user-quote code {
    background: color-mix(in oklab, var(--paper) 70%, var(--rule));
    padding: 1px 6px;
    border: 1px solid var(--rule);
    font-size: 14px;
}
.feed--loud-prompt .turn--user {
    border-width: 2px;
}
.feed--loud-prompt .user-quote {
    font-size: 22px;
    line-height: 1.4;
    font-weight: 500;
    letter-spacing: -0.015em;
}

/* think turn — quiet, no card frame in some modes */
.turn--think {
    background: transparent;
    border: 0;
    border-left: 2px solid var(--rule-strong);
    padding-left: 0;
    border-radius: 0;
}
.turn--think .turn-head {
    background: transparent;
    border-bottom: 1px dashed var(--rule);
    padding-left: 16px;
}
.turn--think.is-current {
    box-shadow: none;
    border-left-color: var(--ink);
}
.think-body {
    color: var(--steel);
    font-size: 14px;
    line-height: 1.6;
    max-width: 72ch;
    padding-left: 16px;
}
.think-body p { margin: 0 0 8px; }
.think-body p:last-child { margin: 0; }
.feed--loud-prompt .turn--think {
    border-left-color: var(--rule);
}
.feed--loud-prompt .think-body {
    font-size: 13px;
}

/* tool calls (bash, read, edit) */
.turn--tool .turn-head--tool {
    gap: 10px;
    align-items: center;
    padding: 8px 12px;
}
.tool-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    background: var(--ink);
    color: var(--paper);
    font-size: 10px;
    line-height: 1;
}
.turn--read .tool-glyph { background: var(--steel); }
.turn--edit .tool-glyph { background: var(--signal); color: var(--btn-fg); }
.tool-cmd {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    color: var(--ink);
    background: color-mix(in oklab, var(--paper) 80%, var(--rule-strong));
    padding: 3px 8px;
    border: 1px solid var(--rule);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tool-status {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border: 1px solid currentColor;
    letter-spacing: 0.06em;
}
.tool-status.ok { color: var(--ok); }
.tool-status.fail { color: var(--accent); background: var(--accent-soft); }
.tool-status.dim { color: var(--steel); border-color: var(--rule); font-weight: 400; }
.turn-disc {
    appearance: none;
    background: transparent;
    border: 1px solid var(--rule);
    color: var(--steel);
    font-family: var(--mono);
    font-size: 10px;
    padding: 1px 6px;
    cursor: pointer;
    line-height: 1.4;
}
.turn-disc:hover { border-color: var(--ink); color: var(--ink); }
.diff-stat {
    border: 0;
    padding: 0;
    display: inline-flex;
    gap: 6px;
}
.diff-plus { color: var(--ok); font-weight: 500; }
.diff-minus { color: var(--accent); font-weight: 500; }

/* tool output */
.tool-out {
    margin: 0;
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--steel);
    background: color-mix(in oklab, var(--paper) 96%, var(--ink));
    border-top: 1px solid var(--rule);
    white-space: pre;
    overflow-x: auto;
    max-height: 320px;
    overflow-y: auto;
}
.tool-out.out-fail {
    background: color-mix(in oklab, var(--accent-soft) 50%, var(--paper));
    color: var(--ink);
}
.tool-out.out-ok {
    border-left: 3px solid var(--ok);
    padding-left: 13px;
}
.file-preview {
    background: var(--paper);
    color: var(--ink);
    max-height: 380px;
}
.ln-num {
    display: inline-block;
    width: 28px;
    color: var(--rule-strong);
    user-select: none;
    text-align: right;
    margin-right: 12px;
}

/* diff renderer */
.diff-shell {
    border-top: 1px solid var(--rule);
}
.diff-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--rule);
    background: color-mix(in oklab, var(--paper) 96%, var(--ink));
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--steel);
}
.diff-tab {
    appearance: none;
    background: transparent;
    border: 1px solid var(--rule);
    color: var(--steel);
    font-family: var(--mono);
    font-size: 10px;
    padding: 2px 8px;
    cursor: pointer;
    letter-spacing: 0.08em;
}
.diff-tab.is-on {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
}
.diff-toolbar-sp { flex: 1; }
.diff-toolbar-path { color: var(--ink); }
.diff-review-btn {
    appearance: none;
    background: var(--paper);
    border: 1px solid var(--ink);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 10.5px;
    padding: 3px 10px;
    cursor: pointer;
    letter-spacing: 0.06em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 1px 1px 0 0 var(--ink);
    transition: transform 80ms steps(2), box-shadow 80ms steps(2), background 80ms steps(2);
}
.diff-review-btn:hover {
    background: var(--signal);
    color: var(--btn-fg);
    border-color: var(--signal);
    box-shadow: 1px 1px 0 0 var(--ink);
}
.diff-review-btn .arrow { transition: transform 0.15s; }
.diff-review-btn:hover .arrow { transform: translateX(2px); }
.diff-pre {
    margin: 0;
    padding: 10px 0;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
    overflow-x: auto;
    max-height: 420px;
    overflow-y: auto;
}
.diff-hunk-head {
    display: block;
    padding: 4px 12px;
    background: color-mix(in oklab, var(--signal) 8%, var(--paper));
    color: var(--signal);
    font-size: 11px;
    border-bottom: 1px solid var(--rule);
    border-top: 1px solid var(--rule);
}
.diff-line {
    display: inline;
}
.diff-line--add {
    background: color-mix(in oklab, var(--ok) 12%, var(--paper));
    display: block;
}
.diff-line--rem {
    background: color-mix(in oklab, var(--accent) 14%, var(--paper));
    display: block;
}
.diff-line--ctx { display: block; }
.diff-sign {
    display: inline-block;
    width: 16px;
    text-align: center;
    color: var(--rule-strong);
    user-select: none;
}
.diff-line--add .diff-sign { color: var(--ok); }
.diff-line--rem .diff-sign { color: var(--accent); }
.diff-body { color: inherit; }

.diff-split-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--rule);
}
.diff-split-col {
    border-right: 1px solid var(--rule);
    min-width: 0;
    overflow: hidden;
}
.diff-split-col:last-child { border-right: 0; }
.diff-split-head {
    padding: 6px 12px;
    border-bottom: 1px solid var(--rule);
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--steel);
    background: color-mix(in oklab, var(--accent) 8%, var(--paper));
}
.diff-split-head--after {
    background: color-mix(in oklab, var(--ok) 10%, var(--paper));
}
.diff-split-col .diff-pre {
    max-height: 380px;
    padding: 6px 0;
}

/* summary turn */
.turn--summary {
    border: 1px solid var(--ink);
    background: var(--paper);
    position: relative;
}
.turn--summary::after {
    content: "";
    position: absolute;
    left: 8px; top: 8px;
    right: -6px; bottom: -7px;
    pointer-events: none;
    background-image: var(--shadow-dither);
    background-size: 4px 4px;
    z-index: -1;
}
.turn-head--summary {
    background: color-mix(in oklab, var(--ok) 8%, var(--paper));
    border-bottom: 1px solid var(--ink);
}
.turn--summary .turn-kind { color: var(--ok); font-weight: 500; }
.summary-body {
    font-size: 15px;
    line-height: 1.55;
    max-width: 72ch;
}
.summary-body p { margin: 0 0 12px; }
.summary-body p:last-child { margin: 0; }
.summary-body b { font-weight: 600; color: var(--ink); }
.summary-body code {
    background: color-mix(in oklab, var(--paper) 70%, var(--rule));
    padding: 1px 5px;
    font-size: 13px;
    border: 1px solid var(--rule);
}
.summary-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-top: 1px solid var(--rule);
    font-size: 11px;
    color: var(--steel);
    letter-spacing: 0.04em;
}
.summary-foot b { color: var(--ink); font-weight: 500; }

/* typing dots (live mode) */
.feed-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border: 1px dashed var(--rule);
    color: var(--steel);
    font-size: 11px;
    letter-spacing: 0.08em;
    background: color-mix(in oklab, var(--accent) 4%, var(--paper));
}
.typing-dot {
    width: 6px; height: 6px;
    background: var(--accent);
    display: inline-block;
    animation: typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-2px); }
}
.typing-label { margin-left: 6px; }

/* ═══ terminal stream mode ════════════════════════════════════════════ */
.terminal-stream {
    background: var(--ink);
    color: var(--paper);
    border: 1px solid var(--ink);
    margin: 0;
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.ts-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-bottom: 1px solid color-mix(in oklab, var(--paper) 14%, transparent);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: color-mix(in oklab, var(--paper) 60%, transparent);
    flex-shrink: 0;
}
.ts-dots { display: inline-flex; gap: 5px; }
.ts-dots i {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: color-mix(in oklab, var(--paper) 22%, transparent);
    display: inline-block;
}
.ts-dots i:first-child { background: var(--signal); }
.ts-title { flex: 1; }
.ts-meta { color: color-mix(in oklab, var(--paper) 50%, transparent); }
.ts-body {
    margin: 0;
    padding: 18px 20px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    color: color-mix(in oklab, var(--paper) 78%, transparent);
    white-space: pre-wrap;
    overflow-y: auto;
    overflow-x: auto;
    flex: 1;
}
.ts-prompt {
    color: var(--paper);
    font-weight: 500;
}
.ts-user { color: var(--signal); }
.ts-arrow { color: var(--paper); }
.ts-meta-line {
    color: color-mix(in oklab, var(--paper) 38%, transparent);
    font-size: 10.5px;
    letter-spacing: 0.05em;
}
.ts-cmd { color: var(--paper); }
.ts-out { color: color-mix(in oklab, var(--paper) 65%, transparent); display: block; }
.ts-out.is-fail { color: var(--accent); }
.ts-think {
    color: color-mix(in oklab, var(--paper) 50%, transparent);
    font-style: italic;
}
.ts-summary { color: color-mix(in oklab, var(--paper) 85%, transparent); }
.ts-plus { color: var(--ok); }
.ts-minus { color: var(--accent); }
.ts-diff--add { color: var(--ok); }
.ts-diff--rem { color: var(--accent); }
.ts-caret {
    color: var(--signal);
    animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* ═══ rails ════════════════════════════════════════════════════════════ */
.rail {
    display: flex;
    flex-direction: column;
    background: color-mix(in oklab, var(--paper) 96%, var(--ink));
    overflow: hidden;
    min-height: 0;
}
.rail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid var(--rule);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--steel);
    background: var(--paper);
}
.rail-head .num { color: var(--ink); font-weight: 500; }
.rail-head-meta { color: var(--steel); }
.rail-foot {
    padding: 10px 14px;
    border-top: 1px solid var(--rule);
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--steel);
}
.rail-foot-k { color: var(--ink); }

/* timeline */
.rail--timeline {
    background: color-mix(in oklab, var(--paper) 97%, var(--ink));
}
.tl-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}
.tl-row {
    display: grid;
    grid-template-columns: 26px 14px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
}
.tl-row:hover { background: var(--paper); }
.tl-num { color: var(--rule-strong); font-size: 10px; letter-spacing: 0.06em; }
.tl-spine {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tl-spine::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0; bottom: -1px;
    width: 1px;
    background: var(--rule);
}
.tl-row:first-child .tl-spine::before { top: 50%; }
.tl-row:last-child .tl-spine::before { bottom: 50%; }
.tl-dot {
    width: 7px; height: 7px;
    background: var(--rule-strong);
    border-radius: 50%;
    position: relative;
    z-index: 1;
    transition: transform 0.12s, background 0.12s;
}
.tl-row.is-past .tl-dot { background: var(--ink); }
.tl-row.is-current .tl-dot {
    background: var(--signal);
    transform: scale(1.3);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 24%, transparent);
}
.tl-row--user .tl-dot { background: var(--ink); }
.tl-row--edit.is-past .tl-dot,
.tl-row--edit.is-current .tl-dot { background: var(--signal); }
.tl-row--summary.is-past .tl-dot { background: var(--ok); }
.tl-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.tl-kind {
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--steel);
    text-transform: uppercase;
}
.tl-row.is-current .tl-kind { color: var(--ink); }
.tl-row--user .tl-kind { color: var(--ink); font-weight: 500; }
.tl-row--edit .tl-kind { color: var(--signal); }
.tl-row--summary .tl-kind { color: var(--ok); }
.tl-blurb {
    font-size: 11px;
    color: var(--steel);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tl-row.is-current .tl-blurb { color: var(--ink); }
.tl-t {
    font-size: 10px;
    color: var(--rule-strong);
    text-align: right;
}
.tl-row.is-current .tl-t,
.tl-row.is-past .tl-t { color: var(--steel); }

/* meta rail */
.rail--meta {
    border-left: 1px solid var(--rule);
}
.rail-sect { border-bottom: 1px solid var(--rule); }
.rail-sect:last-child { border-bottom: 0; }
.rail-sect-head {
    padding: 10px 14px 6px;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--steel);
    text-transform: uppercase;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}
.rail-sect-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.rail-row {
    display: grid;
    grid-template-columns: 92px 1fr;
    gap: 8px;
    align-items: baseline;
    font-size: 11px;
}
.rail-k { color: var(--steel); letter-spacing: 0.04em; }
.rail-v { color: var(--ink); text-align: right; }
.rail-v.hi { font-weight: 500; }
.rail-row--sub .rail-v { color: var(--steel); font-size: 10px; }
.sub-inline { color: var(--steel); font-size: 10px; margin-left: 4px; }
.cost-sov { color: var(--ok); font-weight: 500; }
.rail-bar {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rail-bar-top {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}
.rail-bar-track {
    height: 6px;
    border: 1px solid var(--rule-strong);
    background: transparent;
    position: relative;
}
.rail-bar-fill {
    position: absolute;
    inset: 0;
    background: var(--ink);
}
.rail-bar-fill--sig { background: var(--signal); }

/* file list */
.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.file-item {
    display: grid;
    grid-template-columns: 18px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 11px;
    color: var(--ink);
    cursor: pointer;
}
.file-item:hover .file-path { color: var(--signal); }
.file-op {
    width: 18px;
    text-align: center;
    border: 1px solid var(--rule);
    background: var(--paper);
    padding: 1px 0;
    font-size: 10px;
    font-weight: 500;
    color: var(--steel);
}
.file-op--M { color: var(--signal); border-color: var(--signal); background: color-mix(in oklab, var(--signal) 8%, var(--paper)); }
.file-op--R { color: var(--steel); }
.file-op--A { color: var(--ok); border-color: var(--ok); background: color-mix(in oklab, var(--ok) 10%, var(--paper)); }
.file-path {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-stat {
    display: inline-flex;
    gap: 6px;
    font-size: 10px;
}

/* file tree */
.rail--tree { background: color-mix(in oklab, var(--paper) 97%, var(--ink)); }
.tree-repo {
    padding: 8px 14px;
    border-bottom: 1px solid var(--rule);
    font-size: 11px;
    color: var(--ink);
    font-weight: 500;
}
.tree-repo-glyph { color: var(--steel); margin-right: 4px; }
.tree-list { list-style: none; margin: 0; padding: 4px 0 8px 14px; }
.tree-row {
    appearance: none;
    background: transparent;
    border: 0;
    width: 100%;
    text-align: left;
    padding: 3px 8px 3px 4px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tree-row:hover { background: color-mix(in oklab, var(--signal) 8%, var(--paper)); }
.tree-row.is-file { color: var(--steel); }
.tree-row.is-active {
    background: var(--signal);
    color: var(--btn-fg);
}
.tree-row.is-active .tree-stat .diff-plus,
.tree-row.is-active .tree-stat .diff-minus { color: var(--btn-fg); }
.tree-row.is-active .tree-glyph { color: var(--btn-fg); }
.tree-glyph {
    width: 10px;
    text-align: center;
    color: var(--rule-strong);
    flex-shrink: 0;
}
.tree-name { flex: 1; }
.tree-stat { display: inline-flex; gap: 4px; font-size: 9.5px; }
.tree-stat.dim { color: var(--rule-strong); }

/* ═══ scrubber ═══════════════════════════════════════════════════════════ */
.scrubber {
    border-top: 1px solid var(--ink);
    background: var(--paper);
    position: sticky;
    bottom: 0;
    z-index: 40;
}
.scrubber-inner {
    max-width: var(--col-max);
    margin: 0 auto;
    padding: 10px var(--gutter);
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 18px;
}
.scrubber--no-cta .scrubber-inner {
    grid-template-columns: auto auto 1fr;
}
.scr-controls {
    display: flex;
    gap: 4px;
}
.scr-btn {
    appearance: none;
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 11px;
    padding: 5px 9px;
    min-width: 28px;
    cursor: pointer;
    line-height: 1;
    box-shadow: 1px 1px 0 0 var(--rule-strong);
    transition: transform 80ms steps(2), box-shadow 80ms steps(2), background 80ms steps(2);
}
.scr-btn:hover { border-color: var(--ink); box-shadow: 1px 1px 0 0 var(--ink); }
.scr-btn:active { transform: translate(1px, 1px); box-shadow: 0 0 0 0 var(--ink); }
.scr-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.scr-btn.scr-play {
    background: var(--signal);
    color: var(--btn-fg);
    border-color: var(--signal);
    box-shadow: 1px 1px 0 0 var(--ink);
    min-width: 38px;
}
.scr-btn.scr-play.is-on { background: var(--accent); border-color: var(--accent); }
.scr-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--steel);
    letter-spacing: 0.06em;
}
.scr-step .hi { color: var(--ink); font-weight: 500; }
.scr-step .sep { color: var(--rule-strong); margin: 0 2px; }
.scr-kind {
    padding: 2px 7px;
    border: 1px solid var(--rule);
    color: var(--ink);
    font-size: 10px;
    letter-spacing: 0.1em;
}
.scr-elapsed { color: var(--ink); }
.scr-track {
    position: relative;
    height: 22px;
    border: 1px solid var(--rule-strong);
    background: repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px 8px);
    cursor: pointer;
    min-width: 240px;
}
.scr-track-grid {
    position: absolute;
    inset: 0;
}
.scr-tick {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: var(--rule-strong);
    transform: translateX(-1px);
}
.scr-tick--user { background: var(--ink); width: 3px; }
.scr-tick--edit { background: var(--signal); width: 3px; }
.scr-tick--summary { background: var(--ok); width: 3px; }
.scr-tick.is-past { opacity: 1; }
.scr-tick:not(.is-past) { opacity: 0.35; }
.scr-track-fill {
    position: absolute;
    top: 0; bottom: 0;
    left: 0;
    background: color-mix(in oklab, var(--signal) 16%, transparent);
    pointer-events: none;
}
.scr-track-head {
    position: absolute;
    top: -2px; bottom: -2px;
    width: 3px;
    background: var(--signal);
    transform: translateX(-1px);
    pointer-events: none;
}
.scr-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--btn-bg);
    color: var(--btn-fg);
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--btn-border);
    transition: background 0.15s;
}
.scr-cta:hover { background: var(--btn-hover-bg); }
.scr-cta .arrow { transition: transform 0.15s; }
.scr-cta:hover .arrow { transform: translateX(3px); }

/* review button in scrubber (replaces the old run-yourself CTA) */
.scr-review {
    appearance: none;
    background: var(--paper);
    border: 1px solid var(--ink);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 12px;
    padding: 6px 14px;
    cursor: pointer;
    letter-spacing: 0.04em;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 2px 2px 0 0 var(--ink);
    transition: transform 80ms steps(2), box-shadow 80ms steps(2), background 80ms steps(2);
}
.scr-review:hover {
    background: var(--signal);
    color: var(--btn-fg);
    border-color: var(--signal);
}
.scr-review:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 0 var(--ink);
}
.scr-review.is-on {
    background: var(--ink);
    color: var(--paper);
}
.scr-review.is-min {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-ink);
}
.scr-review-glyph {
    display: inline-flex;
    gap: 3px;
    align-items: center;
}
.scr-review-glyph i {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}
.scr-review-glyph i:nth-child(2) { background: #e9c44d; }
.scr-review-glyph i:nth-child(3) { background: var(--ok); }
.scr-review:hover .scr-review-glyph i,
.scr-review.is-on .scr-review-glyph i {
    background: currentColor;
    opacity: 0.7;
}
.scr-review-label { font-weight: 500; }
.scr-review-meta {
    color: var(--steel);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    padding-left: 8px;
    border-left: 1px solid var(--rule);
}
.scr-review:hover .scr-review-meta,
.scr-review.is-on .scr-review-meta {
    color: color-mix(in oklab, currentColor 70%, transparent);
    border-left-color: color-mix(in oklab, currentColor 30%, transparent);
}
.scr-review.is-min .scr-review-meta {
    color: var(--accent-ink);
    border-left-color: color-mix(in oklab, var(--accent) 40%, transparent);
}

/* ═══ review window (floating, draggable, minimizable) ═══════════════ */
.review-win {
    position: fixed;
    z-index: 180;
    background: var(--paper);
    border: 1px solid var(--ink);
    box-shadow: 6px 6px 0 0 var(--ink), 10px 10px 0 0 color-mix(in oklab, var(--signal) 60%, transparent);
    display: flex;
    flex-direction: column;
    min-width: 480px;
    min-height: 320px;
    overflow: hidden;
    animation: rw-in 0.18s ease-out;
}
.review-win.is-dragging { user-select: none; cursor: grabbing; }
.review-win.is-max {
    box-shadow: 0 0 0 1px var(--ink);
    animation: none;
}
@keyframes rw-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.rw-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--ink);
    background: color-mix(in oklab, var(--paper) 94%, var(--ink));
    cursor: grab;
    user-select: none;
    flex-shrink: 0;
}
.rw-head:active { cursor: grabbing; }
.rw-traffic {
    display: inline-flex;
    gap: 6px;
}
.rw-tl {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid color-mix(in oklab, var(--ink) 18%, transparent);
    cursor: pointer;
    padding: 0;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.rw-tl--close { background: var(--accent); }
.rw-tl--min { background: #e9c44d; }
.rw-tl--zoom { background: var(--ok); }
.rw-tl-glyph {
    font-size: 8px;
    color: rgba(0, 0, 0, 0.55);
    line-height: 1;
    opacity: 0;
    transition: opacity 0.1s;
    font-family: var(--mono);
    font-weight: 600;
}
.rw-traffic:hover .rw-tl-glyph { opacity: 1; }
.rw-title {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--steel);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rw-title-tag { color: var(--ink); font-weight: 600; letter-spacing: 0.12em; }
.rw-title-sep { color: var(--rule-strong); }
.rw-title-meta { color: var(--steel); }
.rw-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.rw-shortcut {
    border: 1px solid var(--rule);
    padding: 2px 6px;
    font-size: 10px;
    color: var(--steel);
    letter-spacing: 0.08em;
}

.rw-body {
    display: grid;
    grid-template-columns: 240px 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.rw-files {
    background: color-mix(in oklab, var(--paper) 96%, var(--ink));
    border-right: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.rw-files-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--rule);
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--steel);
    background: var(--paper);
    flex-shrink: 0;
}
.rw-files-head span:first-child { color: var(--ink); font-weight: 500; }
.rw-files-count { color: var(--steel); }
.rw-files-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}
.rw-file {
    display: grid;
    grid-template-columns: 22px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--rule);
    cursor: pointer;
    font-size: 11px;
    transition: background 0.1s;
}
.rw-file:hover { background: var(--paper); }
.rw-file.is-active {
    background: var(--signal);
    color: var(--btn-fg);
    border-left: 3px solid var(--ink);
    padding-left: 11px;
}
.rw-file.is-active .file-op {
    background: color-mix(in oklab, var(--paper) 30%, transparent);
    border-color: var(--btn-fg);
    color: var(--btn-fg);
}
.rw-file.is-active .diff-plus,
.rw-file.is-active .diff-minus { color: var(--btn-fg); }
.rw-file-path {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rw-file-stat {
    display: inline-flex;
    gap: 5px;
    font-size: 10px;
}
.rw-files-foot {
    border-top: 1px solid var(--rule);
    padding: 10px 14px;
    font-size: 10.5px;
    color: var(--steel);
    flex-shrink: 0;
}
.rw-files-foot-row {
    display: flex;
    justify-content: space-between;
}

.rw-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--paper);
}
.rw-content-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--rule);
    font-size: 11.5px;
    background: var(--paper);
    flex-shrink: 0;
}
.rw-content-path {
    color: var(--ink);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rw-content-stat {
    display: inline-flex;
    gap: 6px;
    font-size: 11px;
}
.rw-content-sp { flex: 1; }
.rw-view-tabs {
    display: inline-flex;
    gap: 0;
}
.rw-view-tab {
    appearance: none;
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    color: var(--steel);
    font-family: var(--mono);
    font-size: 10.5px;
    padding: 3px 10px;
    cursor: pointer;
    letter-spacing: 0.06em;
    margin-left: -1px;
}
.rw-view-tab:first-child { margin-left: 0; }
.rw-view-tab:hover { border-color: var(--ink); color: var(--ink); }
.rw-view-tab.is-on {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
    z-index: 1;
}
.rw-view-tab:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.rw-content-body {
    flex: 1;
    overflow: auto;
    background: var(--paper);
    min-height: 0;
}
.rw-content-body .diff-pre {
    max-height: none;
    height: 100%;
}
.rw-file-pre {
    margin: 0;
    padding: 14px 18px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.55;
    color: var(--ink);
    white-space: pre;
}
.rw-empty {
    color: var(--steel);
    font-style: italic;
}
.rw-content-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-top: 1px solid var(--rule);
    font-size: 10.5px;
    color: var(--steel);
    letter-spacing: 0.06em;
    background: color-mix(in oklab, var(--paper) 96%, var(--ink));
    flex-shrink: 0;
}
.rw-foot-sp { flex: 1; }

/* split view in review */
.rw-split-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
}
.rw-split-col {
    border-right: 1px solid var(--rule);
    min-width: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
}
.rw-split-col:last-child { border-right: 0; }
.rw-split-head {
    padding: 6px 12px;
    border-bottom: 1px solid var(--rule);
    font-size: 10px;
    letter-spacing: 0.1em;
    color: var(--steel);
    background: color-mix(in oklab, var(--accent) 8%, var(--paper));
    flex-shrink: 0;
}
.rw-split-head--after {
    background: color-mix(in oklab, var(--ok) 10%, var(--paper));
}
.rw-split-col .diff-pre {
    max-height: none;
    flex: 1;
}

@media (max-width: 760px) {
    .review-win {
        left: 8px !important;
        right: 8px !important;
        width: auto !important;
        min-width: 0;
        bottom: 80px;
        top: auto !important;
        height: min(70vh, 480px) !important;
    }
    .rw-body { grid-template-columns: 1fr; }
    .rw-files { display: none; }
}

@media (max-width: 900px) {
    .scrubber-inner {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px 16px;
    }
    .scr-track { min-width: 0; }
    .scr-cta { justify-self: start; }
}

/* ═══ toast ════════════════════════════════════════════════════════════ */
.toast {
    position: fixed;
    bottom: 76px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--paper);
    padding: 10px 16px;
    font-size: 12px;
    letter-spacing: 0.04em;
    z-index: 200;
    border: 1px solid var(--ink);
    box-shadow: 4px 4px 0 0 var(--signal);
    animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ═══ modal ════════════════════════════════════════════════════════════ */
.modal-scrim {
    position: fixed;
    inset: 0;
    background: color-mix(in oklab, var(--ink) 40%, transparent);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: scrim-in 0.15s;
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
    width: 100%;
    max-width: 540px;
    background: var(--paper);
    border: 1px solid var(--ink);
    position: relative;
    box-shadow: 8px 8px 0 0 var(--signal);
    animation: modal-in 0.2s ease-out;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--ink);
    font-size: 11px;
    letter-spacing: 0.1em;
    color: var(--ink);
    font-weight: 500;
}
.modal-x {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--steel);
    font-size: 14px;
    cursor: pointer;
    padding: 0 4px;
}
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 20px; }
.modal-lede {
    margin: 0 0 18px;
    color: var(--steel);
    font-size: 14px;
    line-height: 1.5;
}
.modal-row {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 14px;
    padding: 10px 0;
    border-top: 1px solid var(--rule);
    font-size: 12px;
}
.modal-row:first-of-type { border-top: 0; padding-top: 0; }
.modal-k { color: var(--steel); letter-spacing: 0.08em; font-size: 11px; }
.modal-v { color: var(--ink); }
.target-row { display: flex; flex-wrap: wrap; gap: 6px; }
.target-row .pick {
    appearance: none;
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    color: var(--ink);
    font-family: var(--mono);
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    letter-spacing: 0.04em;
    box-shadow: 1px 1px 0 0 var(--rule-strong);
    transition: transform 80ms steps(2), box-shadow 80ms steps(2);
}
.target-row .pick:hover {
    border-color: var(--ink);
    box-shadow: 1px 1px 0 0 var(--ink);
}
.target-row .pick.is-on {
    background: var(--signal);
    color: var(--btn-fg);
    border-color: var(--signal);
    box-shadow: 1px 1px 0 0 var(--ink);
}
.modal-pre {
    margin: 14px 0 0;
    padding: 12px 14px;
    background: color-mix(in oklab, var(--paper) 80%, var(--rule));
    border: 1px solid var(--rule);
    font-size: 11px;
    line-height: 1.55;
    color: var(--ink);
    max-height: 200px;
    overflow: auto;
    white-space: pre;
}
.modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    border-top: 1px solid var(--ink);
    background: color-mix(in oklab, var(--paper) 96%, var(--ink));
}
.modal-foot-note { color: var(--steel); font-size: 11px; letter-spacing: 0.04em; }
.modal-foot .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--btn-bg);
    color: var(--btn-fg);
    border: 1px solid var(--btn-border);
    font-family: var(--mono);
    font-size: 12px;
    padding: 9px 14px;
    cursor: pointer;
}
.modal-foot .btn .arrow { transition: transform 0.15s; }
.modal-foot .btn:hover { background: var(--btn-hover-bg); }
.modal-foot .btn:hover .arrow { transform: translateX(3px); }

/* ═══ tweaks override (panel z-order above scrubber) ═════════════════ */
.twk-panel { z-index: 200 !important; }

/* hide reader meta on small screens */
@media (max-width: 700px) {
    .hs-title { font-size: 28px; }
    .turn-head { gap: 6px; }
    .tool-cmd { font-size: 11px; }
}

/* ─── vanilla viewer compatibility ───────────────────────────────────── */
button, input, textarea { font: inherit; }
pre, code, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
button:active { transform: scale(0.98); }
.tool-toggle {
    width: 100%;
    appearance: none;
    background: transparent;
    border: 0;
    text-align: left;
    cursor: pointer;
    color: inherit;
}
.tool-toggle:active { transform: none; }
.eyebrow {
    margin: 0 0 8px;
    color: var(--signal);
    font-size: 11px;
    letter-spacing: 0.14em;
    font-weight: 700;
}
.hs-task {
    margin: 12px 0 0;
    max-width: 90ch;
    color: var(--steel);
    font-size: 14px;
    text-wrap: pretty;
}
.state-screen {
    min-height: 100vh;
    height: 100vh;
    display: grid;
    place-items: center;
    padding: 48px 24px;
    background: var(--paper);
    overflow: hidden;
}
.state-screen--simple {
    padding: 24px;
    overflow: auto;
}
.state-simple-card {
    width: min(560px, 100%);
    border: 1px solid var(--rule);
    padding: 28px;
    box-shadow: 0 18px 48px color-mix(in oklab, var(--ink) 8%, transparent);
}
.state-simple-mark {
    width: 18px;
    height: 18px;
    background: var(--signal);
    margin-bottom: 18px;
}
.state-simple-card h1 {
    margin: 0 0 12px;
    font-size: clamp(32px, 5vw, 56px);
    line-height: 0.95;
    letter-spacing: -0.06em;
    text-wrap: balance;
}
.state-simple-card p:last-child {
    margin-bottom: 0;
    color: var(--steel);
    text-wrap: pretty;
}
.problem-state {
    width: 100%;
    max-width: 1100px;
}
.problem-card {
    width: 100%;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 56px 60px 60px;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    column-gap: 64px;
    align-items: start;
    position: relative;
}
.problem-mark {
    width: 28px;
    height: 28px;
    background: var(--signal);
    display: block;
    margin-bottom: 32px;
}
.problem-breadcrumb {
    font-size: 15px;
    font-weight: 500;
    color: var(--signal);
    margin: 0 0 24px;
    line-height: 1;
}
.problem-headline {
    font-weight: 800;
    font-size: clamp(48px, 5.6vw, 80px);
    line-height: 0.98;
    letter-spacing: -0.035em;
    margin: 0 0 22px;
    color: var(--ink);
    max-width: 11ch;
    text-wrap: balance;
}
.problem-sub {
    font-size: 18px;
    line-height: 1.5;
    color: color-mix(in oklab, var(--ink) 86%, var(--steel));
    margin: 0;
    max-width: 32ch;
}
.problem-panel-wrap {
    position: relative;
    isolation: isolate;
}
.problem-panel-wrap::after {
    content: "";
    position: absolute;
    z-index: 0;
    left: 10px;
    top: 10px;
    right: -8px;
    bottom: -9px;
    pointer-events: none;
    background-image: var(--shadow-dither);
    background-size: 4px 4px;
}
.problem-panel {
    position: relative;
    z-index: 1;
    background: var(--paper);
    border: 1px solid var(--ink);
}
.problem-panel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--steel);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.problem-panel-row--header { border-bottom: 1px solid var(--rule); }
.problem-panel-row--footer {
    border-top: 1px solid var(--rule);
    min-height: 18px;
    padding: 0 16px;
}
.problem-count { color: var(--signal); }
.problem-panel-body {
    padding: 30px 28px 64px;
    display: flex;
    justify-content: center;
}
.problem-stage { position: relative; }
.problem-grid {
    display: grid;
    grid-template-columns: repeat(16, 14px);
    grid-auto-rows: 14px;
    gap: 3px;
}
.problem-cell {
    width: 14px;
    height: 14px;
    position: relative;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-size: 10px;
    line-height: 1;
    color: color-mix(in oklab, var(--ink) 82%, var(--steel));
    animation: problemCellFill 220ms cubic-bezier(.6, 0, .35, 1) both;
    animation-delay: var(--cell-d, 0ms);
}
@keyframes problemCellFill {
    0% { background: transparent; color: color-mix(in oklab, var(--ink) 82%, var(--steel)); }
    60% { color: transparent; }
    100% { background: var(--signal); color: transparent; }
}
.problem-cell--missing {
    z-index: 20;
    --fall-hr: 240px;
    --fall-off: 900px;
    will-change: transform, background-color;
    animation:
        problemCellFill 220ms cubic-bezier(.6, 0, .35, 1) both,
        problemCellFall 1500ms linear both;
    animation-delay: var(--cell-d, 0ms), 1100ms;
}
@keyframes problemCellFall {
    0% { transform: translateY(0) rotate(0); background-color: var(--signal); animation-timing-function: cubic-bezier(.34, 1.56, .64, 1); }
    6% { transform: translateY(-5px) rotate(-6deg); background-color: var(--signal); }
    11% { transform: translateY(-3px) rotate(-3deg); background-color: var(--accent); animation-timing-function: cubic-bezier(.55, .05, .85, .5); }
    52% { transform: translateY(var(--fall-hr)) rotate(48deg); background-color: var(--accent); animation-timing-function: cubic-bezier(.5, 0, .5, 1); }
    56% { transform: translateY(var(--fall-hr)) rotate(50deg) scaleX(1.45) scaleY(.55); background-color: var(--accent); animation-timing-function: cubic-bezier(.34, 1.4, .64, 1); }
    63% { transform: translateY(calc(var(--fall-hr) - 14px)) rotate(58deg) scaleX(.88) scaleY(1.15); background-color: var(--accent); }
    70% { transform: translateY(calc(var(--fall-hr) - 2px)) rotate(70deg) scaleX(1) scaleY(1); background-color: var(--accent); animation-timing-function: cubic-bezier(.55, .05, .85, .5); }
    100% { transform: translateY(var(--fall-off)) rotate(540deg); background-color: var(--accent); opacity: .9; }
}
.problem-annotation {
    position: absolute;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--accent);
    white-space: nowrap;
    background: var(--paper);
    padding: 2px 6px;
    margin-left: -6px;
    opacity: 0;
    animation: problemAnnotationIn 360ms cubic-bezier(.5, 0, .2, 1) both;
    animation-delay: 2700ms;
}
.problem-annotation::before {
    content: '↳ ';
    color: var(--accent);
    opacity: .85;
}
@keyframes problemAnnotationIn {
    0% { opacity: 0; transform: translateY(-4px); }
    100% { opacity: 1; transform: translateY(0); }
}
@media (max-width: 880px) {
    .state-screen { padding: 24px; overflow: auto; }
    .problem-card {
        grid-template-columns: 1fr;
        padding: 36px 28px 40px;
        row-gap: 36px;
    }
    .problem-headline { font-size: 44px; }
    .problem-panel-body { padding: 24px 16px 52px; }
}
@media (prefers-reduced-motion: reduce) {
    .problem-cell {
        animation: none;
        background: var(--signal);
        color: transparent;
    }
    .problem-cell--missing {
        background: var(--accent);
        transform: translateY(calc(var(--fall-hr) - 2px)) rotate(70deg);
        opacity: .9;
    }
    .problem-annotation {
        animation: none;
        opacity: 1;
    }
}

/* Fixed share viewport: only rails/feed scroll. */
html, body { height: 100%; overflow: hidden; }
.review-win { animation: none; }
.app {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.layout {
    height: 100%;
    min-height: 0;
    overflow: hidden;
}
.split-wrap {
    height: 100%;
    min-height: 0;
}
.rail { min-height: 0; }
.rail--timeline .tl-list,
.rail--meta { overflow-y: auto; }
.split-center { min-height: 0; }
.split-center .feed,
.reader-wrap .feed {
    height: 100%;
    max-height: none;
    overflow-y: auto;
}
.scrubber { position: relative; bottom: auto; flex-shrink: 0; }
.tl-item { margin: 0; padding: 0; }
