:root {
  --bg: #050608;
  --panel: #0f1216;
  --panel-2: #181c23;
  --panel-3: #222730;
  --line: #2a3038;
  --text: #f2f4f7;
  --muted: #9aa3ad;
  --accent: #3d8bff;
  --danger: #ff453a;
  --radius: 24px;
  --gap: 6px;
  --divider-w: 22px;
  --split-x: 50vw;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
}

/* ---------- Stage / split layout ---------- */
.stage {
  position: fixed;
  inset: 0;
  padding: max(var(--gap), env(safe-area-inset-top)) max(var(--gap), env(safe-area-inset-right))
           max(var(--gap), env(safe-area-inset-bottom)) max(var(--gap), env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--divider-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

body.lock219 .stage {
  inset: auto;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  width: min(100vw, 100dvh * 21 / 9);
  height: min(100dvh, 100vw * 9 / 21);
}

.pane {
  position: relative;
  min-width: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #232830;
  isolation: isolate;
  -webkit-mask-image: -webkit-radial-gradient(white, black);
}

#paneYT  { order: 0; }
#divider { order: 1; }
#paneMap { order: 2; }
body.swapped #paneYT  { order: 2; }
body.swapped #paneMap { order: 0; }

body.mode-yt .stage, body.mode-map .stage { grid-template-columns: minmax(0, 1fr) !important; }
body.mode-yt #paneMap, body.mode-yt #divider,
body.mode-map #paneYT, body.mode-map #divider { display: none; }

/* Keep header padding away from the centered menu + swap buttons on the inner edge */
body:not(.swapped):not(.mode-yt) #paneYT .pane-top { padding-right: 32px; }
body:not(.swapped):not(.mode-map) #paneMap .pane-top { padding-left: 32px; }
body.swapped:not(.mode-map) #paneMap .pane-top { padding-right: 32px; }
body.swapped:not(.mode-yt) #paneYT .pane-top { padding-left: 32px; }

.pane-shield { position: absolute; inset: 0; display: none; z-index: 40; }
body.resizing .pane-shield { display: block; cursor: col-resize; }
body.resizing { cursor: col-resize; }

/* ---------- Divider ---------- */
.divider {
  position: relative;
  cursor: col-resize;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
}
.divider-line {
  position: absolute;
  top: 18%;
  bottom: 12%;
  left: 50%;
  width: 3px;
  translate: -50% 0;
  border-radius: 3px;
  background: var(--line);
  transition: background .15s;
}
.grip {
  position: absolute;
  top: 52%;
  left: 50%;
  translate: -50% -50%;
  width: 14px;
  height: 64px;
  border-radius: 999px;
  background: #3a424d;
  border: 1px solid #56606c;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 2px 10px rgb(0 0 0 / .5);
  transition: background .15s, transform .15s;
}
.grip span { width: 4px; height: 4px; border-radius: 50%; background: #c8d0d9; }
.divider:hover .grip,
.divider:focus-visible .grip,
body.resizing .grip { background: var(--accent); border-color: #8ab8ff; transform: scale(1.12); }
body.resizing .divider-line,
.divider:focus-visible .divider-line { background: var(--accent); }
.divider::before { content: ""; position: absolute; inset: 0 -10px; }

/* ---------- Center Floating Menu + Swap Buttons ---------- */
.menu-btn,
.swap-float-btn {
  position: fixed;
  left: var(--split-x);
  translate: -50% 0;
  z-index: 45;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #4a535e;
  background: rgb(20 24 30 / .92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 16px rgb(0 0 0 / .55);
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.menu-btn { top: max(10px, env(safe-area-inset-top)); }
.swap-float-btn {
  top: calc(max(10px, env(safe-area-inset-top)) + 48px);
  width: 38px;
  height: 38px;
}
.menu-btn:active, .swap-float-btn:active { transform: scale(.92); }
.swap-float-btn:hover { border-color: var(--accent); color: #8ab8ff; }
body.resizing .menu-btn,
body.resizing .swap-float-btn { pointer-events: none; opacity: .45; }
body.mode-yt .swap-float-btn,
body.mode-map .swap-float-btn { display: none; }

/* ================================================================== */
/* YouTube Mobile App                                                  */
/* ================================================================== */
.yt-app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #0f0f0f;
}

.yt-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #0f0f0f;
  border-bottom: 1px solid #222;
  flex: none;
  z-index: 20;
}

.yt-logo {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 6px;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -.03em;
  cursor: pointer;
  border-radius: 10px;
  flex: none;
}
.yt-logo:active { background: #222; }

.yt-search-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.yt-search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  background: #1a1a1a;
  border: 1px solid #303030;
  border-radius: 999px;
  overflow: hidden;
  height: 38px;
}
.mic-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid #303030;
  background: #222;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
  transition: background .15s, transform .15s;
}
.mic-btn:active { transform: scale(.92); background: var(--accent); color: #fff; }
.map-mic { color: var(--accent); }
.yt-search:focus-within { border-color: var(--accent); background: #141414; }
.yt-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  outline: none;
}
.yt-search button[type="submit"] {
  width: 40px;
  height: 100%;
  border: 0;
  border-left: 1px solid #2c2c2c;
  background: #242424;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.yt-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  border-radius: 14px;
  background: #1c1c1c;
  border: 1px solid #343434;
  box-shadow: 0 8px 24px rgb(0 0 0 / .65);
  z-index: 30;
}
.yt-suggest[hidden] { display: none; }

.yt-account {
  flex: none;
  height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
}
.yt-account img, .avatar-fallback {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  background: var(--accent); color: #fff; font-weight: 700;
  display: grid; place-items: center;
}
.yt-signin {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid #3ea6ff66;
  color: #3ea6ff;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.yt-chips {
  display: flex;
  gap: 7px;
  padding: 7px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid #1c1c1c;
  flex: none;
}
.yt-chips[hidden] { display: none; }
.yt-chips::-webkit-scrollbar { display: none; }

.chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: #272727;
  border: 1px solid transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}
.chip.active { background: #f1f1f1; color: #0f0f0f; }

.yt-feed {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  overscroll-behavior: contain;
}
.feed-title { margin: 0 0 10px; font-size: 14.5px; color: var(--muted); }

/* Subscribed channels horizontal avatar strip */
.subs-strip {
  display: flex;
  gap: 12px;
  padding: 4px 2px 12px;
  margin-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid #222;
}
.subs-strip::-webkit-scrollbar { display: none; }
.sub-ch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 64px;
  flex: none;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  padding: 0;
}
.sub-ch img, .sub-ch .avatar-fallback {
  width: 46px; height: 46px; border-radius: 50%; object-fit: cover;
  border: 2px solid #333;
}
.sub-ch span {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: #ccc;
}

/* You tab profile header */
.you-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: #181818;
  border: 1px solid #282828;
}
.you-av { width: 48px !important; height: 48px !important; border-radius: 50%; object-fit: cover; }
.you-name { font-weight: 700; font-size: 16px; }
.you-sub { color: var(--muted); font-size: 12.5px; }
.you-tabs { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; }

/* Mobile video cards */
.vgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
  gap: 14px 12px;
}

.vcard {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  border-radius: 12px;
}
.vcard:active .thumb img { transform: scale(.98); }
.vcard .thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #1f1f1f;
}
.vcard .thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .15s;
}
.vcard .dur {
  position: absolute;
  right: 6px; bottom: 6px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgb(0 0 0 / .84);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.vcard .dur.live { background: #cc0000; }
.vcard .dur.pl { background: rgb(0 0 0 / .85); }

.vrow {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 2px 2px;
}
.ch-av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #2a2f38;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: grid;
  place-items: center;
  flex: none;
  margin-top: 2px;
}
.ch-av.lg { width: 38px; height: 38px; }
.vcard .meta { flex: 1; min-width: 0; }
.vcard .t {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vcard .c {
  margin-top: 3px;
  color: #aaa;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Skeleton loading */
.vcard.sk .thumb { background: linear-gradient(90deg, #1b1b1b 25%, #262626 50%, #1b1b1b 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.vcard.sk .ch-av { background: #222; }
.vcard.sk .t { height: 14px; width: 88%; background: #222; border-radius: 4px; margin-bottom: 6px; }
.vcard.sk .c { height: 12px; width: 60%; background: #1c1c1c; border-radius: 4px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.feed-msg {
  max-width: 440px;
  margin: 28px auto;
  padding: 20px;
  text-align: center;
  background: #181818;
  border: 1px solid #2a2a2a;
  border-radius: 16px;
}
.feed-msg h3 { margin: 0 0 8px; }
.feed-msg p { color: var(--muted); margin: 6px 0 14px; }

/* ---------- YouTube Mobile Bottom Navigation ---------- */
.yt-bnav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 50px;
  background: #0f0f0f;
  border-top: 1px solid #222;
  flex: none;
  z-index: 20;
}
.bnav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: transparent;
  border: 0;
  color: #909090;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.bnav-btn.active { color: #fff; }
.bnav-btn:active { background: #1c1c1c; }

/* ---------- YouTube Player (watch / full / mini) ---------- */
.yt-player { position: absolute; z-index: 25; background: #0f0f0f; overflow: hidden; }
.yt-player[hidden] { display: none; }

/* Mobile Watch Mode: Sticky 16:9 video on top + scrollable watch info & related videos below */
.yt-player.watch {
  inset: 0 0 50px 0;
  display: flex;
  flex-direction: column;
}
.yt-player.watch .yt-video-stage {
  position: relative;
  width: 100%;
  max-height: 54%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: flex;
  flex-direction: column;
  flex: none;
}

/* Full Pane Mode: 100% video */
.yt-player.full {
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.yt-player.full .yt-video-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #000;
}
.yt-player.full .yt-watch-scroll { display: none; }

.yt-player-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 8px;
  background: #0f0f0f;
  border-bottom: 1px solid #222;
  flex: none;
}
body:not(.swapped):not(.mode-yt) #paneYT .yt-player-bar { padding-right: 34px; }
body.swapped:not(.mode-yt) #paneYT .yt-player-bar { padding-left: 34px; }

.yt-player-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.yt-frame { position: relative; flex: 1; background: #000; }
.yt-frame iframe, .yt-frame > div {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.yt-mini-expand { display: none; }

/* Watch scroll area underneath video */
.yt-watch-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 18px;
  overscroll-behavior: contain;
  background: #0f0f0f;
}
.watch-info { border-bottom: 1px solid #242424; padding-bottom: 10px; margin-bottom: 12px; }
.watch-title { font-weight: 700; font-size: 15.5px; line-height: 1.32; }
.watch-sub { color: #aaa; font-size: 12.5px; margin-top: 4px; }
.watch-ch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.ch-name { font-weight: 700; font-size: 14px; }
.ch-subs { color: #aaa; font-size: 12px; }
.watch-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.watch-actions::-webkit-scrollbar { display: none; }
.act-pill {
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: #242424;
  border: 1px solid #333;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  text-decoration: none;
  flex: none;
}
.act-pill:active { background: #333; }
.watch-desc {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #1a1a1a;
  font-size: 13px;
  color: #ccc;
}
.watch-desc summary { font-weight: 600; cursor: pointer; color: var(--text); }
.watch-desc p { margin: 6px 0 0; white-space: pre-line; }
.rel-head { margin: 0 0 10px; font-size: 14px; color: #bbb; }

/* Mini Player Mode */
.yt-player.mini {
  right: 10px;
  bottom: 58px;
  width: min(240px, 46%);
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  border: 1px solid #3a3a3a;
  box-shadow: 0 8px 28px rgb(0 0 0 / .75);
}
.yt-player.mini .yt-video-stage { position: absolute; inset: 0; }
.yt-player.mini .yt-watch-scroll { display: none; }
.yt-player.mini .yt-player-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 30px;
  padding: 0 4px !important;
  background: linear-gradient(to bottom, rgb(0 0 0 / .85), transparent);
  border: 0;
  z-index: 3;
}
.yt-player.mini .yt-player-title,
.yt-player.mini #ytFullToggle { display: none; }
.yt-player.mini #ytMin svg { transform: rotate(180deg); }
.yt-player.mini .yt-frame { position: absolute; inset: 0; }
.yt-player.mini .yt-mini-expand {
  display: block;
  position: absolute;
  inset: 30px 0 0 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 2;
}

/* ---------- Overlay (Login) ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 35;
  background: rgb(0 0 0 / .78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
}
.overlay[hidden] { display: none; }
.overlay-card {
  width: min(440px, 100%);
  padding: 20px;
  border-radius: 18px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  text-align: center;
}
.overlay-card.wide { width: min(500px, 100%); }
.overlay-card h3 { margin: 0 0 8px; }
.overlay-card a { color: var(--accent); }
.user-code {
  margin: 12px 0 16px;
  padding: 12px;
  border-radius: 12px;
  background: #0c0e12;
  border: 1px dashed #4a535e;
  font: 700 28px/1.2 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: .12em;
  color: #fff;
}
.err-msg {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgb(255 69 58 / .16);
  border: 1px solid rgb(255 69 58 / .4);
  color: #ff8a80;
  font-size: 13px;
  margin: 8px 0;
}
.stack-form { display: flex; flex-direction: column; gap: 8px; }

/* ================================================================== */
/* Google Maps Pane                                                    */
/* ================================================================== */
.gmap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: 1;
  background: #181c23;
}
.gmap.dark-tiles .leaflet-tile-pane {
  filter: invert(92%) hue-rotate(180deg) brightness(95%) contrast(92%);
}

.map-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
.map-ui > * { pointer-events: auto; }

.map-top {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.map-top[hidden] { display: none; }
.map-top > * { pointer-events: auto; }

.map-search-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.map-search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 8px 0 12px;
  border-radius: 999px;
  background: rgb(20 24 30 / .93);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid #3a424e;
  box-shadow: 0 4px 16px rgb(0 0 0 / .45);
  color: var(--muted);
}
.map-search:focus-within { border-color: var(--accent); background: rgb(20 24 30 / .98); }
.map-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  outline: none;
}
.map-go-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  flex: none;
}
.dir-open-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #4a8cff;
  background: #1a73e8;
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgb(0 0 0 / .45);
  cursor: pointer;
  flex: none;
}
.dir-open-btn:active { transform: scale(.94); }

/* Directions Planner Panel */
.dir-planner {
  padding: 10px;
  border-radius: 16px;
  background: rgb(18 22 28 / .97);
  border: 1px solid #3a424e;
  box-shadow: 0 8px 24px rgb(0 0 0 / .6);
}
.dir-planner[hidden] { display: none; }
.dir-modes {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.mode-pill {
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: #242a34;
  border: 1px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.mode-pill.active { background: rgb(61 139 255 / .22); border-color: var(--accent); color: #fff; }
.dir-close { margin-left: auto; }

.dir-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dir-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dir-field {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  background: #14181f;
  border: 1px solid #2e3540;
}
.dir-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
}
.dir-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dir-dot.start { background: #3d8bff; box-shadow: 0 0 0 3px rgb(61 139 255 / .25); }
.dir-dot.end { background: #ea4335; }
.dir-swap-btn {
  width: 36px;
  height: 64px;
  border-radius: 10px;
  border: 1px solid #2e3540;
  background: #222730;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.dir-go { height: 64px !important; padding: 0 14px !important; }

/* Suggestions dropdown */
.map-suggest {
  max-height: 240px;
  overflow-y: auto;
  border-radius: 14px;
  background: rgb(20 24 30 / .97);
  border: 1px solid #3a424e;
  box-shadow: 0 8px 24px rgb(0 0 0 / .55);
}
.map-suggest[hidden] { display: none; }
.sug-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #262c35;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.sug-item:last-child { border-bottom: 0; }
.sug-item:active { background: var(--panel-3); }
.sug-ic { font-size: 17px; flex: none; }
.sug-item .t { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-item .s { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-dist, .sug-go {
  font-size: 12px;
  font-weight: 600;
  color: #8ab8ff;
  white-space: nowrap;
  flex: none;
}

/* Quick Category & Favorite Pills Bar */
.poi-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.poi-bar::-webkit-scrollbar { display: none; }
.fav-chips-inline { display: contents; }
.poi-chip {
  height: 31px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgb(20 24 30 / .9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid #3a424e;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgb(0 0 0 / .35);
  flex: none;
}
.poi-chip.fav { border-color: #ffd60a66; }
.poi-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Turn-by-turn banner */
.nav-banner {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  border-radius: 16px;
  background: #0d652d;
  color: #fff;
  box-shadow: 0 6px 20px rgb(0 0 0 / .55);
  overflow: hidden;
}
.nav-banner[hidden] { display: none; }
.nav-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.nav-arrow {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: rgb(255 255 255 / .16);
  display: grid; place-items: center;
  font-size: 28px; font-weight: 800; flex: none;
}
.nav-dist { font-size: 20px; font-weight: 800; line-height: 1.1; }
.nav-instr { font-size: 14.5px; opacity: .95; }
.nav-next {
  padding: 5px 14px;
  background: #094a20;
  font-size: 12.5px;
  color: #d8f5e1;
}
.nav-next[hidden] { display: none; }

/* Live GPS Speedometer */
.speed-box {
  position: absolute;
  left: 12px;
  bottom: 14px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgb(16 20 26 / .92);
  border: 2px solid #3a424e;
  box-shadow: 0 4px 14px rgb(0 0 0 / .5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.map-ui:has(.map-sheet:not([hidden])) .speed-box {
  top: 98px;
  bottom: auto;
}
.map-ui:has(.nav-banner:not([hidden])) .speed-box {
  top: auto;
  bottom: 92px;
}
.speed-val { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.speed-unit { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* Right-side floating controls */
.map-controls {
  position: absolute;
  right: 10px;
  top: 50%;
  translate: 0 -50%;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.ctrl {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #3a424e;
  background: rgb(20 24 30 / .9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text);
  font: inherit;
  font-size: 21px;
  font-weight: 600;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 10px rgb(0 0 0 / .45);
  cursor: pointer;
}
.ctrl:active { transform: scale(.94); }
.ctrl.active { border-color: var(--accent); background: rgb(61 139 255 / .28); color: #8ab8ff; }
.ctrl.locate.active { background: var(--accent); color: #fff; }
.ctrl-zoom { display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; border: 1px solid #3a424e; }
.ctrl-zoom .ctrl { border: 0; border-radius: 0; }
.ctrl-zoom .ctrl + .ctrl { border-top: 1px solid #2e3540; }

/* Layers Popover */
.layer-popover {
  position: absolute;
  right: 60px;
  top: 50%;
  translate: 0 -50%;
  width: 230px;
  padding: 12px;
  border-radius: 16px;
  background: rgb(18 22 28 / .96);
  border: 1px solid #3a424e;
  box-shadow: 0 8px 24px rgb(0 0 0 / .6);
}
.layer-popover[hidden] { display: none; }
.layer-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 4px 0 6px; }
.layer-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 8px; }
.layer-btn {
  height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  background: #232832;
  border: 1px solid #323946;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.layer-btn.active { border-color: var(--accent); background: rgb(61 139 255 / .24); color: #8ab8ff; }

/* Bottom place / POI / route sheet */
.map-sheet {
  position: absolute;
  left: 10px;
  right: 60px;
  bottom: 10px;
  z-index: 20;
  padding: 11px 14px;
  border-radius: 18px;
  background: rgb(18 22 28 / .96);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid #3a424e;
  box-shadow: 0 8px 28px rgb(0 0 0 / .6);
  max-height: 60%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.map-sheet[hidden] { display: none; }
.sheet-head { display: flex; align-items: flex-start; gap: 10px; }
.sheet-head.compact { align-items: center; }
.sheet-title { font-weight: 700; font-size: 15.5px; }
.sheet-title .eta { color: #30d158; font-size: 18px; font-weight: 800; }
.sheet-title .dist { color: var(--muted); font-weight: 600; font-size: 13.5px; }
.sheet-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.sheet-actions .btn { height: 38px; padding: 0 12px; font-size: 13.5px; }
.route-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }

.steps-list {
  overflow-y: auto;
  border-top: 1px solid var(--line);
  padding-top: 6px;
  max-height: 170px;
}
.steps-list[hidden] { display: none; }
.step-row, .poi-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #232830;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.step-ic { width: 26px; text-align: center; font-size: 18px; font-weight: 700; color: var(--accent); }
.step-row .s, .poi-info .s { color: var(--muted); font-size: 12px; }
.poi-info {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.poi-info .t { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #ea4335;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
}

/* Custom Leaflet markers */
.gps-marker-wrap, .dest-marker-wrap { background: transparent; border: 0; }
.gps-dot {
  width: 22px; height: 22px;
  margin: 3px;
  border-radius: 50%;
  background: #3d8bff;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgb(61 139 255 / .28), 0 2px 6px rgb(0 0 0 / .45);
  position: relative;
}
.pin-dest { filter: drop-shadow(0 3px 6px rgb(0 0 0 / .5)); }
.pin-origin {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #30d158;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / .5);
}
.poi-pin {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #ea4335;
  border: 2px solid #fff;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgb(0 0 0 / .5);
}

/* ---------- Shared buttons / inputs ---------- */
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 0; background: transparent; color: var(--text);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn:active { background: rgb(255 255 255 / .1); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 14px; }
.icon-btn[hidden] { display: none; }

.row { display: flex; gap: 8px; }
.row.center { justify-content: center; flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; }
.grow { flex: 1; min-width: 0; }

input[type="text"], input[type="password"] {
  height: 44px;
  padding: 0 14px;
  font-size: 15px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}
input:focus-visible { border-color: var(--accent); }

.btn {
  height: 44px;
  padding: 0 15px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: scale(.97); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 9px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.big { height: 54px; font-size: 16px; }
.btn.active { border-color: var(--accent); background: rgb(61 139 255 / .18); }

/* ---------- Menu dialog ---------- */
.menu {
  width: min(1080px, 94vw);
  height: min(620px, 90dvh);
  max-width: none;
  max-height: none;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  color: var(--text);
  overflow: hidden;
}
.menu[open] { display: grid; grid-template-columns: 210px 1fr; }
.menu::backdrop { background: rgb(0 0 0 / .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }

.menu-nav {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px; background: #0a0c10; border-right: 1px solid var(--line);
  overflow-y: auto;
}
.menu-clock { font-size: 32px; font-weight: 700; padding: 4px 8px 10px; font-variant-numeric: tabular-nums; }
.tab {
  height: 48px; text-align: left; padding: 0 14px;
  font: inherit; font-size: 15.5px; font-weight: 600;
  color: var(--muted); background: transparent; border: 0; border-radius: 12px; cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--panel-2); color: var(--text); }
.close-btn { margin-top: auto; }

.menu-body { overflow-y: auto; padding: 8px 22px 22px; overscroll-behavior: contain; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 10px; }
.grid-btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 10px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 8px 0; }
.hint a { color: var(--accent); }

.list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line);
}
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item img.av { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line);
  margin-bottom: 8px; cursor: pointer;
}
.switch {
  appearance: none; -webkit-appearance: none;
  width: 52px; height: 30px; border-radius: 999px; background: #3a414b; position: relative; flex: none;
  cursor: pointer; transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; transition: translate .15s;
}
.switch:checked { background: #30d158; }
.switch:checked::after { translate: 22px 0; }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.check {
  display: flex; align-items: center; gap: 10px; padding: 11px; border-radius: 12px;
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer;
}
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); translate: -50% 0; z-index: 60;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 16px; border-radius: 14px;
  background: rgb(28 32 39 / .96); border: 1px solid var(--line);
  box-shadow: 0 6px 24px rgb(0 0 0 / .55); font-weight: 600;
}
.toast[hidden] { display: none; }
.toast .btn { height: 38px; }
.toast:not(:has(.btn:not([hidden]))) { padding: 11px 16px; }

/* ---------- YouTube Mix Queue ("Danh sách phát kết hợp") ---------- */
.vcard .dur.mix {
  background: linear-gradient(135deg, #7928ca, #ff0080);
  color: #fff;
}
.mix-panel {
  margin-bottom: 14px;
  border-radius: 14px;
  background: #181a20;
  border: 1px solid #2e3440;
  overflow: hidden;
}
.mix-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(90deg, rgb(121 40 202 / .22), rgb(61 139 255 / .18));
  border-bottom: 1px solid #2a303c;
  cursor: pointer;
}
.mix-head-title {
  font-weight: 700;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mix-head-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.mix-list {
  max-height: 210px;
  overflow-y: auto;
  divide-y: 1px solid #232832;
}
.mix-list[hidden] { display: none; }
.mix-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #22262e;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.mix-item.active {
  background: rgb(61 139 255 / .18);
}
.mix-item img {
  width: 64px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  object-fit: cover;
  flex: none;
}
.mix-item .t {
  font-size: 13px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mix-item .c {
  font-size: 11.5px;
  color: var(--muted);
}
.mix-idx {
  width: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  flex: none;
}

/* ---------- Voice Search Modal (YouTube & Maps) ---------- */
.voice-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgb(0 0 0 / .72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
}
.voice-modal[hidden] { display: none; }
.voice-card {
  width: min(360px, 92vw);
  padding: 24px 20px;
  border-radius: 22px;
  background: var(--panel-2);
  border: 1px solid #3a424e;
  box-shadow: 0 12px 36px rgb(0 0 0 / .65);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.voice-pulse {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #ff2d55;
  color: #fff;
  font-size: 30px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 0 rgb(255 45 85 / .6);
  animation: pulseMic 1.3s infinite;
}
@keyframes pulseMic {
  70% { box-shadow: 0 0 0 20px rgb(255 45 85 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(255 45 85 / 0); }
}
.voice-title { font-weight: 700; font-size: 16px; }
.voice-live {
  min-height: 24px;
  color: #8ab8ff;
  font-size: 14.5px;
  font-weight: 600;
}
