/* Elysium System interface */

:root {
    --bg: #07090C;
    --surface: rgba(9, 12, 16, 0.78);
    --surface-solid: #0B0E12;
    --line: rgba(255, 255, 255, 0.12);
    --line-soft: rgba(255, 255, 255, 0.08);
    --text: #EDF1F3;
    --text-2: #A3ADB5;
    --text-3: #7C8791;
    --accent: #5CE1E6;
    --accent-ink: #04181A;
    --accent-soft: rgba(92, 225, 230, 0.08);
    --quantum: #FFB454;
    --radius-panel: 20px;
    --radius-ctl: 12px;
    --font-body: 'Space Grotesk', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --font-brand: 'Bruno Ace SC', var(--font-body);
    --edge: 32px;
    --fade: 3000ms;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.45;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--text-2); text-decoration: none; }
a:hover { color: var(--text); }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}
.i {
    width: 20px; height: 20px; flex-shrink: 0;
    fill: none; stroke: currentColor; stroke-width: 1.75;
    stroke-linecap: round; stroke-linejoin: round;
}
.mono { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.13em; text-transform: uppercase; }
.mono.small { font-size: 11px; }
.accent { color: var(--accent); }
.muted { color: var(--text-2); }
.wordmark { font-family: var(--font-brand); letter-spacing: 0.14em; white-space: nowrap; }
.panel {
    background: var(--surface);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border: 1px solid var(--line-soft);
}
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Stage (full-screen frames) ---------- */

.stage { position: fixed; inset: 0; overflow: hidden; background: var(--bg); }
.frame {
    position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: cover; object-position: center 30%;
    opacity: 0; transition: opacity var(--fade) ease, filter .6s ease;
}
.frame.visible { opacity: 1; }
.frame.kb { animation: kenburns 32s ease-out forwards; }
@keyframes kenburns { from { transform: scale(1.03); } to { transform: scale(1.16); } }
.stage.quantum .frame { filter: saturate(1.35) hue-rotate(-12deg) contrast(1.06); }

/* Quantum Core: scanlines plus periodic slice glitches. --frame-url is the
   current frame, set by stage.js, so the torn slices are the real image */
.stage::before, .stage::after {
    content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .6s;
}
.stage::before {
    z-index: 1; background: var(--frame-url, none) center 30% / cover no-repeat;
    mix-blend-mode: screen; filter: hue-rotate(150deg) saturate(3) contrast(1.2);
}
.stage::after {
    z-index: 3;
    background: repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px);
}
.stage.quantum::after { opacity: 1; }
.stage.quantum::before { opacity: .85; animation: qslice 5.2s steps(1) infinite; }
.stage.quantum .frame.visible.kb { animation: kenburns 32s ease-out forwards, qjitter 5.2s steps(1) infinite; }
@keyframes qslice {
    0%, 84%, 100% { clip-path: inset(0 0 100% 0); translate: 0 0; }
    85% { clip-path: inset(18% 0 64% 0); translate: -18px 0; }
    87% { clip-path: inset(52% 0 33% 0); translate: 22px 0; }
    89% { clip-path: inset(7% 0 81% 0); translate: -10px 0; }
    91% { clip-path: inset(70% 0 12% 0); translate: 14px 0; }
    93% { clip-path: inset(34% 0 50% 0); translate: -24px 0; }
    95% { clip-path: inset(0 0 100% 0); translate: 0 0; }
}
@keyframes qjitter {
    0%, 84%, 96%, 100% { translate: 0 0; }
    86% { translate: 6px 0; }
    88% { translate: -8px 2px; }
    90% { translate: 4px -2px; }
    94% { translate: -3px 0; }
}

.scrim { position: absolute; left: 0; right: 0; pointer-events: none; z-index: 2; }
.scrim-top { top: 0; height: 160px; background: linear-gradient(0deg, rgba(7,9,12,0) 0%, rgba(7,9,12,0.7) 100%); }
.scrim-bottom { bottom: 0; height: 60%; background: linear-gradient(180deg, rgba(7,9,12,0) 0%, rgba(7,9,12,0.55) 45%, rgba(7,9,12,0.9) 100%); }
body.on-landing .scrim-bottom { opacity: .5; }

