/* ==========================================================================
   Photoelectric Effect & Einstein's Quantum Formulation — Stylesheet
   Chapter 11 Simulation 02 | PlusPhysics Suite
   Department of Physics, D B Pampa College, Parumala
   ========================================================================== */

/* --- CSS Root Variables & Design Tokens --- */
:root {
    --primary-color: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --primary-border: #bae6fd;
    --accent-color: #f59e0b;
    --accent-hover: #d97706;
    --accent-light: #fef3c7;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-dark: #090e17;
    --text-main: #0f172a;
    --text-sub: #334155;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --border-subtle: #e2e8f0;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
}

/* Base Reset & Typography */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.55;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Master Container */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.25rem 1.75rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==========================================================================
   1. Top Navigation Bar (Standard 4.1 & Refined Architecture)
   ========================================================================== */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.nav-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 700;
    font-size: 0.92rem;
    transition: color 0.15s ease;
}

.nav-home-btn:hover {
    color: var(--primary-hover);
}

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

.nav-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.nav-pill-btn:hover {
    background: #e2e8f0;
    color: var(--text-main);
    border-color: #94a3b8;
}

.nav-dept-tag {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ==========================================================================
   1.1 Series Modal Dialog
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeInModal 0.2s ease;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
}

.modal-window {
    position: relative;
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 760px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow: hidden;
    border: 1px solid var(--border-color);
    animation: scaleInModal 0.22s ease-out;
}

.modal-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
    background: #f8fafc;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-main);
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.modal-close-btn:hover {
    color: var(--danger-color);
    background: #e2e8f0;
}

.modal-body {
    flex: 1 1 auto;
    padding: 0.85rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    font-size: 0.85rem;
    color: var(--text-sub);
    line-height: 1.5;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.modal-body .series-tagline {
    font-weight: 700;
    color: var(--primary-hover);
    font-size: 0.94rem;
}

/* Compact Admission Callout Card inside Modal (Standard 19: 100% visible) */
.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: var(--radius-md) !important;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.25);
}

.modal-admission .promo-copy {
    gap: 0.1rem;
}

.modal-admission .promo-kicker {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
}

.modal-admission .promo-lead {
    font-size: 0.82rem;
    font-weight: 600;
}

.modal-admission .promo-headline {
    font-size: 1.05rem;
    line-height: 1.25;
}

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

.modal-admission .program-card {
    padding: 0.5rem 0.75rem !important;
    gap: 0.15rem !important;
    height: auto !important;
}

.modal-admission .program-card strong {
    font-size: 0.84rem;
}

.modal-admission .program-card span {
    font-size: 0.74rem;
    line-height: 1.25;
}

.modal-admission .program-card small {
    font-size: 0.68rem;
    margin-top: 0.1rem;
}

.modal-admission .promo-actions {
    display: flex;
    gap: 0.6rem !important;
    margin-top: 0.15rem !important;
}

.modal-admission .promo-button {
    padding: 0.4rem 1.1rem !important;
    font-size: 0.8rem !important;
    border-radius: var(--radius-sm);
}

.modal-footer {
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    padding: 0.65rem 1.25rem;
    border-top: 1px solid var(--border-subtle);
    background: #f8fafc;
}

