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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    min-height: 100vh;
    padding: 20px;
}

.precipitation-container {
    max-width: 1600px;
    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, #06b6d4 0%, #0891b2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

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

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

main {
    padding: 30px;
}

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

.left-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.chart-display h3 {
    color: #1e293b;
    font-size: 1.05rem;
    margin-bottom: 15px;
    font-weight: 600;
}

canvas {
    width: 100%;
    border-radius: 8px;
    background: white;
    display: block;
}

#beakerCanvas,
#particleCanvas {
    height: auto;
}

/* Beaker Info */
.beaker-info {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

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

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

/* Q vs Ksp Display */
.q-ksp-display {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.comparison-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #06b6d4;
}

.comparison-label {
    font-weight: 600;
    color: #475569;
    font-size: 0.95rem;
}

.comparison-value {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #1e293b;
    font-size: 1rem;
}

.comparison-result {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 15px;
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    border-radius: 10px;
    color: white;
}

.result-icon {
    font-size: 1.8rem;
    font-weight: 700;
}

.result-text {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Particle Legend */
.particle-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #475569;
}

.particle-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.3);
}

.particle-icon.cation {
    background: #ef4444;
}

.particle-icon.anion {
    background: #3b82f6;
}

.particle-icon.precipitate {
    background: #e2e8f0;
    border: 2px solid #475569;
}

/* Concentration Grid */
.concentration-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.conc-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

.conc-label {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 4px;
}

.conc-value {
    font-size: 0.95rem;
    color: #1e293b;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

/* Equation Display */
.equation-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 20px;
    background: white;
    border-radius: 10px;
    font-size: 1.2rem;
    font-family: 'Times New Roman', serif;
}

.equation-display .reactant {
    color: #0891b2;
    font-weight: 600;
}

.equation-display .product {
    color: #059669;
    font-weight: 700;
}

/* Controls Panel */
.controls-panel {
    background: #f8fafc;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.controls-panel h3 {
    color: #1e293b;
    font-size: 1.3rem;
    margin-bottom: 20px;
    font-weight: 600;
}

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

.control-group {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.control-group h4 {
    color: #475569;
    font-size: 1rem;
    margin-bottom: 15px;
    font-weight: 600;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
}

.control-group > label {
    display: block;
    margin-bottom: 8px;
    color: #475569;
    font-size: 0.9rem;
}

.control-group input[type="range"] {
    width: 100%;
    margin-bottom: 12px;
    accent-color: #06b6d4;
}

.control-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    color: #1e293b;
    margin-bottom: 12px;
    cursor: pointer;
}

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

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

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

/* Precipitate Details */
.precipitate-details {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 15px;
    margin-top: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.detail-row:last-child {
    margin-bottom: 0;
}

.detail-row span:first-child {
    color: #64748b;
    font-weight: 500;
}

.detail-row span:last-child {
    color: #1e293b;
    font-weight: 600;
}

/* Button Groups */
.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

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

.control-button.mix {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    color: white;
}

.control-button.mix:hover {
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
    transform: translateY(-2px);
}

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

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

/* Formulas Section */
.formulas-section {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.formulas-section h3 {
    color: #1e293b;
    font-size: 1.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

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

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

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

.formula {
    font-family: 'Courier New', monospace;
    color: #1e293b;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Status Text */
.status-text {
    font-weight: 600;
}

.status-text.precipitating {
    color: #dc2626;
}

.status-text.dissolved {
    color: #16a34a;
}

.status-text.saturated {
    color: #d97706;
}

/* Explanation Section */
.explanation {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-top: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.explanation h2 {
    color: #1e293b;
    font-size: 1.6rem;
    margin-bottom: 20px;
    font-weight: 700;
}

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

.explanation p {
    color: #64748b;
    line-height: 1.7;
    margin-bottom: 15px;
}

.explanation strong {
    color: #1e293b;
}

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

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

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

    .subtitle {
        font-size: 0.9rem;
    }

    main {
        padding: 20px;
    }

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

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

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

    .particle-legend {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
}
