:root {
  --glass: rgba(15, 17, 22, 0.78);
  --glass-border: rgba(255, 255, 255, 0.09);
  --text: #e9ebee;
  --muted: #9aa3ad;
  --accent: #ff5a36;
  --accent-soft: rgba(255, 90, 54, 0.16);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: #0f1116;
}

#map { position: fixed; inset: 0; z-index: 0; }
body.fullhd-mode #map { position: fixed; top: 0; left: 0; width: var(--rec-w, 1920px); height: var(--rec-h, 1080px); inset: auto; }

.hidden { display: none !important; }

/* ---------- brand ---------- */
.brand {
  position: fixed; top: 12px; left: 12px; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px 9px 10px;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  text-decoration: none; color: inherit; cursor: pointer;
  transition: border-color 0.15s;
}
.brand:hover { border-color: rgba(255, 255, 255, 0.22); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #ff5a36, #ff9d2e);
  position: relative; flex: 0 0 auto;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 7px 6px;
  border: 2.5px solid #fff; border-radius: 50% 50% 40% 40%;
  border-top-color: transparent; border-left-color: transparent;
  transform: rotate(-40deg) scale(0.9);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 14px; letter-spacing: 0.01em; }
.brand-text span { font-size: 10.5px; color: var(--muted); }

/* ---------- panel ---------- */
.panel {
  position: fixed; top: 12px; right: 12px; z-index: 20;
  width: 318px; max-height: calc(100vh - 96px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--radius); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 6px 14px 12px;
  transition: transform 0.25s ease, opacity 0.25s ease;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 8px; }
body.panel-collapsed .panel { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }

.panel-toggle {
  position: absolute; top: 8px; right: 8px;
  width: 26px; height: 26px; border-radius: 8px;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,0.06);
  color: var(--muted); font-size: 17px; line-height: 1; cursor: pointer;
}
.panel-toggle:hover { color: var(--text); background: rgba(255,255,255,0.12); }

.panel-open {
  position: fixed; top: 12px; right: 12px; z-index: 19;
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--glass-border); background: var(--glass);
  color: var(--text); font-size: 17px; cursor: pointer;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: none;
}
body.panel-collapsed .panel-open { display: block; }
.panel-open:hover { background: rgba(30, 34, 42, 0.9); }

.sec { padding: 10px 0 4px; border-top: 1px solid rgba(255,255,255,0.07); }
.sec:first-of-type { border-top: none; }
.sec h3 {
  margin: 4px 0 10px; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted);
}

.stat {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px; font-size: 13px; color: var(--muted);
}
.stat #routeLen { color: var(--text); font-weight: 600; font-size: 14px; }

.row { display: flex; gap: 8px; margin-bottom: 8px; }
.row .btn { flex: 1 1 0; }

.btn {
  appearance: none; border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.07); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 12.5px;
  font-family: inherit; cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.13); }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--accent); border-color: transparent; color: #fff;
  font-weight: 600; font-size: 13.5px; padding: 11px 12px; width: 100%;
  margin-bottom: 8px;
}
.btn-primary:hover { background: #ff6a48; }

.btn-rec {
  width: 100%; margin-bottom: 6px;
  background: var(--accent-soft); border-color: rgba(255, 90, 54, 0.55);
  color: #ff9d7d; font-weight: 600; font-size: 13.5px; padding: 11px 12px;
}
.btn-rec:hover { background: rgba(255, 90, 54, 0.26); }

.link {
  appearance: none; border: none; background: none; padding: 0;
  color: var(--accent); font-size: 12.5px; font-family: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; opacity: 0.9;
}
.link:hover { opacity: 1; }

.field { display: block; margin-bottom: 12px; font-size: 13px; }
.field > span { display: block; margin-bottom: 6px; color: var(--muted); }
.field b { color: var(--text); font-weight: 600; }

select {
  width: 100%; appearance: none; border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.07); color: var(--text);
  border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
select option { color: #111; }

input[type="range"] { width: 100%; accent-color: var(--accent); cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); }
input[type="radio"] { accent-color: var(--accent); }

.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); margin: 4px 0 8px; cursor: pointer; }
.check input { margin: 0; }

