/* Calculus Fundamentals - Real-World Scenario Design */
* {
    box-sizing: border-box;
}

:root {
    --primary: #8b5cf6;
    --accent: #d946ef;
    --bg: #0f172a;
    --grid: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
    --text-muted: #94a3b8;
    --car-color: #f59e0b;
}

body.math-lab-theme {
    background-color: var(--bg);
    color: white;
    font-family: 'Outfit', sans-serif;
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    touch-action: none;
    /* Mobile optimization */
}

#phet-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    height: 720px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: 0 0;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.4);
    touch-action: none;
}

.phet-nav {
    position: relative !important;
    background: #e2e8f0 !important;
    height: 65px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    border-bottom: 2px solid #cbd5e1;
    flex-shrink: 0;
    box-sizing: border-box;
    z-index: 100;
}


.logo {
    font-weight: 700;
}

.logo span {
    color: var(--primary);
    font-weight: 300;
}

#sim-app {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.canvas-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
}

.graph-container {
    flex: 2;
    position: relative;
    background: radial-gradient(var(--grid) 1px, transparent 1px);
    background-size: 30px 30px;
}

#mainCanvas {
    width: 100%;
    height: 100%;
    cursor: ew-resize;
}

/* Physical World Road Trip Visualization */
.physical-world {
    flex: 1;
    background: #1e293b;
    border-top: 2px solid var(--primary);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 40px;
}

.track {
    height: 10px;
    background: #475569;
    border-radius: 5px;
    position: relative;
    width: 100%;
}

.car {
    position: absolute;
    top: -35px;
    left: 0;
    font-size: 2.5rem;
    color: var(--car-color);
    transition: left 0.1s linear;
}

.speed-vector {
    position: absolute;
    top: 15px;
    left: 40px;
    height: 4px;
    background: #ef4444;
    border-radius: 2px;
    transform-origin: left center;
    transition: width 0.1s linear;
}

.speed-vector::after {
    content: '';
    position: absolute;
    right: -5px;
    top: -4px;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid #ef4444;
}

.distance-markers {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
}

/* Sidebar & HUD */
.calc-sidebar {
    width: 100%;
    height: 100%;
    background: #0f172a;
    border-left: 1px solid var(--border);
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.mode-selector {
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 5px;
    border-radius: 12px;
}

.mode-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Outfit';
    font-weight: 700;
    font-size: 0.85rem;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.mode-btn i {
    font-size: 1.2rem;
}

.mode-btn.active {
    background: var(--primary);
    color: white;
}

.hud-panel {
    margin-top: 10px;
}

.hud-panel h3 {
    color: var(--accent);
    margin-bottom: 10px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-panel p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 25px;
}

.live-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 15px;
    border-radius: 8px;
}

.stat .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stat .val {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.stat.highlight {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid var(--primary);
}

.stat.highlight .val {
    color: var(--accent);
    font-size: 1.5rem;
}

.instruction {
    text-align: center;
    color: var(--car-color);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 15px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 8px;
    border: 1px dashed rgba(245, 158, 11, 0.3);
}

.hidden {
    display: none !important;
}