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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.single-slit-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

main {
    padding: 30px;
}

.optical-diagram-section,
.intensity-section,
.pattern-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.optical-diagram-section h3,
.intensity-section h3,
.pattern-section h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 15px;
}

.optical-diagram-section canvas,
.intensity-section canvas,
.pattern-section canvas {
    width: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.optical-diagram-section canvas {
    height: 300px;
}

.intensity-pattern-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 1024px) {
    .intensity-pattern-row {
        grid-template-columns: 1fr;
    }
}

.intensity-section canvas {
    height: 280px;
}

.pattern-section canvas {
    height: 280px;
}

.optical-measurements {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.measurement-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #475569;
}

.measurement-item span:last-child {
    color: #3b82f6;
    font-weight: 700;
}

.intensity-markers {
    margin-top: 15px;
}

.marker-info {
    padding: 10px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #475569;
}

.marker-info span:last-child {
    color: #ef4444;
    font-weight: 600;
}

.pattern-legend {
    margin-top: 15px;
}

.legend-gradient {
    height: 20px;
    background: linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,1), rgba(0,0,0,0));
    border-radius: 4px;
    margin-bottom: 8px;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #64748b;
}

.controls-panel {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
}

.controls-panel h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: #0c4a6e;
    margin-bottom: 20px;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.control-group {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.control-group h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #6366f1;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e7ff;
}

.control-group label {
    display: block;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
    margin-top: 12px;
    font-size: 0.85rem;
}

.control-group label span:last-child {
    color: #6366f1;
    font-weight: 700;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.checkbox-input {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.wavelength-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.wavelength-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.preset-btn {
    padding: 10px 15px;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 8px;
    width: 100%;
}

.preset-btn:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.formulas-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.formulas-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0c4a6e;
    margin-bottom: 15px;
}

.formula-list {
    display: grid;
    gap: 12px;
}

.formula-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: #f8fafc;
    border-radius: 6px;
}

.formula-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    min-width: 160px;
}

.formula {
    font-family: 'Times New Roman', serif;
    font-size: 0.95rem;
    color: #1e40af;
    font-style: italic;
}

.explanation {
    padding: 30px;
    background: #fafafa;
    border-top: 1px solid #e5e7eb;
}

.explanation h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #0c4a6e;
    margin-bottom: 15px;
}

.explanation h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #6366f1;
    margin: 20px 0 10px;
}

.explanation p {
    line-height: 1.8;
    color: #374151;
    margin-bottom: 12px;
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.6rem;
    }

    header .subtitle {
        font-size: 0.95rem;
    }

    main {
        padding: 15px;
    }

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

    .preset-buttons {
        grid-template-columns: 1fr;
    }

    .formula-label {
        min-width: auto;
    }

    .formula-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
