:root {
  --bg: #0c0e11;
  --panel: #15181d;
  --panel-2: #1d2128;
  --line: #2a2f38;
  --text: #eef1f5;
  --muted: #8b93a1;
  --accent: #ff7a1a;
  --accent-ink: #1a0d02;
  --red: #ff3b3b;
  --red-zone: #5a1a1a;
  --track: #262b33;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, select, input { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
}
.brand { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.status { color: var(--muted); font-size: 14px; text-align: right; }
.status.err { color: var(--red); }
.status.ok { color: #6fd08c; }

.layout {
  display: grid; gap: 16px;
  padding: 0 16px 24px;
  max-width: 1280px; margin: 0 auto;
}
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(380px, 1fr) minmax(380px, 1fr); align-items: start; }
}

.cockpit, .side { display: grid; gap: 14px; min-width: 0; }

.dash { position: relative; width: 100%; max-width: 520px; margin: 0 auto; aspect-ratio: 1.15; }
.dash canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.readout {
  position: absolute; left: 0; right: 0; top: 56%; transform: translateY(-50%);
  text-align: center; pointer-events: none;
}
.gear { font-size: clamp(56px, 14vw, 104px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.speed { font-size: clamp(22px, 5vw, 32px); font-weight: 700; font-variant-numeric: tabular-nums; }
.speed small, .rpm { color: var(--muted); font-size: 14px; font-weight: 500; }
.rpm { font-variant-numeric: tabular-nums; }

.engine-name { text-align: center; color: var(--muted); font-size: 14px; margin-top: -6px; }

.power {
  width: 100%; min-height: 64px; border: 0; border-radius: var(--radius);
  background: var(--accent); color: var(--accent-ink);
  font-size: 20px; font-weight: 800; letter-spacing: 0.02em; cursor: pointer;
}
.power.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 2px var(--accent); }
.power:active { transform: scale(0.99); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: flex; background: var(--panel); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; min-height: 46px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-weight: 700; cursor: pointer;
}
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }

.demo-panel { display: none; gap: 10px; }
body[data-source="demo"] .demo-panel { display: grid; }
.pedals { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.pedal {
  position: relative; overflow: hidden; min-height: 140px; border-radius: var(--radius);
  background: var(--panel); display: grid; place-items: center; font-weight: 800;
  user-select: none; -webkit-user-select: none; touch-action: none; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line);
}
.pedal.brake.active { background: #3a1616; box-shadow: inset 0 0 0 2px var(--red); }
.pedal span { position: relative; display: grid; text-align: center; }
.pedal small { opacity: 0.7; font-weight: 500; font-size: 12px; }
.pedal .fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: linear-gradient(to top, var(--accent), #ffb26b); opacity: 0.85;
}
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
@media (hover: none) { .hint { display: none; } }

.seg.wide button { min-height: 50px; font-size: 17px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.card {
  text-align: left; border: 0; border-radius: 12px; padding: 12px 14px; min-height: 84px;
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer;
  display: grid; align-content: start; gap: 2px;
}
.card b { font-size: 16px; }
.card span { color: var(--muted); font-size: 13px; }
.card em { color: var(--muted); font-size: 12px; font-style: normal; opacity: 0.8; }
.card.on { box-shadow: inset 0 0 0 2px var(--accent); background: var(--panel-2); }

.settings { background: var(--panel); border-radius: var(--radius); padding: 4px 14px 10px; }
.settings summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.field {
  display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 12px;
  min-height: 48px; color: var(--muted);
}
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.field select {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-width: 0;
}
.field .seg { background: var(--panel-2); }

.privacy { color: var(--muted); font-size: 13px; margin: 0; }
.linkish {
  background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline;
  font-size: inherit; cursor: pointer;
}

.consent {
  position: fixed; z-index: 10; left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto; padding: 16px;
  display: grid; gap: 12px;
  background: var(--panel-2); border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--line), 0 12px 40px rgba(0, 0, 0, 0.5);
}
.consent[hidden] { display: none; }
.consent p { margin: 0; font-size: 14px; }
.consent-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.consent-actions button {
  min-height: 48px; border: 0; border-radius: 10px; font-weight: 700; cursor: pointer;
  background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--line);
}
