/* ==========================================================================
   Polarisation, Malus's Law & Brewster's Bench — Stylesheet
   Chapter 10 (Wave Optics) • PlusTwo Physics Simulation Suite
   Department of Physics • D B Pampa College, Parumala
   ========================================================================== */

:root {
    --primary-color: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-light: #eff6ff;
    --accent-color: #0284c7;
    --accent-light: #f0f9ff;
    --success-color: #15803d;
    --success-light: #dcfce7;
    --warning-color: #b45309;
    --warning-light: #fef3c7;
    --danger-color: #b91c1c;
    --gold-color: #fbbf24;
    --dark-bg: #090d16;
    --dark-card: #0f172a;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-sub: #334155;
    --border-color: #e2e8f0;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

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

.container {
    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)
   ========================================================================== */
.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-card {
    position: relative;
    background: #ffffff;
    border-radius: var(--radius-lg);
    padding: 0.85rem 1.25rem;
    max-width: 760px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    z-index: 1;
    max-height: 92vh;
    overflow-y: auto;
    font-size: 0.85rem;
    color: var(--text-sub);
    line-height: 1.5;
}

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

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    transition: color 0.15s ease;
}

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

/* Compact Admission Callout Card inside Modal */
.modal-admission {
    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;
}

.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);
}

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

/* ==========================================================================
   2. Header & Overview
   ========================================================================== */
header {
    background: linear-gradient(135deg, #0b1329 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. Series Overview Card (Standard 4.2)
   ========================================================================== */
.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;
}

/* ==========================================================================
   4. 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-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-topic {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

.poe-prompt {
    font-size: 0.94rem;
    color: #1e293b;
    line-height: 1.5;
}

.poe-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
    gap: 0.65rem;
}

.poe-btn {
    padding: 0.65rem 0.85rem;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    color: #334155;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    min-height: 42px;
}

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

.poe-btn.correct {
    background: #dcfce7;
    border-color: #22c55e;
    color: #15803d;
    font-weight: 700;
}

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

.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;
}

/* ==========================================================================
   5. 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);
}

/* ==========================================================================
   6. Visualizer Panel & 3D Three.js 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;
}

.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;
}

.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;
}

/* 3D Viewport Host Container */
.viewport-wrapper {
    position: relative;
    width: 100%;
    height: 440px;
    background: #080d1a;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid #1e293b;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: height 0.3s ease;
}

.viewport-wrapper.canvas-expanded {
    height: 72vh !important;
}

#threejs-canvas-host {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

#threejs-canvas-host canvas {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

#threejs-canvas-host:active {
    cursor: grabbing;
}

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

.camera-presets {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    padding: 0.25rem 0.45rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.12);
    pointer-events: auto;
    min-width: 0;
    flex-shrink: 1;
}

.preset-label {
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: 600;
    margin-right: 0.2rem;
    text-transform: uppercase;
}

.view-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #cbd5e1;
    font-family: inherit;
    font-size: 0.74rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.12s ease;
    touch-action: manipulation;
}

.view-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.view-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: #3b82f6;
}

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

.icon-btn {
    width: 32px;
    height: 32px;
    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.92rem;
    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);
}

.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;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    pointer-events: none;
    transition: opacity 0.6s ease;
    white-space: normal;
    text-align: center;
    max-width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* 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;
}

.gesture-hint.fade-out {
    opacity: 0;
}

.bench-label-badge {
    position: absolute;
    bottom: 0.65rem;
    left: 0.75rem;
    background: rgba(30, 58, 138, 0.75);
    border: 1px solid rgba(96, 165, 250, 0.4);
    color: #dbeafe;
    font-family: var(--font-mono), monospace;
    font-size: 0.70rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    pointer-events: none;
}

/* Status Banner (Standard 7.3) */
.status-banner {
    width: 100%;
    min-height: 36px;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.5rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: #1e293b;
    transition: all 0.2s ease;
}

