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

.first-order-reaction-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, #5b21b6 0%, #8b5cf6 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

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

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

main {
    padding: 30px;
}

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

.concentration-panel,
.decay-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.1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

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

.chart-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.9rem;
    color: #475569;
}

.legend-color {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

.semilog-info,
.decay-info,
.halflife-info {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.info-item {
    font-size: 0.95rem;
    color: #475569;
    text-align: center;
}

.controls-panel {
    background: #f1f5f9;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

.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 h4 {
    color: #334155;
    font-size: 1rem;
    margin-bottom: 15px;
    font-weight: 600;
}

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

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #cbd5e1;
    outline: none;
    margin-bottom: 15px;
    cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #8b5cf6;
    cursor: pointer;
    transition: background 0.3s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    background: #7c3aed;
}

.checkbox-input {
    width: auto !important;
    height: auto !important;
    margin-right: 8px;
    margin-bottom: 12px !important;
    cursor: pointer;
}

.preset-btn {
    padding: 10px 16px;
    background: #8b5cf6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
    margin-right: 10px;
    margin-bottom: 10px;
}

.preset-btn:hover {
    background: #7c3aed;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

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

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

.control-button.start {
    background: #8b5cf6;
    color: white;
}

.control-button.start:hover {
    background: #7c3aed;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.control-button.pause {
    background: #f59e0b;
    color: white;
}

.control-button.pause:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

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

.control-button.reset:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.formulas-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
}

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

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

.formula-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8fafc;
    border-radius: 8px;
}

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

.formula {
    font-family: 'Courier New', monospace;
    color: #1e293b;
    background: #f1f5f9;
    padding: 8px 12px;
    border-radius: 4px;
}

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

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

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

.explanation p {
    color: #475569;
    line-height: 1.8;
    margin-bottom: 15px;
    font-size: 1rem;
}

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

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

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

@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    main {
        padding: 20px;
    }

    .chart-display {
        padding: 15px;
    }

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

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