/* ==========================================================================
   FIRST LAW OF THERMODYNAMICS SIMULATOR - STYLESHEET
   Aesthetics: Deep Space Lab Theme, Glassmorphism, Neon Energy Accents
   ========================================================================= */

:root {
    /* Color Palette */
    --bg-dark: #0b0f19;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(0, 240, 255, 0.3);

    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;

    /* Energy Themed Accents */
    --color-q: #ff7020;        /* Heat: Flame Amber/Orange */
    --color-q-glow: rgba(255, 112, 32, 0.4);
    --color-w: #00e5ff;        /* Work: Electric Cyan */
    --color-w-glow: rgba(0, 229, 255, 0.4);
    --color-u: #10b981;        /* Internal Energy: Emerald Green */
    --color-u-glow: rgba(16, 185, 129, 0.4);
    --color-purple: #a855f7;

    /* Interface Colors */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    /* Fonts */
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 15% 15%, rgba(0, 229, 255, 0.07) 0px, transparent 50%),
        radial-gradient(at 85% 85%, rgba(255, 112, 32, 0.07) 0px, transparent 50%);
    color: var(--text-main);
    font-family: var(--font-main);
    line-height: 1.5;
    min-height: 100vh;
    padding: 1.5rem;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--color-q), #ef4444);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    box-shadow: 0 0 20px var(--color-q-glow);
}

.header-title h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #ffffff, #d1d5db);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

.equation-badge {
    font-family: var(--font-mono);
    color: var(--color-w);
    font-weight: 700;
    background: rgba(0, 229, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(0, 229, 255, 0.2);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mode-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: transparent;
    padding: 0;
    border: none;
}

.mode-selector-wrapper label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.styled-select {
    background: #1e293b;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.8rem;
    font-size: 0.88rem;
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}

.styled-select:focus, .styled-select:hover {
    border-color: var(--color-w);
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.88rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.btn-secondary {
    background: #334155;
    color: #e2e8f0;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-w);
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-xs:hover {
    background: var(--color-q);
    color: #000;
    border-color: var(--color-q);
}

.btn-xs.btn-neg:hover {
    background: var(--color-w);
    color: #000;
}

/* ==========================================================================
   CARDS & LAYOUT GRID
   ========================================================================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}

.card-header h2, .card-header h3 {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-main);
}

.main-layout {
    display: grid;
    grid-template-columns: 580px 1fr;
    gap: 1.5rem;
}

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

.left-panel, .right-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* TAGS */
.tag {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag-isobaric { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.4); }
.tag-isochoric { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.4); }
.tag-isothermal { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.tag-adiabatic { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }

.tag-idle { background: rgba(107, 114, 128, 0.2); color: #9ca3af; }
.tag-heating { background: rgba(255, 112, 32, 0.2); color: #ff9d00; border: 1px solid var(--color-q); }
.tag-paused { background: rgba(239, 68, 68, 0.2); color: #f87171; }

/* ==========================================================================
   CANVAS & GAUGES
   ========================================================================== */
.canvas-container {
    position: relative;
    width: 100%;
    background: #070a12;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas#simCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.canvas-overlay-gauges {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.gauge-box {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    min-width: 110px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.gauge-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gauge-value {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-w);
}

.sim-controls {
    display: flex;
    gap: 0.8rem;
    margin-top: 1rem;
}

.sim-controls .btn {
    flex: 1;
}

/* PARAMETER CONTROLS GRID */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.control-group.full-width {
    grid-column: 1 / -1;
}

.control-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.control-label-row label {
    color: var(--text-muted);
    font-weight: 500;
}

.value-badge {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-q);
    background: rgba(255, 112, 32, 0.1);
    padding: 1px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255, 112, 32, 0.2);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--color-q);
    cursor: pointer;
}

.quick-heat-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ==========================================================================
   ENERGY BALANCE METER
   ========================================================================== */
.energy-balance-card {
    background: linear-gradient(135deg, rgba(17, 24, 39, 0.9), rgba(15, 23, 42, 0.95));
    border-color: rgba(0, 240, 255, 0.2);
}

.conservation-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-valid {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 12px var(--color-u-glow);
}

.energy-formula-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin: 1rem 0;
}

.energy-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.energy-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.box-q::before { background: var(--color-q); }
.box-u::before { background: var(--color-u); }
.box-w::before { background: var(--color-w); }

.box-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.box-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 800;
}

.box-q .box-value { color: var(--color-q); text-shadow: 0 0 10px var(--color-q-glow); }
.box-u .box-value { color: var(--color-u); text-shadow: 0 0 10px var(--color-u-glow); }
.box-w .box-value { color: var(--color-w); text-shadow: 0 0 10px var(--color-w-glow); }

.box-sub {
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 4px;
}

.operator-symbol {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-muted);
}