.scan {
    position: absolute; left: 0; width: 100%; height: 2px; top: 0; z-index: 3;
    background: rgba(92, 225, 230, 0.8);
    box-shadow: 0 0 24px 6px rgba(92, 225, 230, 0.35);
    opacity: 0; pointer-events: none;
}
.stage.developing .scan { opacity: 1; animation: scan 2.4s linear infinite; }
@keyframes scan { from { top: 0%; } to { top: 100%; } }

/* ---------- Shared controls ---------- */

.text-input {
    width: 100%; height: 48px; padding: 0 16px;
    border-radius: var(--radius-ctl); border: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.38); color: var(--text);
    font-size: 16px; outline: none; transition: border-color .2s;
}
.text-input::placeholder { color: var(--text-3); }
.text-input:focus { border-color: rgba(92, 225, 230, 0.6); }

.btn-primary {
    height: 56px; display: inline-flex; align-items: center; gap: 12px; padding: 0 28px;
    border-radius: 14px; border: none; background: var(--accent); color: var(--accent-ink);
    font-size: 17px; font-weight: 600; transition: filter .2s, transform .2s;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .6; }
.btn-primary.compact { height: 44px; padding: 0 20px; font-size: 15px; }

.icon-btn {
    width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-ctl); border: 1px solid var(--line); background: transparent; color: var(--text);
    transition: border-color .2s, color .2s;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { border-color: rgba(92, 225, 230, 0.6); color: var(--accent); }
.icon-btn.panel { background: var(--surface); }

.ghost-btn {
    height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px;
    border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text);
    font-size: 13px; white-space: nowrap; transition: border-color .2s, color .2s;
}
.ghost-btn .i { width: 16px; height: 16px; }
.ghost-btn:hover:not(:disabled) { border-color: rgba(92, 225, 230, 0.6); color: var(--accent); }
.ghost-btn:disabled { opacity: .45; }
.ghost-btn.compact { height: 36px; }
.ghost-btn.danger { border-color: rgba(255, 180, 84, 0.6); color: var(--quantum); }
.ghost-btn.busy .i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.switch-btn {
    width: 44px; height: 26px; flex-shrink: 0; position: relative; padding: 0;
    border-radius: 999px; border: none; background: rgba(255, 255, 255, 0.22); transition: background .2s;
}
.switch-btn span {
    position: absolute; top: 4px; left: 4px; width: 18px; height: 18px;
    border-radius: 999px; background: var(--bg); transition: left .2s;
}
.switch-btn[aria-checked="true"] { background: var(--accent); }
.switch-btn[aria-checked="true"] span { left: 22px; }

/* ---------- Landing ---------- */

.landing {
    position: fixed; inset: 0; overflow-y: auto; animation: rise .6s ease-out;
    display: flex; flex-direction: column;
}
.landing-scrim {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(900px, 100%); pointer-events: none;
    background: linear-gradient(90deg, rgba(7,9,12,0.94) 0%, rgba(7,9,12,0.8) 55%, rgba(7,9,12,0) 100%);
}
.landing-header {
    position: relative; display: flex; align-items: center; justify-content: space-between; gap: 24px;
    padding: 36px 64px 0 96px;
}
.landing-header .wordmark { font-size: 22px; }
.landing-nav { display: flex; gap: 32px; font-size: 15px; }
.link-btn { background: none; border: none; padding: 0; color: var(--text-2); }
.link-btn:hover { color: var(--text); }

.landing-body {
    position: relative; flex-grow: 1; width: min(736px, 100%); margin: 0; padding: 48px 0 40px 96px;
    display: flex; flex-direction: column; justify-content: center; gap: 24px;
}
.eyebrow { margin: 0 0 -8px; color: var(--accent); }
.landing-body h1 { margin: 0; font-size: 58px; line-height: 1.04; font-weight: 600; letter-spacing: -0.02em; }
.lede { margin: 0; max-width: 520px; font-size: 19px; line-height: 1.5; color: var(--text-2); }
.field { display: flex; flex-direction: column; gap: 10px; }
.field label, .field-label { font-size: 15px; }
.field .text-input { height: 52px; font-size: 17px; border-color: rgba(255,255,255,0.16); background: rgba(0,0,0,0.4); }