.status-banner.brewster-active {
    background: #dcfce7;
    border-color: #22c55e;
    color: #15803d;
}

.status-banner.extinction {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #64748b;
}

/* Pinned Telemetry Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 0.85rem;
    gap: 0.75rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.stat-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-data {
    font-family: var(--font-mono), monospace;
    font-size: 0.96rem;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

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

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

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

.aux-tag {
    font-size: 0.70rem;
    font-family: var(--font-mono), monospace;
    background: #f1f5f9;
    color: var(--text-muted);
    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-canvas-box {
    background: #fafafa;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.aux-canvas-box.cross-section {
    position: relative;
}

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

#aux-cross-canvas {
    width: 100% !important;
    max-width: 180px !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;
}

/* ==========================================================================
   7. Controls Panel (Standard 7.1 — No Scroll Trapping)
   ========================================================================== */
.controls-panel {
    height: auto;
    max-height: none;
    overflow-y: visible;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.control-group.mode-control {
    display: none;
}

.control-group.mode-control.active {
    display: flex;
}

.group-header {
    border-bottom: 1.5px solid #f1f5f9;
    padding-bottom: 0.45rem;
}

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

.group-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.control-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-card.highlight-card {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.control-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.control-label-row label,
.control-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
}

.param-val {
    font-family: var(--font-mono), monospace;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Composite Slider & Stepper Controls (2-Line Flex-Wrap Pattern) */
.slider-stepper-wrap {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.slider-stepper-wrap input[type="range"] {
    flex: 1;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: #cbd5e1;
    border-radius: 9999px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    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.2);
    border: 2px solid #ffffff;
    transition: transform 0.1s ease;
}

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

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

.step-btn {
    padding: 0.35rem 0.6rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono), monospace;
    font-size: 0.76rem;
    font-weight: 700;
    color: #334155;
    cursor: pointer;
    transition: all 0.12s ease;
    touch-action: manipulation;
    min-height: 36px;
}

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

/* Preset Chips */
.preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.2rem;
}

.chip-btn {
    padding: 0.3rem 0.65rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.12s ease;
    touch-action: manipulation;
}

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

.chip-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

/* Custom Toggle Switch */
.toggle-switch-label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.88rem;
    color: #1e293b;
}

.toggle-switch-label input {
    display: none;
}

.toggle-custom {
    width: 38px;
    height: 22px;
    background: #cbd5e1;
    border-radius: 9999px;
    position: relative;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.toggle-custom::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    top: 3px;
    left: 3px;
    transition: transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch-label input:checked + .toggle-custom {
    background: var(--primary-color);
}

.toggle-switch-label input:checked + .toggle-custom::after {
    transform: translateX(16px);
}

.toggle-hint {
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-left: 2.8rem;
}

/* Three-Polarizer Mathematical Cascade Box */
.cascade-formula-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-family: var(--font-mono), monospace;
    font-size: 0.78rem;
}

.cascade-step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.55rem;
    background: #ffffff;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}

.cascade-step.final {
    background: #eff6ff;
    border-color: #bfdbfe;
    font-weight: 700;
}

.step-badge {
    background: #f1f5f9;
    color: #0f172a;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.70rem;
}

.cascade-arrow {
    text-align: center;
    color: #94a3b8;
    font-size: 0.9rem;
    line-height: 1;
}

.highlight-val {
    color: var(--primary-color);
    font-weight: 700;
}

/* Material Buttons Grid */
.material-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.45rem;
}

.mat-btn {
    padding: 0.55rem 0.65rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.12s ease;
    touch-action: manipulation;
}

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

.mat-btn span {
    font-family: var(--font-mono), monospace;
    font-size: 0.72rem;
    color: var(--primary-color);
}

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

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

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

.action-link-btn {
    padding: 0.55rem 0.85rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
    color: var(--primary-color);
    font-family: inherit;
    font-size: 0.80rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: manipulation;
    text-align: center;
    min-height: 38px;
}