.modal-btn-primary {
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.42rem 1.15rem;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.modal-btn-primary:hover {
    background: var(--primary-hover);
}

@keyframes fadeInModal {
    from { opacity: 0; transform: scale(0.97); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes scaleInModal {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   2. Header & Overview
   ========================================================================== */
header {
    background: linear-gradient(135deg, #090e17 0%, #0f172a 60%, #1e293b 100%);
    color: #ffffff;
    padding: 2.25rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

header::after {
    content: '';
    position: absolute;
    top: -40%;
    right: -10%;
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(2, 132, 199, 0.22) 0%, transparent 70%);
    pointer-events: none;
}

header h1 {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.025em;
    margin-bottom: 0.65rem;
    background: linear-gradient(to right, #ffffff, #93c5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    font-size: 0.98rem;
    color: #cbd5e1;
    max-width: 950px;
    line-height: 1.6;
}

/* ==========================================================================
   3. Main Simulation Layout (Dual Column / Option A Mobile Order)
   ========================================================================== */
.sim-layout {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 1.5rem;
    align-items: start;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.panel {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   4. Visualizer Panel & 2D Vector Canvas Viewport
   ========================================================================== */
.visualizer-panel {
    display: flex;
    flex-direction: column;
    padding: 1.15rem;
    gap: 1rem;
    align-items: stretch;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* Investigation Mode Tabs */
.mode-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: #f1f5f9;
    padding: 0.35rem;
    border-radius: var(--radius-md);
    gap: 0.35rem;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.65rem 0.45rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    line-height: 1.25;
    touch-action: manipulation;
    min-height: 48px;
    min-width: 0;
}

.mode-btn .tab-num {
    font-family: var(--font-mono), monospace;
    font-size: 0.70rem;
    font-weight: 700;
    opacity: 0.7;
}

.mode-btn:hover {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.6);
}

.mode-btn.active {
    background: #ffffff;
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    font-weight: 700;
}

/* Viewport Host Container */
.viewport-wrapper {
    position: relative;
    width: 100%;
    background: #060911;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid #1e293b;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

canvas {
    max-width: 100% !important;
}

#mainCanvas,
#main-canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 760 / 440;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

.viewport-wrapper.canvas-expanded,
.viewport-wrapper.maximized {
    height: 68vh !important;
    max-height: 68vh !important;
}

.viewport-wrapper.canvas-expanded #mainCanvas,
.viewport-wrapper.canvas-expanded #main-canvas,
.viewport-wrapper.maximized #mainCanvas,
.viewport-wrapper.maximized #main-canvas {
    height: 100% !important;
    aspect-ratio: auto !important;
}

/* Viewport Overlay Controls Toolbar */
.viewport-overlay-toolbar {
    position: absolute;
    top: 0.65rem;
    left: 0.65rem;
    right: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
    max-width: calc(100% - 1.3rem);
    gap: 0.4rem;
    flex-wrap: wrap;
    min-width: 0;
}

.canvas-badge-overlay {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.74rem;
    font-weight: 600;
    color: #e2e8f0;
    pointer-events: auto;
    max-width: calc(100% - 120px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #38bdf8;
    box-shadow: 0 0 8px #38bdf8;
    flex-shrink: 0;
}

.view-actions {
    display: flex;
    gap: 0.35rem;
    pointer-events: auto;
    flex-shrink: 0;
}

.icon-btn {
    width: 34px;
    height: 34px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.12s ease;
    touch-action: manipulation;
}

.icon-btn:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
}

.icon-btn.active {
    background: var(--primary-color);
    border-color: #38bdf8;
}

.gesture-hint {
    position: absolute;
    bottom: 0.65rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    color: #94a3b8;
    font-size: 0.72rem;
    padding: 0.3rem 0.75rem;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
    transition: opacity 0.3s ease;
    max-width: 90%;
    white-space: normal;
    text-align: center;
}

/* Live Physical Status Badge */
.status-banner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.95rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    color: #0369a1;
    line-height: 1.45;
}

/* Pinned Telemetry Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
}

.stat-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.stat-label {
    font-size: 0.70rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 700;
}

.stat-data {
    font-family: var(--font-mono), monospace;
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
}

.stat-data.highlight {
    color: var(--primary-color);
}

.stat-sub {
    font-size: 0.70rem;
    color: var(--text-muted);
    font-family: var(--font-mono), monospace;
}

/* Auxiliary Visualizer Section */
.aux-visualizer-section {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 0.85rem;
}

.aux-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 0;
    max-width: 100%;
}

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

.aux-tag {
    font-size: 0.70rem;
    font-family: var(--font-mono), monospace;
    background: #e2e8f0;
    color: #475569;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-weight: 600;
}

.aux-canvases-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0.75rem;
}

.aux-canvases-row.single-plot {
    grid-template-columns: 1fr;
}

.aux-canvas-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.45rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

#auxCanvas,
#aux-plot-canvas {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    aspect-ratio: 760 / 260;
    display: block;
}

#aux-gauge-canvas {
    width: 100% !important;
    max-width: 220px !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    display: block;
}

.cross-subtext {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.25rem;
    font-weight: 600;
}

/* ==========================================================================
   5. Predict-Observe-Explain (POE) Pedagogical Card
   ========================================================================== */
.poe-card {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.poe-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.poe-header-row h4 {
    font-size: 1.02rem;
    font-weight: 700;
    color: #0f172a;
}

.poe-badge {
    background: #eff6ff;
    color: var(--primary-color);
    font-family: var(--font-mono), monospace;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    border: 1px solid #bfdbfe;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.poe-prompt {
    font-size: 0.90rem;
    color: var(--text-main);
    line-height: 1.55;
}

.poe-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.poe-btn {
    text-align: left;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    min-height: 44px;
    line-height: 1.4;
}

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

.poe-btn.correct {
    background: #ecfdf5 !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
    font-weight: 600;
}

.poe-btn.incorrect {
    background: #fef2f2;
    border-color: #ef4444;
    color: #b91c1c;
    opacity: 0.85;
}

.poe-explanation {
    padding: 0.85rem 1.1rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    line-height: 1.55;
    color: #166534;
    word-break: break-word;
    overflow-wrap: break-word;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    box-sizing: border-box;
}

/* ==========================================================================
   6. Controls Panel (Right Column on Desktop)
   ========================================================================== */
.controls-panel {
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    gap: 1.25rem;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-bottom: 1.15rem;
    border-bottom: 1px solid var(--border-subtle);
}

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

.group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.group-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
}

.control-subtext {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.badge {
    background: #eff6ff;
    color: var(--primary-color);
    font-size: 0.72rem;
    font-family: var(--font-mono), monospace;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    border: 1px solid #bfdbfe;
}

/* Metal Selector Grid */
.metal-selector-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.45rem;
}

.metal-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.35rem;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    min-height: 52px;
}

.metal-btn .metal-sym {
    font-family: var(--font-mono), monospace;
    font-size: 0.95rem;
    font-weight: 800;
    color: #0f172a;
}

.metal-btn .metal-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 600;
}

