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

.indicator-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;
}

#titrationCanvas,
#spectrumCanvas {
    height: auto;
}

.titration-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;
}

/* pH Meter Display */
.ph-meter-display {
    text-align: center;
    padding: 20px;
}

.ph-value-large {
    font-size: 4rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 15px;
    font-variant-numeric: tabular-nums;
}

.ph-scale-bar {
    position: relative;
    height: 30px;
    background: linear-gradient(to right,
        #ef4444 0%,
        #f97316 14.28%,
        #eab308 28.57%,
        #84cc16 42.86%,
        #22c55e 57.14%,
        #14b8a6 71.43%,
        #3b82f6 85.71%,
        #8b5cf6 100%
    );
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 10px;
}

.ph-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 50%;
    background: rgba(255, 255, 255, 0.3);
    border-right: 3px solid #1e293b;
}

.ph-scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #64748b;
}

/* Color Preview */
.color-preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px;
}

.color-preview-large {
    width: 150px;
    height: 100px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: background-color 0.3s ease;
}

.color-info {
    font-size: 0.85rem;
    color: #1e293b;
    font-weight: 500;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
}

/* Indicators Grid */
.indicators-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.indicator-card {
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.indicator-color-box {
    width: 100%;
    height: 50px;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 2px solid #e2e8f0;
    transition: background-color 0.3s ease;
}

.indicator-info {
    font-size: 0.8rem;
}

.indicator-name {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.indicator-range {
    color: #64748b;
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.indicator-status {
    font-size: 0.7rem;
    color: #94a3b8;
}

.indicator-status.in-transition {
    color: #22c55e;
    font-weight: 600;
}

/* Spectrum Legend */
.spectrum-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;
}

.legend-box {
    width: 20px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid #cbd5e1;
}

.legend-box.acid {
    background: #ef4444;
}

.legend-box.neutral {
    background: #22c55e;
}

.legend-box.basic {
    background: #3b82f6;
}

/* 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: #8b5cf6;
}

.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: #8b5cf6;
}

.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: #8b5cf6;
    cursor: pointer;
}

/* pH Presets */
.ph-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.ph-preset-btn {
    padding: 8px 12px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.ph-preset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(139, 92, 246, 0.3);
}

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

/* 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.start {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.control-button.start:hover {
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
    transform: translateY(-2px);
}

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

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

/* Indicator Details */
.indicator-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;
}

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

/* 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 #8b5cf6;
}

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

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

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

    .ph-value-large {
        font-size: 3rem;
    }

    .indicators-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

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

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