:root {
    --bg-color: #050a10;
    --terminal-green: #33ff33;
    --terminal-dim: #1a801a;
    --alert-red: #ff3333;
    --cold-blue: #a8d5e5;
    --deep-blue: #4a90e2;
    --warning-amber: #ffcc00;
    --dev-grey: #666666;
    --panel-bg: rgba(10, 20, 30, 0.95);
    --font-stack: 'Courier New', Courier, monospace;
}

* { box-sizing: border-box; }

body {
    background-color: var(--bg-color);
    color: var(--terminal-green);
    font-family: var(--font-stack);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-shadow: 0 0 2px rgba(51, 255, 51, 0.4);
    user-select: none;
}

/* High-Res CRT Effect */
body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: 
        linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%), 
        linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
    z-index: 1000;
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
}

/* BOOT SEQUENCE OVERLAY */
#boot-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000;
    z-index: 5000;
    display: flex; flex-direction: column; justify-content: flex-end; padding: 50px;
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    color: var(--terminal-green);
}
.boot-line { margin-bottom: 10px; display: none; }
.boot-error { color: var(--alert-red); }
.boot-system { color: var(--cold-blue); }
.boot-hack { color: var(--terminal-green); text-shadow: 0 0 5px var(--terminal-green); font-weight: bold; }

/* LAYOUT GRID */
.main-layout {
    display: grid;
    grid-template-rows: 60px 1fr 30px;
    height: 100%;
    opacity: 0; /* Hidden until boot finishes */
    transition: opacity 2s;
}

/* HEADER */
header {
    border-bottom: 2px solid var(--terminal-dim);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #000;
    z-index: 10;
}

