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

:root {
    --primary-color: #2196F3;
    --secondary-color: #1976D2;
    --accent-color: #FFC107;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --bg-primary: #0a0e27;
    --bg-secondary: #1a1f3a;
    --bg-tertiary: #252b4a;
    --border-color: #3a4a6a;
    --success-color: #4CAF50;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0f1729 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: 15px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

header h1 {
    font-size: 2.5em;
    background: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    color: var(--text-secondary);
}

/* Main Content */
main {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    margin-bottom: 30px;
}

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

/* Canvas Section */
.canvas-section {
    background: var(--bg-secondary);
    border-radius: 15px;
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 500px;
    margin-bottom: 20px;
}

#dispersionCanvas {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background: radial-gradient(ellipse at center, #0d1329 0%, #050813 100%);
    cursor: grab;
}

#dispersionCanvas:active {
    cursor: grabbing;
}

.zoom-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}

.zoom-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.zoom-btn:hover {
    background: var(--primary-color);
    transform: scale(1.05);
}

/* Spectrum Bar */
.spectrum-bar {
    display: flex;
    height: 40px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.spectrum-color {
    flex: 1;
    transition: all 0.3s ease;
}

.spectrum-color:hover {
    flex: 1.5;
    filter: brightness(1.2);
}

/* Controls Section */
.controls-section {
    background: var(--bg-secondary);
    border-radius: 15px;
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    max-height: 800px;
    overflow-y: auto;
}

.controls-section::-webkit-scrollbar {
    width: 8px;
}

.controls-section::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 10px;
}

.controls-section::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.control-group {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.control-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.control-group h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group h3::before {
    content: "▸";
    color: var(--accent-color);
}

.control-item {
    margin-bottom: 15px;
}

.control-item label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.95em;
}

.control-item label span:first-child {
    display: inline-block;
    margin-bottom: 5px;
}

.value-display {
    float: right;
    color: var(--accent-color);
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-color);
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--accent-color);
    transform: scale(1.2);
}

select {
    width: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.3s ease;
}

select:hover, select:focus {
    border-color: var(--primary-color);
    outline: none;
}

select option {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.checkbox-item:hover {
    background: var(--bg-tertiary);
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* Material Info */
.material-info {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.material-info p {
    margin-bottom: 8px;
    font-size: 0.95em;
}

.material-info p:last-child {
    margin-bottom: 0;
}

.material-info span:first-child {
    color: var(--text-secondary);
    margin-right: 8px;
}

/* Stats Table */
.stats-group {
    max-height: 400px;
    overflow-y: auto;
}

.stats-table {
    overflow-x: auto;
}

.stats-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.stats-table th,
.stats-table td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.stats-table th {
    background: var(--bg-tertiary);
    color: var(--primary-color);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.stats-table tr:hover {
    background: var(--bg-tertiary);
}

.stats-table td {
    color: var(--text-secondary);
}

/* Reset Button */
.reset-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(33, 150, 243, 0.4);
}

.reset-btn:active {
    transform: translateY(0);
}

/* Educational Content */
.educational-content {
    background: var(--bg-secondary);
    border-radius: 15px;
    padding: 30px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.content-block {
    margin-bottom: 30px;
}

.content-block:last-child {
    margin-bottom: 0;
}

.content-block h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 2em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.content-block h2::before {
    content: "◆";
    color: var(--accent-color);
}

.content-block h3 {
    color: var(--accent-color);
    margin-bottom: 15px;
    font-size: 1.5em;
}

.content-block p {
    color: var(--text-secondary);
    margin-bottom: 15px;
    line-height: 1.8;
}

.content-block ul {
    list-style: none;
    padding-left: 0;
}

.content-block ul li {
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-left: 25px;
    position: relative;
    line-height: 1.8;
}

.content-block ul li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary-color);
    font-weight: bold;
}

.formula-section {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
}

.formula-section h4 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 1.1em;
}

.formula {
    background: var(--bg-primary);
    padding: 15px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    text-align: center;
    margin: 10px 0;
    border: 1px solid var(--border-color);
    color: var(--accent-color);
}

.formula-section p {
    margin-top: 10px;
    font-size: 0.95em;
}

/* Spectrum List */
.spectrum-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.spectrum-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.spectrum-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.color-box {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.spectrum-item div {
    flex: 1;
}

.spectrum-item strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.spectrum-item span {
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 1em;
    }

    .canvas-container {
        height: 350px;
    }

    .controls-section {
        max-height: none;
    }

    .spectrum-list {
        grid-template-columns: 1fr;
    }

    .content-block h2 {
        font-size: 1.5em;
    }

    .content-block h3 {
        font-size: 1.2em;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.content-block {
    animation: fadeIn 0.5s ease-out;
}

.control-group {
    animation: fadeIn 0.5s ease-out;
}

/* Loading State */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--text-secondary);
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9em;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tooltip.show {
    opacity: 1;
}
