* {
    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, #8b5cf6 0%, #6366f1 100%);
    min-height: 100vh;
    padding: 20px;
}

.ph-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, #6366f1 0%, #8b5cf6 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;
}

#phScaleCanvas {
    height: 120px;
}

#titrationCanvas {
    height: 300px;
}

#logPlotCanvas {
    height: 250px;
}

.calculator-panel {
    background: white;
    border-radius: 8px;
    padding: 20px;
}

.calc-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.info-item {
    padding: 12px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.9rem;
}

.info-item span:first-child {
    font-weight: 600;
    color: #475569;
    margin-right: 8px;
}

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

.curve-info,
.log-info {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
}

.ph-scale-legend {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    padding: 12px;
    background: white;
    border-radius: 8px;
}

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

.ph-color {
    width: 30px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

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

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

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

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

.control-group h4 {
    color: #475569;
    font-size: 1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.control-group label {
    display: block;
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 8px;
    margin-top: 15px;
}

.control-group label:first-of-type {
    margin-top: 0;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
    margin-top: 8px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: none;
}

.slider-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 6px;
    font-style: italic;
}

.select-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #475569;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.select-input:hover {
    border-color: #cbd5e1;
}

.select-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.titration-btn,
.preset-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 8px;
    margin-top: 8px;
}

.titration-btn:hover,
.preset-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.titration-btn:active,
.preset-btn:active {
    transform: translateY(0);
}

.formulas-section {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

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

.formula-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
}

.formula-item {
    padding: 12px 16px;
    background: #f8fafc;
    border-left: 3px solid #6366f1;
    border-radius: 6px;
}

.formula-label {
    display: block;
    color: #64748b;
    font-size: 0.85rem;
    margin-bottom: 6px;
    font-weight: 500;
}

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

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

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

.explanation h3 {
    color: #475569;
    font-size: 1.3rem;
    margin-top: 30px;
    margin-bottom: 15px;
    font-weight: 600;
}

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

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

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

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

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

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

    .subtitle {
        font-size: 0.95rem;
    }

    main {
        padding: 20px;
    }

    .explanation {
        padding: 25px;
    }

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