.seal {
    font-weight: bold;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.compromised-text {
    color: var(--alert-red);
    animation: flash-red 1s infinite;
}

@keyframes flash-red {
    0%, 100% { opacity: 1; color: var(--alert-red); }
    50% { opacity: 0.3; color: #ff6666; }
}

.seal-icon {
    border: 1px solid var(--terminal-green);
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    font-size: 0.8rem;
}

.header-controls {
    display: flex;
    gap: 20px;
    align-items: center;
}

.protocol-btn {
    background: transparent;
    border: 1px solid var(--warning-amber);
    color: var(--warning-amber);
    padding: 5px 10px;
    font-family: inherit;
    cursor: pointer;
    font-size: 0.8rem;
    animation: pulse-amber 3s infinite;
}

.protocol-btn:hover { background: rgba(255, 204, 0, 0.1); }

/* CONTENT AREA */
.workspace {
    display: grid;
    grid-template-columns: 320px 1fr;
    overflow: hidden;
}

/* SIDEBAR NAV */
aside {
    border-right: 1px solid var(--terminal-dim);
    padding: 20px 0;
    background: #000;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--terminal-dim);
    padding: 15px 20px;
    text-align: left;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-btn:hover {
    color: var(--terminal-green);
    background: rgba(51, 255, 51, 0.05);
}

.nav-btn.active {
    color: var(--terminal-green);
    border-left: 3px solid var(--terminal-green);
    background: rgba(51, 255, 51, 0.1);
    font-weight: bold;
}

.nav-btn.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

/* VIEWPORT (Where the modules load) */
.viewport {
    position: relative;
    overflow-y: auto;
    background: radial-gradient(circle at center, #0a141e 0%, #000 100%);
    padding: 0;
}

/* MODULES (Hidden by default) */
.module { display: none; height: 100%; width: 100%; }
.module.active { display: flex; flex-direction: column; }

/* FOOTER */
footer {
    border-top: 1px solid var(--terminal-dim);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    background: #000;
    color: #666;
}

/* ==================== ARCHIVE / LIST STYLES ==================== */

.archive-grid { display: grid; grid-template-columns: 420px 1fr; gap: 20px; height: 100%; padding: 20px;}
.file-list { border-right: 1px dashed var(--terminal-dim); padding-right: 10px; overflow-y: auto; height: 100%; }

.act-header {
    color: var(--cold-blue);
    font-weight: bold;
    border-bottom: 1px solid var(--terminal-dim);
    margin-top: 20px;
    margin-bottom: 5px;
    padding-bottom: 2px;
    font-size: 0.85rem;
}
.act-header:first-child { margin-top: 0; }

.file-item { 
    padding: 10px; 
    cursor: pointer; 
    opacity: 0.8; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    font-size: 0.85rem;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.file-item:hover { opacity: 1; background: rgba(51,255,51,0.1); }
.file-item.active { border-left: 2px solid var(--terminal-green); opacity: 1; background: rgba(51,255,51,0.05); font-weight: bold; }

/* LOCKED FILES */
.file-item.locked-secure {
    color: var(--dev-grey);
    cursor: not-allowed;
    background: rgba(0,0,0,0.3);
}
.file-item.locked-secure:hover {
    background: rgba(255, 0, 0, 0.1);
    color: var(--alert-red);
}

/* DECRYPTING FILES */
.file-item.decrypting {
    color: var(--warning-amber);
    cursor: progress;
    background: rgba(255, 204, 0, 0.1);
    animation: pulse-amber 2s infinite;
}
.file-item.decrypting:hover {
    background: rgba(255, 204, 0, 0.2);
}

/* PROCESSING FILES */
.file-item.processing {
    color: var(--deep-blue);
    cursor: wait;
    background: rgba(74, 144, 226, 0.12);
    animation: pulse-deep-blue 1.8s infinite;
}
.file-item.processing:hover {
    background: rgba(74, 144, 226, 0.2);
    opacity: 0.8;
}

/* RECEIVING FILES */
.file-item.receiving {
    color: var(--cold-blue);
    cursor: wait;
    background: rgba(168, 213, 229, 0.12);
    animation: pulse-receiving 1.5s infinite;
}
.file-item.receiving:hover {
    background: rgba(168, 213, 229, 0.2);
}

/* STATUS TAGS */
.status-tag { font-size: 0.7rem; padding: 2px 4px; border-radius: 2px; margin-left: 5px; font-weight: bold; }
.tag-audio { color: #000; background: var(--terminal-green); }
.tag-video { color: #000; background: #ff9800; }
.tag-media { color: #000; background: var(--warning-amber); }
.tag-dev { color: #ccc; background: var(--dev-grey); border: 1px solid #555; }
.tag-locked { color: #000; background: var(--alert-red); }
.tag-decrypting { color: #000; background: var(--warning-amber); animation: pulse-amber 2s infinite; }
.tag-processing { color: #000; background: var(--deep-blue); animation: pulse-deep-blue 1.8s infinite; }
.tag-receiving { color: #000; background: var(--cold-blue); animation: pulse-receiving 1.5s infinite; }

.preview-pane { 
    background: rgba(0,0,0,0.5); 
    border: 1px solid var(--terminal-dim); 
    padding: 20px; 
    display: flex; 
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

.timeline { height: 20px; display: flex; margin-bottom: 20px; border: 1px solid #333; margin: 20px;}
.t-seg { height: 100%; position: relative; border-right: 1px solid #000; }
.t-seg:last-child { border-right: none; }
.t-seg:hover::after {
    content: attr(title);
    position: absolute; top: -25px; left: 0;
    background: #000; border: 1px solid currentColor;
    padding: 2px 5px; font-size: 0.7rem; white-space: nowrap; z-index: 10;
}

/* NEW MUSIC PLAYER STYLES */
.spotify-embed {
    width: 100%;
    height: 152px;
    background: #222;
    border: 1px solid var(--terminal-green);
    display: flex; justify-content: center; align-items: center;
    margin-bottom: 20px;
    color: #888;
}

.lyric-sheet {
    flex-grow: 1;
    overflow-y: auto;
    border: 1px solid #333;
    padding: 20px;
    font-family: 'Courier New', monospace;
    line-height: 1.8;
    background: rgba(0,0,0,0.3);
}

.lyric-line { margin-bottom: 10px; }
.speaker-tag { color: var(--cold-blue); font-weight: bold; margin-right: 10px; }

/* Puzzle Elements */
.redacted {
    background: #111; color: #444; cursor: pointer; padding: 0 5px;
    border-bottom: 1px dashed var(--terminal-green); transition: all 0.2s;
}
.redacted:hover { color: var(--terminal-green); background: #000; }
.redacted.revealed { background: var(--terminal-green); color: #000; animation: none; }

.tuner-container { border: 1px solid var(--cold-blue); padding: 10px; text-align: center; margin: 20px 0; }
.tuner-display { font-size: 1.5rem; color: var(--cold-blue); font-family: 'Courier New'; }
.tuner-slider { width: 100%; cursor: crosshair; }

.censor-word { cursor: crosshair; border-bottom: 1px dotted #555; padding: 0 2px; }
.censor-word:hover { background: #222; }
.censor-word.censored { background-color: #000; color: #000; border: none; }

.progress-bar-container {
    margin-top: 10px; border: 1px solid #333; padding: 5px;
    display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem;
}

/* --- OTHER ZONES --- */
.sim-container {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; border: 1px solid var(--alert-red);
    box-shadow: inset 0 0 50px rgba(255,0,0,0.1);
}
.kill-switch-btn {
    width: 120px; height: 120px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #ff6666, #990000);
    border: 4px solid #500; color: #300; font-weight: bold; cursor: pointer;
    box-shadow: 0 0 20px rgba(255,0,0,0.5);
}
.orbit-viz {
    flex-grow: 1; position: relative; background: #000; overflow: hidden;
    display: flex; align-items: center; justify-content: center; border: 1px solid var(--cold-blue);
}
.planet { width: 100px; height: 100px; border-radius: 50%; background: radial-gradient(circle at 30% 30%, #1a4d66, #000); z-index: 2; }
.satellite { position: absolute; width: 6px; height: 6px; background: white; border-radius: 50%; animation: orbit 4s linear infinite; }

/* MODAL STYLES */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 2000;
    display: flex; justify-content: center; align-items: center;
}
.modal-content {
    background: #050a10; border: 2px solid var(--warning-amber);
    width: 600px; max-width: 90%; padding: 30px; color: #ccc;
    box-shadow: 0 0 30px rgba(255, 204, 0, 0.1);
}
.hidden { display: none !important; }

/* ANIMATIONS */
@keyframes pulse-amber { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; text-shadow: 0 0 5px var(--warning-amber); } }
@keyframes pulse-deep-blue { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; text-shadow: 0 0 5px var(--deep-blue); } }
@keyframes pulse-receiving { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; text-shadow: 0 0 5px var(--cold-blue); } }
@keyframes orbit { from { transform: rotate(0deg) translateX(150px) rotate(0deg); } to { transform: rotate(360deg) translateX(150px) rotate(-360deg); } }
@keyframes unlockFlash { 
    0% { background-color: var(--terminal-green); color: black; transform: scale(1.02); } 
    100% { transform: scale(1); } 
}
.unlocked-anim { animation: unlockFlash 1s ease-out; }

/* CUSTOM ALERT STYLES */
.alert-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(20, 0, 0, 0.8); z-index: 3000;
    display: flex; justify-content: center; align-items: center;
    backdrop-filter: blur(2px);
}

.alert-box {
    background: #0a0000;
    border: 2px solid var(--alert-red);
    width: 400px; max-width: 80%;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.3);
    font-family: var(--font-stack);
    animation: alertShake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

.alert-header {
    background: var(--alert-red);
    color: black;
    font-weight: bold;
    padding: 5px 10px;
    font-size: 0.9rem;
    display: flex; justify-content: space-between;
}

.alert-body {
    padding: 20px;
    color: var(--alert-red);
    text-align: center;
    font-size: 1rem;
    line-height: 1.4;
}

.alert-btn {
    background: transparent;
    border: 1px solid var(--alert-red);
    color: var(--alert-red);
    padding: 8px 20px;
    margin: 0 auto 20px auto;
    display: block;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: all 0.2s;
}

.alert-btn:hover {
    background: var(--alert-red);
    color: black;
}

@keyframes alertShake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Tablet and Mobile - Stack layout */
@media (max-width: 900px) {
    .main-layout {
        grid-template-rows: auto 1fr auto;
    }

    header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 10px;
    }

    .workspace {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    aside {
        border-right: none;
        border-bottom: 2px solid var(--terminal-dim);
        padding: 10px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-start;
        background: rgba(0, 0, 0, 0.9);
    }

    .nav-btn {
        flex: 1 1 45%;
        min-width: 140px;
        padding: 12px 10px;
        font-size: 0.85rem;
        text-align: center;
        white-space: normal;
        border-left: none;
        border-bottom: 3px solid transparent;
        border-radius: 3px;
        background: rgba(51, 255, 51, 0.03);
        transition: all 0.15s ease;
    }

    .nav-btn:hover,
    .nav-btn.active {
        border-left: none;
        border-bottom: 3px solid var(--terminal-green);
        background: rgba(51, 255, 51, 0.12);
        transform: translateY(-1px);
    }

    .nav-btn.active {
        font-weight: bold;
        color: var(--terminal-green);
        box-shadow: 0 2px 8px rgba(51, 255, 51, 0.2);
    }

    .viewport {
        margin-left: 0;
        overflow-y: visible;
    }

    .archive-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px;
    }

    .file-list {
        border-right: none;
        border-bottom: 1px dashed var(--terminal-dim);
        padding-right: 0;
        padding-bottom: 10px;
        max-height: 200px;
    }

    .preview-pane {
        padding: 15px;
    }

    .timeline {
        margin: 10px 0;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .alert-box {
        width: 95%;
    }
}

/* Mobile - Full width and compact */
@media (max-width: 600px) {
    body {
        font-size: 14px;
    }

    .main-layout {
        grid-template-rows: auto 1fr auto;
    }

    header {
        padding: 8px;
    }

    .seal {
        font-size: 0.9rem;
        gap: 5px;
    }

    .protocol-btn {
        font-size: 0.75rem;
        padding: 4px 8px;
    }

    aside {
        flex-direction: column;
        gap: 0;
        padding: 5px;
        background: rgba(0, 0, 0, 0.95);
        border-bottom: 2px solid var(--terminal-dim);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .nav-btn {
        flex: 1 1 100%;
        min-width: unset;
        margin-bottom: 4px;
        font-size: 0.9rem;
        padding: 14px 15px;
        text-align: center;
        border-left: none;
        border-bottom: 2px solid transparent;
        border-radius: 2px;
        background: rgba(51, 255, 51, 0.02);
        letter-spacing: 0.5px;
    }

    .nav-btn:hover {
        background: rgba(51, 255, 51, 0.08);
        border-bottom-color: var(--terminal-green);
    }

    .nav-btn.active {
        background: rgba(51, 255, 51, 0.15);
        border-bottom-color: var(--terminal-green);
        border-left: none;
        font-weight: bold;
        color: var(--terminal-green);
        box-shadow: inset 0 0 10px rgba(51, 255, 51, 0.1);
    }

    .nav-btn:last-child {
        margin-bottom: 0;
    }

    .viewport {
        padding: 10px;
    }

    .archive-grid {
        padding: 5px;
        gap: 10px;
    }

    .file-list {
        border-right: none;
        border-bottom: 1px dashed var(--terminal-dim);
        padding-right: 0;
        padding-bottom: 10px;
        max-height: 200px;
    }

    .file-item {
        font-size: 0.8rem;
        padding: 8px;
    }

    .act-header {
        font-size: 0.8rem;
        margin-top: 15px;
    }

    .preview-pane {
        padding: 10px;
    }

    .lyric-sheet {
        padding: 15px;
        font-size: 0.9rem;
    }

    .tuner-display {
        font-size: 1.2rem;
    }

    .kill-switch-btn {
        width: 100px;
        height: 100px;
    }

    .planet {
        width: 80px;
        height: 80px;
    }

    .modal-content {
        padding: 15px;
    }

    .alert-header {
        font-size: 0.8rem;
        padding: 4px 8px;
    }

    .alert-body {
        padding: 15px;
        font-size: 0.9rem;
    }

    .alert-btn {
        padding: 6px 15px;
    }
}

/* Extra small devices - Very compact */
@media (max-width: 400px) {
    body {
        font-size: 13px;
    }

    .seal {
        font-size: 0.8rem;
    }

    .nav-btn {
        font-size: 0.85rem;
        padding: 12px 10px;
        letter-spacing: 0;
    }

    .file-item {
        font-size: 0.75rem;
        padding: 6px;
    }

    .lyric-sheet {
        padding: 10px;
        font-size: 0.85rem;
    }

    .tuner-display {
        font-size: 1rem;
    }

    .kill-switch-btn {
        width: 80px;
        height: 80px;
    }

    .planet {
        width: 60px;
        height: 60px;
    }
}

/* High DPI screens - Reduce CRT effect for better readability */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body::after {
        background-size: 100% 2px, 2px 100%;
    }
}

/* Print styles - Remove CRT effect and dark background */
@media print {
    body::after {
        display: none;
    }
    body {
        background: white;
        color: black;
        overflow: visible;
    }
    .main-layout {
        opacity: 1;
    }
    #boot-overlay {
        display: none;
    }
    .nav-btn,
    .protocol-btn,
    .alert-btn {
        border: 1px solid black;
        color: black;
    }
}
