/* TeslaMapHub — flat surfaces over the map. No outlines, no glows, no gradients:
   layers are told apart by tone and one soft shadow, like the car's own UI.
   Night is the main look; day mirrors it. Type is Fixel by MacPaw (OFL), self-hosted so it works offline. */

@font-face { font-family: 'Fixel Text'; src: url('../fonts/FixelText-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Fixel Text'; src: url('../fonts/FixelText-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Fixel Text'; src: url('../fonts/FixelText-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Fixel Display'; src: url('../fonts/FixelDisplay-Light.woff2') format('woff2'); font-weight: 300; font-display: swap; }
@font-face { font-family: 'Fixel Display'; src: url('../fonts/FixelDisplay-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Fixel Display'; src: url('../fonts/FixelDisplay-SemiBold.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
  --map: #0f1114;
  --surface: #1b1d21;
  --raised: #272a2f;
  --hi: #3b3f46;
  --fg: #f3f4f5;
  --dim: #8f959d;
  --blue: #3e7bfa;
  --red: #e5303c;
  --amber: #f2a31b;
  --green: #22b968;
  --lift: 0 8px 28px rgba(0, 0, 0, 0.4);
  --r-lg: 22px;
  --r-md: 14px;
  --tap: 66px;
  --font: 'Fixel Text', 'Segoe UI', 'Noto Sans', system-ui, sans-serif;
  --display: 'Fixel Display', 'Fixel Text', 'Segoe UI', system-ui, sans-serif;
  color-scheme: dark;
}

:root[data-theme='day'] {
  --map: #eceef1;
  --surface: #ffffff;
  --raised: #eef0f2;
  --hi: #ffffff;
  --fg: #15181b;
  --dim: #646b75;
  --lift: 0 6px 22px rgba(25, 35, 50, 0.16);
  color-scheme: light;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--map);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 500;
  font-size: 18px;
  user-select: none;
  -webkit-user-select: none;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
/* Text fields must stay selectable/typeable even though the app disables selection elsewhere. */
input { font: inherit; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.hidden { display: none !important; }
.num { font-family: var(--display); }

#map { position: fixed; inset: 0; }

.surface { background: var(--surface); box-shadow: var(--lift); }

/* ---------- buttons ---------- */

.btn {
  min-height: 60px;
  padding: 0 26px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 20px;
  background: var(--raised);
  transition: transform 0.12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-go { background: var(--blue); color: #fff; }
.btn-ok { background: var(--green); color: #04150b; }
.btn-no { background: var(--red); color: #fff; }
.btn-end { color: var(--red); }
.btn-big { min-height: 76px; font-size: 23px; padding: 0 48px; border-radius: 18px; }
.btn-wide { width: 100%; }

.icon-btn {
  width: 56px; height: 56px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--raised);
}
.icon-btn svg { width: 26px; height: 26px; }

/* ---------- right rail ---------- */

.rail {
  position: fixed; right: 18px; bottom: 112px; z-index: 6;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.rail-group { display: flex; flex-direction: column; border-radius: 999px; }
.fab {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border-radius: 50%;
  transition: transform 0.12s ease, background 0.12s ease;
}
.fab:active { transform: scale(0.93); background: var(--raised); }
.fab svg { width: 28px; height: 28px; }
.fab-solo { background: var(--surface); box-shadow: var(--lift); }
.fab-report { width: 82px; height: 82px; background: var(--amber); color: #1d1300; box-shadow: var(--lift); }
.fab-report:active { background: var(--amber); }
.fab-report svg { width: 36px; height: 36px; }
.fab-charge { color: var(--green); }

/* ---------- speed cluster ---------- */

.cluster {
  position: fixed; left: 20px; bottom: 22px; z-index: 5;
  display: flex; align-items: center; gap: 14px;
}
.speed {
  min-width: 144px; height: 144px;
  padding: 0 20px;
  border-radius: 30px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface);
  box-shadow: var(--lift);
  transition: background 0.2s ease, color 0.2s ease;
}
.speed span { font-size: 78px; font-weight: 300; line-height: 0.95; letter-spacing: -0.03em; }
.speed small { font-size: 16px; color: var(--dim); font-weight: 600; }
.speed.over { background: var(--red); color: #fff; }
.speed.over small { color: rgba(255, 255, 255, 0.8); }
.speed.dr span { opacity: 0.55; }
.speed.dr span::before { content: '≈'; font-size: 0.5em; vertical-align: top; margin-right: 2px; }

/* Ukrainian speed-limit sign: the one place a ring belongs, because the real sign has it */
.sign {
  width: 104px; height: 104px; flex: none;
  border-radius: 50%;
  background: #fff;
  border: 12px solid #e30613;
  display: grid; place-items: center;
  box-shadow: var(--lift);
}
.sign span { font: 700 40px/1 var(--font); color: #111; letter-spacing: -0.03em; }
.sign-sm { width: 60px; height: 60px; border-width: 7px; box-shadow: none; }
.sign-sm span { font-size: 23px; }

/* ---------- status chips ---------- */

.chips {
  position: fixed; top: 18px; right: 18px; z-index: 6;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 15px; font-weight: 600;
  background: var(--surface);
  box-shadow: var(--lift);
}
.chip svg { width: 18px; height: 18px; }
.chip-warn { color: #1d1300; background: var(--amber); }
.chip-bad { color: #fff; background: var(--red); }
.chip-info { color: var(--fg); }

/* ---------- air-raid banner ---------- */

.air {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 9;
  display: flex; align-items: center; gap: 12px;
  padding: 13px 24px 13px 18px;
  border-radius: 999px;
  color: #fff;
  background: var(--red);
  box-shadow: var(--lift);
  font-size: 19px;
  white-space: nowrap;
}
.air-icon svg { width: 26px; height: 26px; display: block; animation: airBlink 1.6s ease-in-out infinite; }
.air-region { opacity: 0.85; font-weight: 500; }
.air.clear { background: var(--green); color: #04150b; }
.air.clear .air-icon svg { animation: none; }
@keyframes airBlink { 50% { opacity: 0.35; } }
body.air-on .maneuver, body.air-on .alert { top: 84px; }

/* ---------- maneuver ---------- */

.maneuver {
  position: fixed; top: 18px; left: 18px; z-index: 6;
  width: min(440px, 42vw);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.mv-main { display: flex; align-items: center; gap: 18px; padding: 16px 22px 16px 16px; }
.mv-icon {
  width: 80px; height: 80px; flex: none;
  display: grid; place-items: center;
  border-radius: 16px;
  color: #fff;
  background: var(--blue);
}
.mv-icon svg { width: 54px; height: 54px; }
.mv-dist { font-size: 48px; font-weight: 500; line-height: 1; letter-spacing: -0.01em; }
.mv-street { font-size: 21px; font-weight: 600; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mv-next { display: flex; align-items: center; gap: 10px; padding: 11px 22px; background: var(--raised); font-size: 17px; color: var(--dim); }
.mv-next svg { width: 24px; height: 24px; color: var(--fg); }

/* ---------- warning card ---------- */
/* The card fills with a lighter tone from the left as the car gets closer (--p, 0…1). */

.alert {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 7;
  width: min(640px, calc(100vw - 420px));
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  padding: 12px 24px 12px 14px;
  border-radius: var(--r-lg);
  overflow: hidden;
  isolation: isolate;
}
.alert::before {
  content: '';
  position: absolute; inset: 0; z-index: -1;
  background: var(--raised);
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  transition: transform 0.9s linear;
}
body.navigating .alert { left: calc(50% + 120px); width: min(600px, calc(100vw - 700px)); }
.al-icon { width: 72px; height: 72px; flex: none; display: grid; place-items: center; }
.al-icon img { height: 66px; width: auto; }
.al-body { flex: 1; min-width: 0; }
.al-title { font-size: 24px; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.al-sub { font-size: 16px; color: var(--dim); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.al-dist { font-size: 42px; font-weight: 500; white-space: nowrap; letter-spacing: -0.01em; }
.al-vote { display: flex; gap: 12px; width: 100%; }
.al-vote .btn { flex: 1; }
.alert.urgent { background: var(--red); color: #fff; }
.alert.urgent::before { background: rgba(0, 0, 0, 0.16); }
.alert.urgent .al-sub { color: rgba(255, 255, 255, 0.82); }

/* ---------- bottom dock ---------- */

.dock {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 5;
  display: flex; justify-content: center;
}
.search-pill {
  display: flex; align-items: center; gap: 14px;
  width: min(560px, calc(100vw - 2 * 230px));
  min-width: 320px;
  height: 72px; padding: 0 26px;
  border-radius: var(--r-lg);
  font-size: 21px; font-weight: 500; color: var(--dim);
}
.search-pill svg { width: 26px; height: 26px; color: var(--fg); }
.trip {
  display: flex; align-items: center; gap: 30px;
  padding: 10px 10px 10px 28px;
  border-radius: var(--r-lg);
}
.trip-cell { display: flex; flex-direction: column; }
.trip-cell b { font-size: 30px; font-weight: 500; line-height: 1.05; }
.trip-cell small { font-size: 14px; color: var(--dim); font-weight: 500; margin-top: 2px; }
.trip-cams b { color: var(--red); }

/* ---------- panels & sheets ---------- */

.panel {
  position: fixed; top: 18px; left: 18px; bottom: 18px; z-index: 10;
  width: min(480px, calc(100vw - 36px));
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  padding: 14px;
  gap: 10px;
}
.panel-head, .sheet-head { display: flex; align-items: center; gap: 12px; }
.panel-head input {
  flex: 1; min-width: 0; height: 60px;
  border: 0; border-radius: var(--r-md);
  padding: 0 18px; font-size: 21px;
  background: var(--raised); color: var(--fg); outline: none;
  caret-color: var(--blue);
}
.panel-head input::placeholder { color: var(--dim); }
.panel-title { flex: 1; padding-left: 8px; font-size: 23px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.list-empty { padding: 28px 8px; color: var(--dim); text-align: center; }
.item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 12px; text-align: left;
  border-radius: var(--r-md);
  transition: background 0.12s ease;
}
.item:active, .item.selected { background: var(--raised); }
.item-icon { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--raised); color: var(--dim); }
.item-icon svg { width: 24px; height: 24px; }
.item-pin { background: none; }
.item-pin img { height: 44px; width: auto; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 20px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-item .item-title { font-size: 26px; font-weight: 500; }
.item-sub { font-size: 15px; color: var(--dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-side { font-size: 16px; color: var(--dim); font-family: var(--display); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge { font-size: 14px; font-weight: 600; padding: 4px 10px; border-radius: 8px; background: var(--raised); color: var(--dim); }
.item.selected .badge { background: var(--hi); }
.badge-cam { color: #ff6b75; }
.badge-alert { color: var(--amber); }
:root[data-theme='day'] .badge-cam { color: #c81e2b; }
:root[data-theme='day'] .badge-alert { color: #a86600; }
.route-air { padding: 12px 14px; border-radius: var(--r-md); background: var(--red); color: #fff; font-weight: 600; font-size: 16px; }
.ev-sockets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.ev-sockets span { font-size: 13px; font-weight: 600; padding: 3px 9px; border-radius: 8px; background: var(--raised); color: var(--dim); }
.ev-sockets .ev-fast { background: var(--green); color: #04150b; }
.item:active .ev-sockets span:not(.ev-fast) { background: var(--hi); }
.seg-wide button { flex: 1; }

.sheet {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 10;
  width: min(760px, calc(100vw - 36px));
  max-height: calc(100vh - 36px); overflow-y: auto;
  border-radius: var(--r-lg);
  padding: 16px 22px 22px;
}
.sheet .panel-title { padding-left: 0; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-top: 14px; }
.report-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 16px 8px 14px; border-radius: 18px;
  background: var(--raised);
  font-size: 17px; font-weight: 600;
  transition: transform 0.12s ease, background 0.12s ease;
}
.report-tile:active { transform: scale(0.96); background: var(--hi); }
.report-tile img { height: 66px; width: auto; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; }
.setting > span { font-size: 19px; font-weight: 600; }
.seg { display: flex; gap: 2px; padding: 4px; border-radius: var(--r-md); background: var(--raised); }
.seg button { min-height: 52px; padding: 0 18px; border-radius: 10px; font-size: 17px; font-weight: 600; color: var(--dim); transition: background 0.12s ease, color 0.12s ease; }
.seg button.on { background: var(--hi); color: var(--fg); }
:root[data-theme='day'] .seg button.on { box-shadow: 0 1px 4px rgba(20, 30, 45, 0.14); }
.data-info { margin-top: 12px; font-size: 15px; color: var(--dim); line-height: 1.6; }
.data-info b { color: var(--fg); font-weight: 600; }

/* ---------- map popups & car ---------- */

.radar-pop .maplibregl-popup-content {
  background: var(--surface); color: var(--fg);
  border-radius: 18px; padding: 16px 18px; box-shadow: var(--lift);
  font-family: var(--font);
}
.radar-pop .maplibregl-popup-tip { display: none; }
.radar-pop .maplibregl-popup-close-button { font-size: 26px; width: 40px; height: 40px; color: var(--dim); }
.pop-title { font-size: 20px; font-weight: 700; padding-right: 30px; }
.pop-sub { font-size: 15px; color: var(--dim); margin-top: 4px; line-height: 1.4; }
.pop-actions { display: flex; gap: 10px; margin-top: 12px; }
.pop-actions .btn { min-height: 52px; font-size: 17px; flex: 1; }

.me-marker { width: 108px; height: 108px; transition: opacity 0.3s ease; }
.me-marker svg { width: 100%; height: 100%; overflow: visible; }
.me-marker.dr { opacity: 0.75; }
.me-marker.dr path { fill: #8f959d; }
.me-marker.lost { opacity: 0.4; filter: grayscale(1); }

.maplibregl-ctrl-attrib { font-size: 11px; background: rgba(15, 17, 20, 0.55) !important; color: #8f959d; }
.maplibregl-ctrl-attrib a { color: #8f959d; }
:root[data-theme='day'] .maplibregl-ctrl-attrib { background: rgba(255, 255, 255, 0.6) !important; }

/* ---------- start screen ---------- */

.start {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: var(--map);
}
.start-card { text-align: center; padding: 24px; max-width: 640px; }
.start-pins { display: flex; justify-content: center; align-items: flex-end; gap: 16px; margin-bottom: 34px; }
.start-pins img { height: 74px; width: auto; animation: pinDrop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.start-pins img:nth-child(2) { animation-delay: 0.07s; }
.start-pins img:nth-child(3) { animation-delay: 0.14s; }
.start-pins img:nth-child(4) { animation-delay: 0.21s; }
.start-pins img:nth-child(5) { animation-delay: 0.28s; }
@keyframes pinDrop { from { opacity: 0; transform: translateY(-18px); } }
.start-card h1 { font: 600 66px/1 var(--display); letter-spacing: -0.025em; margin: 0 0 16px; }
.start-card p { font-size: 21px; color: var(--dim); line-height: 1.45; margin: 0 auto 34px; max-width: 30em; }
.start-note { font-size: 16px !important; margin: 22px 0 0 !important; max-width: none !important; }

.toast {
  position: fixed; left: 50%; bottom: 112px; transform: translateX(-50%); z-index: 30;
  max-width: min(720px, calc(100vw - 36px));
  padding: 16px 24px; border-radius: 18px;
  background: var(--surface); color: var(--fg);
  box-shadow: var(--lift);
  font-size: 19px; font-weight: 600; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .start-pins img, .air-icon svg { animation: none; }
  .alert::before { transition: none; }
}

/* ---------- small screens (phones) ---------- */

@media (max-width: 900px) {
  html, body { font-size: 16px; }
  .maneuver { width: calc(100vw - 24px); top: 12px; left: 12px; }
  .mv-main { padding: 12px 14px 12px 12px; gap: 12px; }
  .mv-icon { width: 58px; height: 58px; border-radius: 14px; }
  .mv-icon svg { width: 40px; height: 40px; }
  .mv-dist { font-size: 34px; }
  .mv-street { font-size: 17px; }
  .alert, body.navigating .alert { left: 12px; right: 12px; transform: none; width: auto; min-width: 0; top: 12px; padding: 10px 14px 10px 10px; gap: 10px; }
  body.navigating .alert { top: 138px; }
  .al-icon { width: 54px; height: 54px; }
  .al-icon img { height: 50px; }
  .al-title { font-size: 19px; white-space: normal; }
  .sign-sm { width: 46px; height: 46px; border-width: 6px; }
  .sign-sm span { font-size: 18px; }
  .al-dist { font-size: 30px; }
  .chips { top: 12px; right: 12px; }
  body.air-on .chips { top: 66px; }
  body.navigating .chips { top: 138px; }
  body.navigating.air-on .chips { top: 192px; }
  .rail { right: 12px; bottom: 210px; gap: 10px; }
  .fab { width: 56px; height: 56px; }
  .fab svg { width: 24px; height: 24px; }
  .fab-report { width: 68px; height: 68px; }
  .cluster { left: 12px; bottom: 96px; gap: 10px; }
  .speed { min-width: 108px; height: 108px; border-radius: 24px; }
  .speed span { font-size: 56px; }
  .sign { width: 80px; height: 80px; border-width: 9px; }
  .sign span { font-size: 30px; }
  .dock { left: 12px; right: 12px; bottom: 12px; transform: none; }
  .search-pill { width: 100%; min-width: 0; height: 64px; font-size: 19px; }
  .trip { width: 100%; gap: 16px; padding: 8px 8px 8px 16px; }
  .trip-cell b { font-size: 22px; }
  .trip-cell small { font-size: 12px; }
  .trip .btn { margin-left: auto; padding: 0 14px; font-size: 16px; min-height: 52px; }
  .panel { top: 12px; left: 12px; right: 12px; bottom: 12px; width: auto; }
  .sheet { bottom: 12px; width: calc(100vw - 24px); }
  .setting { flex-direction: column; align-items: stretch; }
  .seg button { flex: 1; padding: 0 8px; }
  .air { top: 12px; font-size: 16px; padding: 10px 16px; max-width: calc(100vw - 24px); }
  body.air-on .maneuver { top: 70px; }
  body.air-on .alert { top: 70px; }
  .start-pins img { height: 56px; }
  .start-card h1 { font-size: 44px; }
  .start-card p { font-size: 18px; }
}