.metal-btn .metal-phi {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: var(--font-mono), monospace;
    margin-top: 0.15rem;
}

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

.metal-btn.active {
    background: #eff6ff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1.5px var(--primary-color);
}

.metal-btn.active .metal-sym {
    color: var(--primary-color);
}

/* Modality Selector Grid */
.modality-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
}

.modality-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.65rem 0.75rem;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    text-align: left;
    min-height: 56px;
}

.modality-btn .mod-icon {
    font-size: 1.15rem;
    margin-bottom: 0.15rem;
}

.modality-btn strong {
    font-size: 0.82rem;
    color: #0f172a;
}

.modality-btn small {
    font-size: 0.68rem;
    color: var(--text-muted);
}

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

.modality-btn.active {
    background: #eff6ff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1.5px var(--primary-color);
}

/* Sliders & Steppers (Composite 2-Line Flex-Wrap Pattern) */
.slider-row {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 0.5rem;
}

.slider-header-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.slider-header-wrap label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-sub);
}

.stat-badge {
    font-family: var(--font-mono), monospace;
    font-size: 0.82rem;
    font-weight: 700;
    color: #0284c7;
    background: #eff6ff;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid #bfdbfe;
}

.slider-stepper-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input[type="range"] {
    flex: 1;
    height: 7px;
    background: #e2e8f0;
    border-radius: 9999px;
    outline: none;
    -webkit-appearance: none;
    accent-color: var(--primary-color);
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.stepper-btn-group {
    display: flex;
    gap: 0.25rem;
}

.step-btn {
    width: 38px;
    height: 38px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-sub);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s ease;
    touch-action: manipulation;
}

.step-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
}

.step-btn:active {
    background: #e2e8f0;
}

/* Formula & Calculation Readout Box */
.formula-readout {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.80rem;
}

.readout-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.readout-row span {
    color: var(--text-muted);
}

.readout-row strong {
    font-family: var(--font-mono), monospace;
    color: #0f172a;
    font-size: 0.82rem;
}

/* Presets Action Grid */
.presets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
}

.preset-btn,
.preset-pill {
    padding: 0.55rem 0.65rem;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    min-height: 42px;
    text-align: center;
    line-height: 1.3;
}

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

.preset-btn.active,
.preset-pill.active {
    background: #eff6ff;
    border-color: #0284c7;
    color: #0284c7;
    box-shadow: 0 0 0 1px #0284c7;
}

.preset-btn.highlight,
.preset-pill.highlight {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #b45309;
    font-weight: 700;
}

#mode-focus-group {
    background: #f0f9ff;
    border: 1.5px solid #7dd3fc;
    border-radius: var(--radius-md);
    padding: 1.1rem;
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.08);
}

#mode-focus-group .group-header h3 {
    color: #0369a1;
}

#mode-focus-badge {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

/* --- Foundational Theory & Concepts Section (Option A Standard) --- */
.concepts-box {
    padding: 1.75rem 2rem;
    background: #ffffff;
    border-radius: var(--radius-md);
}

