/* ============================================================
   NIU Companion — KQi Cockpit
   Visual language: an analog instrument cluster at night, not
   a SaaS dashboard. Every device below (arc, ticks, cell
   segments, hairlines) represents real telemetry — nothing is
   decoration for its own sake.
   ============================================================ */

:root {
  /* Structural neutrals — asphalt-at-night, not flat #000 */
  --ink: #0a0b0d;
  --panel: #15171b;
  --line: #2b2e33;

  /* Text */
  --paper: #f2ede4;
  --graphite: #74787f;

  /* The three functional colors — each has one job, not decoration */
  --ember: #ffb020;    /* primary: live value, ride button, active switches */
  --signal: #5ec8d8;   /* connection status only */
  --redline: #ff4438;  /* alerts, lock engaged, finish-ride */

  --ember-dim: rgba(255, 176, 32, 0.16);
  --redline-dim: rgba(255, 68, 56, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: "Space Grotesk", -apple-system, system-ui, sans-serif;
  overscroll-behavior-y: none;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 4px; }

.numeral { font-family: "Big Shoulders Display", "Space Grotesk", sans-serif; font-weight: 800; }

#app { display: flex; flex-direction: column; min-height: 100dvh; }

.screen { display: none; flex: 1; flex-direction: column; padding: 14px 20px 0; overflow-y: auto; min-height: 0; }
.screen.active { display: flex; }

/* ---------- Status banner ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--graphite);
  padding-top: env(safe-area-inset-top, 8px);
  min-height: 20px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--graphite); flex-shrink: 0;
  box-shadow: 0 0 0 rgba(94,200,216,0);
  transition: box-shadow .3s ease, background .3s ease;
}
.dot.connected { background: var(--signal); box-shadow: 0 0 10px 1px rgba(94,200,216,0.7); }
.dot.connecting { background: var(--ember); box-shadow: 0 0 10px 1px rgba(255,176,32,0.6); animation: pulse 1.1s ease-in-out infinite; }
.dot.disconnected, .dot.unsupported { background: var(--redline); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.banner .fault {
  color: var(--redline); font-weight: 600; margin-left: auto;
  display: flex; align-items: center; gap: 5px; font-size: 12px;
}

.connect-cta {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: var(--panel);
  color: var(--paper);
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px;
  font-weight: 600;
}
.connect-cta:active { background: var(--line); }
.connect-cta:disabled { opacity: 0.45; }

/* ---------- Radial speed gauge ---------- */

.gauge-wrap {
  position: relative;
  width: min(76vw, 320px);
  aspect-ratio: 1;
  margin: 10px auto 0;
}
.gauge-wrap svg { width: 100%; height: 100%; overflow: visible; }

.gauge-track { fill: none; stroke: var(--line); stroke-width: 10; stroke-linecap: round; }
.gauge-value {
  fill: none; stroke: var(--ember); stroke-width: 10; stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(255,176,32,0.55));
  transition: stroke-dashoffset .35s cubic-bezier(.2,.8,.2,1), stroke .35s ease;
}
.gauge-value.redline { stroke: var(--redline); filter: drop-shadow(0 0 8px rgba(255,68,56,0.6)); }
.gauge-value.igniting { transition: stroke-dashoffset .55s cubic-bezier(.4,0,.2,1); }

.gauge-tick { stroke: var(--line); stroke-width: 2; }
.gauge-tick.major { stroke: var(--graphite); stroke-width: 2.5; }

.gauge-readout {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
}
.gauge-readout .value {
  font-size: clamp(64px, 20vw, 92px);
  line-height: 1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.gauge-readout .unit-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.gauge-readout .unit { font-size: 13px; color: var(--graphite); letter-spacing: 2px; }
.unit-toggle {
  pointer-events: auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--graphite);
  font-family: "Space Grotesk", sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 3px 7px;
  border-radius: 6px;
}
.unit-toggle:active { border-color: var(--ember); color: var(--ember); }

/* ---------- Battery cell strip ---------- */

