/* =====================================================================
   AutobuzeSV v2 — modern, mobile-first stylesheet.
   Light + dark mode (system + user override).
   ===================================================================== */

:root {
  --brand:        #1d4ed8;
  --brand-2:      #2563eb;
  --brand-soft:   #dbeafe;
  --on:           #16a34a;
  --on-soft:      #dcfce7;
  --off:          #6b7280;
  --warn:         #f59e0b;
  --danger:       #dc2626;

  --bg:           #f6f8fb;
  --bg-elev:      #ffffff;
  --bg-glass:     rgba(255, 255, 255, 0.78);
  --border:       #e5e7eb;
  --border-soft:  #eef0f3;

  --text:         #0f172a;
  --text-muted:   #475569;
  --text-faint:   #94a3b8;

  --shadow-sm:    0 1px 2px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.05);
  --shadow-md:    0 4px 12px rgba(15,23,42,0.08), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg:    0 16px 40px rgba(15,23,42,0.16), 0 4px 12px rgba(15,23,42,0.08);

  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    18px;
  --radius-xl:    22px;

  --font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
                  "Helvetica Neue", Arial, "Noto Sans", sans-serif,
                  "Apple Color Emoji", "Segoe UI Emoji";

  --topbar-h:     60px;
  --bottombar-h:  64px;

  --ease:         cubic-bezier(.2,.8,.2,1);
}

[data-theme="dark"], html[data-theme="dark"] {
  --bg:          #0b1220;
  --bg-elev:     #131c2f;
  --bg-glass:    rgba(19, 28, 47, 0.75);
  --border:      #233149;
  --border-soft: #1a2438;

  --text:        #e6ecf5;
  --text-muted:  #9bb0cd;
  --text-faint:  #607794;

  --brand-soft:  #1e3a8a33;
  --on-soft:     #14532d33;

  --shadow-sm:   0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:   0 8px 24px rgba(0,0,0,0.45);
  --shadow-lg:   0 16px 40px rgba(0,0,0,0.55);
}

/* Auto dark when no explicit preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0b1220;
    --bg-elev:     #131c2f;
    --bg-glass:    rgba(19, 28, 47, 0.75);
    --border:      #233149;
    --border-soft: #1a2438;

    --text:        #e6ecf5;
    --text-muted:  #9bb0cd;
    --text-faint:  #607794;

    --brand-soft:  #1e3a8a33;
    --on-soft:     #14532d33;

    --shadow-sm:   0 1px 2px rgba(0,0,0,0.4);
    --shadow-md:   0 8px 24px rgba(0,0,0,0.45);
    --shadow-lg:   0 16px 40px rgba(0,0,0,0.55);
  }
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must always win over class-level display rules.
   Without this, `.filter-pill { display: inline-flex }` overrides the UA
   `[hidden] { display: none }` because both have specificity (0,1,0). */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }

/* ====================== TOP BAR ====================== */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--topbar-h);
  padding: 0 14px;
  padding-top: env(safe-area-inset-top, 0);
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-glass);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-bottom: 1px solid var(--border-soft);
  z-index: 1100;
}

.topbar__brand {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}

.topbar__logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 22px;
  background: linear-gradient(135deg, var(--brand) 0%, #3b82f6 100%);
  border-radius: 12px;
  color: white;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.topbar__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
  display: flex;
  align-items: center;
  gap: 5px;
}
.topbar__sub::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--off);
  flex-shrink: 0;
  transition: background .2s, box-shadow .2s;
}
.topbar__sub[data-state="live"]::before {
  background: var(--on);
  animation: live-pulse 2s infinite;
}
.topbar__sub[data-state="warn"]::before { background: var(--warn); }
.topbar__sub[data-state="off"]::before  { background: var(--off);  }
.topbar__sub[data-state="live"] .topbar__sub-tag {
  color: var(--on);
  font-weight: 700;
}
.topbar__sub[data-state="warn"] { color: var(--warn); }
.topbar__sub[data-state="off"]  { color: var(--off); }
.topbar__sub-sep { opacity: .45; }

