:root { --back: #0e1014; --panel: #151820; --raised: #1c2029; --edge: #2a2f3b; --text: #e7e9ef; --dim: #8a92a4; --line: #3987e5; --track: #184f95; --grid: #242935; --error: #ff6b63; --line-width: 2; --grid-width: 1; --inset: 0.08; --side: 27rem; --label: 8rem; --value: 4.6rem; --plot: 6.5rem; --visual: 2.4rem; --gap: 0.5rem; --pad: 1rem; --gutter: 11px; --card: 6rem; --round: 10px; --pill: 999px; color-scheme: dark; accent-color: var(--line); }
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: var(--edge) transparent; }
::-webkit-scrollbar { width: var(--gutter); height: var(--gutter); }
::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: var(--pill); background: var(--edge) content-box; }
::-webkit-scrollbar-corner { background: none; }
body { margin: 0; height: 100vh; display: grid; grid-template: auto minmax(0, 1fr) / minmax(0, 1fr); overflow: hidden; background: var(--back); color: var(--text); font: 13px/1.4 Inter, system-ui, sans-serif; }
nav, figure, fieldset { margin: 0; min-width: 0; }
header { position: relative; padding: 0.7rem var(--pad); border-bottom: 1px solid var(--edge); background: var(--panel); }
main { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 0; }
aside { display: flex; flex-direction: column; gap: 0.6rem; min-height: 0; padding: 0.8rem calc(var(--pad) - var(--gutter)) 0.8rem var(--pad); border-right: 1px solid var(--edge); background: var(--panel); }
section { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 0.8rem; min-height: 0; padding: 0.8rem calc(var(--pad) - var(--gutter)) 0 var(--pad); }
button { height: 1.9rem; padding: 0 0.8rem; border: 1px solid var(--edge); border-radius: var(--pill); background: var(--raised); color: var(--dim); font: inherit; white-space: nowrap; cursor: pointer; transition: 0.15s; }
button:hover { border-color: var(--dim); color: var(--text); }
button.active { border-color: var(--line); background: var(--line); color: white; }
output, input[type=number] { font: 12px ui-monospace, monospace; font-variant-numeric: tabular-nums; text-align: right; }
input[type=range] { width: 100%; min-width: 0; height: 1.2rem; margin: 0; }
input[type=number] { width: 100%; min-width: 0; height: 1.7rem; padding: 0 0.45rem; border: 1px solid var(--edge); border-radius: 6px; background: var(--back); color: var(--text); appearance: textfield; }
input[type=number]::-webkit-inner-spin-button { display: none; }
input[type=number]:focus, textarea:focus { outline: 1px solid var(--line); border-color: var(--line); }
input[type=checkbox] { appearance: none; flex: none; position: relative; width: 2rem; height: 1.15rem; margin: 0; border-radius: var(--pill); background: var(--edge); cursor: pointer; transition: 0.15s; }
input[type=checkbox]::before { content: ""; position: absolute; inset: 2px auto 2px 2px; aspect-ratio: 1; border-radius: var(--pill); background: var(--text); transition: 0.15s; }
input[type=checkbox]:checked { background: var(--line); }
input[type=checkbox]:checked::before { translate: 0.85rem; }
code { padding: 0.1rem 0.45rem; border-radius: 6px; background: var(--back); color: var(--dim); font: 11px ui-monospace, monospace; }
#presets { display: flex; gap: var(--gap); overflow: auto hidden; scrollbar-width: none; }
#presets::-webkit-scrollbar { display: none; }
#presets button { flex: none; display: grid; align-items: end; width: var(--card); height: var(--card); padding: 0.4rem; border-radius: var(--round); background: linear-gradient(to top, #000d, #0000 70%), var(--photo) center / cover, linear-gradient(135deg, var(--edge), var(--back)); color: white; font-size: 11px; font-weight: 600; line-height: 1.2; text-align: left; text-shadow: 0 1px 3px black; white-space: normal; }
#presets button.active { outline: 2px solid var(--line); outline-offset: -2px; }
#thumb { position: absolute; bottom: 0.2rem; left: calc(var(--pad) + var(--at) * (100% - 2 * var(--pad))); width: calc(var(--span) * (100% - 2 * var(--pad))); height: 4px; border-radius: var(--pill); background: var(--dim); opacity: 0; cursor: grab; transition: opacity 0.5s; }
#thumb.live, #thumb:hover, #thumb:active { opacity: 1; }
#actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--gap); margin-right: var(--gutter); }
#naming { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--gap); margin-right: var(--gutter); }
input[type=text] { min-width: 0; height: 1.9rem; padding: 0 0.8rem; border: 1px solid var(--edge); border-radius: var(--pill); background: var(--back); color: var(--text); font: inherit; }
input[type=text]:focus { outline: 1px solid var(--line); border-color: var(--line); }
#tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0.2rem; margin-right: var(--gutter); padding: 0.2rem; border-radius: var(--pill); background: var(--back); }
#tabs button { border-color: transparent; background: none; }
#tabs button.active { background: var(--line); }
#error { margin-right: var(--gutter); color: var(--error); text-align: left; }
#error:empty { display: none; }
.pane { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--gap); min-height: 0; overflow: hidden scroll; }
.pane[hidden] { display: none; }
#json { resize: none; margin-right: var(--gutter); padding: 0.7rem; overflow: auto; border: 1px solid var(--edge); border-radius: var(--round); background: var(--back); color: var(--text); font: 12px/1.5 ui-monospace, monospace; tab-size: 2; }
.field { display: grid; grid-template-columns: var(--label) minmax(0, 1fr) var(--value); align-items: center; gap: 0.6rem; min-height: 2rem; }
.field span { overflow: hidden; color: var(--dim); text-overflow: ellipsis; white-space: nowrap; }
.field code { justify-self: start; }
#simple .field span { color: var(--text); }
fieldset { display: grid; gap: 0.1rem; padding: 0.4rem 0.8rem 0.6rem; border: 1px solid var(--edge); border-radius: var(--round); background: var(--raised); }
legend { padding: 0 0.4rem; color: var(--dim); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
details { min-width: 0; border: 1px solid var(--edge); border-radius: var(--round); background: var(--raised); }
details > :not(summary) { margin-inline: 0.6rem; }
details > :last-child:not(summary) { margin-bottom: 0.6rem; }
details details { margin-block: 0.3rem; background: var(--panel); }
details details details { background: var(--raised); }
details fieldset { margin-block: 0.3rem; padding-inline: 0.6rem; background: none; }
details .field { --label: 5.5rem; }
summary { padding: 0.55rem 0.8rem; font-weight: 600; cursor: pointer; }
summary:hover { color: var(--line); }
#controls { display: flex; flex-wrap: wrap; gap: var(--gap); margin-right: var(--gutter); }
#controls nav { display: contents; }
#controls label { flex: 1 1 auto; order: 1; display: grid; grid-auto-flow: column; align-items: center; justify-content: space-between; gap: 0.5rem; height: 2.3rem; padding: 0 0.8rem; border: 1px solid var(--edge); border-radius: var(--pill); background: var(--raised); }
#controls .slider { flex: 4 1 13rem; order: 0; grid-template-columns: auto minmax(0, 1fr) 2.4rem; justify-content: stretch; }
#controls .shifter { grid-template-columns: 1fr auto auto auto; }
#controls .pedal { flex: 8 1 20rem; order: 0; grid-template-columns: auto minmax(0, 1fr) auto 2.4rem; justify-content: stretch; }
.pedal input { --knob: 1rem; --fill: linear-gradient(to right, var(--edge) calc(var(--knob) / 2 + min(var(--at), 0.5) * (100% - var(--knob))), var(--error) 0 50%, var(--line) 0 calc(var(--knob) / 2 + max(var(--at), 0.5) * (100% - var(--knob))), var(--edge) 0); appearance: none; background: none; }
.pedal input::-webkit-slider-runnable-track { height: 6px; border-radius: var(--pill); background: var(--fill); }
.pedal input::-moz-range-track { height: 6px; border-radius: var(--pill); background: var(--fill); }
.pedal input::-webkit-slider-thumb { appearance: none; width: var(--knob); height: var(--knob); margin-top: calc(3px - var(--knob) / 2); border-radius: var(--pill); background: var(--line); }
.pedal input::-moz-range-thumb { width: var(--knob); height: var(--knob); border: 0; border-radius: var(--pill); background: var(--line); }
#controls button { width: 1.6rem; height: 1.6rem; padding: 0; }
#controls .shifter output { min-width: 1rem; }
#charts { display: grid; gap: var(--gap); margin-right: var(--gutter); }
#charts div { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--gap); }
#charts div:empty { display: none; }
#charts .bar { --visual: 0.5rem; }
#charts figure { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto var(--visual); align-items: center; gap: 0.3rem 0.5rem; padding: 0.5rem 0.7rem 0.6rem; border: 1px solid var(--edge); border-radius: var(--round); background: var(--raised); }
#charts figcaption { overflow: hidden; color: var(--dim); text-overflow: ellipsis; white-space: nowrap; }
#charts output { font-size: 13px; font-weight: 600; }
#charts svg, #charts i, #charts canvas { grid-column: 1 / -1; }
#charts svg { height: 100%; justify-self: center; }
#charts path { fill: none; stroke: var(--track); stroke-width: 8; stroke-linecap: round; }
#charts path + path { stroke: var(--line); stroke-dasharray: var(--level) 1; }
#charts i { height: 6px; border-radius: var(--pill); background: linear-gradient(to right, var(--line) calc(var(--level) * 100%), var(--track) 0); }
#charts canvas { height: 100%; border: 0; background: none; cursor: crosshair; }
#traces { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 0.7rem; padding-bottom: 0.8rem; overflow: hidden scroll; }
#traces figure { display: grid; gap: 0.25rem; }
#traces figcaption { color: var(--dim); }
#top, #shade { display: none; }
canvas { display: block; width: 100%; height: var(--plot); border: 1px solid var(--edge); border-radius: var(--round); background: var(--panel); }
@media (max-width: 900px) {
  :root { --gutter: 0px; --plot: 4.5rem; --pad: 0.75rem; --top: 3.2rem; --drawer: min(86vw, 24rem); }
  body { display: block; height: auto; min-height: 100dvh; overflow: auto; }
  body:has(.open) { overflow: hidden; }
  main { display: block; }
  section { grid-template-rows: none; padding: 0.8rem var(--pad); }
  #top { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--gap); height: var(--top); padding: 0 var(--pad); border-bottom: 1px solid var(--edge); background: var(--panel); }
  #drawers { display: contents; }
  #drawers button:last-child { order: 1; }
  #car { overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
  #shade { display: block; position: fixed; inset: var(--top) 0 0; z-index: 1; background: #000a; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
  body:has(.open) #shade { opacity: 1; pointer-events: auto; }
  #garage, #tuning { position: fixed; inset: var(--top) auto 0 0; z-index: 2; width: var(--drawer); padding: var(--pad); border: 0; border-right: 1px solid var(--edge); translate: -100%; visibility: hidden; transition: translate 0.25s, visibility 0.25s; overscroll-behavior: contain; }
  #tuning { inset-inline: auto 0; border-right: 0; border-left: 1px solid var(--edge); translate: 100%; }
  #garage.open, #tuning.open { translate: 0; visibility: visible; }
  #garage { overflow: hidden auto; }
  #presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; }
  #presets button { width: auto; height: auto; aspect-ratio: 1; }
  #thumb { display: none; }
  #traces { padding: 0; overflow: visible; }
  .field { grid-template-columns: minmax(0, 1fr) var(--value); gap: 0.2rem 0.6rem; padding-block: 0.25rem; }
  .field input[type=range] { grid-area: 2 / 1 / auto / -1; }
  details > :not(summary) { margin-inline: 0.35rem; }
  #charts div { display: flex; flex-wrap: wrap; }
  #charts figure { flex: 1 1 calc(100% / (var(--columns) + 1) + 1px); min-width: 0; gap: 0.25rem 0.3rem; padding: 0.35rem 0.4rem 0.45rem; }
  #charts .gauge, #charts .bar { --columns: 4; }
  #charts .line { --columns: 3; }
  #charts figcaption { font-size: 11px; }
  #charts output { font-size: 12px; }
}
@media (pointer: coarse) {
  :root { --value: 5.4rem; }
  button, input[type=text] { height: 2.4rem; }
  input[type=range] { height: 2rem; }
  input[type=number] { height: 2.1rem; }
  input[type=number], input[type=text], #json { font-size: 16px; }
  #controls label { height: 2.8rem; }
  #controls button { width: 2.1rem; height: 2.1rem; }
  .pedal input { --knob: 1.5rem; }
  #controls, #presets, #tabs, #actions { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
}
