:root {
    --page: #070503;
    --bg: #0b0805;
    --bar-bg: #090604;
    --fg: #f3e7d3;
    --dim: #a68f70;
    --faint: #62533f;
    --accent: #ffb000;
    --accent-glow: 0 0 8px rgba(255, 176, 0, 0.55);
    --danger: #ff6b5e;
    --line: #22190d;
    --chip-bg: #150f07;
    --chip-border: #3a2a12;
    --font-mono: 'Fira Code', ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: var(--page);
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 17px;
    line-height: 1.65;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

::selection {
    background: var(--accent);
    color: var(--bg);
}

/* ---------- Colour / text utilities ---------- */
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.fg { color: var(--fg); }
.accent { color: var(--accent); }
.danger { color: var(--danger); }
.bold { font-weight: 700; }
/* Phosphor glow: accent elements only */
.glow { text-shadow: var(--accent-glow); }

a {
    color: var(--accent);
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}

a:hover,
a:focus-visible {
    text-shadow: var(--accent-glow);
    text-decoration-style: solid;
}

a:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- CRT overlay (whole viewport) ---------- */
.crt-scanlines,
.crt-vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
}

.crt-scanlines {
    background: repeating-linear-gradient(to bottom,
            rgba(0, 0, 0, 0) 0,
            rgba(0, 0, 0, 0) 2px,
            rgba(0, 0, 0, 0.14) 2px,
            rgba(0, 0, 0, 0.14) 3px);
}

.crt-vignette {
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.4) 100%);
}

/* ---------- Terminal layout ---------- */
.terminal-window {
    position: relative;
    z-index: 2;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.terminal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scrollbar-color: var(--chip-border) transparent;
}

.terminal-body::-webkit-scrollbar { width: 8px; }
.terminal-body::-webkit-scrollbar-track { background: transparent; }
.terminal-body::-webkit-scrollbar-thumb {
    background: var(--chip-border);
    border-radius: 4px;
}

.column {
    width: 100%;
    padding: 16px 20px;
}

.line {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.spacer { height: 12px; }
.echo { margin-top: 12px; }

/* ---------- Boot log ---------- */
.boot { color: var(--dim); }
.boot .ts { color: var(--faint); }

/* ---------- ls / help grids ---------- */
.ls {
    display: flex;
    flex-wrap: wrap;
    column-gap: 24px;
}

.dir {
    color: var(--accent);
    font-weight: 700;
}

.cmdlist {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    column-gap: 24px;
}

.art {
    white-space: pre;
    color: var(--accent);
    text-shadow: var(--accent-glow);
}

/* ---------- Spinner for remote commands ---------- */
.spinner::after {
    content: '|';
    display: inline-block;
    animation: spin 0.6s steps(4) infinite;
}

@keyframes spin {
    0% { content: '|'; }
    25% { content: '/'; }
    50% { content: '-'; }
    75% { content: '\\'; }
}

/* ---------- Prompt + input ---------- */
.dock { margin-top: 12px; }
.chips { display: none; }

.input-line {
    display: flex;
    gap: 10px;
    align-items: baseline;
}

.prompt { white-space: nowrap; }
.prompt-user { color: var(--accent); font-weight: 700; }
.prompt-path { color: var(--fg); font-weight: 700; }

.input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

/* Visible text mirror + block cursor; the real input sits invisibly on top. */
.mirror {
    display: block;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    min-height: 1.65em;
}

#cli-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    background: transparent;
    border: none;
    outline: none;
    color: transparent;
    caret-color: transparent;
    font-family: var(--font-mono);
    font-size: 17px; /* keep >= 16px so iOS does not zoom on focus */
    line-height: inherit;
}

.cursor {
    display: inline-block;
    width: 0.62em;
    height: 1.2em;
    vertical-align: -0.22em;
    background: var(--accent);
    box-shadow: var(--accent-glow);
    animation: blink 1.06s steps(1) infinite;
}

.input-line:not(:focus-within) .cursor {
    animation: none;
    background: transparent;
    box-shadow: none;
    outline: 1px solid var(--accent);
    outline-offset: -1px;
}

@keyframes blink {
    50% { opacity: 0; }
}

/* No prompt until login; opacity (not visibility) keeps the input focusable so Enter skips the boot. */
body.booting .input-line { opacity: 0; }
body.ended .dock { display: none; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .cursor,
    .spinner::after { animation: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
    body { font-size: 15px; }

    #cli-input { font-size: 16px; }

    .column {
        min-height: 100%;
        display: flex;
        flex-direction: column;
        padding: 12px 12px 0;
    }

    #output { flex: 0 0 auto; }

    .boot { font-size: 12px; line-height: 1.5; }
    .prompt-host { display: none; }

    /* Chips + input pinned to the bottom of the scroll area */
    .dock {
        position: sticky;
        bottom: 0;
        margin: auto -12px 0;
        padding: 10px 12px max(24px, env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        background: var(--bar-bg);
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .chips {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .chip {
        font: inherit;
        font-size: 15px;
        min-height: 44px;
        padding: 0 16px;
        border-radius: 6px;
        background: var(--chip-bg);
        color: var(--fg);
        border: 1px solid var(--chip-border);
        cursor: pointer;
    }

    .chip:active { background: var(--chip-border); }

    .input-line {
        min-height: 44px;
        align-items: center;
        gap: 8px;
    }
}