.battery-module { margin-top: 18px; }
.battery-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 7px;
}
.battery-head .pct { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.battery-head .label { font-size: 11px; color: var(--graphite); }
.cell-strip { display: flex; gap: 4px; height: 20px; }
.cell {
  flex: 1;
  background: var(--line);
  border-radius: 3px;
  transition: background .25s ease, box-shadow .25s ease;
}
.cell.lit { background: var(--ember); box-shadow: 0 0 6px rgba(255,176,32,0.5); }
.cell.lit.warn { background: var(--redline); box-shadow: 0 0 6px rgba(255,68,56,0.55); }

/* ---------- Instrument strip (trip stats) ---------- */

.instrument-strip {
  display: flex;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.instrument-strip .readout {
  flex: 1; text-align: center; padding: 12px 4px;
  position: relative;
}
.instrument-strip .readout + .readout::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px; background: var(--line);
}
.instrument-strip .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.instrument-strip .t { font-size: 10.5px; color: var(--graphite); margin-top: 3px; }

/* ---------- Scooter info strip (read-only) ---------- */

.info-strip .v { font-size: 20px; }
.info-strip .v.off { color: var(--graphite); }
.info-strip .v.on { color: var(--ember); }

.spacer { flex: 1; min-height: 14px; }

/* ---------- Ride button ---------- */

.ride-btn {
  border: none;
  border-radius: 16px;
  padding: 19px 0;
  font-family: "Big Shoulders Display", sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  background: var(--ember);
  color: #1a1200;
  margin-bottom: 10px;
  box-shadow: 0 0 22px rgba(255,176,32,0.25);
}
.ride-btn.riding { background: var(--redline); color: #2a0300; box-shadow: 0 0 22px rgba(255,68,56,0.28); }
.ride-btn:disabled { opacity: 0.35; box-shadow: none; }

.demo-toggle {
  margin: 2px 0 12px;
  align-self: center;
  background: none;
  border: none;
  color: var(--graphite);
  font-size: 11px;
  letter-spacing: .3px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- Rides screen ---------- */

.screen-title {
  font-family: "Big Shoulders Display", sans-serif;
  font-size: 30px;
  font-weight: 700;
  padding-top: env(safe-area-inset-top, 8px);
  margin-bottom: 2px;
}

.rides-list { list-style: none; margin: 6px 0 0; padding: 0; overflow-y: auto; }
.ride-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}
.ride-row .when { display: flex; flex-direction: column; gap: 2px; min-width: 62px; }
.ride-row .when .date { font-weight: 600; font-size: 14px; }
.ride-row .when .time { font-size: 11px; color: var(--graphite); }
.ride-row .spark { flex: 1; height: 26px; }
.ride-row .metrics { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.ride-row .metrics .dist { font-weight: 700; font-size: 15px; color: var(--ember); font-variant-numeric: tabular-nums; }
.ride-row .metrics .dur { font-size: 11px; color: var(--graphite); }
.ride-row .delete-btn {
  background: none; border: none; color: var(--graphite); font-size: 11px;
  padding: 4px 0 4px 6px;
}
.ride-row .delete-btn:active { color: var(--redline); }

.empty-state { text-align: center; padding: 52px 24px; color: var(--graphite); }
.empty-state svg { width: 34px; height: 34px; margin-bottom: 12px; opacity: 0.7; color: var(--ember); }
.empty-state h3 { color: var(--paper); margin: 0 0 6px; font-family: "Big Shoulders Display", sans-serif; font-size: 20px; font-weight: 700; }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.5; }

/* ---------- Ride detail overlay ---------- */

#rideDetail {
  position: fixed; inset: 0; background: var(--ink);
  display: none; flex-direction: column; z-index: 20;
}
#rideDetail.active { display: flex; }
#rideDetailMap { flex: 1; filter: saturate(0.85) brightness(0.92); }
.detail-header {
  position: absolute;
  top: env(safe-area-inset-top, 12px);
  left: 16px; right: 16px;
  display: flex; align-items: center; justify-content: space-between;
  z-index: 25;
}
.back-btn {
  background: rgba(21,23,27,0.9);
  border: 1px solid var(--line);
  color: var(--paper);
  width: 38px; height: 38px;
  border-radius: 19px;
  font-size: 18px;
  font-family: "Space Grotesk", sans-serif;
}
.detail-date-chip {
  background: rgba(21,23,27,0.9);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 12.5px;
  font-weight: 600;
}
.detail-summary.instrument-strip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 12px 16px max(14px, env(safe-area-inset-bottom));
}
.detail-summary.instrument-strip .readout + .readout::before { top: 12px; bottom: 12px; }
.detail-summary.instrument-strip .v { font-size: 20px; white-space: nowrap; }

/* ---------- Setup screen ---------- */

.setup-card { margin-top: 14px; overflow-y: auto; }
.setup-card h3 {
  margin: 0 0 8px; font-family: "Big Shoulders Display", sans-serif;
  font-size: 22px; font-weight: 700;
}
.setup-card p { margin: 0 0 10px; font-size: 13px; line-height: 1.5; }
.setup-card .hint { color: var(--graphite); }
.setup-card .hint.small { font-size: 11.5px; margin-top: 12px; }
.setup-card textarea {
  width: 100%; background: var(--panel); color: var(--paper);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px;
  resize: vertical; min-height: 120px;
}
.setup-card textarea:focus { outline: 1px solid var(--ember); }
.setup-actions { display: flex; gap: 10px; margin-top: 10px; }
.btn {
  flex: 1; border-radius: 12px; padding: 13px 0; font-size: 14px; font-weight: 600;
  font-family: "Space Grotesk", sans-serif;
  background: var(--panel); color: var(--paper); border: 1px solid var(--line);
}
.btn.primary { background: var(--ember); color: #1a1200; border-color: var(--ember); }
.keys-status { margin-top: 12px; font-size: 13px; color: var(--graphite); }
.keys-status.ok { color: var(--signal); }
.keys-status.err { color: var(--redline); }

/* ---------- Range line, charts, insights ---------- */

.range-line { margin-top: 8px; font-size: 12px; color: var(--graphite); min-height: 16px; }
.range-line b { color: var(--paper); font-weight: 600; }

.btn.small { padding: 9px 14px; font-size: 13px; flex: 0 0 auto; }
#exportAllBtn { margin: 8px 0 4px; align-self: flex-start; }

.battery-body { overflow-y: auto; padding-bottom: 12px; }
.chart-title {
  margin: 18px 0 6px; font-family: "Space Grotesk", sans-serif;
  font-size: 12px; font-weight: 600; letter-spacing: .3px; color: var(--graphite); text-transform: uppercase;
}
.chart-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 4px; min-height: 40px; }
.chart-box .empty { color: var(--graphite); font-size: 12px; padding: 14px 10px; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--graphite); font-size: 9.5px; font-family: "Space Grotesk", sans-serif; }
.chart-line { stroke: var(--ember); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { fill: var(--ember); }
.hint { color: var(--graphite); font-size: 12px; line-height: 1.5; margin: 8px 0; }
.hint.small { font-size: 11.5px; }
.charges-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.charges-list li { display: flex; justify-content: space-between; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.charges-list li span:last-child { color: var(--ember); font-variant-numeric: tabular-nums; }
.charges-list li.none { color: var(--graphite); }

.detail-panel { background: var(--panel); border-top: 1px solid var(--line); padding: 10px 16px 4px; max-height: 38vh; overflow-y: auto; }
.route-legend { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--graphite); }
.legend-bar { flex: 1; height: 6px; border-radius: 3px; }
.insights { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.insights li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.insights li span:first-child { color: var(--graphite); }
.insights li span:last-child { font-variant-numeric: tabular-nums; text-align: right; }
.detail-panel .setup-actions { margin: 10px 0 8px; }

/* ---------- Diagnostics ---------- */

.diag-entry-title {
  margin: 22px 0 8px; font-family: "Big Shoulders Display", sans-serif; font-size: 22px; font-weight: 700;
}
#diagScreen {
  position: fixed; inset: 0; background: var(--ink); display: none; flex-direction: column; z-index: 22;
}
#diagScreen.active { display: flex; }
.diag-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(env(safe-area-inset-top, 12px), 12px) 16px 8px;
}
.diag-title { font-family: "Big Shoulders Display", sans-serif; font-size: 24px; font-weight: 700; }
.diag-body { flex: 1; overflow-y: auto; padding: 0 16px max(24px, env(safe-area-inset-bottom)); }
.diag-status { font-size: 13px; color: var(--signal); margin: 8px 0 6px; min-height: 18px; }
.diag-progress { width: 100%; height: 6px; accent-color: var(--ember); margin-bottom: 6px; }
.diag-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.diag-actions .btn:disabled { opacity: 0.4; }
.diag-note {
  width: 100%; background: var(--panel); color: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; font-size: 13px; font-family: "Space Grotesk", sans-serif; resize: vertical;
}
.diag-summary { font-size: 12.5px; color: var(--graphite); margin: 10px 0 2px; }
.diag-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 12px; color: var(--graphite); margin-bottom: 8px; }
.diag-filters input[type="search"] {
  flex: 1 1 140px; background: var(--panel); color: var(--paper); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 13px;
}
.diag-table { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; }
/* Each row: name and value on one line, the raw bytes underneath. Long names get the full width. */
.diag-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.diag-row .n { grid-column: 1; color: var(--paper); overflow-wrap: anywhere; }
.diag-row .v { grid-column: 2; color: var(--ember); text-align: right; overflow-wrap: anywhere; max-width: 55vw; }
.diag-row .r { grid-column: 1 / -1; color: var(--graphite); font-size: 10px; word-break: break-all; }
.diag-row .r:empty { display: none; }
.diag-row.no .v, .diag-row.no .n { color: var(--graphite); }
.diag-row.head { grid-template-columns: 1fr; color: var(--signal); font-weight: 600; padding-top: 10px; }
.diag-row.empty { grid-template-columns: 1fr; color: var(--graphite); }
.diag-row.chg { grid-template-columns: 1fr; }
.diag-row.chg .v { grid-column: 1; text-align: left; max-width: none; }
.diag-preview {
  width: 100%; margin-top: 8px; background: var(--panel); color: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px;
}