.concepts-box h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 1.25rem;
    padding-bottom: 0.65rem;
    border-bottom: 2px solid var(--border-subtle);
}

.theory-grid,
.concepts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.theory-card,
.concept-card {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.theory-card h3,
.concept-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-color);
}

.theory-card p,
.concept-card p {
    font-size: 0.88rem;
    color: var(--text-sub);
    line-height: 1.6;
}

/* MathJax Responsive Container Guard */
/* Display Math Blocks (Centered, block-level, horizontally scrollable) */
.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;
}

/* Inline Math (Seamlessly inline with surrounding text, no line break jumps) */
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: 0;
}

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

/* ==========================================================================
   8. Standard Series Overview Card (Standard 4.2 & Retained Bottom Placement)
   ========================================================================== */
.series-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: 1.35rem 1.6rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    user-select: text;
}

.series-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
}

.series-tagline {
    font-style: italic;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.92rem;
}

.series-card p {
    font-size: 0.88rem;
    color: var(--text-sub);
    line-height: 1.6;
}

.series-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
}

.series-pill {
    font-size: 0.78rem;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    background: #f1f5f9;
    color: var(--text-sub);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.15s ease;
}

.series-pill:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.series-pill.current {
    background: var(--primary-light);
    color: var(--primary-color);
    border: 1px solid #bfdbfe;
    font-weight: 700;
}

/* ==========================================================================
   9. Institutional Admission Callout Card (Standard 4.3)
   ========================================================================== */
.admission-card {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #0f172a 100%);
    color: #ffffff;
    padding: 2.25rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
}

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

@keyframes bannerGlowPulse {
    0% {
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
        border-color: rgba(251, 191, 36, 0.2);
    }
    50% {
        box-shadow: 0 0 25px 6px rgba(251, 191, 36, 0.45);
        border-color: rgba(251, 191, 36, 0.85);
    }
    100% {
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
        border-color: rgba(251, 191, 36, 0.2);
    }
}

.promo-copy {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.promo-kicker {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #fbbf24;
    font-weight: 700;
}

.promo-lead {
    font-size: 1.05rem;
    color: #93c5fd;
    font-weight: 500;
}

.promo-headline {
    font-size: 1.75rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.015em;
    line-height: 1.25;
}

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

.program-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    backdrop-filter: blur(6px);
}

.program-card strong {
    font-size: 1.05rem;
    color: #ffffff;
}

.program-card span {
    font-size: 0.84rem;
    color: #cbd5e1;
}

.program-card small {
    font-size: 0.74rem;
    color: #fbbf24;
    margin-top: 0.35rem;
    font-weight: 600;
}

.promo-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.promo-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.92rem;
    text-decoration: none;
    transition: all 0.15s ease;
    touch-action: manipulation;
    min-height: 46px;
}

.promo-button.main-cta {
    background: #fbbf24;
    color: #0f172a;
    border: none;
}

.promo-button.main-cta:hover {
    background: #f59e0b;
    transform: translateY(-1px);
}

.promo-button.sub-cta {
    background: transparent;
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.4);
}

.promo-button.sub-cta:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffffff;
}

/* ==========================================================================
   10. Feedback & Suggestions Channel (Standard 4.4)
   ========================================================================== */
