* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b1020; color: #dbe3ef; font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; overflow: hidden; }
header { height: 48px; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: #10172a; border-bottom: 1px solid #1f2a44; }
header h1 { font-size: 17px; margin: 0; white-space: nowrap; }
.grow { flex: 1; }
main { position: absolute; top: 48px; left: 0; right: 0; bottom: 0; display: flex; }
#side { width: 340px; flex: none; overflow-y: auto; background: #0f1628; border-right: 1px solid #1f2a44; padding: 8px 12px 40px; }
#side section { border-bottom: 1px solid #1c2640; padding: 10px 0 12px; }
#side h2 { font-size: 15px; margin: 0 0 8px; color: #93c5fd; }
select, input[type=number], input[type=text] { width: 100%; background: #0b1222; color: #e5e7eb; border: 1px solid #2a3756; border-radius: 6px; padding: 5px 7px; font-size: 13px; }
input[type=color] { width: 100%; height: 30px; border: 1px solid #2a3756; border-radius: 6px; background: #0b1222; padding: 2px; }
button { background: #1c2742; color: #dbe3ef; border: 1px solid #2c3a5e; border-radius: 7px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
button:hover { background: #243257; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: #2563eb; border-color: #3b82f6; color: #fff; }
button.primary:hover { background: #1d4ed8; }
button.danger { color: #fca5a5; }
button.ghost { background: transparent; }
.row { display: flex; gap: 8px; margin-top: 8px; }
.row > * { flex: 1; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; margin-top: 8px; }
.fields label { display: block; font-size: 12px; color: #94a3b8; }
.fields label.full { grid-column: 1 / 3; }
.fields label.chk { display: flex; align-items: center; gap: 6px; color: #cbd5e1; font-size: 13px; }
.fields .unit { color: #64748b; }
.hint { color: #8fa1bd; font-size: 12px; margin: 8px 0 0; }
.foot { color: #5b6b86; font-size: 12px; }
.seg { display: inline-flex; background: #0b1222; border: 1px solid #2a3756; border-radius: 8px; padding: 2px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 4px 12px; border-radius: 6px; }
.seg button.on { background: #2563eb; color: #fff; }
.seg.wide { display: flex; margin-bottom: 6px; }
.seg.wide button { flex: 1; }
.seg button:disabled { opacity: .35; }
label.chk { display: flex; align-items: center; gap: 6px; margin: 4px 0; cursor: pointer; }
label.slider { display: flex; align-items: center; gap: 6px; }
label.slider input { flex: 1; }
#fit .it { display: flex; gap: 6px; padding: 3px 0; font-size: 13px; border-bottom: 1px dashed #1c2640; }
#fit .it .ic { width: 18px; flex: none; }
#fit .it .k { color: #94a3b8; }
#fit .it .tip { color: #8fa1bd; font-size: 12px; }
#fit .ok { color: #34d399; } #fit .bad { color: #f87171; }

#stage { position: relative; flex: 1; overflow: hidden; touch-action: none; }
#c2d, #c3d { position: absolute; inset: 0; width: 100%; height: 100%; }
#c3d canvas { display: block; }
#hud { position: absolute; left: 10px; top: 10px; background: rgba(11,16,32,.82); border: 1px solid #23304f; border-radius: 10px; padding: 8px 12px; pointer-events: none; min-width: 250px; }
.hrow { display: flex; align-items: baseline; gap: 8px; margin: 2px 0; }
.gear { display: inline-block; width: 26px; text-align: center; font-weight: 700; border-radius: 5px; background: #16a34a; color: #fff; }
.gear.R { background: #ea580c; }
#speed { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sep { width: 8px; }
.stats span { color: #94a3b8; font-size: 12px; }
.stats b { color: #e5e7eb; }
#status { font-weight: 600; }
#status.ok { color: #34d399; } #status.warn { color: #fbbf24; } #status.bad { color: #f87171; }
.clear { font-size: 12px; color: #fbbf24; font-family: ui-monospace, Consolas, monospace; }
#camSeg { position: absolute; right: 10px; top: 10px; }
#rearLabel { position: absolute; display: none; color: #fff; background: rgba(234,88,12,.85); font-size: 12px; padding: 1px 8px; border-radius: 4px; pointer-events: none; }
#toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); background: rgba(6,78,59,.95); border: 1px solid #10b981; color: #ecfdf5; padding: 14px 20px; border-radius: 12px; font-size: 15px; max-width: min(92%, 520px); display: none; z-index: 5; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
#toast.bad { background: rgba(127,29,29,.95); border-color: #ef4444; }
#toast .x { float: right; margin-left: 10px; cursor: pointer; opacity: .8; }
#controls { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 12px 16px; pointer-events: none; }
#controls > * { pointer-events: auto; }
.wheelBox { display: flex; align-items: flex-end; gap: 8px; }
#wheel { width: 120px; height: 120px; border-radius: 50%; background: rgba(15,22,40,.6); touch-action: none; cursor: grab; }
#wheel svg { width: 100%; height: 100%; }
button.mini { padding: 4px 8px; font-size: 12px; }
.pedals { display: flex; gap: 8px; }
.pedal { width: 74px; height: 74px; border-radius: 14px; font-size: 15px; font-weight: 600; user-select: none; -webkit-user-select: none; touch-action: none; }
.pedal small { font-weight: 400; font-size: 11px; opacity: .7; }
.pedal.fwd { background: #14532d; border-color: #16a34a; }
.pedal.back { background: #7c2d12; border-color: #ea580c; }
.pedal.brake { background: #3f1d1d; border-color: #b91c1c; }
.pedal.active { filter: brightness(1.6); }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal.hidden { display: none; }
.modal .card { background: #111a30; border: 1px solid #2a3756; border-radius: 12px; padding: 16px 20px; max-width: 560px; margin: 12px; max-height: 90vh; overflow: auto; }
.modal ol { padding-left: 20px; } .modal li { margin: 6px 0; }
#menuBtn { display: none; }
#editBar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: calc(100% - 24px); background: rgba(15,22,40,.92); border: 1px solid #2c3a5e; border-radius: 10px; padding: 6px; z-index: 4; }
#editBar button { padding: 5px 9px; }
#editBar button.on { background: #2563eb; border-color: #3b82f6; color: #fff; }
#editBar select { width: auto; max-width: 150px; }
#editBar .edTip { flex-basis: 100%; text-align: center; font-size: 12px; color: #93a4c0; }
#editProps { margin-top: 10px; padding: 8px; border: 1px solid #3b4a6b; border-radius: 8px; background: #0c1426; }
#editProps .ptitle { font-weight: 600; color: #facc15; font-size: 13px; }
.seg.wide { flex-wrap: wrap; }

@media (max-width: 820px) {
  #menuBtn { display: inline-block; }
  header h1 { font-size: 15px; }
  #helpBtn { display: none; }
  #side { position: absolute; z-index: 10; top: 0; bottom: 0; left: 0; width: min(92vw, 360px); transform: translateX(-102%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.5); }
  #side.open { transform: none; }
  #hud { min-width: 0; font-size: 12px; padding: 6px 8px; }
  #speed { font-size: 18px; }
  #camSeg { top: auto; bottom: 150px; right: 6px; flex-wrap: wrap; max-width: 200px; }
  #wheel { width: 104px; height: 104px; }
  .pedal { width: 62px; height: 62px; font-size: 14px; }
}