/* ---------- Tab bar ---------- */

.tabbar {
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.tab-btn {
  flex: 1; background: none; border: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--graphite); font-family: "Space Grotesk", sans-serif;
  font-size: 10.5px; font-weight: 600; padding: 6px 0;
}
.tab-btn svg { width: 21px; height: 21px; }
.tab-btn.active { color: var(--ember); }

/* ---------- Toast ---------- */

#toast {
  position: fixed; bottom: 92px; left: 20px; right: 20px;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--paper); padding: 12px 16px; border-radius: 12px;
  font-size: 13px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
  z-index: 30;
}
#toast.visible { opacity: 1; }

@media (min-width: 480px) {
  .screen { max-width: 420px; margin: 0 auto; width: 100%; }
  .tabbar, #toast { max-width: 420px; margin: 0 auto; }
}

/* Compact-height variant — iPhone SE and similar ~667px-tall screens.
   Without this, the ride button sits below the fold on short devices;
   this keeps the whole cockpit reachable without scrolling. */
@media (max-height: 720px) {
  .gauge-wrap { width: min(58vw, 230px); margin-top: 4px; }
  .gauge-readout .value { font-size: clamp(48px, 15vw, 66px); }
  .battery-module { margin-top: 10px; }
  .instrument-strip { margin-top: 12px; }
  .instrument-strip .readout { padding: 8px 4px; }
  .spacer { min-height: 6px; }
  .demo-toggle { margin: 0 0 8px; }
  .ride-btn { padding: 15px 0; }
}

/* ============================================================
   Visual layer — atmosphere, depth and motion.
   Purely presentational: no element here changes what is shown.
   ============================================================ */

body {
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255,176,32,0.14), transparent 60%),
    radial-gradient(90% 50% at 100% 100%, rgba(94,200,216,0.08), transparent 60%),
    radial-gradient(80% 40% at 0% 70%, rgba(255,68,56,0.05), transparent 60%),
    var(--ink);
  background-attachment: fixed;
}
/* faint carbon-fibre weave over everything, behind content */
#app { position: relative; }
#app::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.025) 75%),
    linear-gradient(45deg, rgba(255,255,255,0.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.025) 75%);
  background-size: 6px 6px; background-position: 0 0, 3px 3px;
}
.screen, .tabbar { position: relative; z-index: 1; }

/* staggered entrance whenever a screen is shown */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.screen.active > * { animation: rise .5s cubic-bezier(.2,.8,.2,1) both; }
.screen.active > *:nth-child(2) { animation-delay: .05s; }
.screen.active > *:nth-child(3) { animation-delay: .10s; }
.screen.active > *:nth-child(4) { animation-delay: .15s; }
.screen.active > *:nth-child(5) { animation-delay: .20s; }
.screen.active > *:nth-child(6) { animation-delay: .25s; }
.screen.active > *:nth-child(7) { animation-delay: .30s; }