.modes { margin: 0; padding: 0; border: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.mode {
    position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
    padding: 20px; border-radius: 16px; cursor: pointer;
    background: rgba(9, 12, 16, 0.72); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    border: 1.5px solid rgba(255, 255, 255, 0.14); transition: border-color .2s, background .2s;
}
.mode:hover { border-color: rgba(92, 225, 230, 0.7); }
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode:has(input:checked) { border-color: var(--accent); background: rgba(92, 225, 230, 0.08); }
.mode:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-icon { width: 22px; height: 22px; color: var(--text-2); }
.mode:has(input:checked) .mode-icon, .mode:has(input:checked) .mode-tag { color: var(--accent); }
.mode-title { font-size: 18px; font-weight: 500; }
.mode-desc { font-size: 14px; line-height: 1.45; color: var(--text-2); }
.mode-tag { font-size: 11px; color: var(--text-3); }

.cta-row { display: flex; align-items: center; gap: 20px; }
.hint { max-width: 280px; font-size: 14px; line-height: 1.45; color: var(--text-2); }

.landing-body > :not(h1):not(.eyebrow) { max-width: 600px; }
.landing-footer {
    position: relative; display: flex; justify-content: space-between; gap: 16px;
    padding: 0 64px 28px 96px; font-size: 11px; color: var(--text-3);
}
body.leaving .landing { animation: leave .5s ease-in forwards; }
@keyframes leave { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Session ---------- */

.session { position: fixed; inset: 0; animation: rise .6s ease-out; }

.topbar {
    position: absolute; left: var(--edge); right: var(--edge); top: 24px; z-index: 5;
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 24px;
}
.brand { height: 44px; display: flex; align-items: center; gap: 16px; min-width: 0; }
#round-label { white-space: nowrap; }
.brand .wordmark { font-size: 20px; }
.divider { width: 1px; height: 20px; background: rgba(255, 255, 255, 0.2); }

.objective {
    min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-radius: 22px;
    max-width: min(560px, 40vw); min-width: 0; border-color: var(--line); color: var(--text);
    text-align: left; transition: border-color .2s;
}
.objective:hover { border-color: rgba(92, 225, 230, 0.5); }
.objective .i { width: 18px; height: 18px; }
.objective .mono { flex-shrink: 0; }
.objective-text { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.objective[aria-expanded="true"] { align-items: flex-start; max-width: min(640px, 48vw); background: rgba(9, 12, 16, 0.92); border-color: rgba(92, 225, 230, 0.5); }
.objective[aria-expanded="true"] .i, .objective[aria-expanded="true"] .mono { margin-top: 2px; }
.objective[aria-expanded="true"] .objective-text { white-space: normal; overflow: visible; line-height: 1.5; font-size: 15px; }

.controls { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.pill {
    height: 44px; display: inline-flex; align-items: center; gap: 10px; padding: 0 16px;
    border-radius: 999px; border-color: var(--line); color: var(--text); font-size: 14px;
    transition: border-color .2s, color .2s;
}
.pill .i { width: 18px; height: 18px; }
.pill:hover { border-color: rgba(92, 225, 230, 0.6); }
.pill .switch { width: 30px; height: 18px; border-radius: 999px; background: rgba(255,255,255,0.22); position: relative; transition: background .2s; }
.pill .switch span { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 999px; background: var(--bg); transition: left .2s; }
.pill[aria-pressed="true"] { color: var(--quantum); border-color: rgba(255, 180, 84, 0.7); }
.pill[aria-pressed="true"] .switch { background: var(--quantum); }
.pill[aria-pressed="true"] .switch span { left: 14px; }

/* Dock holds the story panel and the frame panel */
.dock {
    position: absolute; left: var(--edge); right: var(--edge); bottom: var(--edge); z-index: 4;
    display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; pointer-events: none;
}
.dock > * { pointer-events: auto; }

.story {
    width: min(720px, 100% - 356px); max-height: calc(100dvh - 130px); overflow-y: auto;
    padding: 24px 28px; border-radius: var(--radius-panel); border-color: rgba(255,255,255,0.1);
    display: flex; flex-direction: column; gap: 18px;
}
.story-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.speaker { display: flex; align-items: center; gap: 10px; }
.speaker .mono { text-transform: none; letter-spacing: 0.08em; }
.story-tools { display: flex; align-items: center; gap: 12px; }
.collapse-btn {
    width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--text-2);
    transition: border-color .2s, color .2s;
}
.collapse-btn:hover { border-color: rgba(92, 225, 230, 0.6); color: var(--accent); }
.collapse-btn .i { width: 16px; height: 16px; transition: transform .25s; }
.story.collapsed { gap: 10px; padding: 16px 22px; }
.story.collapsed .collapse-btn .i { transform: rotate(180deg); }
.story.collapsed .echo, .story.collapsed .kicker,
.story.collapsed .choices, .story.collapsed .composer { display: none !important; }
.story.collapsed .narrative {
    font-size: 17px; cursor: pointer; white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.story.collapsed .narrative:empty { display: none; }
.story.collapsed .thinking { padding: 2px 0; }
.story.collapsed .thinking .bar:nth-child(n+2) { display: none; }

/* Quantum Core on the story panel */
body.quantum .story { border-color: rgba(255, 180, 84, 0.35); }
body.quantum .dot { background: var(--quantum); box-shadow: 0 0 10px rgba(255, 180, 84, 0.8); }
body.quantum .narrative { animation: rise .5s ease-out, qtext 1.1s steps(1); }
@keyframes qtext {
    0% { text-shadow: 3px 0 rgba(255, 60, 90, 0.8), -3px 0 rgba(92, 225, 230, 0.8); }
    20% { text-shadow: -2px 0 rgba(255, 60, 90, 0.7), 2px 0 rgba(92, 225, 230, 0.7); }
    40% { text-shadow: 1px 0 rgba(255, 60, 90, 0.5), -1px 0 rgba(92, 225, 230, 0.5); }
    60%, 100% { text-shadow: none; }
}
.dot { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 10px rgba(92,225,230,0.8); }
.dot.busy { animation: pulse 1.2s ease-in-out infinite; }
.echo { margin: 0; display: flex; gap: 10px; font-size: 14px; color: var(--text-2); }
.echo .mono { font-size: 11px; color: var(--text-3); padding-top: 2px; }
.kicker { margin: 0 0 -8px; }
.narrative { margin: 0; font-size: 22px; line-height: 1.45; white-space: pre-line; animation: rise .5s ease-out; }
.narrative:empty { display: none; }

.thinking { display: flex; flex-direction: column; gap: 12px; padding: 6px 0; }
.thinking .bar {
    height: 16px; border-radius: 6px;
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, rgba(92,225,230,0.22) 50%, rgba(255,255,255,0.05) 100%);
    background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
.thinking .bar:nth-child(1) { width: 92%; }
.thinking .bar:nth-child(2) { width: 76%; }
.thinking .bar:nth-child(3) { width: 52%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choices:empty { display: none; }
.choice {
    display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 12px 16px;
    border-radius: 14px; border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.03);
    font-size: 16px; line-height: 1.35; text-align: left; animation: rise .45s ease-out both;
    transition: border-color .2s, background .2s, transform .2s;
}
.choice:nth-child(2) { animation-delay: .06s; }
.choice:nth-child(3) { animation-delay: .12s; }
.choice:hover:not(:disabled) { border-color: var(--accent); background: rgba(92,225,230,0.08); transform: translateX(3px); }
.choice:disabled { opacity: .45; }
.choice .key {
    width: 28px; height: 28px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid rgba(92,225,230,0.5); color: var(--accent);
    font-family: var(--font-mono); font-size: 13px;
}
.choice .label { flex-grow: 1; }
.choice .i { width: 18px; height: 18px; color: var(--text-3); }
.choice.primary { border-color: rgba(92,225,230,0.6); background: rgba(92,225,230,0.1); }

.suggestions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.suggestions .mono { font-size: 11px; color: var(--text-3); margin-right: 4px; }
.suggestion {
    min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
    background: rgba(255,255,255,0.03); font-size: 14px; transition: border-color .2s, color .2s;
}
.suggestion:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.composer { display: flex; gap: 10px; margin: 0; }
.composer .text-input { background: rgba(0,0,0,0.35); }
.send-btn {
    width: 48px; height: 48px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-ctl); border: none; background: var(--accent); color: var(--accent-ink);
}
.send-btn:disabled { opacity: .5; }

/* Frame panel */
.framebar {
    width: 332px; flex-shrink: 0; padding: 16px; border-radius: var(--radius-panel);
    border-color: rgba(255,255,255,0.1); display: flex; flex-direction: column; gap: 14px;
}
.frame-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.progress { height: 3px; border-radius: 999px; background: rgba(255,255,255,0.1); overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); animation: develop 7s cubic-bezier(.2,.7,.3,1) forwards; }
@keyframes develop { from { width: 4%; } to { width: 92%; } }
.filmstrip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.filmstrip:empty { display: none; }
.thumb {
    padding: 0; height: 44px; border-radius: 6px; overflow: hidden; border: 2px solid transparent;
    background: rgba(255,255,255,0.06); opacity: .6; transition: opacity .2s, border-color .2s;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { opacity: 1; }
.thumb[aria-current="true"] { border-color: var(--accent); opacity: 1; }
.frame-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }

/* Settings popover */
.settings {
    position: absolute; right: var(--edge); top: 80px; z-index: 6; width: 360px; padding: 20px;
    border-radius: 16px; border-color: var(--line); display: flex; flex-direction: column; gap: 18px;
    background: rgba(9, 12, 16, 0.92); animation: rise .25s ease-out;
}
.section { margin: 0; }
.divided { padding-top: 16px; border-top: 1px solid var(--line-soft); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.setting-text { display: flex; flex-direction: column; gap: 2px; }
.setting-title { font-size: 15px; }
.setting-desc { font-size: 13px; color: var(--text-2); }
.setting-stack { display: flex; flex-direction: column; gap: 8px; }
.segmented { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 10px; background: rgba(255,255,255,0.06); }
.segmented button { height: 34px; padding: 0 4px; border: none; border-radius: 7px; background: transparent; font-size: 12.5px; white-space: nowrap; }
.segmented button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.setting-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* Journey log drawer */
.log {
    position: absolute; right: 0; top: 0; bottom: 0; z-index: 7; width: 440px; max-width: 100%;
    padding: 28px; display: flex; flex-direction: column; gap: 20px;
    background: rgba(7, 9, 12, 0.94); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
    border-left: 1px solid rgba(255,255,255,0.1); animation: slide .3s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.log-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.log-heading { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.log-title { font-size: 20px; font-weight: 500; line-height: 1.3; }
.log-list { list-style: none; margin: 0; padding: 0; flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.log-list li { display: flex; flex-direction: column; gap: 6px; padding-left: 14px; border-left: 2px solid rgba(92,225,230,0.6); }
.log-list li.you { border-left-color: rgba(255,255,255,0.18); }
.log-list .who { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; color: var(--accent); }
.log-list li.you .who, .log-list li.you .text { color: var(--text-2); }
.log-list .text { font-size: 15px; line-height: 1.5; white-space: pre-line; }
.wide-btn {
    height: 48px; display: flex; align-items: center; justify-content: center; gap: 10px;
    border-radius: var(--radius-ctl); border: 1px solid rgba(92,225,230,0.5); background: var(--accent-soft);
    color: var(--accent); font-size: 15px;
}
.wide-btn:disabled { opacity: .5; }

/* Toasts */
.toasts {
    position: absolute; top: 84px; left: 50%; transform: translateX(-50%); z-index: 8;
    width: min(520px, calc(100% - 32px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px;
    border-radius: 14px; border: 1px solid var(--line); background: rgba(9, 12, 16, 0.92);
    -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); animation: rise .3s ease-out;
}
.toast.warn { border-color: rgba(255, 180, 84, 0.5); }
.toast.warn > .i { color: var(--quantum); }
.toast .toast-text { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.toast .toast-sub { font-size: 13px; color: var(--text-2); }
.toast .ghost-btn { height: 34px; }
.toast .ghost-btn.warn { border-color: rgba(255, 180, 84, 0.6); color: var(--quantum); }

/* Dialogs */
.dialog {
    width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 48px); padding: 0; overflow: auto;
    border-radius: 20px; border: 1px solid var(--line); background: var(--surface-solid); color: var(--text);
}
.dialog.narrow { width: min(420px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(4, 6, 8, 0.72); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.dialog[open] { animation: rise .25s ease-out; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 20px 0 28px; }
.dialog-head h2 { margin: 0; font-size: 22px; font-weight: 500; }
.dialog-body { padding: 8px 28px 24px; display: flex; flex-direction: column; gap: 10px; }
.dialog-body p { margin: 0; line-height: 1.55; }
.dialog-body h3 { margin: 12px 0 0; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 28px 24px; }
.dialog .error { color: var(--quantum); font-size: 14px; }
kbd { font-family: var(--font-mono); font-size: 13px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- Narrower desktops ---------- */

@media (max-width: 1180px) {
    .brand .divider, .brand #round-label { display: none; }
    .pill-label { display: none; }
}

/* ---------- Mobile ---------- */

@media (max-width: 760px) {
    :root { --edge: 16px; }

    .landing-header { padding: 20px 16px 0; }
    .landing-header .wordmark { font-size: 17px; }
    .landing-nav { gap: 18px; font-size: 14px; }
    .landing-nav a { display: none; }
    .landing-scrim { width: 100%; background: linear-gradient(180deg, rgba(7,9,12,0.55) 0%, rgba(7,9,12,0.92) 45%); }
    .landing-body { padding: 48px 16px 96px; gap: 22px; }
    .landing-body h1 { font-size: 40px; }
    .lede { font-size: 16px; }
    .modes { grid-template-columns: 1fr; }
    .mode { padding: 16px; }
    .cta-row { flex-direction: column; align-items: stretch; gap: 12px; }
    .btn-primary { justify-content: center; }
    .hint { max-width: none; text-align: center; }
    .landing-footer { position: static; padding: 0 16px 24px; flex-direction: column; gap: 6px; }

    .topbar { top: 16px; grid-template-columns: 1fr auto; row-gap: 10px; }
    .brand .wordmark { font-size: 16px; }
    .objective { grid-row: 2; grid-column: 1 / -1; max-width: none; padding: 8px 14px; min-height: 40px; }
    .objective[aria-expanded="true"] { max-width: none; }
    .story.collapsed { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
    .collapse-btn { width: 44px; height: 44px; }
    .objective .mono { display: none; }
    .objective-text { font-size: 13px; }
    .controls { gap: 8px; }
    .pill { width: 44px; padding: 0; justify-content: center; }
    .pill .switch { display: none; }

    .dock { left: 0; right: 0; bottom: 0; flex-direction: column-reverse; align-items: stretch; gap: 10px; }
    .story {
        width: 100%; max-height: 62dvh; border-radius: 24px 24px 0 0; border-width: 1px 0 0;
        padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); gap: 14px;
        background: var(--surface-solid);
    }
    .narrative { font-size: 17px; }
    .choice { font-size: 15px; padding: 10px 14px; }

    .framebar {
        width: auto; margin: 0 16px; padding: 0; gap: 8px; border: none;
        background: none; -webkit-backdrop-filter: none; backdrop-filter: none;
        flex-direction: row; align-items: center; justify-content: space-between;
    }
    .framebar .frame-head { padding: 6px 10px; border-radius: 999px; background: rgba(9,12,16,0.72); }
    .framebar .progress, .framebar .filmstrip { display: none; }
    .frame-actions { display: flex; gap: 6px; }
    .frame-actions .ghost-btn { width: 44px; height: 44px; padding: 0; background: rgba(9,12,16,0.72); }
    .frame-actions .ghost-btn span { display: none; }

    .settings { left: 16px; right: 16px; width: auto; top: 128px; }
    .setting-actions { grid-template-columns: 1fr; }
    .log { width: 100%; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
    .toasts { top: 124px; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
    .frame { transition-duration: 0ms !important; }
    .stage.developing .scan { opacity: 0; }
    .progress div { width: 60%; }
}
