* {
    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;
}

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

header {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

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

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

main {
    padding: 30px;
}

.visualization-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.molecule-panel,
.mirror-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    position: relative;
}

.molecule-panel h3,
.mirror-panel h3 {
    color: #5b21b6;
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
    background: #1a1a2e;
    margin-bottom: 15px;
}

.molecule-info {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    color: #475569;
}

.mirror-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(100, 200, 255, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0.8;
}

.polarized-light-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.polarized-light-panel h3 {
    color: #5b21b6;
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.light-visualization {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.light-info {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
}

.light-indicator {
    text-align: center;
    font-size: 0.9rem;
    color: #475569;
}

.cip-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.cip-panel h3 {
    color: #5b21b6;
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

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

.priority-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.priority-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
    color: white;
}

.priority-number[data-priority="1"] {
    background: #ef4444;
}

.priority-number[data-priority="2"] {
    background: #f59e0b;
}

.priority-number[data-priority="3"] {
    background: #10b981;
}

.priority-number[data-priority="4"] {
    background: #6b7280;
}

.priority-atom {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.95rem;
    color: #475569;
}

.priority-desc {
    font-size: 0.8rem;
    color: #64748b;
    margin-left: auto;
}

.cip-explanation {
    background: #ede9fe;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #7c3aed;
}

.cip-explanation p {
    font-size: 0.9rem;
    color: #4c1d95;
    line-height: 1.5;
}

.controls-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.controls-panel h3 {
    color: #5b21b6;
    font-size: 1.2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

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

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

.control-group label {
    font-size: 0.9rem;
    color: #475569;
    font-weight: 500;
}

.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: #7c3aed;
    cursor: pointer;
    transition: background 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #6d28d9;
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #7c3aed;
    cursor: pointer;
    border: none;
}

.control-group select {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.control-group select:hover {
    border-color: #7c3aed;
}

.molecule-selector,
.config-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.molecule-btn,
.config-btn {
    flex: 1 1 100px;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    background: white;
    color: #475569;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.molecule-btn:hover,
.config-btn:hover {
    border-color: #7c3aed;
    color: #7c3aed;
}

.molecule-btn.active,
.config-btn.active {
    background: #7c3aed;
    color: white;
    border-color: #7c3aed;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 25px;
}

.control-button {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s;
}

.control-button.toggle {
    background: #64748b;
    color: white;
}

.control-button.toggle:hover {
    background: #475569;
}

.control-button.switch {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
}

.control-button.switch:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.control-button.animate-light {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
}

.control-button.animate-light:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.control-button.reset {
    background: #ef4444;
    color: white;
}

.control-button.reset:hover {
    background: #dc2626;
}

.options-section,
.formulas-section {
    margin-top: 25px;
    padding-top: 25px;
    border-top: 1px solid #e2e8f0;
}

.options-section h3,
.formulas-section h3 {
    color: #5b21b6;
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

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

.option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #475569;
    cursor: pointer;
}

.option-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #7c3aed;
}

.formula-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.formula-label {
    font-weight: 600;
    color: #5b21b6;
    font-size: 0.9rem;
}

.formula {
    color: #475569;
    font-size: 0.9rem;
}

.explanation {
    background: #f8fafc;
    padding: 30px;
    border-radius: 12px;
}

.explanation h2 {
    color: #5b21b6;
    font-size: 1.5rem;
    margin-bottom: 20px;
    font-weight: 700;
}

.explanation h3 {
    color: #7c3aed;
    font-size: 1.2rem;
    margin-top: 25px;
    margin-bottom: 12px;
    font-weight: 600;
}

.explanation p {
    color: #475569;
    line-height: 1.7;
    margin-bottom: 15px;
    font-size: 1rem;
}

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

    .priority-display {
        grid-template-columns: 1fr;
    }

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

    .button-group {
        flex-direction: column;
    }

    .molecule-selector,
    .config-selector {
        flex-direction: column;
    }

    .molecule-btn,
    .config-btn {
        width: 100%;
        min-width: auto;
        flex: none;
    }

    header h1 {
        font-size: 1.5rem;
    }

    main {
        padding: 15px;
    }
}
