:root {
    color-scheme: dark;
    --amber: #ffd27a;
    --amber-bright: #ffe8b4;
    --amber-muted: #b78b48;
    --amber-dim: #765729;
    --screen: #17110a;
    --screen-warm: #2b1f0f;
    --bezel: #3a3026;
    --bezel-edge: #746047;
    --ink: #f8d797;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
    background: #15110e;
    color: var(--ink);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #15110e; }

body {
    margin: 0;
    min-height: 100dvh;
    padding: clamp(12px, 2.4vw, 36px);
    background:
        radial-gradient(circle at 50% 10%, rgba(116, 83, 40, .22), transparent 38rem),
        linear-gradient(145deg, #1c1713, #0f0d0b 70%);
}

button, input { font: inherit; }

button, .file-control { -webkit-tap-highlight-color: transparent; }

.crt-console {
    width: min(1240px, 100%);
    margin: 0 auto;
    padding: 12px 12px 18px;
    border: 1px solid var(--bezel-edge);
    border-radius: 24px;
    background:
        linear-gradient(155deg, rgba(255,255,255,.06), transparent 20%),
        var(--bezel);
    box-shadow:
        0 34px 90px rgba(0,0,0,.55),
        inset 0 1px 0 rgba(255,255,255,.09),
        inset 0 -3px 8px rgba(0,0,0,.38);
}

.console-header {
    height: 34px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #c4a87e;
    font-size: .68rem;
    letter-spacing: .1em;
}

.power-state { display: inline-flex; align-items: center; gap: 8px; }
.power-state i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 9px var(--amber);
}

.crt-screen {
    position: relative;
    isolation: isolate;
    min-height: calc(100dvh - 116px);
    overflow: hidden;
    padding: clamp(20px, 3.4vw, 46px);
    border: 2px solid #19120b;
    border-radius: 38px / 26px;
    background:
        radial-gradient(ellipse at 50% 34%, rgba(72, 50, 20, .74), transparent 62%),
        var(--screen);
    box-shadow:
        inset 0 0 36px rgba(0,0,0,.95),
        inset 0 0 110px rgba(0,0,0,.72),
        0 0 0 4px #251c14,
        0 0 0 6px rgba(132,107,71,.55);
}

.screen-effects,
.crt-screen::before,
.crt-screen::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

.screen-effects {
    opacity: .19;
    background: repeating-linear-gradient(to bottom, transparent 0, transparent 3px, rgba(0,0,0,.52) 4px);
    mix-blend-mode: multiply;
}

.crt-screen::before {
    background: radial-gradient(ellipse at center, transparent 51%, rgba(0,0,0,.55) 100%);
}

.crt-screen::after {
    height: 18%;
    background: linear-gradient(to bottom, transparent, rgba(255,207,113,.035), transparent);
    animation: scan-sweep 9s linear infinite;
}

.screen-nav,
.hero,
.word-stage,
.signal-strip,
.debug-panel,
.screen-footer { position: relative; z-index: 2; }

.screen-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--amber-dim);
    font-size: .76rem;
    letter-spacing: .08em;
}

.brand { color: var(--amber-bright); text-decoration: none; font-weight: 800; }
.nav-status { color: var(--amber-muted); }

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
    gap: clamp(30px, 6vw, 84px);
    align-items: center;
    padding: clamp(50px, 8vw, 94px) 0 clamp(42px, 6vw, 72px);
}

.eyebrow {
    margin: 0;
    color: #dfa94e;
    font-size: .78rem;
    letter-spacing: .14em;
}

.cursor { animation: cursor-pulse 1.05s steps(1) infinite; }

h1 {
    margin: 18px 0 22px;
    color: var(--amber-bright);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(3.5rem, 7.5vw, 7.2rem);
    font-weight: 400;
    font-style: italic;
    line-height: .87;
    letter-spacing: -.055em;
    text-shadow:
        0 0 5px rgba(255,224,161,.48),
        0 0 25px rgba(255,185,60,.21),
        0 0 55px rgba(255,171,35,.11);
}

.intro {
    max-width: 58ch;
    margin: 0 0 28px;
    color: #d4b474;
    font-size: clamp(.9rem, 1.2vw, 1.02rem);
    line-height: 1.7;
}

.file-control {
    position: relative;
    display: inline-flex;
    padding: 12px 17px;
    border: 1px solid var(--amber);
    background: var(--amber);
    color: #21170b;
    font-size: .74rem;
    font-weight: 900;
    letter-spacing: .06em;
    cursor: pointer;
    transition: transform 160ms ease, filter 160ms ease;
}