.sign-convention-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.sign-tag {
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
}

.text-q { color: var(--color-q); background: rgba(255, 112, 32, 0.1); }
.text-w { color: var(--color-w); background: rgba(0, 229, 255, 0.1); }
.text-u { color: var(--color-u); background: rgba(16, 185, 129, 0.1); }

.error-check {
    font-family: var(--font-mono);
    color: var(--text-dim);
}

/* ==========================================================================
   ENERGY FLOW DIAGRAM (SANKEY NODE SYSTEM)
   ========================================================================== */
.flow-diagram-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(7, 10, 18, 0.7);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 1.2rem;
    position: relative;
    overflow: hidden;
}

.flow-node {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    z-index: 2;
}

.node-heat { border-color: rgba(255, 112, 32, 0.4); }
.node-system { border-color: rgba(59, 130, 246, 0.4); background: rgba(30, 58, 138, 0.3); }
.node-u { border-color: rgba(16, 185, 129, 0.4); }
.node-w { border-color: rgba(0, 229, 255, 0.4); }

.node-icon {
    font-size: 1.2rem;
    margin-bottom: 4px;
}

.node-heat .node-icon { color: var(--color-q); }
.node-system .node-icon { color: var(--primary); }
.node-u .node-icon { color: var(--color-u); }
.node-w .node-icon { color: var(--color-w); }

.node-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-main);
}

.node-val {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: 4px;
}

.node-sub { font-size: 0.7rem; color: var(--text-dim); }

.flow-arrow {
    color: var(--text-dim);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    position: relative;
}

.flow-split-arrows {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.flow-branch {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

/* ==========================================================================
   CHARTS
   ========================================================================== */
.chart-tabs {
    display: flex;
    gap: 0.5rem;
}

.chart-tab {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.chart-tab.active, .chart-tab:hover {
    background: rgba(0, 229, 255, 0.1);
    color: var(--color-w);
    border-color: var(--color-w);
}

.chart-container-wrapper {
    height: 250px;
    position: relative;
}

.chart-tab-content {
    display: none;
    width: 100%;
    height: 100%;
}

.chart-tab-content.active {
    display: block;
}

/* ==========================================================================
   OBSERVATION TABLE
   ========================================================================== */
.styled-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.styled-table th {
    background: rgba(30, 41, 59, 0.8);
    color: var(--text-muted);
    padding: 0.8rem 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.styled-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-family: var(--font-mono);
}

.styled-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.empty-row td {
    text-align: center;
    color: var(--text-dim);
    padding: 2rem;
    font-family: var(--font-main);
}

.trial-actions {
    display: flex;
    gap: 0.6rem;
}

.btn-danger-outline {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
}

/* ==========================================================================
   EDUCATIONAL PANEL
   ========================================================================== */
.edu-tabs {
    display: flex;
    gap: 0.5rem;
}

.edu-tab {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
}

.edu-tab.active, .edu-tab:hover {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary);
    border-color: var(--primary);
}

.edu-tab-content {
    display: none;
    margin-top: 1rem;
}

.edu-tab-content.active {
    display: block;
}

.edu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.2rem;
}

.edu-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.2rem;
}

.edu-box h3 {
    font-size: 1rem;
    color: var(--color-w);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.math-block {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    background: rgba(0, 229, 255, 0.08);
    color: var(--color-w);
    border: 1px solid rgba(0, 229, 255, 0.2);
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    margin-top: 0.8rem;
}

.sign-convention-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.2rem;
}

.sign-card {
    border-radius: var(--radius-md);
    padding: 1.2rem;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
}

.card-positive { border-color: rgba(16, 185, 129, 0.3); }
.card-positive h3 { color: var(--success); }

.card-negative { border-color: rgba(239, 68, 68, 0.3); }
.card-negative h3 { color: var(--danger); }

