:root {
    --bg-color: #f8fafc;
    --panel-bg: #ffffff;
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --secondary-color: #475569;
    --secondary-hover: #334155;
    --accent-color: #f59e0b;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #10b981;
    --text-color: #0f172a;
    --border-color: #cbd5e1;
}

*:not(mjx-container):not(mjx-container *) {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 1.25rem 1rem 3rem;
    display: flex;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

.container {
    max-width: 1140px;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Standard 4.1 Top Navigation Bar
   -------------------------------------------------------------------------- */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 1.15rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.nav-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: #0284c7;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: color 0.15s ease;
}

.nav-home-btn:hover {
    color: #0369a1;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.nav-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.15s ease;
}

.nav-pill-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.nav-dept-tag {
    font-size: 0.82rem;
    color: #64748b;
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   Standard 22 Clean Header Architecture (Zero Badge Rows)
   -------------------------------------------------------------------------- */
.sim-header {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 0.25rem 0;
}

.sim-title {
    font-size: 2.1rem;
    color: #0f172a;
    font-weight: 800;
    margin-bottom: 0.35rem;
    line-height: 1.25;
}

.sim-subtitle {
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 900px;
    margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Predict-Observe-Explain (POE) Challenge Card
   -------------------------------------------------------------------------- */
.poe-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #0284c7;
    border-radius: 12px;
    padding: 1.25rem 1.4rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
}

.poe-badge {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    margin-bottom: 0.5rem;
}

.poe-title {
    font-size: 1.05rem;
    color: #0f172a;
    font-weight: 700;
    margin-bottom: 0.45rem;
}

.poe-prompt {
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.5;
    margin-bottom: 0.85rem;
}

.poe-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.poe-option-btn {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    text-align: left;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.15s ease;
    font-size: 0.85rem;
    color: #1e293b;
    min-height: 42px;
}

.poe-option-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.poe-option-btn .opt-key {
    background: #e2e8f0;
    color: #0f172a;
    font-weight: 700;
    font-size: 0.78rem;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 1px;
}

.poe-option-btn.correct {
    background: #ecfdf5;
    border-color: #10b981;
    color: #065f46;
}

.poe-option-btn.correct .opt-key {
    background: #10b981;
    color: #ffffff;
}

.poe-option-btn.wrong {
    background: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}

.poe-option-btn.wrong .opt-key {
    background: #ef4444;
    color: #ffffff;
}

.poe-feedback {
    margin-top: 0.85rem;
    padding: 0.75rem 0.95rem;
    border-radius: 8px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    font-size: 0.84rem;
    line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Mobile Controls Toggle Bar (Standard 1.6)
   -------------------------------------------------------------------------- */
.mobile-controls-bar {
    display: none;
    margin-bottom: 1rem;
}

.mobile-controls-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #0f172a;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.mobile-controls-toggle .toggle-icon { font-size: 1.1rem; }
.mobile-controls-toggle .toggle-indicator {
    font-size: 0.75rem;
    background: #e0f2fe;
    color: #0284c7;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    margin-left: auto;
}
.mobile-controls-toggle .toggle-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}
.mobile-controls-toggle[aria-expanded="true"] .toggle-arrow {
    transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   Mobile Canvas View Switcher (Option A - Standard 20 & 21)
   -------------------------------------------------------------------------- */
.canvas-view-switcher {
    display: flex;
    margin-top: 0.45rem;
    margin-bottom: 0.55rem;
    gap: 0.45rem;
}

.view-switch-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.65rem;
    background: #f1f5f9;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s ease;
}

.view-switch-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.view-switch-btn.active {
    background: #0284c7;
    border-color: #0284c7;
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
}

/* --------------------------------------------------------------------------
   Simulation Layout Grid (Desktop & Standard Flow)
   -------------------------------------------------------------------------- */
.sim-layout {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: start;
}

.panel {
    background: var(--panel-bg);
    border-radius: 12px;
    padding: 1.35rem 1.45rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.control-group {
    margin-bottom: 1.15rem;
    padding-bottom: 1.15rem;
    border-bottom: 1px dashed var(--border-color);
}

.control-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.control-group h3 {
    font-size: 0.98rem;
    margin-bottom: 0.65rem;
    color: #1e293b;
    font-weight: 700;
}

.hidden-control {
    display: none !important;
}

/* Mode Switcher Buttons */
.mode-toggle-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    width: 100%;
}

.mode-btn {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    text-align: left;
    transition: all 0.15s ease;
    min-height: 40px;
}

.mode-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.mode-btn.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
}

/* Composite Slider Rows */
.slider-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    margin-bottom: 0.65rem;
}

