:root {
    --border-color: #000;
    --bg-color: #fff;
    --text-color: #000;
    --spacing: clamp(16px, 1.5vw, 32px);
    --sidebar-width: clamp(260px, 22vw, 320px);
    --font-base: clamp(12px, 0.9vw, 14px);
}

* { box-sizing: border-box; }

html {
    font-size: var(--font-base);
}

body {
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    font-size: 1rem;
    line-height: 1.5;
    height: 100vh;
    overflow-x: hidden;
    text-transform: uppercase;
}

/* =========================================
   SHARED LAYOUT (Self-Contained)
   ========================================= */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.sidebar {
    border-right: 2px solid var(--border-color);
    padding: clamp(16px, 1.8vw, 24px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    background: #fff;
    z-index: 10;
    overflow-y: auto;
}

.main-content {
    height: 100%;
    overflow-y: auto;
    display: block; 
}

/* NAV */
.brand {
    font-weight: bold;
    font-size: clamp(1.1rem, 1.6vw, 1.5rem);
    margin-bottom: clamp(24px, 3vw, 40px);
    padding-bottom: clamp(12px, 1.5vw, 20px);
    border-bottom: 1px solid var(--border-color);
    letter-spacing: -1px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
}

.nav-item {
    display: block;
    padding: clamp(8px, 1vw, 14px);
    text-decoration: none;
    color: var(--text-color);
    border: 1px solid transparent;
    transition: all 0.1s;
    font-size: clamp(0.85rem, 1vw, 1rem);
}

.nav-item:hover, .nav-item.active {
    border: 1px solid var(--border-color);
    background: #000;
    color: #fff;
}

/* =========================================
   SIMULATOR SPECIFIC
   ========================================= */
.sim-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.controls-area {
    padding: clamp(20px, 2.5vw, 36px);
    border-bottom: 2px solid #000;
    background: #fff;
    flex-shrink: 0;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    flex-grow: 1;
}

.system-col {
    padding: clamp(20px, 2.5vw, 36px);
    border-right: 2px solid #000;
    overflow-y: auto;
    position: relative;
    background: #fff;
}
.system-col:last-child { border-right: none; }

h1, h2, h3 { font-weight: bold; margin-bottom: 1rem; }
h2 { text-decoration: underline; font-size: 1.2rem; }

/* Widgets */
.counter-display {
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    font-weight: 900;
    margin: clamp(12px, 1.5vw, 24px) 0;
}

.integrity-wrapper {
    margin: 20px 0;
    border: 1px solid #000;
    padding: 5px;
}
.integrity-label { font-size: 11px; margin-bottom: 5px; font-weight: bold; display: flex; justify-content: space-between; }

.viz-track { height: 25px; border: 1px solid #000; background: #fff; display: flex; position: relative; }
.viz-valid { background: #000; height: 100%; transition: width 0.5s; }
.viz-corrupt { background: repeating-linear-gradient(45deg, #fff, #fff 5px, #000 5px, #000 10px); height: 100%; border-left: 1px solid #fff; transition: width 0.5s; }

.btn {
    width: 100%;
    padding: clamp(12px, 1.5vw, 18px);
    border: 2px solid #000;
    background: transparent;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.1s;
    font-size: clamp(0.9rem, 1.1vw, 1.1rem);
}
.btn:hover:not(:disabled) { background: #000; color: #fff; }
.btn:disabled { opacity: 0.3; cursor: not-allowed; }

.log-terminal {
    background: #fff;
    border-top: 2px solid #000;
    height: 200px;
    overflow-y: auto;
    padding: 10px;
    font-size: 12px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 5px;
    margin-bottom: 10px;
    font-weight: bold;
}

.explanation-box {
    text-transform: none;
    font-size: 14px;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    margin: 15px 0;
    background: transparent;
}
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 2px; background: #000; border: none; cursor: pointer; }
input[type=range]::-webkit-slider-thumb { border: 2px solid #000; height: 18px; width: 18px; background: #fff; cursor: pointer; -webkit-appearance: none; margin-top: -8px; }

/* Tech Specs */
.tech-trigger {
    cursor: help;
    display: inline-block;
    color: #fff;
    background: #000;
    padding: 0 6px;
    font-size: 0.8em;
    margin-left: 8px;
    border: 1px solid #000;
    vertical-align: middle;
}
.tech-explainer {
    background: #1a1a1a;
    color: #00ff00;
    padding: 15px;
    border: 1px solid #000;
    margin: 10px 0 20px 0;
    font-size: 0.85rem;
    display: none;
    text-transform: none;
    box-shadow: 5px 5px 0px rgba(0,0,0,0.2);
}
.tech-explainer.active { display: block; }
.tech-title { font-weight: bold; border-bottom: 1px dashed #00ff00; display: block; margin-bottom: 5px; text-transform: uppercase; }

/* =========================================
   MID-SIZED SCREENS (1000px - 1399px)
   ========================================= */
@media (min-width: 1000px) and (max-width: 1399px) {
    :root {
        --font-base: 11px;
        --spacing: 18px;
        --sidebar-width: 240px;
    }
}

/* =========================================
   LARGE SCREENS (1400px - 1599px)
   ========================================= */
@media (min-width: 1400px) and (max-width: 1599px) {
    :root {
        --font-base: 12px;
        --spacing: 22px;
        --sidebar-width: 280px;
    }
}

/* =========================================
   EXTRA LARGE SCREENS (Min Width 1600px)
   ========================================= */
@media (min-width: 1600px) {
    :root {
        --font-base: 14px;
        --spacing: 28px;
        --sidebar-width: 320px;
    }
}

/* =========================================
   MOBILE
   ========================================= */
@media (max-width: 900px) {
    body { overflow-y: auto; height: auto; }
    .layout { display: flex; flex-direction: column; overflow: visible; height: auto; }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 2px solid #000;
        padding: 15px;
        flex-direction: row;
        flex-wrap: wrap;
        position: sticky;
        top: 0;
    }
    .brand { margin: 0 20px 0 0; padding: 0; border: none; font-size: 1.1rem; }
    .nav { flex-direction: row; gap: 10px; }
    
    .sidebar-extra { display: none; } /* Hide logs in sidebar on mobile */

    .controls-grid { grid-template-columns: 1fr; gap: 20px; }
    .comparison-grid { display: block; }
    .system-col { border-right: none; border-bottom: 2px solid #000; padding: 20px; }
    
    /* Ensure log doesn't break mobile */
    .log-terminal { display: none; } 
}
