/* --- Base Retro Theme Setup --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: #0c100c;
    background-image:
        radial-gradient(ellipse at 50% 0%, rgba(40, 70, 40, 0.25), transparent 55%),
        radial-gradient(rgba(0, 0, 0, 0.85) 20%, transparent 20%),
        radial-gradient(rgba(100, 255, 120, 0.04) 1px, transparent 0);
    background-size: 100% 100%, 100% 100%, 18px 18px;
    background-position: 0 0, 0 0, 9px 9px;
    font-family: 'Share Tech Mono', monospace;
    color: #a9b7c6;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* CRT Screen Scanline Overlay */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 6px 100%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.18;
}

/* Subtle Fallout-style CRT flicker */
.scanline-flicker {
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.35) 100%);
    opacity: 0.4;
    animation: crtFlicker 8s infinite;
}

@keyframes crtFlicker {
    0%, 100% { opacity: 0.35; }
    48% { opacity: 0.4; }
    50% { opacity: 0.55; }
    52% { opacity: 0.38; }
}

.control-hint {
    font-size: 0.6rem;
    color: #6b8f6b;
    text-align: center;
    margin-top: 8px;
    line-height: 1.3;
    letter-spacing: 0.02em;
}

.viz-caption {
    font-size: 0.65rem;
    color: #5a7060;
    text-align: center;
    margin-top: 8px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* --- PHYSICS DEBUG TRACE PANEL --- */
.debug-panel {
    margin-top: 10px;
    background: #0a100c;
    border: 1px solid #1a3a24;
    border-radius: 3px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.68rem;
    color: #8fbc8f;
    max-height: 280px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.debug-panel.is-collapsed {
    max-height: none;
}
.debug-panel.is-collapsed .debug-body {
    display: none !important;
}
.debug-header {
    flex-wrap: wrap;
    gap: 6px;
}
.debug-toggle-panel {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 2px 4px;
    min-height: 28px;
}
.debug-toggle-panel:hover .debug-title { color: #b8e0a0; }
.debug-chevron {
    display: inline-block;
    transition: transform 0.15s ease;
    color: #6a9a6a;
}
.debug-panel:not(.is-collapsed) .debug-chevron {
    transform: rotate(90deg);
}
.debug-header-tools {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    width: 100%;
}
.debug-panel:not(.is-collapsed) .debug-header-tools {
    display: flex;
}
.debug-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.debug-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 6px 8px;
    background: #121a14;
    border-bottom: 1px solid #1a3a24;
}
.debug-title {
    color: #ffb700;
    letter-spacing: 0.06em;
    margin-right: 4px;
}
.debug-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #6b8f6b;
    cursor: pointer;
    user-select: none;
}
.debug-toggle input { accent-color: #00ff66; }
.btn-dbg {
    font-family: inherit;
    font-size: 0.62rem;
    padding: 2px 7px;
    background: #1a2820;
    color: #8fbc8f;
    border: 1px solid #2a4a34;
    cursor: pointer;
}
.btn-dbg:hover {
    background: #243830;
    color: #00ff88;
    border-color: #00ff66;
}
.debug-live {
    padding: 6px 8px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 2px 10px;
    border-bottom: 1px solid #1a3a24;
    background: #0c140e;
    max-height: 110px;
    overflow-y: auto;
}
.debug-live .kv {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.debug-live .k { color: #5a7a5a; }
.debug-live .v { color: #c8f0c8; }
.debug-live .v.warn { color: #ffb700; }
.debug-live .v.bad { color: #ff5555; }
.debug-live .v.good { color: #00ff88; }
.debug-log {
    flex: 1;
    min-height: 90px;
    max-height: 140px;
    margin: 0;
    padding: 6px 8px;
    overflow: auto;
    font-size: 0.62rem;
    line-height: 1.35;
    color: #7a9a7a;
    white-space: pre-wrap;
    word-break: break-word;
    scrollbar-width: thin;
    scrollbar-color: #2a4a34 transparent;
}
.debug-log .ev-warn { color: #ffb700; }
.debug-log .ev-error { color: #ff6666; }
.debug-log .ev-mark { color: #66ccff; }
.debug-log .ev-phase { color: #e0a0ff; }

/* Outer Cabinet Frame */
.console-cabinet {
    width: 100%;
    max-width: 1500px;
    background-color: #2b3036;
    border: 8px solid #1a1c1e;
    border-radius: 8px;
    box-shadow: 
        inset 0 0 40px rgba(0, 0, 0, 0.8),
        0 15px 35px rgba(0, 0, 0, 0.9);
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Console Panel Structure - 1960s Scientific Metal Plate */
.panel {
    position: relative;
    background: linear-gradient(135deg, #32383e, #3a4148);
    border: 3px solid #23272b;
    border-top-color: #4b535b;
    border-left-color: #4b535b;
    border-radius: 4px;
    box-shadow: 
        inset 0 1px 3px rgba(255, 255, 255, 0.1),
        0 4px 10px rgba(0, 0, 0, 0.5);
    padding: 20px;
}

/* Industrial Rivet / Flat Screw Details */
.screws {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #4f5860;
    border: 1px solid #1a1c1e;
    border-radius: 50%;
    box-shadow: inset 1px 1px 2px rgba(255, 255, 255, 0.2);
}
.screws::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 1px;
    width: 8px;
    height: 1px;
    background-color: #1a1c1e;
}
.screws.top-left { top: 6px; left: 6px; transform: rotate(35deg); }
.screws.top-right { top: 6px; right: 6px; transform: rotate(-45deg); }
.screws.bottom-left { bottom: 6px; left: 6px; transform: rotate(15deg); }
.screws.bottom-right { bottom: 6px; right: 6px; transform: rotate(80deg); }

/* --- HEADER PANEL --- */
.header-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, #24292e, #1c2024);
    border: 3px solid #101214;
    padding: 15px 30px;
}

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

.radiation-symbol {
    font-size: 3rem;
    color: #ffb700;
    text-shadow: 0 0 10px rgba(255, 183, 0, 0.4);
    animation: rotateSlow 20s linear infinite;
}

h1 {
    font-size: 1.6rem;
    font-family: 'Share Tech Mono', monospace;
    color: #e2e8f0;
    letter-spacing: 2px;
    text-shadow: 1px 1px 2px #000;
}

h2 {
    font-size: 0.9rem;
    color: #ffb700;
    letter-spacing: 1px;
    font-weight: 300;
}

/* Annunciator Warning Lights */
.status-annunciators {
    display: grid;
    grid-template-columns: repeat(4, 130px);
    gap: 8px;
}

.annunciator-lamp {
    height: 36px;
    background-color: #101214;
    border: 2px solid #2d3238;
    border-radius: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: #3b424a;
    text-align: center;
    text-transform: uppercase;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8);
    transition: all 0.2s ease;
}

.annunciator-lamp.normal.active {
    background-color: #1f3d1f;
    color: #00ff66;
    border-color: #00ff66;
    text-shadow: 0 0 10px #00ff66;
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.4);
}

.annunciator-lamp.warning.active {
    background-color: #4a3c19;
    color: #ffb700;
    border-color: #ffb700;
    text-shadow: 0 0 10px #ffb700;
    box-shadow: 0 0 8px rgba(255, 183, 0, 0.4);
}

.annunciator-lamp.scram.active {
    background-color: #4d1515;
    color: #ff3b30;
    border-color: #ff3b30;
    text-shadow: 0 0 10px #ff3b30;
    box-shadow: 0 0 8px rgba(255, 59, 48, 0.4);
    animation: flashLamp 1s infinite alternate;
}

.annunciator-lamp.drain.active {
    background-color: #472b4f;
    color: #e040fb;
    border-color: #e040fb;
    text-shadow: 0 0 10px #e040fb;
    box-shadow: 0 0 8px rgba(224, 64, 251, 0.4);
    animation: flashLamp 1.5s infinite alternate;
}

/* --- MAIN LAYOUT --- */
.console-layout {
    display: grid;
    grid-template-columns: 360px 1fr 380px;
    gap: 15px;
}

h3 {
    font-size: 0.95rem;
    color: #ffb700;
    border-bottom: 2px solid #23272b;
    padding-bottom: 8px;
    margin-bottom: 15px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* --- LEFT PANEL: CONTROLS --- */
.control-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Auto cold-start sequencer strip */
.auto-start-bar {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
    background: rgba(0, 40, 20, 0.35);
    border: 1px solid #1a4a2a;
    border-radius: 4px;
    padding: 8px;
}
.auto-start-switch {
    flex: 0 0 auto;
    min-width: 110px;
}
.auto-start-phase {
    flex: 1;
    font-family: 'VT323', monospace;
    font-size: 1.15rem;
    color: #00ff88;
    text-shadow: 0 0 8px rgba(0, 255, 100, 0.45);
    display: flex;
    align-items: center;
    line-height: 1.2;
    letter-spacing: 0.5px;
    border-left: 1px solid #1a4a2a;
    padding-left: 10px;
}
.auto-start-phase.done {
    color: #8fbc8f;
    text-shadow: none;
}
.auto-start-phase.warn {
    color: #ffb700;
}

/* Switch Grid */
.control-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    background: rgba(0, 0, 0, 0.15);
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #23272b;
    margin-bottom: 15px;
}

.switch-widget {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, #373e44, #2a2f34);
    border: 1px solid #1a1c1e;
    padding: 8px;
    border-radius: 2px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.widget-label {
    font-size: 0.65rem;
    color: #8c9ba5;
    text-transform: uppercase;
    margin-bottom: 6px;
    text-align: center;
}

/* Heavy Duty Toggle Switch — UP = ON, DOWN = OFF (missile-switch metaphor) */
.switch {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 52px;
    background-color: #151719;
    border: 2px solid #3c444a;
    border-radius: 2px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}

.switch::before,
.switch::after {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    font-family: "Share Tech Mono", monospace;
    font-size: 0.48rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    pointer-events: none;
    z-index: 0;
    line-height: 1;
}
.switch::before {
    content: "ON";
    top: 3px;
    color: rgba(0, 255, 102, 0.35);
}
.switch::after {
    content: "OFF";
    bottom: 3px;
    color: rgba(255, 59, 48, 0.4);
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.slider-switch {
    position: absolute;
    cursor: pointer;
    z-index: 1;
    left: 2px;
    right: 2px;
    height: 22px;
    /* Default OFF = paddle DOWN */
    top: auto;
    bottom: 2px;
    background: linear-gradient(to bottom, #7e8790, #4b535a);
    border: 1px solid #1a1c1e;
    border-radius: 1px;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.2);
    transition:
        top 0.15s cubic-bezier(0.4, 0, 0.2, 1),
        bottom 0.15s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.15s ease;
}

.slider-switch::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 2px;
    background-color: #1a1c1e;
    transform: translateY(-50%);
}

/* ON = paddle UP */
.switch input:checked + .slider-switch {
    top: 2px;
    bottom: auto;
    background: linear-gradient(to bottom, #a5d6a7, #2e7d32);
    box-shadow:
        0 2px 4px rgba(0,0,0,0.35),
        inset 0 1px 0 rgba(255,255,255,0.35),
        0 0 8px rgba(0, 255, 100, 0.25);
}

.switch:has(input:checked)::before {
    color: rgba(0, 255, 102, 0.85);
}
.switch:has(input:checked)::after {
    color: rgba(255, 59, 48, 0.25);
}
.switch:not(:has(input:checked))::before {
    color: rgba(0, 255, 102, 0.22);
}
.switch:not(:has(input:checked))::after {
    color: rgba(255, 59, 48, 0.75);
}

.switch-status {
    font-size: 0.7rem;
    font-weight: bold;
    color: #ff3b30;
    margin-top: 6px;
}
.switch-status.active {
    color: #00ff66;
    text-shadow: 0 0 5px rgba(0, 255, 102, 0.5);
}

/* Slider Levers (Control Rods) */
.lever-group {
    background: rgba(0, 0, 0, 0.15);
    padding: 12px;
    border-radius: 4px;
    border: 1px solid #23272b;
    margin-bottom: 15px;
}
.lever-group label {
    font-size: 0.7rem;
    color: #ffb700;
    display: block;
    margin-bottom: 8px;
    text-align: center;
}
.lever-container {
    display: flex;
    align-items: center;
    gap: 10px;
}
.lever-limit {
    font-size: 0.65rem;
    color: #8c9ba5;
    white-space: nowrap;
}

input[type=range].lever {
    -webkit-appearance: none;
    flex: 1;
    height: 12px;
    background: #151719;
    border: 2px solid #3c444a;
    border-radius: 6px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}
input[type=range].lever::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 3px;
    background: linear-gradient(135deg, #8a929b, #3e444a);
    border: 2px solid #1c2024;
    cursor: pointer;
    box-shadow: 
        0 2px 5px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Dial and Rotary Inputs */
.dial-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}
.dial-control {
    background: rgba(0,0,0,0.15);
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #23272b;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.dial-control input[type=range] {
    -webkit-appearance: none;
    width: 90%;
    height: 6px;
    background: #151719;
    border-radius: 3px;
    margin: 10px 0;
}
.dial-control input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle, #8a929b 20%, #32383e 80%);
    border: 2px solid #1a1c1e;
    cursor: pointer;
}
#readout-load-demand, #readout-speed {
    font-family: 'VT323', monospace;
    font-size: 1.4rem;
    color: #00ff66;
    text-shadow: 0 0 5px rgba(0, 255, 102, 0.4);
}

/* Mission Deck Drawer */
.deck-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid #23272b;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 15px;
}
.deck-section h4 {
    font-size: 0.75rem;
    color: #ffb700;
    margin-bottom: 8px;
    text-align: center;
}
.mission-deck {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: 10px;
}
.btn-mission {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.65rem;
    background: #24292e;
    color: #8c9ba5;
    border: 1px solid #3c444a;
    padding: 6px;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}
.btn-mission:hover {
    background: #373e44;
    color: #ffb700;
}
.btn-mission.active {
    background: #005020;
    color: #00ff66;
    border-color: #00ff66;
    text-shadow: 0 0 5px rgba(0,255,102,0.5);
    box-shadow: inset 0 0 5px rgba(0,255,102,0.3);
}

/* CRT Screen Subcomponents */
.crt-screen {
    position: relative;
    background-color: #070f07;
    border: 4px solid #1a1c1e;
    box-shadow: 
        inset 0 0 20px rgba(0, 255, 102, 0.2),
        0 4px 6px rgba(0,0,0,0.3);
    overflow: hidden;
}
.crt-glow-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 255, 102, 0.08) 0%, transparent 80%);
    pointer-events: none;
    z-index: 2;
}

.mini-screen {
    padding: 10px;
    font-size: 0.75rem;
    height: 100px;
    overflow-y: auto;
}
.mini-screen h5 {
    font-family: 'Special Elite', cursive;
    color: #ffa726;
    margin-bottom: 4px;
}
.mini-screen p {
    font-family: 'Special Elite', cursive;
    color: #d1d5db;
    line-height: 1.25;
}

/* Giant Red SCRAM Switch */
.btn-emergency-scram {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.95rem;
    font-weight: bold;
    background: linear-gradient(to bottom, #d32f2f, #9a0007);
    color: #fff;
    border: 3px solid #5f0909;
    border-radius: 4px;
    padding: 12px;
    width: 100%;
    cursor: pointer;
    box-shadow: 
        0 5px 0 #5f0909,
        0 8px 15px rgba(0,0,0,0.5);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    transition: all 0.1s ease;
}
.btn-emergency-scram:active {
    transform: translateY(4px);
    box-shadow: 
        0 1px 0 #5f0909,
        0 3px 6px rgba(0,0,0,0.5);
}
.scram-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}
.btn-clear-scram {
    appearance: none;
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    font-family: "Share Tech Mono", monospace;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    color: #c8e0c8;
    background: linear-gradient(180deg, #2a3a2c, #1a241c);
    border: 2px solid #3a5a40;
    border-radius: 3px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.btn-clear-scram:hover:not(:disabled) {
    border-color: #6aaa58;
    color: #e8ffe8;
}
.btn-clear-scram:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    color: #6a7a6a;
}


/* --- CENTER PANEL: 3D VISUALIZER --- */

/* --- View mode toggle (3D / 2D) --- */
.viz-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.viz-head h3 {
    margin: 0;
    flex: 1 1 auto;
}
.viz-mode-toggle {
    display: inline-flex;
    border: 1px solid #5a6a60;
    border-radius: 4px;
    overflow: hidden;
    background: #1a221c;
    flex-shrink: 0;
}
.btn-viz-mode {
    appearance: none;
    border: 0;
    margin: 0;
    padding: 6px 14px;
    min-height: 32px;
    min-width: 48px;
    font-family: "Share Tech Mono", monospace;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    cursor: pointer;
    color: #8a9a90;
    background: transparent;
    border-right: 1px solid #3a4a40;
}
.btn-viz-mode:last-child { border-right: 0; }
.btn-viz-mode:hover { color: #cfe8d8; background: rgba(80, 120, 90, 0.25); }
.btn-viz-mode.active {
    color: #0a120e;
    background: linear-gradient(180deg, #b8e0a0 0%, #6aaa58 100%);
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(255,255,255,0.25);
}
.btn-viz-mode:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.btn-viz-mode:focus-visible {
    outline: 2px solid #a87a2d;
    outline-offset: -2px;
}

.visual-panel {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 600px;
    min-width: 0;
    overflow: hidden;
}
#canvas-container {
    flex: 1 1 auto;
    flex-shrink: 0;
    width: 100%;
    min-width: 0;
    /* Never allow flex thrash to collapse the plant view */
    min-height: 480px;
    height: 520px;
    background: radial-gradient(ellipse at 50% 40%, #2a3a32 0%, #151c18 70%);
    border: 2px solid #3a4a40;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
#canvas-container canvas {
    display: block !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    touch-action: none;
}
#canvas-container .viz-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    color: #ff6b6b;
    font-size: 0.85rem;
    z-index: 2;
    background: rgba(20, 0, 0, 0.75);
}
#canvas-container .viz-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    padding: 6px 10px;
    font-size: 0.68rem;
    letter-spacing: 0.03em;
    text-align: center;
    color: #ffcc66;
    background: rgba(40, 28, 0, 0.82);
    border-bottom: 1px solid rgba(255, 180, 0, 0.35);
    pointer-events: none;
}
#canvas-container .plant-2d-canvas {
    display: block !important;
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* --- RIGHT PANEL: CO-PILOT AGENT --- */
.diagnostics-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.main-crt {
    padding: 15px;
    height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-radius: 4px;
}

.agent-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(0, 255, 102, 0.2);
    padding-bottom: 8px;
    z-index: 3;
}
.agent-avatar {
    font-size: 2.2rem;
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.5);
}
.agent-title {
    display: flex;
    flex-direction: column;
}
.agent-name {
    font-size: 0.95rem;
    font-weight: bold;
    color: #00ff66;
    text-shadow: 0 0 5px rgba(0,255,102,0.6);
}
.agent-subtitle {
    font-size: 0.65rem;
    color: #81c784;
}

.agent-speech-bubble {
    font-size: 0.8rem;
    color: #c8e6c9;
    line-height: 1.4;
    height: 100px;
    overflow-y: auto;
    padding: 5px 0;
    z-index: 3;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 255, 102, 0.3) transparent;
}

.agent-faq-deck {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    z-index: 3;
}
.agent-faq-deck button {
    font-family: 'Share Tech Mono', monospace;
    font-size: 0.6rem;
    background: transparent;
    color: #81c784;
    border: 1px solid rgba(0, 255, 102, 0.3);
    padding: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.agent-faq-deck button:hover {
    background: rgba(0, 255, 102, 0.1);
    color: #00ff66;
    border-color: #00ff66;
}

/* Nixie Tube Digital Display Panel */
.nixie-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}
.nixie-tube {
    background-color: #120b05;
    border: 2px solid #231c15;
    border-radius: 4px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 
        inset 0 0 10px rgba(0,0,0,0.9),
        0 2px 4px rgba(0,0,0,0.4);
}
.nixie-label {
    font-size: 0.6rem;
    color: #7b8893;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.nixie-val {
    font-family: 'VT323', monospace;
    font-size: 1.9rem;
    color: #ff5500;
    text-shadow: 
        0 0 10px rgba(255, 85, 0, 0.8),
        0 0 2px rgba(255, 85, 0, 0.5);
    letter-spacing: 1px;
}

/* --- BOTTOM PANEL: STRIP CHART RECORDER --- */
/* Chart.js needs a sized, overflow-hidden parent — never flex-size the canvas itself */
.telemetry-panel {
    width: 100%;
    min-width: 0;
    overflow: hidden;
}
.charts-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    height: 200px;
    min-height: 200px;
    max-height: 200px;
    min-width: 0;
    overflow: hidden;
}
.chart-recorder {
    background-color: #070708;
    border: 2px solid #1a1c1e;
    border-radius: 2px;
    padding: 6px 8px 8px;
    position: relative;
    height: 100%;
    min-height: 0;
    min-width: 0; /* allow grid item shrink */
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}
.chart-title {
    flex: 0 0 auto;
    font-size: 0.6rem;
    color: #78909c;
    letter-spacing: 1px;
    margin-bottom: 4px;
    text-transform: uppercase;
    border-bottom: 1px solid #1c2024;
    padding-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Absolute-fill wrapper is the Chart.js-recommended containment pattern */
.chart-canvas-wrap {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.chart-canvas-wrap canvas {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    display: block;
}

/* --- SAFETY DRAIN EMERGENCY OVERLAY --- */
.drain-emergency-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 12, 12, 0.95);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
}
.alert-content {
    background: linear-gradient(135deg, #3a1515, #220b0b);
    border: 4px solid #f44336;
    border-radius: 8px;
    padding: 40px;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 0 50px rgba(244, 67, 54, 0.4);
}
.flash-alert {
    font-family: 'Share Tech Mono', monospace;
    font-size: 2.2rem;
    color: #ff3b30;
    text-shadow: 0 0 10px rgba(255, 59, 48, 0.5);
    margin-bottom: 15px;
    animation: flashAlertText 1s infinite alternate;
}
.alert-content h2 {
    color: #ffb700;
    font-size: 1.2rem;
    margin-bottom: 20px;
}
.alert-content p {
    font-size: 0.95rem;
    color: #cfd8dc;
    line-height: 1.6;
    margin-bottom: 30px;
}
.btn-reset-core {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1rem;
    font-weight: bold;
    background-color: #00e676;
    color: #120b05;
    border: none;
    border-radius: 4px;
    padding: 12px 30px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 230, 118, 0.4);
    transition: all 0.2s ease;
}
.btn-reset-core:hover {
    background-color: #00ff88;
    box-shadow: 0 6px 15px rgba(0, 230, 118, 0.6);
}

/* --- ANIMATION KEYFRAMES --- */
@keyframes rotateSlow {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes flashLamp {
    0% { opacity: 0.3; filter: brightness(0.6); }
    100% { opacity: 1; filter: brightness(1.2); }
}

@keyframes flashAlertText {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Responsive Scaling & Mobile/Tablet Friendliness */
@media (max-width: 1200px) {
    .console-layout {
        grid-template-columns: 1fr;
    }
    .visual-panel {
        height: 480px;
        min-height: 480px;
    }
    #canvas-container {
        min-height: 380px;
        height: 400px;
    }
    .charts-row {
        grid-template-columns: 1fr 1fr;
        height: auto;
        min-height: 0;
        max-height: none;
        grid-auto-rows: 180px;
    }
    .chart-recorder {
        height: 180px;
        max-height: 180px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    .console-cabinet {
        border-width: 4px;
        padding: 8px;
        gap: 10px;
    }
    .header-panel {
        flex-direction: column;
        gap: 15px;
        align-items: center;
        text-align: center;
        padding: 15px 10px;
    }
    .status-annunciators {
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
        max-width: 320px;
    }
    .annunciator-lamp {
        height: 32px;
        font-size: 0.65rem;
    }
    .visual-panel {
        height: 380px;
        min-height: 380px;
    }
    #canvas-container {
        min-height: 280px;
        height: 300px;
    }
    .charts-row {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        grid-auto-rows: 160px;
    }
    .chart-recorder {
        height: 160px;
        max-height: 160px;
    }
    .nixie-panel {
        grid-template-columns: 1fr;
    }
}