.hint { margin: 8px 0 4px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }

.styles label {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px; border-radius: 10px; cursor: pointer; font-size: 13px;
}
.styles label:hover { background: rgba(255,255,255,0.06); }
.styles input { margin: 0; }
.sw { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(255,255,255,0.25); }
.sw-liberty { background: linear-gradient(135deg, #f2efe9 0 45%, #9fc4e7 45% 75%, #f7c873 75%); }
.sw-bright { background: linear-gradient(135deg, #fafaf8 0 45%, #a6cbe8 45% 75%, #7fc97f 75%); }
.sw-positron { background: linear-gradient(135deg, #f4f4f2 0 45%, #d4d9dd 45% 75%, #e8e4da 75%); }

.foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.07); font-size: 10.5px; color: var(--muted); }
.foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.foot a:hover { color: var(--text); }

/* ---------- banner / toast ---------- */
.banner {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 30; max-width: min(680px, calc(100vw - 400px));
  padding: 11px 16px; border-radius: 12px;
  background: rgba(255, 176, 46, 0.13); border: 1px solid rgba(255, 176, 46, 0.42);
  color: #ffd08a; font-size: 12.5px; line-height: 1.5;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
@media (max-width: 900px) { .banner { max-width: calc(100vw - 24px); } }
.banner-link { color: #ffd08a; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.banner-link:hover { color: #ffe4b8; }

.toast {
  position: fixed; left: 12px; bottom: 12px; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 12px;
  background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 13px; max-width: min(420px, calc(100vw - 24px));
  transition: opacity 0.2s;
}
.toast button {
  appearance: none; border: 1px solid rgba(255, 90, 54, 0.55); background: var(--accent-soft);
  color: #ff9d7d; border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer;
}

/* ---------- recording chrome ---------- */
.recdot {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 35; display: none; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 99px;
  background: rgba(20, 18, 24, 0.85); border: 1px solid rgba(255, 59, 48, 0.5);
  color: #fff; font-size: 12px; font-weight: 700; letter-spacing: 0.12em;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.recdot i { width: 9px; height: 9px; border-radius: 50%; background: #ff3b30; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }
body.recording .recdot { display: flex; }

.progress {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 25; width: min(560px, 70vw); height: 6px;
  background: rgba(255, 255, 255, 0.18); border-radius: 99px; overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 99px; }

.stopbtn {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  z-index: 26; padding: 10px 18px; border-radius: 99px;
  border: 1px solid var(--glass-border); background: rgba(20, 22, 28, 0.85);
  color: #fff; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.stopbtn:hover { background: rgba(35, 38, 46, 0.92); }

/* ---------- playing / recording states ---------- */
body.playing .brand,
body.playing .panel,
body.playing .panel-open,
body.playing .maplibregl-ctrl,
body.recording .brand,
body.recording .panel,
body.recording .panel-open,
body.recording .maplibregl-ctrl,
body.recording .stopbtn { display: none !important; }

body.playing .pt-marker { opacity: 0; pointer-events: none; }

/* ---------- markers ---------- */
.pt-marker {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--accent);
  color: #23272e; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  cursor: grab; user-select: none; -webkit-user-select: none;
  transition: transform 0.12s ease;
}
.pt-marker:hover { transform: scale(1.14); }
.pt-marker:active { cursor: grabbing; }

body.degraded .styles { opacity: 0.45; pointer-events: none; }
body.degraded #hintStyles { display: block; }

/* ---------- vehicle chips ---------- */
.veh-box { display: flex; flex-wrap: wrap; gap: 6px; }
.veh-chip {
  width: 38px; height: 38px; padding: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--glass-border);
  border-radius: 10px; cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.veh-chip canvas { width: 28px; height: 28px; display: block; }
.veh-chip:hover { background: rgba(255, 255, 255, 0.13); }
.veh-chip.active { border-color: var(--accent); background: var(--accent-soft); }