@keyframes live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(22,163,74,0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(22,163,74,0);  }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0);    }
}

.topbar__actions { display: flex; gap: 8px; flex-shrink: 0; }

.iconbtn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s var(--ease);
}
.iconbtn:hover { background: var(--bg-elev); color: var(--text); }
.iconbtn:active { transform: scale(0.96); }

.langbtn {
  display: grid; place-items: center;
  height: 38px; min-width: 50px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: all .15s var(--ease);
}
.langbtn:hover { border-color: var(--brand); color: var(--brand); }

/* ====================== STATUS STRIP ====================== */
.statusstrip {
  position: fixed;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 900;
  pointer-events: none;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 24px);
}
.statusstrip > * { pointer-events: auto; }

.status-pill,
.counter-pill,
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

.status-pill .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--off);
  flex-shrink: 0;
  transition: background .2s;
}
.status-pill[data-state="live"]   .status-dot { background: var(--on);    box-shadow: 0 0 0 0 rgba(22,163,74,0.5); animation: pulse 2s infinite; }
.status-pill[data-state="warn"]   .status-dot { background: var(--warn); }
.status-pill[data-state="off"]    .status-dot { background: var(--off); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(22,163,74,0.55); }
  70%  { box-shadow: 0 0 0 10px rgba(22,163,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}

.filter-pill {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  padding-right: 6px;
}
.filter-pill__clear {
  width: 20px; height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  color: #fff;
  cursor: pointer;
  font-size: 11px;
  display: grid; place-items: center;
}
.filter-pill__clear:hover { background: rgba(255,255,255,0.35); }

/* ====================== FAV SEGMENTED SWITCH ====================== */
.seg-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.seg-switch__opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background .18s var(--ease), color .18s var(--ease), transform .12s var(--ease);
}
.seg-switch__opt:hover  { color: var(--text); }
.seg-switch__opt:active { transform: scale(0.97); }
.seg-switch__opt.is-active {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 1px 3px rgba(15,23,42,0.20);
}
.seg-switch__opt.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.seg-switch__opt.is-disabled:hover  { color: var(--text-muted); transform: none; }
.seg-switch__opt.is-disabled:active { transform: none; }
.seg-switch__icon { font-size: 13px; line-height: 1; }
.seg-switch__opt.is-active[data-mode="favs"] .seg-switch__icon { color: #fde047; }
.seg-switch__num {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--bg);
  color: var(--text-faint);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.seg-switch__opt.is-active .seg-switch__num {
  background: rgba(255,255,255,0.22);
  color: #fff;
}
[data-theme="dark"] .seg-switch__opt:not(.is-active) .seg-switch__num { background: #1a2438; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .seg-switch__opt:not(.is-active) .seg-switch__num { background: #1a2438; }
}

/* ====================== MAP ====================== */
#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.leaflet-container { background: var(--bg); }

.leaflet-control-attribution {
  background: rgba(255,255,255,0.78) !important;
  font-size: 10px !important;
}
[data-theme="dark"] .leaflet-control-attribution,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .leaflet-control-attribution {
    background: rgba(11,18,32,0.78) !important;
    color: var(--text-muted) !important;
  }
  :root:not([data-theme="light"]) .leaflet-control-attribution a { color: var(--brand-2) !important; }
}
[data-theme="dark"] .leaflet-control-attribution { background: rgba(11,18,32,0.78) !important; color: var(--text-muted) !important; }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--brand-2) !important; }

.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-md) !important;
  border-radius: 12px !important;
  overflow: hidden;
  margin-top: calc(var(--topbar-h) + 56px) !important;
  margin-left: 12px !important;
}
.leaflet-control-zoom a {
  background: var(--bg-elev) !important;
  color: var(--text) !important;
  border-color: var(--border-soft) !important;
}

