:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text: #1e293b;
    --text-muted: #64748b;
    --border: rgba(226, 232, 240, 0.8);
    --radius: 12px;
    --laser: #ef4444;
    --refracted: #3b82f6;
    --reflected: #f59e0b;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.8);
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: rgba(51, 65, 85, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Header */
.simulation-header {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.sim-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary), #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.back-link {
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.85rem;
}

/* Layout */
.sim-main {
    padding: 2rem 0;
}

.sim-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
}

@media (max-width: 950px) {
    .sim-layout { grid-template-columns: 1fr; }
}

/* Controls */
.controls-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 2rem;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: fit-content;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05);
}

.control-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.input-select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: 0.2s;
}

.input-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.theory-box {
    padding: 1.25rem;
    background: rgba(37, 99, 235, 0.05);
    border-radius: 8px;
    border-left: 4px solid var(--primary);
}

.theory-box h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.theory-box p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.button-group {
    display: flex;
    gap: 0.75rem;
}

.btn {
    flex: 1;
    padding: 0.75rem 0.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    transition: 0.2s;
}

.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--border); color: var(--text); }

.instruction-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

/* Visualizer */
.visualizer {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 500px;
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: crosshair;
}

#opticsCanvas {
    width: 100%;
    height: 100%;
}

.medium-label {
    position: absolute;
    left: 20px;
    font-weight: 800;
    font-family: 'Outfit';
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    pointer-events: none;
}

.medium-label.top { top: 20px; background: rgba(0,0,0,0.05); }
.medium-label.bottom { bottom: 20px; background: rgba(37, 99, 235, 0.1); color: var(--primary); }

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.data-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 1.25rem;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.data-card .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.data-card .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Outfit';
}
