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

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

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

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

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

main {
    padding: 30px;
}

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

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

.cell-panel,
.graph-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chart-display {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.chart-display h3 {
    color: #dc2626;
    margin-bottom: 15px;
    font-size: 1.3em;
    font-weight: 600;
    text-align: center;
}

canvas {
    width: 100%;
    height: 300px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

.cell-info,
.bubble-info,
.product-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.info-item {
    background: white;
    padding: 10px;
    border-radius: 6px;
    border-left: 4px solid #dc2626;
    font-size: 0.9em;
}

.info-item span:first-child {
    font-weight: 600;
    color: #dc2626;
}

.graph-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    flex-wrap: wrap;
}

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

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #374151;
}

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

.controls-panel h3 {
    color: #dc2626;
    margin-bottom: 20px;
    font-size: 1.5em;
    font-weight: 600;
}

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

.control-group {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.control-group h4 {
    color: #f97316;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
}

.control-group label {
    display: block;
    margin-bottom: 10px;
    font-size: 0.9em;
    color: #374151;
}

.control-group input[type="range"] {
    width: 100%;
    margin-bottom: 15px;
    height: 8px;
    border-radius: 4px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
}

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

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

.control-group select {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    font-size: 0.95em;
    cursor: pointer;
}

.control-group select:focus {
    outline: none;
    border-color: #f97316;
}

.checkbox-input {
    width: auto !important;
    margin-right: 10px;
    margin-bottom: 15px !important;
    height: auto !important;
}

.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.control-button {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.control-button.start {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.control-button.start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.3);
}

.control-button.pause {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

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

.control-button.reset {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.control-button.reset:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(239, 68, 68, 0.3);
}

.preset-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 8px;
    border: 2px solid #f97316;
    border-radius: 6px;
    background: white;
    color: #f97316;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    background: #f97316;
    color: white;
    transform: translateY(-1px);
}

.formulas-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

.formulas-section h3 {
    color: #dc2626;
    margin-bottom: 15px;
    font-size: 1.3em;
    font-weight: 600;
}

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

.formula-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: #f8fafc;
    border-radius: 6px;
    border-left: 4px solid #f97316;
}

.formula-label {
    font-weight: 600;
    color: #dc2626;
    min-width: 180px;
    font-size: 0.95em;
}

.formula {
    font-family: 'Courier New', monospace;
    color: #374151;
    font-size: 1.05em;
    background: white;
    padding: 8px 12px;
    border-radius: 4px;
    flex: 1;
}

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

.explanation h2 {
    color: #dc2626;
    margin-bottom: 20px;
    font-size: 2em;
    font-weight: 700;
}

.explanation h3 {
    color: #f97316;
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.5em;
    font-weight: 600;
}

.explanation p {
    color: #374151;
    margin-bottom: 15px;
    font-size: 1.05em;
}

.explanation strong {
    color: #dc2626;
    font-weight: 600;
}

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

    .subtitle {
        font-size: 0.95em;
    }

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

    .cell-info,
    .bubble-info,
    .product-info {
        grid-template-columns: 1fr;
    }

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

    .control-button {
        width: 100%;
    }
}