/* ====================== BUS MARKERS ====================== */
/* Auto-sizing pill anchored above the geo point (no fixed icon box). */
.bus-marker { background: transparent; border: 0; pointer-events: none; }

.bus-pin {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -100%) translateY(-7px);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 12px 3px 3px;
  background: #fff;
  border: 2px solid var(--bus-color, var(--brand));
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(15,23,42,0.18), 0 1px 2px rgba(15,23,42,0.08);
  pointer-events: auto;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  color: #0f172a;
  letter-spacing: -0.01em;
  white-space: nowrap;
  max-width: 200px;
  will-change: transform;
}

/* Tail pointing down to the geographic point */
.bus-pin::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid var(--bus-color, var(--brand));
}

.bus-pin__icon {
  width: 22px; height: 22px;
  background: var(--bus-color, var(--brand));
  color: #fff;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 13px;
  flex-shrink: 0;
}

.bus-pin__label {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
  padding-right: 1px;
}

.bus-pin--off          { opacity: .6;  filter: grayscale(0.6); }
.bus-pin--off::after   { opacity: .6; }

.bus-pin--following {
  z-index: 999;
  animation: bus-bounce .5s var(--ease);
}
@keyframes bus-bounce {
  0%   { transform: translate(-50%, -100%) translateY(-7px)  scale(1); }
  40%  { transform: translate(-50%, -100%) translateY(-12px) scale(1.10); }
  100% { transform: translate(-50%, -100%) translateY(-7px)  scale(1); }
}

[data-theme="dark"] .bus-pin { background: var(--bg-elev); color: var(--text); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bus-pin { background: var(--bg-elev); color: var(--text); }
}

/* ====================== STATION + POI MARKERS ====================== */
.station-marker, .poi-marker { background: transparent; border: 0; }

.station-pin {
  position: relative;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 2px solid var(--brand);
  display: grid; place-items: center;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  transform: translate(-50%,-50%);
}
.station-pin--fav {
  border-color: #ec4899;
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.22), var(--shadow-sm);
}
.station-pin__star {
  position: absolute;
  top: -7px; right: -7px;
  width: 16px; height: 16px;
  background: #ec4899;
  border: 2px solid var(--bg-elev);
  border-radius: 50%;
  font-size: 9px;
  color: #fff;
  display: grid;
  place-items: center;
  line-height: 1;
  font-weight: 700;
}

/* Heart toggle button inside the station popup */
.popup-fav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.popup-fav:hover  { border-color: #ec4899; color: #ec4899; }
.popup-fav.is-on  {
  background: linear-gradient(135deg, #ec4899 0%, #db2777 100%);
  color: #fff;
  border-color: transparent;
}
.popup-fav.is-on:hover { filter: brightness(1.06); }

.poi-pin {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 2px solid var(--on);
  display: grid; place-items: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transform: translate(-50%,-50%);
}
.poi-pin img { width: 100%; height: 100%; object-fit: cover; }

.me-marker { background: transparent; border: 0; }
.me-pin {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--brand-2);
  border: 3px solid white;
  box-shadow: 0 0 0 8px rgba(37,99,235,0.18), var(--shadow-sm);
  transform: translate(-50%,-50%);
}

/* ====================== POPUPS ====================== */
.leaflet-popup-content-wrapper {
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-md);
  padding: 4px;
}
.leaflet-popup-tip { background: var(--bg-elev) !important; }
.leaflet-popup-content { margin: 12px 14px; min-width: 220px; }
.leaflet-popup-close-button { color: var(--text-faint) !important; padding: 8px !important; font-size: 18px !important; }

