body {
    background-color: #0a0a0a;
    color: #33ff33;
    font-family: 'Courier New', Courier, monospace;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    user-select: none;
}

/* Creates the physical scanline texture */
body::after {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%);
    background-size: 100% 4px;
    z-index: 999;
    pointer-events: none;
}

/* The Flicker (Noticeable Voltage Hum) */
@keyframes crt-flicker {
    0% {
        opacity: 0.98;
    }

    5% {
        opacity: 0.96;
    }

    10% {
        opacity: 0.99;
    }

    15% {
        opacity: 0.96;
    }

    20% {
        opacity: 0.99;
    }

    100% {
        opacity: 1;
    }
}

/* Creates a slow-rolling vertical synchronization bar */
body::before {
    content: " ";
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(to bottom, rgba(51, 255, 51, 0), rgba(51, 255, 51, 0.04) 50%, rgba(51, 255, 51, 0));
    background-size: 100% 20vh;
    animation: crt-scan-roll 10s linear infinite;
    z-index: 998;
    pointer-events: none;
}

@keyframes crt-scan-roll {
    0% {
        transform: translateY(-20vh);
    }

    100% {
        transform: translateY(100vh);
    }
}

body {
    animation: crt-flicker 0.15s infinite;
}

#waterfall {
    width: 100%;
    height: 200px;
    display: block;
    border-bottom: 1px solid #33ff33;
    opacity: 0.9;
}

#terminal-wrapper {
    padding: 2% 5% 5% 5%;
    max-width: 900px;
    margin: 0 auto;
}

.term-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0a0a0c;
    border-bottom: 1px solid #1c1c24;
    padding: 6px 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #8a8a9e;
}

.term-header h1 {
    font-size: 0.95rem;
    color: #e0e0e0;
    margin: 0;
    letter-spacing: 1.5px;
    font-weight: bold;
}

/* Compact Telemetry Readout Container */
.telemetry-readout {
    display: flex;
    align-items: center;
    gap: 6px;
}

.telemetry-readout .stat {
    font-weight: bold;
    color: #777788;
}

.telemetry-readout .stat strong {
    margin-left: 2px;
}

.telemetry-divider {
    color: #333344;
    margin: 0 2px;
}

/* Tight Band Tag Group */
.band-group {
    display: flex;
    align-items: center;
    gap: 3px;
}

.band-tag {
    padding: 1px 5px;
    border: 1px solid #22222e;
    border-radius: 2px;
    background: #050508;
    font-weight: bold;
    font-size: 0.75rem;
}

h1 {
    font-size: 1.1rem;
    letter-spacing: 2px;
    margin: 0;
}

.cls-btn {
    background: transparent;
    border: 1px solid #33ff33;
    color: #33ff33;
    font-family: inherit;
    font-size: 0.8rem;
    padding: 2px 8px;
    cursor: pointer;
    letter-spacing: 1px;
}

.cls-btn:hover {
    background-color: #33ff33;
    color: #0a0a0a;
}

/* Scrollable Terminal Output Box */
#terminal-output {
    height: 280px;
    overflow-y: auto;
    border: 1px solid rgba(51, 255, 51, 0.2);
    background-color: rgba(5, 5, 5, 0.6);
    padding: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    user-select: text;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

#terminal-output::-webkit-scrollbar {
    width: 8px;
}

#terminal-output::-webkit-scrollbar-track {
    background: #0a0a0a;
}

#terminal-output::-webkit-scrollbar-thumb {
    background: #115511;
    border: 1px solid #33ff33;
}

/* Message Colors */
.msg-system {
    color: #33ff33;
    opacity: 0.85;
    margin-bottom: 6px;
}

.msg-user {
    white-space: pre-wrap;
    /* This forces HTML to render \n as a line break */
    color: #ff9933;
    margin: 8px 0 4px 0;
    font-weight: bold;
}

.msg-collins {
    color: #00d2ff;
    margin: 4px 0 12px 0;
    line-height: 1.4;
}

.msg-error {
    color: #ff3333;
    margin: 6px 0;
}

/* Input Bar Area */
.input-line {
    display: flex;
    align-items: center;
    margin-top: 10px;
    background-color: rgba(5, 5, 5, 0.8);
    border: 1px solid #33ff33;
    padding: 6px 10px;
}

.prompt-symbol {
    color: #ff9933;
    font-weight: bold;
    margin-right: 8px;
}

#term-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #ff9933;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95rem;
}

#audio-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(10, 10, 10, 0.92);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.auth-btn {
    border: 1px solid #33ff33;
    padding: 20px;
    text-align: center;
    font-weight: bold;
    letter-spacing: 2px;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.story-ribbon {
    display: flex;
    overflow-x: auto;
    gap: 15px;
    padding: 15px 0;
    border-top: 1px solid rgba(51, 255, 51, 0.3);
    margin-top: 20px;
}

/* Story Ribbon Horizontal Scrollbar */
.story-ribbon::-webkit-scrollbar {
    height: 8px;
}

.story-ribbon::-webkit-scrollbar-track {
    background: #0a0a0a;
}

.story-ribbon::-webkit-scrollbar-thumb {
    background: #115511;
    border: 1px solid #33ff33;
}

