:root {
  --bg: #0e1013; --panel: #171a1f; --line: #262a31; --fg: #e9ecef; --dim: #3a404a; --muted: #8a93a0;
  --accent: #4fd17a; --red: #ff4d4d; --boost: #f5a524;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.4 Bahnschrift, "Segoe UI", system-ui, sans-serif; }
button, select, input { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 14px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.5; cursor: wait; }
select { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }

header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--line); }
h1 { font-size: 20px; margin: 0; letter-spacing: 0.04em; }
h1 small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; letter-spacing: 0; }
.preset { display: flex; gap: 8px; align-items: center; color: var(--muted); margin-left: auto; }
.modes { display: flex; }
.modes button { border-radius: 0; }
.modes button:first-child { border-radius: 6px 0 0 6px; }
.modes button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.modes button.active { background: var(--accent); color: #08130c; border-color: var(--accent); }
#ignition { background: #1d3325; border-color: var(--accent); font-weight: 600; min-width: 130px; }
#ignition.on { background: #3a1a1a; border-color: var(--red); }

main { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 20px; padding: 20px; }
@media (max-width: 860px) { main { grid-template-columns: 1fr; padding: 16px; } }

.dash { display: flex; flex-direction: column; gap: 16px; }
.gauge { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; aspect-ratio: 1 / 0.9; }
#tach { width: 100%; height: 100%; display: block; }
.event { position: absolute; left: 0; right: 0; top: 14px; text-align: center; font-weight: 700; letter-spacing: 0.08em; color: var(--boost); opacity: 0; transition: opacity 0.15s; }
.event.show { opacity: 1; }

.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.readouts .k { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.readouts .k em { font-style: normal; color: var(--fg); text-transform: none; float: right; }
.readouts .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.readouts .v.small { font-size: 16px; font-weight: 500; }
.bar i { display: block; height: 8px; background: var(--dim); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar b { display: block; height: 100%; width: 0; background: var(--accent); }
.bar b.boost { background: var(--boost); }

.pedalWrap { display: flex; gap: 14px; align-items: stretch; }
#pedal { position: relative; width: 90px; min-width: 90px; height: 120px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); overflow: hidden; cursor: ns-resize; touch-action: none; user-select: none; }
#pedalFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, var(--accent), #2a7d4a); }
#pedal span { position: absolute; inset: auto 0 8px; text-align: center; font-size: 12px; color: var(--fg); mix-blend-mode: difference; }
.shiftBtns { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.shiftBtns button { white-space: nowrap; }
.keys { margin: 0; color: var(--muted); font-size: 12px; line-height: 2; }
kbd { background: var(--panel); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font: 11px/1.6 inherit; color: var(--fg); }

.export h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 6px 0 8px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.rec.on { background: #3a1a1a; border-color: var(--red); color: var(--red); }
.file {background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 14px; cursor: pointer; }
.file input { display: none; }
.muted { color: var(--muted); font-size: 12px; margin: 8px 0; }

.controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; align-content: start; }
fieldset { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 12px; margin: 0; min-width: 0; }
legend { padding: 0 6px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; font-size: 12px; }
.row { display: grid; grid-template-columns: 118px 1fr 64px; align-items: center; gap: 8px; padding: 4px 0; }
.row > span { color: var(--muted); font-size: 13px; }
.row output { text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--fg); }
.row select { grid-column: 2 / 4; min-width: 0; }
.row input[type=checkbox] { justify-self: start; accent-color: var(--accent); width: 18px; height: 18px; }
.row.pick select { grid-column: 2 / 3; }
.row.pick button { padding: 4px 0; font-size: 12px; }
input[type=range] { width: 100%; accent-color: var(--accent); min-width: 0; }

/* engine pack */
.export h2 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.pack label { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.pack label input { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; color: var(--fg); font: inherit; }
#packList { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
#packList li { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px 4px 4px; }
#packList li.sel { border-color: var(--accent); }
#packList .load { flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: var(--fg); padding: 4px 6px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#packList code { font-size: 11px; color: var(--muted); white-space: nowrap; }
#packList .del { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 8px; }
#packList .del:hover { color: var(--red); }
