:root { color-scheme: dark; font-family: Arial, sans-serif; color: #e5e5e5; background: #050505; }
* { box-sizing: border-box; letter-spacing: 0; }
html, body { width: 100%; height: 100%; margin: 0; }
body { display: grid; grid-template-columns: 234px minmax(0, 1fr); overflow: hidden; }
#ui-panel { padding: 16px; background: #121212; border-right: 1px solid #333; overflow: auto; min-width: 0; }
header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
h1 { font-size: 15px; color: #fbbf24; margin: 0; }
.playback { display: flex; gap: 6px; }
button { font: inherit; font-size: 12px; color: #e5e5e5; background: #27272a; border: 1px solid #3f3f46; border-radius: 5px; cursor: pointer; min-height: 38px; padding: 8px; }
button:hover { background: #38383e; }
button:focus-visible, input:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; }
.playback button { font-size: 11px; min-height: 30px; padding: 4px 8px; }
.mode-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 22px; }
#balancedBtn.active { background: #2563eb; border-color: #3b82f6; color: #fff; }
#pileBtn.active { background: #c2410c; border-color: #f97316; color: #fff; }
.currents { display: grid; gap: 16px; }
label { display: flex; align-items: baseline; gap: 5px; font-size: 12px; color: #bac4d1; }
output { margin-left: auto; white-space: nowrap; color: #e5e5e5; font-variant-numeric: tabular-nums; }
input[type="range"] { display: block; width: 100%; margin: 6px 0 0; height: 22px; accent-color: #3b82f6; cursor: pointer; }
.balance { border-top: 1px solid #303030; padding-top: 16px; margin-top: 20px; }
.katex { font-size: 1.06em; }
#balanceEquation { font-size: 14px; min-height: 34px; }
.readings { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 12px; min-height: 27px; }
#storedValue { color: #fb923c; }
#statusText { color: #a3a3a3; font-size: 12px; line-height: 1.4; margin: 7px 0 0; }
body[data-mode="accumulation"] #balanceValue, body[data-mode="accumulation"] #statusText { color: #fb923c; }
#scene-container { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
#scene-container canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.current-label { font-size: 14px; color: #e5e5e5; white-space: nowrap; pointer-events: none; user-select: none; text-shadow: 0 1px 4px #000; }
.current-label[data-wire="feed"] { color: #fbbf24; }
@media (max-width: 680px) {
    body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
    #scene-container { grid-row: 1; }
    #ui-panel { grid-row: 2; padding: 10px 12px; border-right: 0; border-top: 1px solid #333; max-height: 50dvh; }
    header { margin-bottom: 8px; gap: 6px; }
    h1 { font-size: 14px; }
    .playback button { min-height: 34px; }
    .mode-buttons { margin-bottom: 8px; gap: 6px; }
    .mode-buttons button { min-height: 36px; padding: 6px; }
    .currents { gap: 2px; }
    .control-group { display: grid; grid-template-columns: 155px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 34px; }
    input[type="range"] { margin: 0; height: 30px; }
    .balance { margin-top: 6px; padding-top: 8px; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
    #balanceEquation { font-size: 12px; min-height: 25px; }
    .readings { font-size: 11px; justify-content: flex-end; min-height: 25px; align-items: center; }
    #statusText { grid-column: 1 / -1; margin: 2px 0 0; font-size: 11px; }
    .current-label { font-size: 12px; }
}
@media (max-width: 360px) {
    #ui-panel { padding: 8px; }
    .control-group { grid-template-columns: 143px minmax(0, 1fr); gap: 8px; }
    .balance { grid-template-columns: 1fr; gap: 2px; }
    .readings { justify-content: flex-start; gap: 14px; }
}
@media (max-height: 450px) and (min-width: 540px) {
    body { grid-template-columns: 212px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
    #ui-panel { grid-column: 1; grid-row: 1; max-height: none; border-top: 0; border-right: 1px solid #333; padding: 10px; }
    #scene-container { grid-column: 2; grid-row: 1; }
    header { margin-bottom: 8px; gap: 6px; }
    .mode-buttons { margin-bottom: 10px; }
    .control-group { display: block; }
    .currents { gap: 6px; }
    .balance { display: block; margin-top: 8px; padding-top: 8px; }
    #balanceEquation { font-size: 12px; min-height: 30px; }
    .readings { justify-content: space-between; }
}