.file-control:hover { filter: brightness(1.08); }
.file-control:active { transform: scale(.98); }
.file-control:focus-within { outline: 2px solid var(--amber-bright); outline-offset: 4px; }
.file-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-note { margin: 10px 0 0; color: #876632; font-size: .62rem; letter-spacing: .08em; }

.session-panel {
    padding: 18px;
    border: 1px solid var(--amber-dim);
    background: rgba(10, 7, 4, .58);
    box-shadow: inset 0 0 28px rgba(255,190,70,.035);
}

.panel-title {
    display: flex;
    justify-content: space-between;
    padding-bottom: 10px;
    border-bottom: 1px dashed #624921;
    color: #a87f40;
    font-size: .64rem;
}

.terminal-status {
    min-height: 3em;
    padding: 18px 0 10px;
    color: var(--amber-bright);
    font-size: .8rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

progress {
    width: 100%;
    height: 7px;
    border: 1px solid #624921;
    background: #100c07;
    accent-color: var(--amber);
}

progress::-webkit-progress-bar { background: #100c07; }
progress::-webkit-progress-value { background: var(--amber); box-shadow: 0 0 8px rgba(255,210,122,.5); }

.controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 16px;
}

button {
    min-height: 38px;
    border: 1px solid #765a2b;
    border-radius: 0;
    background: transparent;
    color: var(--amber);
    font-size: .67rem;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

button:not(:disabled):hover { background: var(--amber); color: #21170b; }
button:not(:disabled):active { transform: scale(.97); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--amber-bright); outline-offset: 3px; }
button:disabled { opacity: .28; cursor: not-allowed; }

.tempo-control,
.toggle {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    color: #a98142;
    font-size: .64rem;
}

.toggle { grid-template-columns: auto 1fr; }
.tempo-control input { width: 100%; accent-color: var(--amber); }

.word-stage {
    min-height: clamp(360px, 52vw, 610px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(34px, 6vw, 70px) 0 28px;
    border-top: 1px solid var(--amber-dim);
}

.stage-label { color: #876632; font-size: .65rem; letter-spacing: .14em; }

.word {
    width: 100%;
    min-height: 1.2em;
    margin: 24px 0 40px;
    color: var(--amber-bright);
    text-align: center;
    font-size: clamp(4.5rem, 13vw, 12.5rem);
    font-weight: 800;
    line-height: .92;
    letter-spacing: -.055em;
    overflow-wrap: anywhere;
    text-shadow: 0 0 7px rgba(255,224,161,.55), 0 0 35px rgba(255,183,54,.22);
}

.metadata {
    width: min(900px, 100%);
    margin: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--amber-dim);
    border-bottom: 1px solid var(--amber-dim);
}

.metadata > div { padding: 16px 10px; text-align: center; }
.metadata > div + div { border-left: 1px solid var(--amber-dim); }
dt { color: #8f6b34; font-size: .58rem; letter-spacing: .08em; }
dd { margin: 7px 0 0; color: var(--amber); font-size: 1rem; font-variant-numeric: tabular-nums; }

.api-state { margin-top: 14px; min-height: 1.4em; color: #96703a; font-size: .68rem; }
.api-state.error { color: #ff9d74; }

.signal-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--amber-dim);
    border-bottom: 1px solid var(--amber-dim);
}

.signal-strip > div { padding: 18px; }
.signal-strip > div + div { border-left: 1px solid var(--amber-dim); }
.signal-strip b { display: block; color: var(--amber); font-size: .7rem; }
.signal-strip span { display: block; margin-top: 5px; color: #8f6b34; font-size: .62rem; }

.debug-panel { padding: 18px 0; color: #98733c; font-size: .68rem; }
.debug-panel summary { cursor: pointer; }
.debug-panel pre {
    max-height: 220px;
    overflow: auto;
    margin: 14px 0 0;
    padding: 14px;
    border: 1px dashed #56401e;
    background: rgba(8,6,4,.55);
    color: #ba9250;
    white-space: pre-wrap;
    line-height: 1.5;
}

.screen-footer {
    display: flex;
    justify-content: space-between;
    padding-top: 17px;
    border-top: 1px solid var(--amber-dim);
    color: #76582b;
    font-size: .58rem;
    letter-spacing: .08em;
}

@keyframes cursor-pulse { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .16; } }
@keyframes scan-sweep { from { transform: translateY(-120%); } to { transform: translateY(660%); } }

@media (max-width: 800px) {
    body { padding: 8px; }
    .crt-console { padding: 7px 7px 12px; border-radius: 16px; }
    .crt-screen { min-height: calc(100dvh - 70px); padding: 20px 16px; border-radius: 25px / 18px; }
    .nav-status { display: none; }
    .hero { grid-template-columns: 1fr; padding: 50px 0; }
    h1 { font-size: clamp(3.6rem, 18vw, 6.2rem); }
    .word { font-size: clamp(3.5rem, 20vw, 8rem); }
    .metadata { grid-template-columns: repeat(2, 1fr); }
    .metadata > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--amber-dim); }
    .metadata > div:nth-child(4) { border-top: 1px solid var(--amber-dim); }
    .signal-strip { grid-template-columns: 1fr; }
    .signal-strip > div + div { border-left: 0; border-top: 1px solid var(--amber-dim); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
