:root {
    --bg-sim: #f8fafc;
    --panel-bg: rgba(255, 255, 255, 0.9);
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.3);
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: rgba(0, 0, 0, 0.05);
    --copper: #d97706;
    --iron: #475569;
}

body.solenoid-page {
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    background-color: #000;
    color: var(--text-main);
    overflow: hidden;
    touch-action: none;
}

#phet-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    height: 720px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-sim);
    transform-origin: top left;
}

#bgCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.drag-handle:active {
    cursor: grabbing !important;
}

nav {
    position: relative !important;
    background: white;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.logo span {
    font-weight: 300;
}

.nav-center {
    display: flex;
    align-items: center;
    gap: 10px;
}

.divider {
    color: #cbd5e1;
    font-weight: 300;
}

.chapter-label {
    color: var(--secondary);
    font-weight: 700;
    font-size: 0.9rem;
}

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

.btn-back {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

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

#sim-app {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.sim-container {
    flex: 1;
    display: flex;
    position: relative;
}

.canvas-panel {
    flex: 1;
    position: relative;
    background: #0f172a; /* Dark background for better field visibility */
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.control-panel {
    width: 320px;
    background: white;
    border-left: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 10;
    overflow-y: auto;
}

@media (max-width: 1024px) {
    .control-panel {
        width: 220px;
        padding: 12px;
        gap: 10px;
    }
    .stats-box {
        gap: 8px;
    }
    .stat-item .value {
        font-size: 1rem;
    }
    .stat-item .label {
        font-size: 0.7rem;
    }
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-header {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.phet-box {
    background: #f8fafc;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid var(--border);
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.control-row label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.val-display {
    font-family: 'Space Grotesk', monospace;
    font-weight: 700;
    color: var(--primary);
    font-size: 0.95rem;
}

.slider-blue {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    margin-bottom: 15px;
}

.slider-blue::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.material-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 5px;
}

.material-btn {
    padding: 8px;
    border: 1px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    font-family: 'Outfit';
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-item .value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--secondary);
}

.btn-action {
    background: #f1f5f9;
    border: none;
    padding: 12px;
    border-radius: 12px;
    font-family: 'Outfit';
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
}

.hint-overlay {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: white;
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

.field-legend {
    position: absolute;
    bottom: 24px;
    left: 24px;
    background: rgba(15, 23, 42, 0.8);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: white;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.line-sample {
    width: 20px;
    height: 2px;
    border-radius: 2px;
}

.line-sample.positive { background: #60a5fa; }
.line-sample.negative { background: #f87171; }