.story-card {
    flex: 0 0 auto;
    width: 250px;
    border: 1px solid #33ff33;
    background: rgba(5, 5, 5, 0.8);
    cursor: pointer;
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.story-card:hover {
    background: rgba(51, 255, 51, 0.1);
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(51, 255, 51, 0.2);
}

.story-thumb {
    width: 100%;
    height: 140px;
    background-color: #080808;
    border-bottom: 1px solid #33ff33;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.8;
    transition: opacity 0.2s, background-color 0.2s;
}

.story-card:hover .story-thumb {
    opacity: 1;
    background-color: #112211;
}

.story-info {
    padding: 10px;
}

.story-title {
    color: #ff9933;
    font-weight: bold;
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.story-desc {
    color: #e0e0e0;
    font-size: 0.8rem;
}

#reader-panel {
    display: none;
    border: 1px solid #33ff33;
    background-color: #0a0a0a;
    margin-top: 15px;
    padding: 40px 20px 20px 20px;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: #111;
    color: #33ff33;
    border: 1px solid #33ff33;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    padding: 5px 10px;
}

.close-btn:hover {
    background: #33ff33;
    color: #000;
}

/* --- RESTORED STORY STYLES --- */
.transcript-wrapper {
    font-family: 'Courier New', Courier, monospace;
    color: #33ff33;
    background-color: rgba(5, 5, 5, 0.85);
    border: 1px solid rgba(51, 255, 51, 0.4);
    padding: 20px;
    max-width: 800px;
    margin: 20px auto;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.9);
    text-shadow: 0 0 3px rgba(51, 255, 51, 0.4);
}

.transcript-header {
    border-bottom: 1px dotted #33ff33;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.meta-data {
    color: #ff9933;
    font-size: 0.85rem;
    margin: 2px 0;
}

.speaker-host {
    color: #33ff33;
    font-weight: bold;
    margin-top: 15px;
}

.speaker-guest {
    color: #ff9933;
    font-weight: bold;
    margin-top: 15px;
}

.speaker-collins {
    color: #00d2ff;
    font-weight: bold;
    margin-top: 15px;
    text-transform: uppercase;
}

.dialogue {
    color: #e0e0e0;
    margin-top: 5px;
    line-height: 1.5;
    margin-left: 15px;
}

.dialogue-para {
    margin-bottom: 10px;
}

.sfx-block {
    color: #888888;
    font-style: italic;
    margin: 15px 0;
    text-align: center;
    letter-spacing: 1px;
}

.status-green,
.band-green {
    color: #00FF41 !important;
    text-shadow: 0 0 5px rgba(0, 255, 65, 0.4);
}

.status-yellow,
.band-yellow {
    color: #FFB000 !important;
    text-shadow: 0 0 5px rgba(255, 176, 0, 0.4);
}

.status-red,
.band-red {
    color: #FF3333 !important;
    text-shadow: 0 0 5px rgba(255, 51, 51, 0.4);
}

.status-gray {
    color: #555566;
}

/* --- REASONING / SCRATCHPAD LOG --- */
.reasoning-block {
    color: #cc8833;
    font-style: italic;
    font-size: 0.9em;
    border-left: 2px solid #cc8833;
    padding-left: 10px;
    margin: 8px 0;
    opacity: 0.85;
}

/* --- LUA WASM SANDBOX --- */
.lua-sandbox {
    background-color: rgba(0, 50, 100, 0.3);
    border-left: 2px solid #00d2ff;
    padding: 10px;
    margin: 10px 0;
    font-family: 'Courier New', Courier, monospace;
}

.lua-code {
    color: #88ccff;
    margin-bottom: 8px;
}

.lua-result {
    color: #ffffff;
    font-weight: bold;
    border-top: 1px dashed rgba(0, 210, 255, 0.4);
    padding-top: 5px;
}

/* Ensure the prompt and the text align at the top as it grows */
.input-line {
    display: flex;
    align-items: flex-start;
}

/* Match the prompt's line-height to the textarea so they align perfectly */
.prompt-symbol {
    margin-right: 8px;
    line-height: 1.5;
}

/* Style the textarea to look like a clean terminal input */
#term-input {
    width: 100%;
    background: transparent;
    border: none;
    color: inherit;
    /* Inherit your terminal green color */
    font-family: inherit;
    /* Inherit your terminal monospace font */
    font-size: 1rem;
    outline: none;
    resize: none;
    /* Disables the manual drag-to-resize handle */
    overflow-y: hidden;
    /* Hides the scrollbar as it expands */
    line-height: 1.5;
    padding: 0;
    margin: 0;
    word-wrap: break-word;
    /* Automatically breaks on spaces/hyphens */
}

/* Inline code snippet */
.inline-code {
    background: #112211;
    color: #ffb700;
    padding: 2px 5px;
    font-family: 'Courier New', monospace;
    border-radius: 3px;
}

/* Multiline code blocks */
.code-block {
    background: #081408;
    border: 1px solid #115511;
    color: #88ff88;
    padding: 8px 12px;
    margin: 8px 0;
    font-family: 'Courier New', monospace;
    overflow-x: auto;
}

/* Bold accenting */
#terminal-output strong {
    color: #ffffff;
    font-weight: bold;
}

/* Tactical Terminal Tables */
.term-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    border: 1px solid #115511;
}

.term-table th,
.term-table td {
    border: 1px solid #115511;
    padding: 8px 12px;
    text-align: left;
}

.term-table th {
    background-color: #0a1f0a;
    color: #88ff88;
    font-weight: bold;
    text-transform: uppercase;
}

.term-table tr:nth-child(even) {
    background-color: #051005;
}