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

.buffer-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, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

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

header .subtitle {
    font-size: 1.1em;
    opacity: 0.95;
    line-height: 1.6;
}

main {
    padding: 30px;
}

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

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

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

.chart-display h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
    font-weight: 600;
}

.chart-display canvas {
    width: 100%;
    height: auto;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.ph-info,
.curve-info,
.capacity-info {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.95em;
}

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

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

.molecule-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

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

.molecule-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-block;
}

.molecule-icon.ha {
    background: #e74c3c;
}

.molecule-icon.a {
    background: #3498db;
}

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

.controls-panel h3 {
    color: #333;
    margin-bottom: 25px;
    font-size: 1.5em;
    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;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-size: 0.95em;
}

.control-group input[type="range"] {
    width: 100%;
    margin-bottom: 15px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    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: #667eea;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

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

.slider-hint {
    font-size: 0.85em;
    color: #888;
    margin-bottom: 15px;
    font-style: italic;
}

.select-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95em;
    background: white;
    cursor: pointer;
}

.select-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.titration-btn,
.preset-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    margin-right: 10px;
    margin-bottom: 10px;
}

.titration-btn {
    background: #667eea;
    color: white;
}

.titration-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.preset-btn {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #ddd;
}

.preset-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-2px);
}

.ph-change-display {
    background: #f0f0f0;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.ph-change-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.ph-change-item:last-child {
    margin-bottom: 0;
}

.ph-change-item span:first-child {
    font-weight: 600;
    color: #555;
}

.ph-change-item span:last-child {
    font-weight: 700;
    color: #667eea;
}

.formulas-section {
    background: white;
    padding: 25px;
    border-radius: 10px;
    margin-top: 30px;
}

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

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

.formula-item {
    display: flex;
    flex-direction: column;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.formula-label {
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
    font-size: 0.95em;
}

.formula {
    font-family: 'Courier New', monospace;
    color: #333;
    font-size: 1.1em;
    background: white;
    padding: 10px;
    border-radius: 4px;
    display: inline-block;
}

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

.explanation h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 1.8em;
    font-weight: 700;
}

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

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

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

.values-display {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

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

.value-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.value-label {
    display: block;
    font-size: 0.9em;
    color: #777;
    margin-bottom: 5px;
    font-weight: 600;
}

.value-value {
    display: block;
    font-size: 1.3em;
    font-weight: 700;
    color: #333;
}

.value-value.red {
    color: #e74c3c;
}

.value-value.blue {
    color: #3498db;
}

.value-value.green {
    color: #2ecc71;
}

.color-box {
    display: inline-block;
    width: 30px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 5px;
}

.indicator-preview {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

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

    header .subtitle {
        font-size: 0.95em;
    }

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

    .chart-display h3 {
        font-size: 1em;
    }

    .explanation h2 {
        font-size: 1.5em;
    }

    .explanation h3 {
        font-size: 1.2em;
    }
}
