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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.2em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    min-height: 700px;
}

.sidebar {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-btn {
    padding: 12px 16px;
    border: none;
    background: #f0f0f0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: left;
}

.nav-btn:hover {
    background: #e0e0e0;
    transform: translateX(5px);
}

.nav-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.theory-panel {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.theory-panel h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1em;
}

#theory-content {
    font-size: 0.9em;
    line-height: 1.6;
}

#theory-content p {
    margin-bottom: 10px;
}

.visualization-area {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.canvas-container {
    position: relative;
    background: #f8f8f8;
    border-radius: 10px;
    overflow: hidden;
    height: 500px;
}

#polarizationCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.intensity-display {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    min-width: 250px;
}

.intensity-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.intensity-label {
    font-weight: 600;
    color: #333;
    font-size: 0.9em;
}

.intensity-bar {
    flex: 1;
    height: 20px;
    background: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.intensity-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 100%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.intensity-value {
    font-weight: bold;
    color: #667eea;
    min-width: 50px;
    text-align: right;
}

.controls-panel {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

#controls-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-value {
    color: #667eea;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #d3d3d3;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 10px 20px;
    border: none;
    background: #667eea;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.control-btn.active {
    background: #764ba2;
}

.info-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.formula-box, .calculation-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.formula-box h4, .calculation-box h4 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1em;
}

#formula-content, #calculation-content {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.8;
}

.math {
    background: white;
    padding: 10px;
    border-radius: 5px;
    margin: 5px 0;
    font-weight: 500;
}

.problem-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 15px;
    border-left: 4px solid #667eea;
}

.problem-container h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.problem-input {
    display: flex;
    gap: 10px;
    margin: 15px 0;
    align-items: center;
}

.problem-input input {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 0.95em;
    width: 150px;
}

.problem-input input:focus {
    outline: none;
    border-color: #667eea;
}

.check-btn {
    padding: 8px 20px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
}

.check-btn:hover {
    background: #45a049;
}

.result {
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    font-weight: 500;
}

.result.correct {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.result.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .info-panel {
        grid-template-columns: 1fr;
    }
}