.popup-h {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.popup-h .badge {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px;
  padding: 0 7px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.popup-h .badge--on  { background: var(--on-soft);  color: var(--on); }
.popup-h .badge--off { background: #f3f4f6; color: var(--off); }

[data-theme="dark"] .popup-h .badge--off { background: #1e2a40; color: var(--text-muted); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .popup-h .badge--off { background: #1e2a40; color: var(--text-muted); }
}

.popup-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0 0 10px;
}
.popup-meta strong { color: var(--text); font-weight: 600; }

.popup-img {
  width: 100%;
  max-height: 130px;
  object-fit: cover;
  border-radius: 10px;
  margin: 0 0 10px;
  display: block;
}
.popup-empty {
  margin: 0 0 10px;
  padding: 18px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}
.popup-empty .ico { font-size: 28px; display: block; margin-bottom: 4px; }

.popup-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.popup-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: white;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
  transition: filter .15s;
}
.popup-btn:hover { filter: brightness(1.08); }
.popup-btn--ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.popup-btn--ok    { background: var(--on); }
.popup-btn--warn  { background: var(--warn); color: #1f1300; }
.popup-btn--alert { background: var(--danger); }

.popup-cat {
  display: inline-block;
  padding: 2px 9px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin: 0 0 8px;
}
.popup-fare {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--on-soft);
  color: var(--on);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  margin: 0 0 8px;
}

/* ====================== FAB STACK ====================== */
.fabstack {
  position: fixed;
  right: 12px;
  bottom: calc(var(--bottombar-h) + 16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 800;
}
.fab {
  width: 48px; height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--bg-elev);
  color: var(--text);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all .15s var(--ease);
}
.fab:hover  { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.fab:active { transform: scale(0.95); }
.fab[aria-pressed="true"] { background: var(--brand); color: white; border-color: var(--brand); }
.fab--alert { background: var(--danger); color: white; border-color: transparent; }

/* ====================== BOTTOM BAR ====================== */
.bottombar {
  position: fixed;
  inset: auto 0 0 0;
  height: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  padding-right: 12px;
  background: var(--bg-glass);
  backdrop-filter: blur(14px) saturate(180%);
  -webkit-backdrop-filter: blur(14px) saturate(180%);
  border-top: 1px solid var(--border-soft);
  z-index: 1000;
  overflow-x: auto;
  scrollbar-width: none;
}
.bottombar::-webkit-scrollbar { display: none; }

.bbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.bbtn:hover  { border-color: var(--brand); color: var(--brand); }
.bbtn:active { transform: scale(0.97); }
.bbtn--primary { background: var(--brand); color: white; border-color: var(--brand); }
.bbtn--primary:hover { color: white; filter: brightness(1.08); }
.bbtn-sep { flex: 1; }
.bbtn--info { cursor: default; opacity: .85; padding: 0 12px; font-weight: 500; color: var(--text-muted); }
.bbtn--info:hover { color: var(--text-muted); border-color: var(--border-soft); }
.bbtn__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--on); animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ====================== BOTTOM SHEET ====================== */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.45);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease);
}
.sheet-backdrop.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1600;
  background: var(--bg-elev);
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  pointer-events: none;
  transition: transform .3s var(--ease);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sheet.is-open { transform: translateY(0); pointer-events: auto; }

.sheet__handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 4px;
}
.sheet__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.sheet__header h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }

.sheet__search {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.sheet__search svg { color: var(--text-faint); flex-shrink: 0; margin-left: 6px; }
.sheet__search input {
  flex: 1;
  height: 44px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  font: inherit;
  color: var(--text);
  outline: none;
}
.sheet__search input::placeholder { color: var(--text-faint); }
.chip--all { height: 36px; padding: 0 14px; flex-shrink: 0; }

.sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  align-content: start;
}