/* ---------- Gauge ---------- */
.gauge-disc { fill: url(#gaugeDisc); stroke: rgba(255,255,255,0.05); stroke-width: 1; }
.gauge-halo { fill: none; stroke: rgba(255,176,32,0.10); stroke-width: 1; stroke-dasharray: 2 5; transform-origin: 100px 100px; animation: spin 60s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.gauge-track { stroke: #202329; stroke-width: 11; }
.gauge-value { stroke: url(#gaugeGrad); stroke-width: 11; filter: drop-shadow(0 0 7px rgba(255,150,30,0.65)); }
.gauge-value.redline { stroke: var(--redline); }
.gauge-wrap::after {                      /* soft glow behind the dial */
  content: ""; position: absolute; inset: 8%; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(255,176,32,0.20), transparent 68%);
  filter: blur(14px);
}
.gauge-readout .value {
  background: linear-gradient(180deg, #fff6e0 10%, #ffcf6e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 10px rgba(255,176,32,0.35));
}
.gauge-readout .unit { letter-spacing: 3px; font-weight: 600; }

/* ---------- Status banner as a pill ---------- */
.banner {
  align-self: flex-start; padding: 7px 14px; margin-top: env(safe-area-inset-top, 8px);
  background: rgba(21,23,27,0.7); border: 1px solid var(--line); border-radius: 999px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); min-height: 0;
}
.connect-cta {
  border: 1px solid rgba(94,200,216,0.35);
  background: linear-gradient(135deg, rgba(94,200,216,0.14), rgba(94,200,216,0.03));
  color: var(--signal); letter-spacing: .4px; border-radius: 14px;
  box-shadow: 0 0 18px rgba(94,200,216,0.10), inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ---------- Battery cells ---------- */
.battery-head .pct { font-family: "Big Shoulders Display", sans-serif; font-size: 30px; font-weight: 800; color: var(--ember); }
.cell { border-radius: 4px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04); }
.cell.lit { background: linear-gradient(180deg, #ffd36b, #ff9d1a); box-shadow: 0 0 8px rgba(255,160,30,0.55), inset 0 1px 0 rgba(255,255,255,0.4); }
.cell.lit.warn { background: linear-gradient(180deg, #ff7a6e, #ff4438); }

/* ---------- Instrument strips become glass cards ---------- */
.instrument-strip {
  border: 1px solid rgba(255,255,255,0.07); border-radius: 16px;
  background: linear-gradient(160deg, rgba(255,255,255,0.055), rgba(255,255,255,0.012));
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.instrument-strip .v { font-family: "Big Shoulders Display", sans-serif; font-size: 28px; font-weight: 700; }
.instrument-strip .t { text-transform: uppercase; letter-spacing: 1.2px; font-size: 9.5px; }
.info-strip { margin-top: 10px; }
.info-strip .v { font-size: 24px; }
.info-strip .v.on { text-shadow: 0 0 12px rgba(255,176,32,0.6); }

/* ---------- Ride button ---------- */
.ride-btn {
  position: relative; overflow: hidden; border-radius: 18px; letter-spacing: 3px;
  background: linear-gradient(135deg, #ffc548, #ff8f1f);
  box-shadow: 0 8px 26px rgba(255,150,30,0.35), inset 0 1px 0 rgba(255,255,255,0.45);
  transition: transform .12s ease, box-shadow .2s ease;
}
.ride-btn:not(:disabled):active { transform: scale(.975); }
.ride-btn:not(:disabled)::after {          /* slow light sweep */
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,0.45), transparent);
  animation: sweep 3.6s ease-in-out infinite;
}
@keyframes sweep { 0%, 55% { left: -60%; } 100% { left: 130%; } }
.ride-btn.riding { background: linear-gradient(135deg, #ff6a5e, #e0281d); box-shadow: 0 8px 26px rgba(255,68,56,0.4), inset 0 1px 0 rgba(255,255,255,0.3); animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%,100% { box-shadow: 0 8px 26px rgba(255,68,56,0.35); } 50% { box-shadow: 0 8px 38px rgba(255,68,56,0.65); } }

/* ---------- Titles with an accent bar ---------- */
.screen-title, .diag-entry-title { position: relative; padding-left: 14px; }
.screen-title::before, .diag-entry-title::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 4px; height: 62%; transform: translateY(-50%);
  border-radius: 2px; background: linear-gradient(180deg, var(--ember), #ff6a2a); box-shadow: 0 0 10px rgba(255,150,30,0.6);
}
.screen-title { padding-top: calc(env(safe-area-inset-top, 8px) + 2px); }
.screen-title::before { top: calc(50% + 4px); }

/* ---------- Cards: rides, charts, setup ---------- */
.ride-row {
  margin-bottom: 10px; padding: 14px; border: 1px solid rgba(255,255,255,0.07); border-radius: 16px;
  background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  box-shadow: 0 6px 18px rgba(0,0,0,0.3);
}
.ride-row .metrics .dist { font-family: "Big Shoulders Display", sans-serif; font-size: 22px; }
.chart-box, .setup-card textarea, .diag-preview {
  background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
  border-color: rgba(255,255,255,0.08); box-shadow: 0 6px 18px rgba(0,0,0,0.28);
}
.chart-line { filter: drop-shadow(0 0 5px rgba(255,176,32,0.6)); }
.btn { border-radius: 14px; background: linear-gradient(160deg, rgba(255,255,255,0.06), rgba(255,255,255,0.015)); }
.btn.primary { background: linear-gradient(135deg, #ffc548, #ff8f1f); box-shadow: 0 6px 18px rgba(255,150,30,0.28); }
.detail-summary.instrument-strip, .detail-panel { background: rgba(21,23,27,0.88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.back-btn, .detail-date-chip { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* ---------- Tab bar ---------- */
.tabbar {
  background: rgba(15,16,19,0.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.tab-btn { position: relative; transition: color .2s ease, transform .2s ease; }
.tab-btn.active { text-shadow: 0 0 12px rgba(255,176,32,0.55); }
.tab-btn.active svg { filter: drop-shadow(0 0 6px rgba(255,176,32,0.8)); transform: translateY(-1px); }
.tab-btn.active::before {
  content: ""; position: absolute; top: -9px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--ember); box-shadow: 0 0 12px 1px rgba(255,176,32,0.8);
}
#toast { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); background: rgba(21,23,27,0.9); border-color: rgba(255,176,32,0.3); }

/* ---------- Efficiency colouring (green = efficient, yellow, red = high drain) ---------- */
.gauge-value { filter: drop-shadow(0 0 7px rgba(255,200,60,0.5)); }
.gauge-value.redline { stroke: url(#gaugeGrad); }
.gauge-track { stroke: #1d2025; }
.eff {
  margin-top: 8px; min-height: 14px; font-size: 10.5px; font-weight: 700; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--graphite); transition: color .3s ease, text-shadow .3s ease;
}
.eff[data-zone="good"] { color: #4fe07a; text-shadow: 0 0 10px rgba(79,224,122,0.6); }
.eff[data-zone="fair"] { color: #ffd23f; text-shadow: 0 0 10px rgba(255,210,63,0.55); }
.eff[data-zone="poor"] { color: #ff5a3c; text-shadow: 0 0 10px rgba(255,90,60,0.6); }

/* ---------- Plan (trip planning) ---------- */
.plan-form { display: flex; gap: 8px; margin-top: 12px; }
.plan-form input {
  flex: 1; min-width: 0; background: linear-gradient(160deg, rgba(255,255,255,0.06), rgba(255,255,255,0.015)); color: var(--paper);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 13px 14px; font-size: 15px; font-family: "Space Grotesk", sans-serif;
}
.plan-form input:focus { outline: 1px solid var(--ember); }
.plan-form .btn { flex: 0 0 auto; padding: 0 18px; }
.plan-status { min-height: 18px; margin: 10px 2px 0; font-size: 13px; color: var(--signal); }
.plan-status[data-kind="err"] { color: var(--redline); }
.plan-results { list-style: none; margin: 4px 0 0; padding: 0; }
.plan-result {
  width: 100%; text-align: left; background: var(--panel); color: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px; margin-bottom: 6px; font-size: 13px; line-height: 1.35; font-family: "Space Grotesk", sans-serif;
}
.plan-result:active { border-color: var(--ember); }
.plan-summary {
  margin-top: 12px; padding: 14px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(160deg, rgba(255,255,255,0.055), rgba(255,255,255,0.012)); box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.plan-top { display: flex; justify-content: space-between; align-items: baseline; }
.plan-big { font-family: "Big Shoulders Display", sans-serif; font-size: 34px; font-weight: 800; color: var(--ember); }
.plan-note { margin-top: 6px; font-size: 11.5px; color: var(--graphite); line-height: 1.45; }
.plan-verdict { margin-top: 10px; padding: 9px 11px; border-radius: 10px; font-size: 13px; font-weight: 600; line-height: 1.4; }
.plan-verdict.ok { background: rgba(79,224,122,0.12); color: #4fe07a; }
.plan-verdict.tight { background: rgba(255,210,63,0.12); color: #ffd23f; }
.plan-verdict.no { background: var(--redline-dim); color: var(--redline); }
.plan-map { height: 260px; margin-top: 12px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); filter: saturate(0.85) brightness(0.92); }
.plan-actions { display: flex; gap: 10px; margin-top: 12px; }
.plan-steps { list-style: none; margin: 12px 0 0; padding: 0; counter-reset: s; }
.plan-step { counter-increment: s; display: flex; gap: 10px; align-items: baseline; padding: 10px 6px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.plan-step::before { content: counter(s); color: var(--graphite); font-size: 11px; min-width: 16px; font-variant-numeric: tabular-nums; }
.plan-step .plan-step-text { flex: 1; }
.plan-step .plan-step-dist { color: var(--graphite); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.plan-step.current { background: var(--ember-dim); border-radius: 10px; }
.plan-step.current::before { color: var(--ember); }
.plan-banner {
  position: sticky; top: 0; z-index: 5; margin: 8px 0 4px; padding: 14px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,176,32,0.22), rgba(21,23,27,0.95)); border: 1px solid rgba(255,176,32,0.4);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.plan-banner[hidden] { display: none; }
.plan-banner-main { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.plan-banner-text { font-size: 16px; font-weight: 700; line-height: 1.3; }
.plan-banner-dist { font-size: 34px; color: var(--ember); white-space: nowrap; }
.plan-banner-sub { margin-top: 4px; font-size: 12px; color: var(--graphite); }
.plan-banner .btn { margin-top: 10px; width: 100%; }
[hidden] { display: none !important; }
.tab-btn { font-size: 10px; }

/* ============================================================
   Design pass 2: cockpit header, compact layout, ride cards,
   setup cards, plan empty state.
   ============================================================ */

/* ---------- Cockpit header ---------- */
.cockpit-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: env(safe-area-inset-top, 8px);
}
.brand { display: flex; align-items: baseline; gap: 7px; }
.brand-mark {
  font-family: "Big Shoulders Display", sans-serif; font-weight: 800; font-size: 26px; letter-spacing: .5px; line-height: 1;
  background: linear-gradient(135deg, #ffd36b, #ff8f1f); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 8px rgba(255,160,30,0.35));
}
.brand-sub { font-size: 10px; font-weight: 700; letter-spacing: 2.4px; text-transform: uppercase; color: var(--graphite); }
.cockpit-head .banner { margin-top: 0; padding: 6px 12px; font-size: 12px; gap: 7px; max-width: 62%; }
.cockpit-head .banner #statusLabel { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.connect-cta { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; padding: 12px 14px; }

/* ---------- Gauge numbers ---------- */
.gauge-num {
  fill: #8a8f97; font-family: "Space Grotesk", sans-serif; font-size: 8.5px; font-weight: 600;
  text-anchor: middle; font-variant-numeric: tabular-nums;
}
.gauge-wrap { width: min(72vw, 296px); margin-top: 6px; }

/* ---------- Battery card ---------- */
.battery-module {
  margin-top: 8px; padding: 14px 14px 12px; border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.07);
  background: linear-gradient(160deg, rgba(255,255,255,0.055), rgba(255,255,255,0.012));
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
}
.battery-head { margin-bottom: 9px; align-items: center; }
.battery-head .label { font-size: 10px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--graphite); }
.battery-head .pct { font-size: 30px; line-height: 1; }
.cell-strip { height: 16px; gap: 3px; }
.range-line { font-size: 12px; margin-top: 9px; min-height: 0; }
.range-line:empty { display: none; }
#drawLine { margin-top: 4px; font-size: 10.5px; opacity: .75; }

/* Trip numbers only matter while riding; outside a ride they would just read zero. */
#cockpitScreen:not(.riding) .trip-strip { display: none; }
#cockpitScreen.riding .trip-strip { border-color: rgba(255,68,56,0.35); box-shadow: 0 0 22px rgba(255,68,56,0.12), inset 0 1px 0 rgba(255,255,255,0.06); }
.instrument-strip { margin-top: 10px; }
.info-strip .readout { padding: 10px 2px; }
.info-strip .t { letter-spacing: 1px; }

/* ---------- Titles with an action ---------- */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.12); color: var(--paper); box-shadow: none; padding: 8px 14px; font-size: 12.5px; }
.btn.ghost:active { border-color: var(--ember); color: var(--ember); }
#exportAllBtn { margin: 0; align-self: center; padding-top: calc(env(safe-area-inset-top, 8px) + 2px); padding-top: 8px; }
.title-row .screen-title { margin-bottom: 0; }

/* ---------- Ride cards ---------- */
.rides-summary { margin: 12px 0 4px; }
.rides-summary .v { font-size: 26px; }
.rides-list { margin-top: 10px; }
.ride-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto 34px; align-items: center; gap: 12px;
  padding: 10px 10px 10px 10px; cursor: pointer; transition: transform .12s ease, border-color .2s ease;
}
.ride-row:active { transform: scale(.985); border-color: rgba(255,176,32,0.35); }
.route-thumb {
  width: 56px; height: 56px; border-radius: 12px; display: block;
  background:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px) 0 0 / 11px 11px,
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px) 0 0 / 11px 11px,
    #101215;
  border: 1px solid rgba(255,255,255,0.06);
}
.ride-row .when { min-width: 0; }
.ride-row .when .date { font-size: 14.5px; }
.ride-row .when .time { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ride-row .metrics .dist { white-space: nowrap; line-height: 1; }
.ride-row .metrics .dist small { font-family: "Space Grotesk", sans-serif; font-size: 11px; font-weight: 600; color: var(--graphite); margin-left: 3px; }
.ride-row .delete-btn {
  width: 34px; height: 34px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  color: var(--graphite); background: transparent; transition: background .2s ease, color .2s ease;
}
.ride-row .delete-btn.armed { background: var(--redline); color: #fff; box-shadow: 0 0 14px rgba(255,68,56,0.6); }
.ride-row.simulated { opacity: .7; }
.ride-row.simulated .date::after {
  content: "demo"; margin-left: 6px; padding: 1px 6px; border-radius: 6px; font-size: 9.5px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--graphite); border: 1px solid var(--line); vertical-align: 2px;
}

/* ---------- Setup cards ---------- */
.setup-card { margin-top: 10px; padding-bottom: 16px; }
.card {
  padding: 16px; margin-bottom: 12px; border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.07);
  background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.012));
  box-shadow: 0 8px 24px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
}
.card.quiet { background: transparent; box-shadow: none; border-style: dashed; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.card-head h3 { margin: 0 !important; font-size: 20px !important; }
.chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 10px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase; border: 1px solid var(--line); color: var(--graphite);
}
.chip.ok { color: #4fe07a; border-color: rgba(79,224,122,0.35); background: rgba(79,224,122,0.08); }
.btn.wide { width: 100%; flex: none; }
.keys-status { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 12.5px; }
.keys-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--graphite); flex: none; }
.keys-status.ok { border-color: rgba(94,200,216,0.35); background: rgba(94,200,216,0.08); }
.keys-status.ok::before { background: var(--signal); box-shadow: 0 0 8px var(--signal); }
.keys-status.err { border-color: rgba(255,68,56,0.35); background: var(--redline-dim); border-radius: 12px; }
.keys-status.err::before { background: var(--redline); }

/* ---------- Plan empty state and details ---------- */
.plan-empty { text-align: center; padding: 26px 18px 10px; color: var(--graphite); }
.plan-empty h3 { margin: 8px 0 6px; color: var(--paper); font-family: "Big Shoulders Display", sans-serif; font-size: 24px; font-weight: 700; }
.plan-empty p { margin: 0 auto; max-width: 290px; font-size: 13px; line-height: 1.5; }
.plan-empty-art svg { width: 150px; height: 100px; }
.plan-empty-art .route { stroke: url(#none); stroke: #ffb020; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 2 9; filter: drop-shadow(0 0 6px rgba(255,176,32,0.6)); animation: march 1.6s linear infinite; }
.plan-empty-art .a { fill: #5ec8d8; filter: drop-shadow(0 0 6px rgba(94,200,216,0.8)); }
.plan-empty-art .b { fill: #ff4438; filter: drop-shadow(0 0 8px rgba(255,68,56,0.8)); }
@keyframes march { to { stroke-dashoffset: -22; } }
.plan-status:empty { min-height: 0; margin: 0; }
.plan-about { margin: 16px 0 18px; border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; }
.plan-about summary { cursor: pointer; padding: 12px 0; font-size: 13px; font-weight: 600; color: var(--graphite); list-style: none; display: flex; justify-content: space-between; }
.plan-about summary::-webkit-details-marker { display: none; }
.plan-about summary::after { content: "+"; font-size: 16px; line-height: 1; }
.plan-about[open] summary::after { content: "–"; }
.plan-about p { margin: 0 0 12px; }

/* Short phones: keep the ride button on screen. */
@media (max-height: 760px) {
  .gauge-wrap { width: min(60vw, 240px); }
  .battery-module { padding: 11px 12px 10px; }
  .battery-head .pct { font-size: 24px; }
}
.no-track {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--graphite); font-size: 13px; text-align: center; padding: 0 30px;
  background:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / 22px 22px,
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--ink);
}
.no-track[hidden] { display: none; }

/* ============================================================
   EDGE THEME — angular, HUD-style. Cut corners instead of
   rounded ones, a segmented dial, slanted type and cells,
   hazard striping. Presentation only.
   ============================================================ */
:root {
  --cut: 12px;
  --cut-sm: 7px;
  --chamfer: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  --chamfer-sm: polygon(var(--cut-sm) 0, 100% 0, 100% calc(100% - var(--cut-sm)), calc(100% - var(--cut-sm)) 100%, 0 100%, 0 var(--cut-sm));
  --chamfer-r: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}

/* Background: diagonal hairlines + faint scanlines instead of the carbon weave */
#app::before {
  opacity: 1;
  background-image:
    repeating-linear-gradient(-45deg, rgba(255,255,255,0.022) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.22) 0 1px, transparent 1px 3px);
  background-size: auto; background-position: 0 0;
}
body {
  background:
    radial-gradient(110% 55% at 50% -12%, rgba(255,150,30,0.18), transparent 60%),
    linear-gradient(115deg, transparent 62%, rgba(255,68,56,0.06) 62%, rgba(255,68,56,0.06) 63%, transparent 63%),
    linear-gradient(115deg, transparent 66%, rgba(255,176,32,0.05) 66%, rgba(255,176,32,0.05) 66.6%, transparent 66.6%),
    var(--ink);
  background-attachment: fixed;
}

/* ---------- Cut corners everywhere ---------- */
.instrument-strip, .battery-module, .card, .ride-row, .chart-box, .plan-summary, .plan-map,
.plan-banner, .setup-card textarea, .diag-preview, .diag-note, .plan-about, #toast {
  border-radius: 0 !important; clip-path: var(--chamfer);
}
.btn, .connect-cta, .ride-btn, .plan-result, .plan-form input, .diag-filters input[type="search"] {
  border-radius: 0 !important; clip-path: var(--chamfer-sm);
}
.banner, .chip, .keys-status, .unit-toggle, .detail-date-chip, .route-thumb, .plan-verdict {
  border-radius: 0 !important; clip-path: var(--chamfer-sm);
}
.back-btn { border-radius: 0 !important; clip-path: polygon(30% 0, 100% 0, 100% 100%, 30% 100%, 0 50%); }
.ride-row .delete-btn { border-radius: 0; clip-path: var(--chamfer-sm); }
/* clip-path hides outer glows, so give cards a lit top edge instead */
.instrument-strip, .battery-module, .card, .ride-row, .plan-summary {
  border-top-color: rgba(255,176,32,0.28) !important;
  background:
    linear-gradient(90deg, rgba(255,176,32,0.9), rgba(255,176,32,0) 38%) top left / 100% 2px no-repeat,
    linear-gradient(160deg, rgba(255,255,255,0.06), rgba(255,255,255,0.012));
}
.card.quiet { background: transparent; }

/* ---------- Type: condensed, slanted, uppercase headings ---------- */
.screen-title, .diag-title, .plan-empty h3, .card-head h3, .empty-state h3 {
  text-transform: uppercase; letter-spacing: 1.5px; font-style: italic;
}
.screen-title { font-size: 34px; font-weight: 800; }
.screen-title::before, .diag-entry-title::before {
  width: 9px; height: 70%; border-radius: 0; transform: translateY(-50%) skewX(-20deg);
  background: repeating-linear-gradient(180deg, var(--ember) 0 3px, transparent 3px 5px);
}
.instrument-strip .v, .battery-head .pct, .plan-big, .plan-banner-dist, .ride-row .metrics .dist, .gauge-readout .value {
  display: inline-block; transform: skewX(-8deg); font-style: normal;
}
.instrument-strip .t, .battery-head .label, .chart-title, .brand-sub { font-weight: 700; }
.chart-title::before { content: "▸ "; color: var(--ember); }
.brand-mark { font-style: italic; letter-spacing: 1px; transform: skewX(-6deg); display: inline-block; }

/* ---------- Gauge: segmented arc, corner brackets, red zone ---------- */
.gauge-cut { fill: none; stroke: #0a0b0d; stroke-width: 16; stroke-dasharray: 1.6 5.4; pointer-events: none; }
.gauge-redzone { fill: none; stroke: var(--redline); stroke-width: 2.5; opacity: .85; filter: drop-shadow(0 0 4px rgba(255,68,56,0.8)); }
.gauge-track { stroke: #1c1f24; stroke-linecap: butt; }
.gauge-value { stroke-linecap: butt; }
.gauge-tick { stroke: #3a3e45; stroke-width: 1.5; }
.gauge-tick.major { stroke: var(--paper); stroke-width: 2.5; }
.gauge-halo { stroke: rgba(94,200,216,0.22); stroke-dasharray: 14 6 2 6; stroke-width: 1.2; }
.gauge-disc { stroke: rgba(255,176,32,0.12); stroke-width: 1.5; }
.gauge-num { fill: #aab0b8; font-weight: 700; font-style: italic; }
.gauge-wrap::before {
  content: ""; position: absolute; inset: -4%; pointer-events: none;
  background:
    linear-gradient(var(--ember), var(--ember)) top left / 18px 2px no-repeat,
    linear-gradient(var(--ember), var(--ember)) top left / 2px 18px no-repeat,
    linear-gradient(var(--ember), var(--ember)) top right / 18px 2px no-repeat,
    linear-gradient(var(--ember), var(--ember)) top right / 2px 18px no-repeat,
    linear-gradient(var(--ember), var(--ember)) bottom left / 18px 2px no-repeat,
    linear-gradient(var(--ember), var(--ember)) bottom left / 2px 18px no-repeat,
    linear-gradient(var(--ember), var(--ember)) bottom right / 18px 2px no-repeat,
    linear-gradient(var(--ember), var(--ember)) bottom right / 2px 18px no-repeat;
  opacity: .55;
}
.eff { font-style: italic; }

/* ---------- Battery cells as slanted blades ---------- */
.cell { border-radius: 0; transform: skewX(-20deg); }
.cell-strip { gap: 5px; padding: 0 4px; }

/* ---------- Ride button: hazard ends, angular, pulsing stripes while riding ---------- */
.ride-btn {
  font-style: italic; letter-spacing: 4px; font-weight: 800;
  background:
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.85) 0 7px, transparent 7px 14px) left / 30px 100% no-repeat,
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.85) 0 7px, transparent 7px 14px) right / 30px 100% no-repeat,
    linear-gradient(135deg, #ffc548, #ff8f1f);
}
.ride-btn.riding {
  background:
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.22) 0 12px, transparent 12px 24px),
    linear-gradient(135deg, #ff6a5e, #e0281d);
  background-size: 34px 34px, 100% 100%;
  animation: hazard 0.9s linear infinite, beat 1.6s ease-in-out infinite;
}
@keyframes hazard { to { background-position: 34px 0, 0 0; } }
.btn.primary { font-style: italic; text-transform: uppercase; letter-spacing: 1px; }

/* ---------- Header pill, connect ---------- */
.connect-cta { text-transform: uppercase; letter-spacing: 1.5px; font-size: 12.5px; }

/* ---------- Tab bar: parallelogram indicator ---------- */
.tabbar { border-top: 1px solid rgba(255,176,32,0.2); }
.tab-btn { text-transform: uppercase; letter-spacing: 1px; font-size: 9.5px; }
.tab-btn.active::before {
  top: -9px; left: 26%; right: 26%; height: 4px; border-radius: 0; transform: skewX(-30deg);
  background: repeating-linear-gradient(90deg, var(--ember) 0 6px, transparent 6px 8px);
}

/* ---------- Lists ---------- */
.plan-step.current { border-radius: 0; box-shadow: inset 3px 0 0 var(--ember); }
.charges-list li, .insights li { border-bottom-style: dashed; }
.gauge-wrap::before { inset: 3% -2%; }
.gauge-wrap { margin-top: 12px; margin-bottom: 4px; }
.screen-title, .diag-entry-title { padding-left: 22px; }

/* ---------- Plan: quick chips, parked card, save row, round trip, voice ---------- */
.plan-quick { display: flex; gap: 8px; overflow-x: auto; margin: 10px -2px 0; padding: 2px; scrollbar-width: none; }
.plan-quick::-webkit-scrollbar { display: none; }
.plan-chip {
  flex: 0 0 auto; padding: 8px 13px; font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  font-family: "Space Grotesk", sans-serif; color: var(--paper); background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12); clip-path: var(--chamfer-sm); white-space: nowrap;
}
.plan-chip:active { border-color: var(--ember); color: var(--ember); }
.plan-chip.home, .plan-chip.work { color: var(--ember); border-color: rgba(255,176,32,0.4); }
.plan-chip.range { color: #4fe07a; border-color: rgba(79,224,122,0.4); }
.plan-chip.park { color: var(--signal); border-color: rgba(94,200,216,0.4); }
.plan-parked {
  display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 12px 12px 12px 14px;
  border: 1px solid rgba(94,200,216,0.35); background: linear-gradient(90deg, rgba(94,200,216,0.14), rgba(94,200,216,0.02));
  clip-path: var(--chamfer);
}
.plan-parked[hidden] { display: none; }
.plan-parked-info { flex: 1; min-width: 0; }
.plan-parked-title { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; font-style: italic; }
.plan-parked-sub { font-size: 11.5px; color: var(--graphite); margin-top: 2px; }
.plan-parked .btn { flex: 0 0 auto; padding: 8px 12px; }
.plan-save { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.plan-save[hidden] { display: none; }
.plan-save-label { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--graphite); margin-right: 2px; }
.plan-round { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12.5px; }
.plan-round-label { color: var(--graphite); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 11px; }
.plan-round-val { text-align: right; font-variant-numeric: tabular-nums; }
.plan-round.warn .plan-round-val { color: #ffd23f; }
.plan-actions .btn.voice { flex: 0 0 auto; padding: 0 14px; font-size: 12px; color: var(--graphite); }
.plan-actions .btn.voice.on { color: #4fe07a; border-color: rgba(79,224,122,0.4); }

/* ---------- Garage: odometer, records, maintenance ---------- */
.garage { margin-top: 12px; }
.odo-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.odo-label { font-size: 10px; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase; color: var(--graphite); }
.odo-value { display: flex; align-items: baseline; gap: 6px; }
.odo-value .numeral {
  font-size: 46px; line-height: 1; font-variant-numeric: tabular-nums; display: inline-block; transform: skewX(-8deg);
  background: linear-gradient(180deg, #fff6e0, #ffb020); -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: 1px;
}
.odo-value small { font-size: 13px; font-weight: 700; color: var(--graphite); }
.odo-form { margin-top: 10px; }
.odo-form[hidden] { display: none; }
.odo-form label { display: block; font-size: 11.5px; color: var(--graphite); margin-bottom: 6px; }
.odo-form-row { display: flex; gap: 8px; }
.odo-form input {
  flex: 1; min-width: 0; background: rgba(0,0,0,0.35); color: var(--paper); border: 1px solid rgba(255,255,255,0.14);
  padding: 10px 12px; font-size: 16px; font-family: "Space Grotesk", sans-serif; clip-path: var(--chamfer-sm);
}
.garage .rides-summary { margin: 14px 0 0; box-shadow: none; }
.week-bars { display: flex; align-items: flex-end; gap: 5px; height: 46px; margin: 14px 2px 4px; }
.week-bar { flex: 1; background: rgba(255,176,32,0.28); transform: skewX(-12deg); min-height: 3px; }
.week-bar.current { background: linear-gradient(180deg, #ffd36b, #ff8f1f); box-shadow: 0 0 10px rgba(255,160,30,0.5); }
.records { list-style: none; margin: 10px 0 0; padding: 0; }
.records li { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.records .k { color: var(--graphite); }
.records .v { grid-row: span 2; align-self: center; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ember); }
.records .w { font-size: 10.5px; color: #555a61; }
.maint-list { list-style: none; margin: 4px 0 0; padding: 0; }
.maint-item { display: flex; align-items: center; gap: 10px; padding: 10px 0 10px 10px; border-bottom: 1px dashed var(--line); box-shadow: inset 3px 0 0 #2b2e33; }
.maint-item.soon { box-shadow: inset 3px 0 0 #ffd23f; }
.maint-item.due { box-shadow: inset 3px 0 0 var(--redline); }
.maint-info { flex: 1; min-width: 0; }
.maint-name { font-size: 13.5px; font-weight: 600; }
.maint-sub { font-size: 11px; color: var(--graphite); margin-top: 2px; }
.maint-item.due .maint-sub { color: #ff7a6e; }
.maint-item.soon .maint-sub { color: #ffd23f; }
.maint-item .btn { flex: 0 0 auto; padding: 7px 13px; }
.chip.warn { color: var(--redline); border-color: rgba(255,68,56,0.45); background: var(--redline-dim); }
.tab-btn.has-badge::after {
  content: ""; position: absolute; top: 4px; right: calc(50% - 16px); width: 8px; height: 8px;
  background: var(--redline); transform: rotate(45deg); box-shadow: 0 0 8px rgba(255,68,56,0.8);
}
#ridesListTitle { margin-top: 18px; }
.plan-parked { flex-wrap: wrap; }
.plan-parked-info { flex: 1 1 100%; }
.plan-parked .btn.primary { flex: 1; }
.plan-actions #planFollow { flex: 1.7; white-space: nowrap; }
.plan-actions #planClear { flex: 0 0 auto; padding: 0 16px; }