.feedback-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.feedback-icon {
    width: 44px;
    height: 44px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 50%;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feedback-text h4 {
    font-size: 0.98rem;
    font-weight: 700;
    color: #0f172a;
}

.feedback-text p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.feedback-btn {
    padding: 0.6rem 1.2rem;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.84rem;
    text-decoration: none;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

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

/* ==========================================================================
   11. Standard Series Footer (Standard 4.5)
   ========================================================================== */
.series-footer {
    text-align: center;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
}

.series-footer p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ==========================================================================
   12. Responsive Optimization (Option A Mobile Order & Standards)
   ========================================================================== */
/* Mobile Controls Bar (Hidden on desktop) */
.mobile-controls-bar {
    display: none;
}

@media (max-width: 900px) {
    .container {
        padding: 1rem 0.85rem 2.5rem;
        gap: 1.25rem;
        box-sizing: border-box;
    }

    .sim-layout {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Option A Canvas-First: Visualizer renders FIRST */
    .visualizer-panel {
        order: 1;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Mobile Controls Toggle Bar sits right beneath visualizer */
    .mobile-controls-bar {
        display: block;
        order: 2;
        width: 100%;
    }

    .mobile-controls-toggle {
        width: 100%;
        padding: 0.85rem 1.25rem;
        background: #f8fafc;
        border: 1.5px solid #cbd5e1;
        border-radius: var(--radius-md);
        display: flex;
        align-items: center;
        justify-content: space-between;
        cursor: pointer;
        font-family: inherit;
        font-size: 0.88rem;
        font-weight: 700;
        color: #1e293b;
        box-shadow: var(--shadow-sm);
        transition: all 0.2s ease;
        touch-action: manipulation;
        min-height: 48px;
    }

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

    .mobile-controls-toggle .toggle-icon {
        font-size: 1.15rem;
        margin-right: 0.35rem;
    }

    .mobile-controls-toggle .toggle-text {
        flex: 1;
        text-align: left;
    }

    .mobile-controls-toggle .toggle-indicator {
        font-family: var(--font-mono), monospace;
        font-size: 0.72rem;
        color: var(--primary-color);
        background: #eff6ff;
        padding: 0.2rem 0.55rem;
        border-radius: 9999px;
        margin-right: 0.45rem;
        font-weight: 700;
    }

    .mobile-controls-toggle .toggle-arrow {
        font-size: 0.75rem;
        color: #64748b;
        transition: transform 0.2s ease;
    }

    .mobile-controls-toggle.open .toggle-arrow {
        transform: rotate(180deg);
    }

    /* Controls Panel sits underneath the toggle bar */
    .controls-panel {
        order: 3;
        display: none; /* Collapsed by default on mobile so visualizer dominates */
        border-top: 2px solid var(--primary-color);
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .controls-panel.mobile-open,
    .controls-panel.drawer-open {
        display: flex !important;
        animation: slideDownControls 0.22s ease;
    }

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

    .theory-grid,
    .concepts-grid {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 680px) {
    .mode-tabs {
        grid-template-columns: repeat(2, 1fr);
    }

    .slider-stepper-wrap {
        flex-direction: column;
        align-items: stretch;
    }

    .stepper-btn-group {
        justify-content: flex-end;
    }

    .aux-canvases-row {
        grid-template-columns: 1fr;
    }

    .metal-selector-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .program-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    /* Standard 19 Option A: Priority Admission Placement, Flexible Height & Smooth Modal Scroll */
    .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;
        height: auto !important;
        min-height: fit-content !important;
    }

    .modal-admission .promo-kicker {
        font-size: 0.65rem !important;
    }

    .modal-admission .promo-lead {
        font-size: 0.82rem !important;
    }

    .modal-admission .promo-headline {
        font-size: 0.95rem !important;
        line-height: 1.2 !important;
    }

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

    .modal-admission .program-card {
        padding: 0.38rem 0.5rem !important;
        gap: 0.15rem !important;
        height: auto !important;
    }

    .modal-admission .program-card strong {
        font-size: 0.78rem !important;
    }

    .modal-admission .program-card span,
    .modal-admission .program-card small {
        font-size: 0.62rem !important;
        line-height: 1.25 !important;
    }

    .modal-admission .promo-actions {
        margin-top: 0.25rem !important;
        gap: 0.45rem !important;
    }

    .modal-admission .promo-button {
        padding: 0.38rem 0.85rem !important;
        font-size: 0.76rem !important;
    }

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

    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }

    header {
        padding: 1.25rem 1rem;
    }

    header h1 {
        font-size: 1.45rem;
    }

    .viewport-overlay-toolbar {
        top: 0.45rem;
        left: 0.45rem;
        right: 0.45rem;
        max-width: calc(100% - 0.9rem);
    }

    .canvas-badge-overlay {
        display: none !important;
    }

    .admission-card {
        padding: 1.5rem 1.25rem;
    }

    .promo-headline {
        font-size: 1.45rem;
    }

    .promo-actions {
        flex-direction: column;
        width: 100%;
    }

    .promo-button {
        width: 100%;
    }

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

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

@media (max-width: 400px) {
    .container {
        padding: 0.75rem 0.5rem 2rem;
    }

    .mode-tabs {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        grid-template-columns: 1fr;
    }

    .metal-selector-grid {
        grid-template-columns: 1fr;
    }

    .modality-grid {
        grid-template-columns: 1fr;
    }

    .presets-grid {
        grid-template-columns: 1fr;
    }
}
