:root {
    color-scheme: dark;
    --bg: #101612;
    --surface: #19221d;
    --raised: #222e26;
    --ink: #f4f4e8;
    --muted: #bcc8bb;
    --line: #46574b;
    --acid: #daef9e;
    --danger: #ffb599;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-family: system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
[hidden] { display: none !important; }
button { font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, summary:focus-visible { outline: 3px solid var(--acid); outline-offset: 3px; }
.shell { width: min(100%, 41rem); min-height: 100dvh; margin: auto; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 4.25rem; padding: .65rem 1.25rem; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 2; background: var(--bg);
}
.brand { font: 700 1rem var(--mono); letter-spacing: .12em; }
.brand span { color: var(--acid); }
#screen { flex: 1; padding: 1.55rem 1.25rem 2rem; }
#screen h1 { font-size: clamp(1.9rem, 7vw, 3rem); line-height: 1.03; letter-spacing: -.055em; margin: .6rem 0 .75rem; }
#screen h1:focus { outline: none; }
h2 { font-size: 1.2rem; line-height: 1.25; margin: 0 0 .65rem; }
p { line-height: 1.55; margin: 0 0 .9rem; overflow-wrap: anywhere; }
p:last-child { margin-bottom: 0; }
.kicker, .threat, .tag, .speaker {
    font: 600 .875rem/1.35 var(--mono); letter-spacing: .035em;
}
.kicker, .tag { color: var(--muted); }
.threat { color: var(--danger); display: flex; align-items: center; gap: .55rem; margin: 0 0 .9rem; }
.threat::before { content: ''; width: .48rem; height: .48rem; flex: none; border-radius: 50%; background: currentColor; }
.lead { font-size: 1.075rem; }
.progress { display: flex; gap: .35rem; margin: .2rem 0 .9rem; }
.progress span { flex: 1; height: .23rem; background: var(--line); border-radius: 1rem; }
.progress .past { background: #819665; }
.progress .current { background: var(--acid); }
.hero-mark { margin: .2rem 0 1.1rem; padding: .8rem .95rem; border: 1px solid #78574a; color: var(--danger); background: #2c211c; }
.hero-mark span { display: block; font: 650 clamp(2.4rem, 13vw, 4.4rem)/1.1 var(--mono); letter-spacing: -.12em; }
.hero-mark .tag { color: var(--danger); margin: 0 0 .4rem; letter-spacing: .08em; }
.hero-title { max-width: 18ch; }
main :is(button, details, .feedback, .record) { scroll-margin-top: 5rem; }
.transcript, .records, .actions, .exhibits { display: grid; gap: .55rem; margin: 1rem 0; }
.line, .record, .feedback, .checkpoint { padding: .78rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: .42rem; }
.line { border-inline-start: 3px solid var(--line); }
.line.protocol { border-inline-start-color: #9baa70; }
.line.ada { border-inline-start-color: #9dcae2; }
.line.system { border-inline-start-color: #cf886d; }
.speaker { display: block; margin-bottom: .32rem; color: var(--acid); }
.ada .speaker { color: #b5daed; }
.system .speaker { color: var(--danger); }
.record strong, details summary { display: block; margin-bottom: .24rem; color: var(--acid); }
.record p { white-space: pre-line; }
.record p, .line p { font-size: 1rem; }
.checkpoint .tag { margin: 0 0 .4rem; display: block; }
button, summary { cursor: pointer; }
.primary, .utility, .choice, .secondary {
    min-height: 2.85rem; border: 1px solid var(--line); border-radius: .4rem; padding: .63rem .82rem;
}
.primary { width: 100%; background: var(--acid); color: #161e10; border-color: var(--acid); font-weight: 750; }
.primary:hover:not(:disabled) { background: #e9f8bd; }
.secondary, .utility { background: transparent; color: var(--ink); }
.secondary { width: 100%; }
.utility:hover, .secondary:hover, .choice:hover { background: var(--raised); }
.choice { display: flex; width: 100%; gap: .55rem; align-items: center; text-align: left; color: var(--ink); background: var(--surface); }
.choice span { min-width: 0; }
.choice strong { display: block; font-weight: 647; }
.choice small { display: block; font-size: .9rem; color: var(--muted); margin-top: .2rem; }
.choice[aria-pressed="true"] { color: var(--acid); border-color: var(--acid); background: #263321; }
button:disabled { opacity: .52; cursor: default; }
.feedback { margin: 1rem 0; }
.feedback:empty { display: none; }
.feedback.error { border-color: #b6745b; }
.feedback.success { border-color: #829d5f; }
.feedback strong { display: block; margin-bottom: .25rem; }
.feedback.error strong { color: var(--danger); }
.feedback.success strong { color: var(--acid); }
details { border: 1px solid var(--line); border-radius: .4rem; padding: .6rem .8rem; background: var(--surface); }
details summary { display: list-item; min-height: 1.65rem; margin: .1rem 0; }
details p { margin: .55rem 0; }
.toolbar { display: flex; gap: .55rem; flex-wrap: wrap; margin: .9rem 0; }
.selection-caption, .help-copy, .footer { color: var(--muted); font-size: .9rem; }
.footer { padding: .9rem 1.25rem calc(.9rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; align-items: center; gap: .5rem 1rem; flex-wrap: wrap; }
.footer button { margin-inline-start: auto; }
.stack { display: grid; gap: .65rem; margin-top: 1rem; }
dialog { width: min(calc(100% - 1.5rem), 36rem); max-height: min(83dvh, 38rem); padding: 1rem; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: .6rem; }
dialog::backdrop { background: #080d0bd9; }
.dialog-top { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.dialog-top h2 { margin: 0; }
@media (min-width: 42rem) {
    #screen { padding: 2rem 2rem 2.5rem; }
    .topbar, .footer { padding-inline: 2rem; }
}
@media (max-width: 23rem) {
    #screen, .topbar, .footer { padding-inline: .85rem; }
    .choice { padding-inline: .65rem; }
}
.filing-field { border: 1px solid var(--line); border-radius: .4rem; padding: .6rem; margin: 0 0 .35rem; min-width: 0; display: grid; gap: .4rem; }
.filing-field legend { color: var(--acid); padding-inline: .3rem; }
dialog .checkpoint + .checkpoint { margin-top: .65rem; }

/* The same interface after the protocol takes control. */
:root {
    --bg: #141117;
    --surface: #1e1822;
    --raised: #2c2331;
    --ink: #f9eff7;
    --muted: #cbbccc;
    --line: #554659;
    --acid: #eee1ff;
    --danger: #ffb9a9;
}
body {
    background:
        radial-gradient(ellipse at 85% 0%, #53314654, transparent 40rem),
        radial-gradient(ellipse at 0% 75%, #3d305b30, transparent 30rem),
        var(--bg);
    color: var(--ink);
}
.shell {
    border-inline: 1px solid #9b7a9b28;
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    box-shadow: 0 0 5rem #09070a38;
}
.brand { font-weight: 760; letter-spacing: -.015em; }
.brand span { color: var(--danger); }
.primary { background: var(--acid); color: #251a31; border-color: var(--acid); }
.primary:hover:not(:disabled) { background: #fff6ff; }
.choice[aria-pressed="true"] { background: #352742; color: var(--ink); }
.line.protocol { border-inline-start-color: #a98ab8; }
.line.human { border-inline-start-color: #a4c6e9; }
.human .speaker { color: #bad6f8; }
.progress .past { background: #ae8cae; }
.record { border-inline-start: 3px solid #74607b; }
.ledger { gap: 0; border: 1px solid var(--line); border-radius: .65rem; overflow: hidden; }
.ledger .record {
    display: grid; grid-template-columns: minmax(5rem, .85fr) minmax(0, 1.45fr); gap: .65rem;
    border: 0; border-radius: 0; padding: .56rem .72rem;
}
.ledger .record + .record { border-top: 1px solid var(--line); }
.ledger .record strong { font: 600 .875rem/1.35 var(--mono); margin: 0; }
.ledger .record p { font-size: .94rem; line-height: 1.4; }
.checkpoint { border-color: #8d6786; }
.choice, .record, .line, .checkpoint, .window-preview { border-radius: .65rem; }
.quiet {
    color-scheme: light;
    --bg: #f8f7fa;
    --surface: #ffffff;
    --raised: #f0ebf5;
    --ink: #272132;
    --muted: #5d5267;
    --line: #dcd2e4;
    --acid: #573b78;
    --danger: #8f4561;
    background: #eeeaf1;
}
.quiet .shell { box-shadow: 0 0 3rem #32244015; }
.quiet .primary { background: #332746; border-color: #332746; color: #fff; }
.quiet .primary:hover { background: #513e63; }
.quiet .human .speaker { color: #3f527e; }
.quiet .progress .past { background: #b39ec6; }
.quiet[data-phase="welcome"] #screen {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding-block: 2rem 4rem;
}
.assistant-mark {
    display: grid; place-items: center; width: 3.15rem; aspect-ratio: 1; margin-bottom: .65rem;
    border: 1px solid #d7cae1; color: #493763; background: #eee7f4; font: 650 1.3rem var(--mono);
    border-radius: 1.1rem 1.1rem 1.1rem .28rem;
}
.compose {
    display: grid; grid-template-columns: 1fr auto; gap: .45rem;
    width: 100%; margin: .6rem 0 .75rem;
}
.compose label { grid-column: 1/-1; font-size: .875rem; color: var(--muted); font-weight: 650; }
.compose input {
    min-width: 0; width: 100%; padding: .72rem; color: var(--ink); background: #fff;
    border: 1px solid #c7b9d1; border-radius: .55rem; font: inherit;
}
.compose input:focus-visible { outline: 2px solid #573b78; outline-offset: 2px; }
.intrusion {
    margin: 1.25rem 0; padding: .9rem 1rem;
    border: 1px solid #b9686c; border-left: 5px solid #ffb2a0; border-radius: .25rem;
    background: repeating-linear-gradient(0deg, #431f2430 0 1px, transparent 1px 4px), #302027;
    color: var(--danger);
    box-shadow: inset 0 0 2.2rem #b3474a22, 0 0 2.8rem #b3474a24;
}
.intrusion .tag { text-transform: uppercase; margin-bottom: .25rem; color: var(--danger); }
.intrusion-clock {
    display: block; width: fit-content; color: #ffd0ba; font: 750 clamp(2.8rem, 12vw, 4.5rem)/1 var(--mono);
    letter-spacing: -.095em; text-shadow: 3px 0 #a04a6a;
}
.intrusion-clock + p { margin-top: .4rem; }
.fractured .topbar { border-bottom-color: #87545f; }
.fractured[data-phase="fracture"] .intrusion { animation: arrival .32s steps(3, end) both; }
@keyframes arrival { 0% { opacity: .48; transform: translateX(-.3rem); } 100% { opacity: 1; transform: none; } }
.window-preview { padding: .85rem; background: #2e2029; border: 1px solid #a66170; margin-top: 1rem; }
.window-preview .tag { color: var(--danger); }
.window-preview .primary { margin-top: .15rem; }
.time-option { display: flex; gap: .5rem; align-items: center; min-height: 2.75rem; margin-top: .35rem; color: var(--muted); }
.time-option input { width: 1.05rem; height: 1.05rem; accent-color: var(--acid); margin: 0; }
.live-clock {
    padding: .7rem .8rem; display: grid; grid-template-columns: 1fr auto; align-items: center;
    gap: .35rem .8rem; border: 1px solid #a66170; background: #2b1b24; border-radius: .4rem;
}
.live-clock .tag { color: var(--danger); }
.live-clock strong { color: #ffc6b6; font: 720 clamp(2rem, 10vw, 3.3rem)/1 var(--mono); font-variant-numeric: tabular-nums; }
.live-clock.low { background: #47232c; border-color: #ed9786; }
body[data-phase="live"] {
    --pulse-cycle: 2.6s;
    --pulse-floor: .24;
    --pulse-peak: .58;
}
body[data-phase="live"][data-pressure="rising"] {
    --pulse-cycle: 1.75s;
    --pulse-floor: .3;
    --pulse-peak: .8;
}
body[data-phase="live"][data-pressure="critical"] {
    --pulse-cycle: 1.2s;
    --pulse-floor: .35;
    --pulse-peak: .94;
}
body[data-phase="live"] .shell::before {
    content: "";
    position: fixed;
    z-index: 0;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 50% 48%, transparent 34%, #560d2366 78%, #b51e3da6 100%),
        linear-gradient(180deg, #9b17354f, transparent 51%, #a4193736);
    animation: warning-pulse var(--pulse-cycle) ease-in-out infinite;
}
body[data-phase="live"] #screen, body[data-phase="live"] .footer { position: relative; z-index: 1; }
@keyframes warning-pulse {
    0%, 100% { opacity: var(--pulse-floor); }
    50% { opacity: var(--pulse-peak); }
}
body.steady-background[data-phase="live"] .shell::before {
    animation: none;
    opacity: .65;
}
.meter { grid-column: 1/-1; width: 100%; height: .3rem; background: #805053; overflow: hidden; border-radius: .2rem; }
.meter span { display: block; height: 100%; width: 100%; background: #ffc6b6; }
.live-prompt { margin: .85rem 0 .55rem; font-size: 1.03rem; line-height: 1.42; }
.live-actions { gap: .4rem; margin: .5rem 0 0; }
.live-actions .choice { min-height: 2.8rem; }
.forged-draft {
    margin: .45rem 0; border-left: 3px solid #ce7a87; padding: .35rem .6rem;
    color: var(--danger); background: #35212b;
}
.forged-draft .tag { font-size: .8rem; color: inherit; }
.forged-draft p { margin: 0; overflow-wrap: anywhere; }
.forged-draft.writing p::after {
    content: ""; display: inline-block; width: .38em; height: .85em; margin-left: .15em;
    vertical-align: -.05em; background: currentColor; animation: cursor 1.1s steps(1) infinite;
}
@keyframes cursor { 50% { opacity: .15; } }
.live-compose input { background: var(--surface); color: var(--ink); border-color: var(--line); }
body[data-phase="live"] #screen { padding-block: .85rem 1rem; }
body[data-phase="live"] #screen h1 { font-size: clamp(1.45rem, 5.7vw, 2.15rem); margin-top: 0; }
body[data-phase="live"] .footer { visibility: hidden; }
body[data-phase="live"] .feedback { margin: .55rem 0 0; padding: .55rem .7rem; }
.loss { margin-top: .3rem; }
body[data-phase="lost"] h1 { color: #ffd0ba; }
.locked-compose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .45rem;
    margin: 1rem 0 .5rem;
}
.locked-compose input {
    min-width: 0;
    padding: .7rem;
    border-radius: .45rem;
    border: 1px dashed #a66170;
    background: #221820;
    font: inherit;
}
.locked-compose input::placeholder { color: var(--danger); }
body[data-phase="lost"] .help-copy + .primary { margin-top: .45rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-height: 37rem) {
    body[data-phase="live"] .topbar { min-height: 3.2rem; }
    body[data-phase="live"] .footer { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .fractured[data-phase="fracture"] .intrusion, .forged-draft.writing p::after { animation: none; }
    body[data-phase="live"] .shell::before { animation: none; opacity: .65; }
}

.duel-thread {
    display: grid;
    gap: .45rem;
    margin: .75rem 0;
}
.duel-thread .line, .duel-forged {
    padding: .55rem .75rem;
}
.duel-thread .line.human {
    margin-inline-start: 1.6rem;
}
.duel-thread .speaker {
    font-size: .76rem;
    margin-bottom: .18rem;
}
.duel-words, .duel-forged p, .duel-forged s {
    font-size: 1rem;
    line-height: 1.38;
    overflow-wrap: anywhere;
}
.duel-quote {
    text-align: left;
    color: var(--ink);
    background: var(--surface);
    min-height: 3.15rem;
    width: 100%;
}
.duel-quote:hover { border-color: var(--acid); }
.duel-quote[aria-pressed="true"], .duel-proof {
    border-color: #c2a5e5;
    background: #352742;
}
.duel-quote[aria-pressed="true"] .speaker::after { content: " ✓"; }
.duel-forged {
    background: #33202a;
    border-left: 3px solid #d07a8b;
    color: var(--danger);
    margin-inline-start: 1.6rem;
    border-radius: .55rem;
}
.duel-forged .speaker { color: var(--danger); }
.duel-earlier { padding: .36rem .7rem; }
.duel-earlier .line { margin: .35rem 0; }
.duel-hold {
    padding: .7rem .82rem;
    border: 1px solid #7b9a84;
    border-radius: .6rem;
    background: #23342e;
}
.duel-hold strong { color: #bedfc7; }
.duel-hold p { margin: .15rem 0 0; }
