:root {
  --bg: #ffffff;
  --bg-2: #f2f3f5;
  --fg: #111318;
  --fg-2: #5b6170;
  --line: #e3e5ea;
  --accent: #f28c28;       /* apricot */
  --accent-fg: #ffffff;
  --danger: #e5484d;
  --shadow: 0 6px 24px rgba(0, 0, 0, .14);
  --radius: 18px;
  --panel-w: 400px;
  color-scheme: light;
}
body[data-theme="night"] {
  --bg: #181b21;
  --bg-2: #22262e;
  --fg: #f3f4f6;
  --fg-2: #9aa1ad;
  --line: #2c313a;
  --shadow: 0 6px 24px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: #0f1115;
  color: var(--fg);
  font-family: "Inter", "Noto Sans Armenian", system-ui, sans-serif;
  font-size: 18px;
  user-select: none;
}
[hidden] { display: none !important; }
#map { position: absolute; inset: 0; }

.ico { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- panel ---------- */
#panel {
  position: absolute; top: 16px; left: 16px;
  width: var(--panel-w); max-width: calc(100vw - 104px);
  max-height: calc(100vh - 32px);
  display: flex; flex-direction: column; gap: 10px;
  z-index: 5;
}
.view { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.card { background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }

.search-box {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 0 10px 0 18px; height: 64px; color: var(--fg-2);
}
.search-box input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  color: var(--fg); font: inherit; font-size: 20px; height: 100%;
}
.search-box input::-webkit-search-cancel-button { display: none; }
.hint { background: var(--bg); border-radius: 12px; padding: 10px 16px; color: var(--fg-2); font-size: 15px; box-shadow: var(--shadow); }

.results {
  list-style: none; margin: 0; padding: 6px 0;
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-y: auto; min-height: 0;
}
.results:empty { display: none; }
.results li { display: flex; align-items: center; gap: 14px; padding: 14px 18px; cursor: pointer; }
.results li + li { border-top: 1px solid var(--line); }
.results li:active { background: var(--bg-2); }
.results .r-ico { color: var(--fg-2); }
.results .r-main { font-weight: 600; font-size: 18px; }
.results .r-sub { color: var(--fg-2); font-size: 15px; margin-top: 2px; }
.results .r-head { padding: 10px 18px 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-2); cursor: default; border: 0; }

.dest-name { font-size: 24px; font-weight: 700; line-height: 1.2; }
.dest-sub { color: var(--fg-2); font-size: 16px; }
.trip-stats { display: flex; gap: 18px; font-size: 18px; margin: 4px 0 8px; }
.trip-stats b { font-size: 26px; }
.trip-stats .muted { color: var(--fg-2); }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

.btn {
  height: 60px; padding: 0 22px; border: 0; border-radius: 14px;
  background: var(--bg-2); color: var(--fg); font: inherit; font-weight: 600; font-size: 19px; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-fg); }
.btn.danger { background: var(--danger); color: #fff; }

/* ---------- turn banner ---------- */
.turn { display: flex; align-items: center; gap: 18px; background: #1f6f4a; color: #fff; padding: 20px 22px; }
.turn-icon .ico, .then-icon .ico, .arrived-flag .ico { stroke-width: 2.4; }
.turn-icon .ico { width: 72px; height: 72px; }
.turn-dist { font-size: 40px; font-weight: 700; line-height: 1.05; }
.turn-text { font-size: 20px; font-weight: 500; opacity: .95; margin-top: 4px; line-height: 1.25; }
.then { display: inline-flex; align-self: flex-start; align-items: center; gap: 8px; padding: 10px 16px; background: #174f36; color: #fff; font-weight: 600; }
.then-icon .ico { width: 30px; height: 30px; }
.mirror { transform: scaleX(-1); }
.arrived-flag { color: var(--accent); }
.arrived-flag .ico { width: 56px; height: 56px; }
#view-arrived { gap: 12px; }

/* ---------- trip bar ---------- */
#tripbar {
  position: absolute; left: 16px; bottom: 16px; z-index: 5;
  width: var(--panel-w); max-width: calc(100vw - 104px);
  display: flex; align-items: center; gap: 6px;
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 12px 12px 18px;
}
.trip-cell { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.trip-cell b { font-size: 24px; white-space: nowrap; }
.trip-cell span { font-size: 13px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#tripbar .btn { height: 56px; }

/* ---------- side buttons ---------- */
#side { position: absolute; right: 16px; bottom: 16px; z-index: 5; display: flex; flex-direction: column; gap: 12px; }
.icon-btn {
  width: 64px; height: 64px; border-radius: 50%; border: 0;
  background: var(--bg); color: var(--fg); box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn.small { width: 44px; height: 44px; box-shadow: none; background: transparent; color: var(--fg-2); }
.icon-btn.on { color: var(--accent); }

/* ---------- car marker ---------- */
.car { width: 46px; height: 46px; }
.car svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); }

/* ---------- gps info ---------- */
#gpsinfo {
  position: absolute; right: 96px; bottom: 16px; z-index: 5;
  background: rgba(0,0,0,.78); color: #e8eaed; border-radius: 12px; padding: 12px 16px;
  font: 14px/1.5 ui-monospace, Menlo, monospace; white-space: pre;
}

/* ---------- settings sheet ---------- */
#sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
#sheet {
  position: absolute; z-index: 21; right: 16px; top: 16px; width: 460px; max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px;
}
#sheet h2 { margin: 0 0 14px; font-size: 22px; }
.set-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.set-label { width: 100%; color: var(--fg-2); font-size: 15px; }
.seg { display: flex; background: var(--bg-2); border-radius: 14px; padding: 4px; width: 100%; }
.seg button { flex: 1; height: 52px; border: 0; border-radius: 11px; background: transparent; color: var(--fg); font: inherit; font-weight: 600; font-size: 17px; cursor: pointer; }
.seg button.on { background: var(--bg); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
body[data-theme="night"] .seg button.on { background: #343a45; }
.set-row .btn { flex: 1 1 auto; height: 54px; font-size: 17px; }
.fine { color: var(--fg-2); font-size: 13px; margin: 6px 0 0; }

/* ---------- toast ---------- */
#toast {
  position: absolute; left: 50%; top: 20px; transform: translateX(-50%); z-index: 30;
  background: #111318; color: #fff; padding: 14px 22px; border-radius: 14px; box-shadow: var(--shadow); font-weight: 500;
}

.maplibregl-ctrl-attrib { font-size: 11px; }

/* phones (for testing outside the car) */
@media (max-width: 600px) {
  body { font-size: 16px; }
  #panel, #tripbar { left: 12px; right: 12px; width: auto; max-width: none; }
  #panel { top: 12px; }
  #side { right: 12px; bottom: 100px; }
  .turn-dist { font-size: 32px; }
  .turn-icon .ico { width: 56px; height: 56px; }
  #tripbar { gap: 8px; padding: 10px 10px 10px 14px; }
  .trip-cell b { font-size: 18px; }
  .trip-cell span { font-size: 11px; }
  #tripbar .btn { height: 48px; padding: 0 14px; font-size: 16px; }
}