.slider-row label {
    flex: 1 1 auto;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e293b;
    min-width: 0;
}

.stat-badge {
    flex: 0 0 auto;
    margin-left: auto;
    background: #e2e8f0;
    color: #0f172a;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    text-align: right;
}

.stepper-container {
    flex: 0 0 100%;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.15rem;
}

.stepper-container input[type="range"] {
    flex: 1;
    min-width: 0;
    height: 8px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.step-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    font-size: 1.15rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.15s ease;
}

.step-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

/* Preset Buttons Pill Bar */
.preset-pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.preset-pill {
    padding: 0.35rem 0.65rem;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    border-radius: 9999px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.15s ease;
}

.preset-pill:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.preset-pill.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

/* Action Grids & Toggle Buttons */
.action-grid-2col {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.btn {
    padding: 0.65rem 0.85rem;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.15s ease;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
}

.btn-toggle {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    font-size: 0.8rem;
    text-align: center;
}

.btn-toggle:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.btn-toggle.active {
    background: #e0f2fe;
    border-color: #0284c7;
    color: #0369a1;
    font-weight: 700;
}

.btn-secondary { background-color: var(--secondary-color); color: #ffffff; }
.btn-secondary:hover { background-color: var(--secondary-hover); }

.btn-neutral { background-color: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.btn-neutral:hover { background-color: #e2e8f0; color: #0f172a; }

.slider-hint {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.45;
    margin-top: 0.5rem;
}

.formula-callout {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    margin-top: 0.65rem;
    font-size: 0.82rem;
    color: #166534;
}

.formula-callout strong {
    color: #14532d;
    display: block;
    margin-bottom: 0.2rem;
}

.formula-callout p {
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: #15803d;
}

.concepts-box {
    background-color: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #0284c7;
    overflow-x: auto;
    margin-top: 0.75rem;
}

.concepts-box h3 {
    font-size: 0.92rem;
    margin-bottom: 0.45rem;
    color: #0f172a;
    font-weight: 700;
}

.concepts-box ul {
    list-style-type: none;
}

.concepts-box li {
    font-size: 0.82rem;
    margin-bottom: 0.45rem;
    line-height: 1.45;
    color: #334155;
}

/* --------------------------------------------------------------------------
   Visualizer Panel & Telemetry Elements
   -------------------------------------------------------------------------- */
.visualizer-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
}

/* Stats Telemetry Bar */
.stats-bar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.45rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.55rem;
    min-height: 48px;
    box-sizing: border-box;
}

.stat-item {
    font-size: 0.68rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-value {
    color: #0f172a;
    font-weight: 800;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

.unit {
    font-size: 0.72rem;
    font-weight: 700;
    color: #0284c7;
    text-transform: none;
}

/* Status Indicator Badges */
#status-badge {
    width: 100%;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 800;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    margin-bottom: 0.65rem;
    letter-spacing: 0.03em;
    transition: all 0.25s ease;
    box-sizing: border-box;
}

.status-normal {
    background-color: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}

.status-optimal {
    background-color: #ecfdf5;
    color: #047857;
    border: 1px solid #6ee7b7;
}

.status-paused {
    background-color: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.status-overload {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    animation: alertPulse 0.45s infinite alternate;
}

@keyframes alertPulse {
    0% { background-color: #fee2e2; box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
    100% { background-color: #fecaca; box-shadow: 0 0 10px rgba(239, 68, 68, 0.5); }
}

/* 2D Dual-Bench Canvas Viewport */
.canvas-container {
    width: 100%;
    height: 480px;
    background: #080c14;
    border: 1px solid #1e293b;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    display: flex;
    margin-bottom: 1rem;
    box-sizing: border-box;
}

#simCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Secondary 2D Diagnostic Graph Card */
.graph-card {
    width: 100%;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    box-sizing: border-box;
}

.graph-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
    flex-wrap: wrap;
}

.graph-title {
    font-size: 0.84rem;
    font-weight: 700;
    color: #1e293b;
}

.graph-legend-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.graph-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.74rem;
    color: #64748b;
    font-weight: 600;
}

.graph-legend-color {
    width: 12px;
    height: 3px;
    border-radius: 2px;
}

.graph-wrapper {
    width: 100%;
    height: 140px;
    background: #080c14;
    border-radius: 8px;
    border: 1px solid #1e293b;
    overflow: hidden;
}

#graph-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* --------------------------------------------------------------------------
   Standard Series Card (Bottom Placement)
   -------------------------------------------------------------------------- */
.series-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.35rem 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.series-card h3 {
    font-size: 0.95rem;
    color: #1e3a8a;
    margin-bottom: 0.45rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.series-card p {
    font-size: 0.88rem;
    color: #475569;
    line-height: 1.55;
    margin-bottom: 0.45rem;
}

.series-card p:last-child { margin-bottom: 0; }
.series-card .series-tagline {
    font-weight: 700;
    color: #0f172a;
    font-style: italic;
}

/* --------------------------------------------------------------------------
   Standard 4.3 Institutional Admission Callout Card
   -------------------------------------------------------------------------- */
.admission-card { 
    background: linear-gradient(135deg, #1e3a8a, #0f172a); 
    color: #ffffff; 
    padding: 1.5rem; 
    border-radius: 12px; 
    display: flex; 
    flex-wrap: wrap; 
    align-items: center; 
    justify-content: space-between; 
    gap: 1.5rem; 
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); 
    position: relative; 
    border: 2px solid transparent; 
}

.attention-flash { 
    animation: bannerGlowPulse 3s infinite ease-in-out; 
}

@keyframes bannerGlowPulse { 
    0% { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: transparent; } 
    50% { box-shadow: 0 0 20px 4px rgba(251, 191, 36, 0.4); border-color: rgba(251, 191, 36, 0.6); } 
    100% { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-color: transparent; } 
}

.promo-copy .promo-kicker { 
    color: #60a5fa; 
    font-weight: 600; 
    text-transform: uppercase; 
    font-size: 0.8rem; 
    letter-spacing: 0.05em; 
    margin-bottom: 0.2rem; 
}

.promo-copy .promo-lead { 
    color: #ffffff; 
    font-weight: 600; 
    font-size: 1.05rem; 
    margin-bottom: 0.25rem; 
}

.promo-copy .promo-headline { 
    color: #fcd34d; 
    font-weight: 800; 
    font-size: 1.45rem; 
    line-height: 1.25; 
}

.program-grid { 
    display: flex; 
    gap: 1.5rem; 
    flex: 1; 
    justify-content: center; 
}

.program-card { 
    background: rgba(255, 255, 255, 0.08); 
    padding: 0.75rem 1rem; 
    border-radius: 8px; 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    font-size: 0.85rem; 
    display: flex; 
    flex-direction: column; 
    gap: 0.2rem; 
}

.program-card strong { color: #fcd34d; font-size: 0.95rem; } 
.program-card span { color: #e2e8f0; } 
.program-card small { color: #94a3b8; font-style: italic; }

.promo-actions { 
    display: flex; 
    flex-direction: column; 
    gap: 0.5rem; 
    min-width: 160px; 
}

.promo-button { 
    padding: 0.65rem 1.2rem; 
    border-radius: 6px; 
    font-weight: 700; 
    text-decoration: none; 
    transition: all 0.2s ease; 
    text-align: center; 
    font-size: 0.9rem; 
    min-height: 44px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    touch-action: manipulation;
}

.main-cta { background-color: #fbbf24; color: #0f172a; } 
.main-cta:hover { background-color: #f59e0b; transform: translateY(-1px); }

.sub-cta { background-color: transparent; color: #e2e8f0; border: 1px solid rgba(255, 255, 255, 0.3); } 
.sub-cta:hover { background-color: rgba(255, 255, 255, 0.1); color: #fff; border-color: #fff; }

/* --------------------------------------------------------------------------
   Standard 4.4 Feedback & Suggestions Channel
   -------------------------------------------------------------------------- */
.feedback-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.15rem 1.35rem;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

.feedback-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.feedback-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #e0f2fe;
    color: #0284c7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feedback-text h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.2rem;
}

.feedback-text p {
    font-size: 0.84rem;
    color: #64748b;
    line-height: 1.4;
    margin: 0;
}

.feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.15rem;
    border-radius: 8px;
    background: #0284c7;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease;
    flex-shrink: 0;
    touch-action: manipulation;
}

.feedback-btn:hover {
    background: #0369a1;
}

/* --------------------------------------------------------------------------
   Standard 4.5 Series Footer
   -------------------------------------------------------------------------- */
.series-footer { 
    text-align: center; 
    padding: 1.5rem 0 0; 
    border-top: 1px solid #e2e8f0; 
    margin-top: 2rem; 
}

.series-footer p { 
    font-size: 0.82rem; 
    color: #64748b; 
    font-weight: 500; 
}

/* --------------------------------------------------------------------------
   Standard 4.2 & 19 Accessible Series Modal Architecture
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    box-sizing: border-box;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-window {
    position: relative;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 760px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    animation: modalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.35rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.modal-close-btn:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.modal-body {
    padding: 1.15rem 1.35rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1 1 auto;
}

.modal-admission {
    flex-shrink: 0 !important;
    min-height: fit-content !important;
    height: auto !important;
    margin-top: 0.25rem;
    padding: 0.85rem 1.15rem !important;
    gap: 0.6rem !important;
    border-radius: 10px !important;
}

.modal-admission .promo-copy { gap: 0.1rem; }
.modal-admission .promo-kicker { font-size: 0.68rem !important; }
.modal-admission .promo-lead { font-size: 0.82rem !important; }
.modal-admission .promo-headline { font-size: 1.05rem !important; line-height: 1.25 !important; }

.modal-admission .program-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.55rem !important;
}

.modal-admission .program-card { padding: 0.5rem 0.75rem !important; }
.modal-admission .program-card strong { font-size: 0.88rem !important; }
.modal-admission .program-card span { font-size: 0.72rem !important; }
.modal-admission .program-card small { font-size: 0.65rem !important; }

.modal-admission .promo-actions {
    gap: 0.55rem !important;
    margin-top: 0.15rem !important;
    flex-direction: row !important;
}

.modal-admission .promo-button {
    padding: 0.4rem 1.1rem !important;
    font-size: 0.78rem !important;
    min-height: 36px !important;
}

.modal-series-card {
    padding: 0.85rem 1.15rem;
    gap: 0.45rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.modal-series-card h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.35rem;
}

.modal-series-card p {
    font-size: 0.82rem;
    line-height: 1.5;
    color: #475569;
    margin-bottom: 0.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 0.75rem 1.35rem;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.modal-dismiss-btn {
    padding: 0.45rem 1.25rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    font-size: 0.85rem;
    font-weight: 600;
    color: #0f172a;
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.15s ease;
}

.modal-dismiss-btn:hover {
    background: #f1f5f9;
}

/* --------------------------------------------------------------------------
   Standard 11: MathJax Dual-Rule Inline/Display CSS
   -------------------------------------------------------------------------- */
.math-display mjx-container,
mjx-container[display="true"] {
    display: block !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    margin: 0.4rem auto !important;
    text-align: center;
}

mjx-container:not([display="true"]) {
    display: inline-block !important;
    max-width: 100% !important;
    overflow: visible !important;
    margin: 0 0.12em !important;
    vertical-align: -0.15em !important;
    line-height: normal !important;
}

mjx-container svg {
    max-width: 100% !important;
    height: auto !important;
    display: inline-block;
    vertical-align: middle;
}

/* --------------------------------------------------------------------------
   Option A Responsive Reordering (Mobile First: Screens <= 900px)
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .sim-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
    }

    .mobile-controls-bar {
        display: block !important;
        margin-bottom: 0.65rem;
    }

    .controls-panel {
        order: 1 !important;
        width: 100% !important;
        max-height: none !important;
        overflow-y: visible !important;
        display: none; /* Collapsible drawer default */
    }

    .controls-panel.mobile-open {
        display: flex !important;
        animation: drawerSlideDown 0.25s ease-out;
    }

    .visualizer-panel {
        order: 2 !important;
        width: 100% !important;
    }

    @keyframes drawerSlideDown {
        from { opacity: 0; transform: translateY(-8px); }
        to { opacity: 1; transform: translateY(0); }
    }

    .admission-card { 
        flex-direction: column; 
        text-align: center; 
        gap: 1.5rem; 
    } 
    .program-grid { 
        flex-direction: column !important; 
    } 
    .promo-actions { 
        width: 100%; 
    }
}

/* --------------------------------------------------------------------------
   Compact Mobile Responsive Adjustments (Screens <= 680px)
   -------------------------------------------------------------------------- */
@media (max-width: 680px) {
    body {
        padding: 0.4rem 0.35rem 2rem;
    }

    .sim-header {
        margin-bottom: 0.35rem !important;
        padding: 0 !important;
    }

    .sim-title {
        font-size: 1.25rem;
        margin-bottom: 0.2rem;
    }

    .sim-subtitle {
        font-size: 0.78rem;
        line-height: 1.35;
        margin-bottom: 0.35rem;
    }

    .top-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
        margin-bottom: 0.35rem;
    }

    .nav-dept-tag {
        display: none !important;
    }

    .nav-actions {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .canvas-container {
        height: 280px;
    }

    .stats-bar {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.35rem !important;
        padding: 0.4rem !important;
    }

    .stat-item {
        font-size: 0.65rem;
        padding: 0.25rem 0.4rem !important;
    }

    .stat-value {
        font-size: 0.8rem;
    }

    .mobile-controls-toggle {
        padding: 0.55rem 0.85rem;
        font-size: 0.85rem;
    }

    .canvas-view-switcher {
        display: flex;
    }

    #btn-view-dual {
        display: none !important;
    }

    .feedback-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
    }

    .feedback-btn {
        width: 100%;
        text-align: center;
    }

    .modal-overlay {
        padding: 0.65rem;
    }

    .modal-window {
        max-height: 90vh;
    }

    .modal-body {
        padding: 0.75rem 0.85rem;
        gap: 0.6rem;
    }

    .modal-admission {
        order: -1 !important;
        margin-top: 0 !important;
        margin-bottom: 0.5rem !important;
        padding: 0.75rem 0.85rem !important;
        gap: 0.45rem !important;
    }

    .modal-admission .program-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.35rem !important;
    }

    .modal-admission .promo-actions {
        flex-direction: column !important;
    }

    .action-grid-2col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .canvas-container {
        height: 250px;
    }
    .view-switch-btn {
        font-size: 0.74rem;
        padding: 0.4rem 0.45rem;
    }
}
