:root {
    --bg-gradient: linear-gradient(135deg, #f0f2f5 0%, #e2e6ec 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.1);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --input-bg: rgba(0, 0, 0, 0.06);
    --secondary-btn-bg: rgba(0, 0, 0, 0.08);
    --status-bg: rgba(0, 0, 0, 0.04);
    --number-bg: rgba(0, 0, 0, 0.06);
    --mol-bg: rgba(0, 0, 0, 0.03);
    --bar-track-bg: rgba(0, 0, 0, 0.04);
    --reaction-dir-bg: rgba(0, 0, 0, 0.04);
    --dir-equilibrium: #94a3b8;
    --panel-shadow: rgba(0, 0, 0, 0.08);

    --color-a: #3b82f6;
    --color-b: #8b5cf6;
    --color-c: #f59e0b;
    --color-d: #10b981;

    --primary: #0284c7;
    --font-main: 'Outfit', sans-serif;
}

:root[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #1a1c2e 0%, #0f172a 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --input-bg: rgba(0, 0, 0, 0.2);
    --secondary-btn-bg: rgba(255, 255, 255, 0.1);
    --status-bg: rgba(0, 0, 0, 0.2);
    --number-bg: rgba(0, 0, 0, 0.2);
    --mol-bg: rgba(255, 255, 255, 0.03);
    --bar-track-bg: rgba(255, 255, 255, 0.02);
    --reaction-dir-bg: rgba(255, 255, 255, 0.05);
    --dir-equilibrium: #94a3b8;
    --panel-shadow: rgba(0, 0, 0, 0.3);

    --primary: #38bdf8;
}

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

body {
    font-family: var(--font-main);
    background: var(--bg-gradient);
    color: var(--text-main);
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    transition: background 0.2s ease, color 0.2s ease;
}

.app-container {
    display: flex;
    height: 100%;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px var(--panel-shadow), 0 2px 4px -1px var(--panel-shadow);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar {
    width: 320px;
    padding: 24px;
    margin: 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0;
    background: linear-gradient(to right, #0284c7, #6366f1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

:root[data-theme="dark"] .sidebar-header h1 {
    background: linear-gradient(to right, #38bdf8, #818cf8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-credit {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.theme-toggle {
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--glass-bg);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.control-group h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.input-grid {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-grid input {
    width: 40px;
}

.moles-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-wrapper label {
    font-size: 0.8rem;
    font-weight: 500;
}

input[type="number"] {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 6px;
    color: var(--text-main);
    font-family: inherit;
    width: 100%;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

input[type="range"] {
    width: 100%;
    margin: 8px 0;
}

.actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

button {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

button:active {
    transform: scale(0.98);
}

.primary-btn {
    background: var(--primary);
    color: #0f172a;
    transition: background-color 0.2s ease;
}

.secondary-btn {
    background: var(--secondary-btn-bg);
    color: var(--text-main);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.status-panel {
    background: var(--status-bg);
    border-radius: 8px;
    padding: 12px;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.status-item .mono {
    font-family: 'SF Mono', 'Monaco', monospace;
    color: var(--primary);
}

.main-view {
    flex: 1;
    margin: 16px 16px 16px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.header-equation {
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    font-size: 1.5rem;
    font-weight: 500;
}

.equation-line {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mol-display {
    padding: 4px 12px;
    border-radius: 8px;
    background: var(--mol-bg);
    transition: background-color 0.2s ease;
}

.chart-container {
    flex: 1;
    padding: 32px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chart-area {
    width: 100%;
    flex: 1;
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    max-width: 800px;
    margin: 0 auto;
}

.bar-group {
    height: 100%;
    width: 15%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
}

.bar-track {
    width: 100%;
    height: 90%;
    background: var(--bar-track-bg);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    transition: background-color 0.2s ease;
}

.bar-fill {
    width: 100%;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px 8px 0 0;
}

.bar-label {
    margin-top: 12px;
    font-weight: 700;
}

.bar-value {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.number-display {
    font-family: 'SF Mono', 'Monaco', monospace;
    color: var(--primary);
    background: var(--number-bg);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 6px;
    width: 100%;
    margin-right: 8px;
    text-align: right;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

sup.exp {
    font-size: 0.7em;
    vertical-align: super;
    margin-left: 2px;
}

.status-divider {
    border: none;
    height: 1px;
    background: var(--glass-border);
    margin: 12px 0;
}

.reaction-direction {
    margin-top: 12px;
    padding: 8px;
    background: var(--reaction-dir-bg);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-height: 50px;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.dir-arrow {
    font-size: 1.5rem;
    font-weight: 700;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dir-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.color-text-a { color: var(--color-a); }
.color-text-b { color: var(--color-b); }
.color-text-c { color: var(--color-c); }
.color-text-d { color: var(--color-d); }

.color-bg-a { background: var(--color-a); }
.color-bg-b { background: var(--color-b); }
.color-bg-c { background: var(--color-c); }
.color-bg-d { background: var(--color-d); }

.color-left-a { border-left: 3px solid var(--color-a); padding-left: 8px; }
.color-left-b { border-left: 3px solid var(--color-b); padding-left: 8px; }
.color-left-c { border-left: 3px solid var(--color-c); padding-left: 8px; }
.color-left-d { border-left: 3px solid var(--color-d); padding-left: 8px; }

.arrow,
.plus {
    color: var(--text-muted);
    font-family: system-ui;
}

@media (max-width: 768px) {
    body {
        height: auto;
    }

    .app-container {
        flex-direction: column;
        height: auto;
    }

    .sidebar {
        width: calc(100% - 32px);
        margin: 16px;
        max-height: none;
        overflow: visible;
    }

    .main-view {
        margin: 0 16px 16px 16px;
    }

    .chart-container {
        padding: 16px;
        min-height: 400px;
    }

    .chart-area {
        height: 350px;
        flex: none;
    }

    .equation-line {
        flex-wrap: wrap;
        justify-content: center;
    }
}