.line-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
  cursor: pointer;
  text-align: left;
  transition: all .15s var(--ease);
  min-height: 60px;
}
.line-chip:hover  { border-color: var(--brand); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.line-chip:active { transform: scale(0.97); }
.line-chip[aria-selected="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}
.line-chip[aria-selected="true"] .line-chip__count { color: rgba(255,255,255,0.85); }

.line-chip__head {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
}
.line-chip__sw {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.line-chip__name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.line-chip__count {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 18px;
}

.line-empty {
  grid-column: 1 / -1;
  padding: 36px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ====================== TOAST ====================== */
.toast {
  position: fixed;
  top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 12px);
  left: 50%;
  transform: translate(-50%, -10px);
  background: #0f172a;
  color: white;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
  max-width: calc(100% - 32px);
}
.toast:not([hidden]) {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

/* ====================== INSTALL PROMPT ====================== */
/* Pinned at the very bottom, on top of every UI surface (topbar, bottombar,
   sheet, FAB) but below the toast (which is for critical alerts). */
.install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 1900;
  animation: install-slide-in .35s var(--ease);
}
@keyframes install-slide-in {
  from { transform: translateY(120%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.install-banner__icon {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand) 0%, #3b82f6 100%);
  border-radius: 12px;
  font-size: 22px;
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.install-banner__body  { flex: 1; min-width: 0; }
.install-banner__title { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.install-banner__sub   { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.install-banner__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.install-banner__close {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.install-banner__close:hover { background: var(--bg); color: var(--text); }

/* Tighter layout on small screens — keep CTA visible without overflow */
@media (max-width: 380px) {
  .install-banner { padding: 10px 10px; gap: 8px; }
  .install-banner__icon { width: 38px; height: 38px; font-size: 18px; }
  .install-banner__title { font-size: 13px; }
  .install-banner__sub   { font-size: 11px; }
}

/* ====================== SEO ====================== */
.seo {
  position: relative;
  z-index: 5;
  margin-top: 100vh;
  padding: 48px 0 64px;
  background: var(--bg-elev);
  border-top: 1px solid var(--border-soft);
  color: var(--text);
}
.seo__content {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 18px;
  font-size: 15px;
  line-height: 1.65;
}
.seo h1 {
  margin: 0 0 18px;
  font-size: clamp(22px, 3.6vw, 30px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.seo h2 {
  margin: 36px 0 12px;
  font-size: clamp(18px, 2.6vw, 22px);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.seo h3 {
  margin: 24px 0 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.seo p { margin: 0 0 12px; color: var(--text-muted); }
.seo p strong, .seo li strong { color: var(--text); font-weight: 600; }

.seo ul {
  margin: 0 0 16px;
  padding-left: 22px;
  color: var(--text-muted);
}
.seo ul li { margin-bottom: 4px; }

.seo__cols {
  column-count: 2;
  column-gap: 28px;
  list-style: disc inside;
  padding-left: 0;
}
.seo__cols li { break-inside: avoid; }
@media (min-width: 720px) { .seo__cols { column-count: 3; } }

.seo__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0 28px;
}
.seo__card {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.seo__card:hover { border-color: var(--brand); transform: translateY(-2px); }
.seo__card .seo__ico {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  font-size: 20px;
  background: var(--brand-soft);
  border-radius: 10px;
  margin-bottom: 8px;
}
.seo__card h3 { margin: 0 0 4px; font-size: 15px; }
.seo__card p  { margin: 0; font-size: 13px; line-height: 1.55; }

.seo__footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-faint);
}

/* ====================== RESPONSIVE ====================== */
@media (min-width: 720px) {
  body { font-size: 14px; }

  .topbar__title { font-size: 17px; }

  .bottombar { gap: 10px; padding-left: 16px; padding-right: 16px; }
  .bbtn { padding: 0 18px; }

  .fabstack { right: 18px; bottom: calc(var(--bottombar-h) + 22px); }

  .sheet { left: 50%; right: auto; bottom: 16px; transform: translate(-50%, calc(100% + 16px)); width: min(560px, calc(100% - 24px)); border-radius: 22px; max-height: 70vh; }
  .sheet.is-open { transform: translate(-50%, 0); }
}

@media (min-width: 1024px) {
  .sheet__body { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

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

.leaflet-container a{
    color:#fff;
}

.popup-btn--ghost{
    border:1px solid #000;
    color:#000!important;
}