.action-link-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}

/* Calculation & Invariant Boxes */
.calc-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.80rem;
}

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

.calc-row.highlight {
    background: #f0fdf4;
    padding: 0.45rem 0.55rem;
    border-radius: 4px;
    border: 1px solid #bbf7d0;
    color: #15803d;
    font-weight: 700;
}

/* Visualization Options Toggles Grid */
.toggles-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.80rem;
    color: #334155;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input {
    accent-color: var(--primary-color);
    width: 16px;
    height: 16px;
}

.sub-card {
    margin-top: 0.45rem;
}

/* ==========================================================================
   8. Dedicated Full-Width Theory Section (Option A Standard)
   ========================================================================== */
.concepts-box {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.25rem 2rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    user-select: text;
}

.concepts-header {
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 0.85rem;
}

.concepts-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.concepts-sub {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.concepts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: 1.35rem;
}

.concept-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.concept-tag {
    font-family: var(--font-mono), monospace;
    font-size: 0.70rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.05em;
}

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

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

.concept-card ul {
    padding-left: 1.25rem;
    font-size: 0.84rem;
    color: var(--text-sub);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.formula-callout {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    text-align: center;
    font-size: 0.95rem;
    color: #0f172a;
    overflow-x: auto;
}

/* ==========================================================================
   9. Institutional Admission Callout Card (Standard 4.3)
   ========================================================================== */
.admission-card {
    background: linear-gradient(135deg, #1e3a8a, #0f172a);
    color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 2.25rem 2rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    overflow: hidden;
    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.2);
        border-color: rgba(251, 191, 36, 0.15);
    }
    50% {
        box-shadow: 0 0 25px 6px rgba(251, 191, 36, 0.45);
        border-color: rgba(251, 191, 36, 0.75);
    }
    100% {
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
        border-color: rgba(251, 191, 36, 0.15);
    }
}

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

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

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

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

.program-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 1rem;
}

.program-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.program-card strong {
    font-size: 1.15rem;
    color: #fbbf24;
}

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

.program-card small {
    font-size: 0.76rem;
    color: #94a3b8;
}

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

.promo-button {
    padding: 0.75rem 1.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.90rem;
    font-weight: 700;
    text-decoration: none;
    text-align: center;
    transition: all 0.15s ease;
    touch-action: manipulation;
}

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

.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.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    flex-wrap: wrap;
}

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

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

.feedback-text h4 {
    font-size: 0.96rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.15rem;
}

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

.feedback-btn {
    padding: 0.65rem 1.25rem;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    color: #1e293b;
    font-size: 0.84rem;
    font-weight: 600;
    text-decoration: none;
    font-family: var(--font-mono), monospace;
    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 canvas dominates screen */
        border-top: 2px solid var(--primary-color);
    }

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

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

    /* Generous canvas height on mobile for deep interactivity */
    .viewport-wrapper {
        height: 460px;
    }

    .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;
    }

    .camera-presets {
        overflow-x: auto;
    }
}

@media (max-width: 600px) {
    .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.5rem;
        left: 0.5rem;
        right: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .camera-presets {
        max-width: calc(100% - 110px);
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .camera-presets::-webkit-scrollbar {
        display: none;
    }

    .viewport-wrapper {
        height: 420px;
    }

    .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;
    }

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

/* Readouts, status lines and labels wrap instead of being cut off. */
.stat-label,
.stat-data {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
}

/* Phones: the toolbar already wraps the icon buttons onto a second row, so the view buttons
   can use the full width (and wrap if needed) instead of hiding "Side"/"End-On" off to the right. */
@media (max-width: 600px) {
    .camera-presets {
        max-width: 100%;
        flex-wrap: wrap;
        overflow-x: visible;
        white-space: normal;
        row-gap: 0.3rem;
    }
}