.card-note { border-color: rgba(245, 158, 11, 0.3); }
.card-note h3 { color: var(--warning); }

.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.2rem;
}

.app-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.2rem;
    transition: var(--transition);
}

.app-card:hover {
    transform: translateY(-3px);
    border-color: var(--color-w);
    box-shadow: 0 6px 20px rgba(0, 229, 255, 0.15);
}

.app-icon {
    font-size: 2rem;
    color: var(--color-q);
    margin-bottom: 0.6rem;
}

.app-card h3 {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.app-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* QUIZ STYLES */
.quiz-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.4rem;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}

.quiz-score {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-u);
}

.quiz-item {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.quiz-question {
    font-weight: 600;
    margin-bottom: 0.8rem;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quiz-option-btn {
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.quiz-option-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
}

.quiz-option-btn.correct {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
    color: #34d399;
}

.quiz-option-btn.incorrect {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
    color: #f87171;
}

/* ==========================================================================
   MODALS & FOOTER
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 1;
    transition: opacity 0.25s ease;
}

.modal-backdrop.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    background: var(--bg-dark);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}

.presets-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.preset-item {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.preset-item:hover {
    border-color: var(--color-w);
    background: rgba(30, 41, 59, 0.9);
    transform: translateX(4px);
}

.preset-item h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
    color: var(--color-w);
}

.preset-item p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.help-body ol {
    padding-left: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.app-footer {
    text-align: center;
    padding: 1rem;
    color: var(--text-dim);
    font-size: 0.82rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

/* ==========================================================================
   LIGHT THEME OVERRIDES
   ========================================================================== */

html[data-theme="light"],
html:not(.dark):not([data-theme="dark"]) {
    --bg-dark: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border-color: #e2e8f0;
    --border-highlight: rgba(2, 132, 199, 0.3);

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #64748b;

    --color-q: #ea580c;        /* Rich burnt orange */
    --color-q-glow: rgba(234, 88, 12, 0.2);
    --color-w: #0284c7;        /* Deep sky blue */
    --color-w-glow: rgba(2, 132, 199, 0.2);
    --color-u: #059669;        /* Forest emerald */
    --color-u-glow: rgba(5, 150, 105, 0.2);

    --shadow-lg: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] body,
html:not(.dark):not([data-theme="dark"]) body {
    background-color: #f8fafc;
    background-image: 
        radial-gradient(at 15% 15%, rgba(2, 132, 199, 0.04) 0px, transparent 50%),
        radial-gradient(at 85% 85%, rgba(234, 88, 12, 0.04) 0px, transparent 50%);
    color: #0f172a;
}

html[data-theme="light"] .app-header,
html:not(.dark):not([data-theme="dark"]) .app-header {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .header-title h1,
html:not(.dark):not([data-theme="dark"]) .header-title h1 {
    background: linear-gradient(90deg, #0f172a, #0284c7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

html[data-theme="light"] .subtitle,
html:not(.dark):not([data-theme="dark"]) .subtitle {
    color: #64748b;
}

html[data-theme="light"] .equation-badge,
html:not(.dark):not([data-theme="dark"]) .equation-badge {
    background: #f0f9ff;
    border-color: #bae6fd;
    color: #0284c7;
}

html[data-theme="light"] .styled-select,
html:not(.dark):not([data-theme="dark"]) .styled-select {
    background: #ffffff;
    color: #0f172a;
    border-color: #cbd5e1;
}

html[data-theme="light"] .btn-secondary,
html:not(.dark):not([data-theme="dark"]) .btn-secondary {
    background: #f1f5f9;
    color: #334155;
    border-color: #e2e8f0;
}

html[data-theme="light"] .btn-secondary:hover,
html:not(.dark):not([data-theme="dark"]) .btn-secondary:hover {
    background: #e2e8f0;
}

html[data-theme="light"] .btn-outline,
html:not(.dark):not([data-theme="dark"]) .btn-outline {
    border-color: #cbd5e1;
    color: #334155;
}

html[data-theme="light"] .btn-icon,
html:not(.dark):not([data-theme="dark"]) .btn-icon {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #334155;
}

html[data-theme="light"] .btn-icon:hover,
html:not(.dark):not([data-theme="dark"]) .btn-icon:hover {
    background: #f1f5f9;
    color: #0284c7;
}

html[data-theme="light"] .btn-xs,
html:not(.dark):not([data-theme="dark"]) .btn-xs {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

html[data-theme="light"] .card,
html:not(.dark):not([data-theme="dark"]) .card {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

html[data-theme="light"] .card-header h2,
html[data-theme="light"] .card-header h3,
html:not(.dark):not([data-theme="dark"]) .card-header h2,
html:not(.dark):not([data-theme="dark"]) .card-header h3 {
    color: #0f172a;
}

html[data-theme="light"] .canvas-container,
html:not(.dark):not([data-theme="dark"]) .canvas-container {
    background: #f8fafc;
    border-color: #e2e8f0;
}

html[data-theme="light"] .gauge-box,
html:not(.dark):not([data-theme="dark"]) .gauge-box {
    background: rgba(255, 255, 255, 0.95);
    border-color: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

html[data-theme="light"] .gauge-label,
html:not(.dark):not([data-theme="dark"]) .gauge-label {
    color: #64748b;
}

html[data-theme="light"] .gauge-value,
html:not(.dark):not([data-theme="dark"]) .gauge-value {
    color: #0284c7;
}

html[data-theme="light"] .energy-balance-card,
html:not(.dark):not([data-theme="dark"]) .energy-balance-card {
    background: #ffffff;
    border-color: #e2e8f0;
}

html[data-theme="light"] .energy-box,
html:not(.dark):not([data-theme="dark"]) .energy-box {
    background: #f8fafc;
    border-color: #e2e8f0;
}

html[data-theme="light"] .box-title,
html:not(.dark):not([data-theme="dark"]) .box-title {
    color: #475569;
}

html[data-theme="light"] .box-q .box-value,
html:not(.dark):not([data-theme="dark"]) .box-q .box-value {
    color: #ea580c;
    text-shadow: none;
}

html[data-theme="light"] .box-u .box-value,
html:not(.dark):not([data-theme="dark"]) .box-u .box-value {
    color: #059669;
    text-shadow: none;
}

html[data-theme="light"] .box-w .box-value,
html:not(.dark):not([data-theme="dark"]) .box-w .box-value {
    color: #0284c7;
    text-shadow: none;
}

html[data-theme="light"] .box-sub,
html:not(.dark):not([data-theme="dark"]) .box-sub {
    color: #64748b;
}

html[data-theme="light"] .operator-symbol,
html:not(.dark):not([data-theme="dark"]) .operator-symbol {
    color: #475569;
}

html[data-theme="light"] .sign-convention-strip,
html:not(.dark):not([data-theme="dark"]) .sign-convention-strip {
    background: #f1f5f9;
    color: #475569;
}

html[data-theme="light"] .flow-diagram-container,
html:not(.dark):not([data-theme="dark"]) .flow-diagram-container {
    background: #f8fafc;
    border-color: #e2e8f0;
}

html[data-theme="light"] .flow-node,
html:not(.dark):not([data-theme="dark"]) .flow-node {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

html[data-theme="light"] .node-system,
html:not(.dark):not([data-theme="dark"]) .node-system {
    background: #f0f9ff;
    border-color: #bae6fd;
}

html[data-theme="light"] .node-title,
html:not(.dark):not([data-theme="dark"]) .node-title {
    color: #0f172a;
}

html[data-theme="light"] .node-val,
html:not(.dark):not([data-theme="dark"]) .node-val {
    color: #0f172a;
}

html[data-theme="light"] .node-sub,
html:not(.dark):not([data-theme="dark"]) .node-sub {
    color: #64748b;
}

html[data-theme="light"] .flow-arrow,
html:not(.dark):not([data-theme="dark"]) .flow-arrow {
    color: #94a3b8;
}

html[data-theme="light"] .control-label-row label,
html:not(.dark):not([data-theme="dark"]) .control-label-row label {
    color: #334155;
}

html[data-theme="light"] .value-badge,
html:not(.dark):not([data-theme="dark"]) .value-badge {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #ea580c;
}

html[data-theme="light"] input[type="range"],
html:not(.dark):not([data-theme="dark"]) input[type="range"] {
    accent-color: #ea580c;
}

html[data-theme="light"] .chart-tab,
html:not(.dark):not([data-theme="dark"]) .chart-tab {
    color: #64748b;
    border-color: #e2e8f0;
}

html[data-theme="light"] .chart-tab.active,
html[data-theme="light"] .chart-tab:hover,
html:not(.dark):not([data-theme="dark"]) .chart-tab.active,
html:not(.dark):not([data-theme="dark"]) .chart-tab:hover {
    background: #f0f9ff;
    color: #0284c7;
    border-color: #0284c7;
}

html[data-theme="light"] .styled-table th,
html:not(.dark):not([data-theme="dark"]) .styled-table th {
    background: #f1f5f9;
    color: #0369a1;
    border-bottom-color: #e2e8f0;
}

html[data-theme="light"] .styled-table td,
html:not(.dark):not([data-theme="dark"]) .styled-table td {
    color: #334155;
    border-bottom-color: #e2e8f0;
}

html[data-theme="light"] .styled-table tbody tr:hover,
html:not(.dark):not([data-theme="dark"]) .styled-table tbody tr:hover {
    background: #f8fafc;
}

html[data-theme="light"] .edu-tab,
html:not(.dark):not([data-theme="dark"]) .edu-tab {
    color: #64748b;
    border-color: #e2e8f0;
}

html[data-theme="light"] .edu-tab.active,
html:not(.dark):not([data-theme="dark"]) .edu-tab.active,
html:not(.dark):not([data-theme="dark"]) .edu-tab:hover {
    background: #f0f9ff;
    color: #0284c7;
    border-color: #0284c7;
}

html[data-theme="light"] .edu-box,
html:not(.dark):not([data-theme="dark"]) .edu-box {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #334155;
}

html[data-theme="light"] .edu-box h3,
html:not(.dark):not([data-theme="dark"]) .edu-box h3 {
    color: #0284c7;
}

html[data-theme="light"] .math-block,
html:not(.dark):not([data-theme="dark"]) .math-block {
    background: #f0f9ff;
    border-color: #bae6fd;
    color: #0369a1;
}

html[data-theme="light"] .sign-card,
html:not(.dark):not([data-theme="dark"]) .sign-card {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #334155;
}

html[data-theme="light"] .app-card,
html:not(.dark):not([data-theme="dark"]) .app-card {
    background: #f8fafc;
    border-color: #e2e8f0;
}

html[data-theme="light"] .app-card:hover,
html:not(.dark):not([data-theme="dark"]) .app-card:hover {
    border-color: #0284c7;
    background: #f0f9ff;
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.1);
}

html[data-theme="light"] .app-card h3,
html:not(.dark):not([data-theme="dark"]) .app-card h3 {
    color: #0f172a;
}

html[data-theme="light"] .quiz-container,
html:not(.dark):not([data-theme="dark"]) .quiz-container {
    background: #f8fafc;
    border-color: #e2e8f0;
}

html[data-theme="light"] .quiz-item,
html:not(.dark):not([data-theme="dark"]) .quiz-item {
    background: #ffffff;
    border-color: #e2e8f0;
}

html[data-theme="light"] .quiz-question,
html:not(.dark):not([data-theme="dark"]) .quiz-question {
    color: #0f172a;
}

html[data-theme="light"] .quiz-option-btn,
html:not(.dark):not([data-theme="dark"]) .quiz-option-btn {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #334155;
}

html[data-theme="light"] .quiz-option-btn:hover,
html:not(.dark):not([data-theme="dark"]) .quiz-option-btn:hover {
    background: #f0f9ff;
    border-color: #0284c7;
}

html[data-theme="light"] .modal-card,
html:not(.dark):not([data-theme="dark"]) .modal-card {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #0f172a;
}

html[data-theme="light"] .preset-item,
html:not(.dark):not([data-theme="dark"]) .preset-item {
    background: #f8fafc;
    border-color: #e2e8f0;
}

html[data-theme="light"] .preset-item:hover,
html:not(.dark):not([data-theme="dark"]) .preset-item:hover {
    background: #f0f9ff;
    border-color: #0284c7;
}

html[data-theme="light"] .preset-item h4,
html:not(.dark):not([data-theme="dark"]) .preset-item h4 {
    color: #0284c7;
}

html[data-theme="light"] .app-footer,
html:not(.dark):not([data-theme="dark"]) .app-footer {
    border-top-color: #e2e8f0;
    color: #64748b;
}

