:root {
  --orange: #E8792B;
  --orange-dark: #B85A16;
  --orange-soft: #FCE9DA;
  --on-orange: #FFFFFF;
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F2F3F5;
  --text: #1C1D20;
  --muted: #5F646B;
  --border: rgba(20, 22, 26, 0.10);
  --shadow: 0 6px 24px rgba(20, 22, 26, 0.16);
  --scrim: rgba(12, 13, 15, 0.42);
  --top-h: 60px;
  --nav-h: 64px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --orange: #E0712A;
  --orange-dark: #A34E12;
  --orange-soft: #3A2616;
  --bg: #141619;
  --surface: #1C1F23;
  --surface-2: #272B31;
  --text: #ECEDEF;
  --muted: #A2A7AE;
  --border: rgba(236, 237, 239, 0.12);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  --scrim: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --orange: #E0712A;
    --orange-dark: #A34E12;
    --orange-soft: #3A2616;
    --bg: #141619;
    --surface: #1C1F23;
    --surface-2: #272B31;
    --text: #ECEDEF;
    --muted: #A2A7AE;
    --border: rgba(236, 237, 239, 0.12);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    --scrim: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
.ic { width: 22px; height: 22px; display: block; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Верхня панель ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  padding: var(--safe-t) 10px 0;
  height: calc(var(--top-h) + var(--safe-t));
  background: var(--orange);
  color: var(--on-orange);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}
.logo { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.logo img { width: 34px; height: 34px; display: block; }
.logo-text { display: none; font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: 0.1px; white-space: nowrap; }
@media (min-width: 720px) { .logo-text { display: inline; } .topbar { padding-left: 16px; padding-right: 16px; } }

.search { position: relative; max-width: 560px; width: 100%; justify-self: center; }
.search input {
  width: 100%; height: 42px;
  border: 0; border-radius: 12px;
  padding: 0 38px 0 40px;
  font: inherit; font-size: 15px;
  background: var(--surface); color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { outline: 2px solid var(--orange-dark); outline-offset: 0; }
.search-ic { position: absolute; left: 11px; top: 10px; color: var(--muted); pointer-events: none; }
.search-clear { position: absolute; right: 4px; top: 4px; width: 34px; height: 34px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 10px; }

.suggest {
  position: absolute; top: 48px; left: 0; right: 0;
  margin: 0; padding: 6px; list-style: none;
  background: var(--surface); color: var(--text);
  border-radius: 14px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.suggest li {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
}
.suggest li.active, .suggest li:hover { background: var(--surface-2); }
.sg-ic { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.sg-ic .ic { width: 18px; height: 18px; }
.sg-ic.city { background: var(--surface-2); color: var(--muted); }
.sg-txt { min-width: 0; display: flex; flex-direction: column; }
.sg-name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-name mark { background: none; color: var(--orange-dark); }
:root[data-theme="dark"] .sg-name mark { color: var(--orange); }
.sg-sub { display: block; font-size: 13px; color: var(--muted); }
.sg-empty { cursor: default !important; background: none !important; flex-direction: column; align-items: flex-start !important; gap: 4px !important; }
.sg-empty button { border: 0; background: none; padding: 0; color: var(--orange-dark); font-weight: 600; }

.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 12px;
  background: transparent; color: inherit;
  display: grid; place-items: center;
}
.icon-btn:active, .icon-btn[aria-expanded="true"] { background: var(--orange-dark); }

/* ---------- Карта ---------- */
#map {
  position: fixed; left: 0; right: 0;
  top: calc(var(--top-h) + var(--safe-t));
  bottom: calc(var(--nav-h) + var(--safe-b));
  background: var(--surface-2);
  z-index: 1;
}
.leaflet-container { font-family: var(--font); background: var(--surface-2); }
.leaflet-control-attribution { font-size: 10px; background: rgba(255,255,255,0.75) !important; }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(20,22,25,0.75) !important; color: #aaa; }
:root[data-theme="dark"] .leaflet-control-attribution a { color: #ddd; }
.leaflet-control-zoom a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
@media (hover: none) { .leaflet-control-zoom { display: none; } }

.mk {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--c); color: #fff;
  display: grid; place-items: center;
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.15s ease;
}
.mk .ic { width: 20px; height: 20px; }
.mk.selected { transform: scale(1.22); border-color: var(--orange); }
.cluster {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--orange); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2F7BF6; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(47,123,246,0.25); }

/* ---------- Кнопка «Моє місцезнаходження» ---------- */
.fab {
  position: fixed; right: 14px; z-index: 500;
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px);
  width: 50px; height: 50px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  display: grid; place-items: center;
  box-shadow: var(--shadow);
}
.fab:active { background: var(--surface-2); }
.fab.busy .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Нижня панель ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 6px var(--safe-b);
  background: var(--orange); color: var(--on-orange);
  display: grid; grid-template-columns: repeat(5, 1fr);
  align-items: center;
}
.nav-btn {
  border: 0; background: none; color: inherit;
  height: 54px; margin: 0 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 12px;
  font-size: 11.5px; font-weight: 600;
}
.nav-btn .ic { width: 22px; height: 22px; }
.nav-btn.active, .nav-btn:active { background: var(--orange-dark); }
.nav-lbl { white-space: nowrap; }
.nav-dice { position: relative; }
.nav-dice .dice-ic {
  width: 50px; height: 50px; margin-top: -26px; margin-bottom: 1px;
  border-radius: 50%;
  background: var(--surface); color: var(--orange);
  display: grid; place-items: center;
  border: 3px solid var(--orange);
  box-shadow: 0 4px 12px rgba(0,0,0,0.22);
}
.nav-dice .dice-ic .ic { width: 28px; height: 28px; }
.nav-dice:active { background: none; }
.nav-dice:active .dice-ic { background: var(--orange-dark); color: #fff; border-color: var(--orange-dark); }
.nav-dice.rolling .dice-ic .ic { animation: roll 0.5s ease; }
@keyframes roll { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } }

/* ---------- Панель каталогу / збережених ---------- */
.panel {
  position: fixed; left: 0; right: 0; z-index: 700;
  top: calc(var(--top-h) + var(--safe-t));
  bottom: calc(var(--nav-h) + var(--safe-b));
  background: var(--bg);
  display: flex; flex-direction: column;
  transform: translateY(12px); opacity: 0; visibility: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
.panel.open { transform: none; opacity: 1; visibility: visible; transition: opacity 0.18s ease, transform 0.18s ease; }
.panel-head { padding: 18px 18px 6px; max-width: 720px; width: 100%; margin: 0 auto; }
.panel-title { font-family: var(--display); font-weight: 600; font-size: 20px; margin: 0; }
.panel-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 18px 12px; scrollbar-width: none; max-width: 720px; width: 100%; margin: 0 auto; flex-shrink: 0; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; height: 36px; padding: 0 14px;
  border-radius: 18px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.chip .ic { width: 17px; height: 17px; color: var(--c, var(--muted)); }
.chip.active { background: var(--orange); border-color: var(--orange); color: #fff; }
.chip.active .ic { color: #fff; }
.panel-list { flex: 1; overflow-y: auto; padding: 0 12px 24px; max-width: 720px; width: 100%; margin: 0 auto; -webkit-overflow-scrolling: touch; }
.row {
  width: 100%; border: 0; background: none; text-align: left;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 8px; border-radius: 12px;
  border-bottom: 1px solid var(--border);
}
.row:active, .row:hover { background: var(--surface-2); }
.row-thumb { width: 58px; height: 58px; border-radius: 12px; flex-shrink: 0; display: grid; place-items: center; color: #fff; background: var(--c); overflow: hidden; }
.row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-thumb .ic { width: 26px; height: 26px; }
.row-txt { min-width: 0; flex: 1; }
.row-name { font-weight: 700; font-size: 15.5px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-cat { margin: 1px 0 0; font-size: 13px; font-weight: 600; color: var(--c); }
:root[data-theme="dark"] .row-cat { filter: brightness(1.45); }
.row-city { margin: 0; font-size: 13px; color: var(--muted); }
.row-flags { display: flex; gap: 4px; color: var(--orange); }
.row-flags .ic { width: 18px; height: 18px; }
.empty { text-align: center; padding: 48px 24px; max-width: 360px; margin: 0 auto; }
.empty-ic { width: 64px; height: 64px; border-radius: 50%; background: var(--orange-soft); color: var(--orange); display: grid; place-items: center; margin: 0 auto 16px; }
.empty-ic .ic { width: 30px; height: 30px; }
.empty h3 { font-size: 17px; margin: 0 0 6px; }
.empty p { margin: 0; color: var(--muted); }

/* ---------- Картка місця (шторка) ---------- */
.sheet {
  position: fixed; left: 0; right: 0; z-index: 900;
  bottom: calc(var(--nav-h) + var(--safe-b));
  height: calc(100% - var(--top-h) - var(--safe-t) - var(--nav-h) - var(--safe-b) - 8px);
  max-width: 560px; margin: 0 auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 30px rgba(0,0,0,0.22);
  display: flex; flex-direction: column;
  transform: translateY(100%);
  visibility: hidden;
  will-change: transform;
}
.sheet.anim { transition: transform 0.28s cubic-bezier(.2,.8,.2,1); }
.sheet.visible { visibility: visible; }
.sheet-top { position: relative; height: 34px; flex-shrink: 0; touch-action: none; cursor: grab; }
.grab { position: absolute; left: 50%; top: 10px; width: 40px; height: 5px; margin-left: -20px; border-radius: 3px; background: var(--border); }
:root[data-theme="dark"] .grab { background: rgba(255,255,255,0.25); }
.sheet-close {
  position: absolute; right: 8px; top: 2px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--surface-2); color: var(--text);
  display: grid; place-items: center;
}
.sheet-close .ic { width: 20px; height: 20px; }
.sheet-scroll { flex: 1; overflow: hidden; overscroll-behavior: contain; padding-bottom: 20px; }
.sheet.full .sheet-scroll { overflow-y: auto; }

.carousel { user-select: none; -webkit-user-select: none; position: relative; margin: 0 12px; height: 230px; border-radius: 16px; overflow: hidden; touch-action: pan-y; background: var(--surface-2); }
.car-track { display: flex; height: 100%; will-change: transform; }
.car-track.anim { transition: transform 0.3s ease; }
.slide { flex: 0 0 100%; height: 100%; position: relative; }
.slide img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; }
.ph { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: rgba(255,255,255,0.92); font-size: 13px; font-weight: 600; background: var(--c); }
.ph .ic { width: 56px; height: 56px; stroke-width: 1.4; }
.ph.v2 { background: color-mix(in srgb, var(--c) 78%, #000); }
.ph.v3 { background: color-mix(in srgb, var(--c) 72%, #fff); }
.photo-btn {
  position: absolute; top: 10px; right: 10px;
  width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,0.42); color: #fff;
  display: grid; place-items: center;
}
.photo-btn[aria-pressed="true"] { background: var(--orange); }
.carousel { cursor: pointer; }
.car-arrow {
  position: absolute; top: 50%; margin-top: -18px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: rgba(0,0,0,0.42); color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.car-arrow[hidden] { display: none; }
.car-arrow.prev { left: 8px; }
.car-arrow.next { right: 8px; }
.car-arrow .ic { width: 22px; height: 22px; stroke-width: 2.2; }
@media (hover: hover) { .car-arrow:hover { background: rgba(0,0,0,0.62); } }
.photo-btn[aria-pressed="true"] .ic { fill: currentColor; }
.dots { position: absolute; bottom: 10px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; pointer-events: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.55); transition: width 0.2s ease; }
.dot.on { background: #fff; width: 18px; border-radius: 4px; }
.photo-credit { margin: 6px 16px 0; font-size: 11px; line-height: 1.35; color: var(--muted, #888); overflow-wrap: anywhere; }
.photo-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.sheet-body { padding: 0 20px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin: 10px 0 2px; }
.act-btn {
  height: 38px; padding: 0 14px; border-radius: 19px;
  border: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; gap: 6px;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.act-btn .ic { width: 19px; height: 19px; }
.act-btn[aria-pressed="true"] { background: var(--orange-soft); border-color: var(--orange); color: var(--orange-dark); }
:root[data-theme="dark"] .act-btn[aria-pressed="true"] { color: var(--orange); }
.place-name { font-family: var(--display); font-weight: 700; font-size: 22px; line-height: 1.25; margin: 6px 0 4px; }
.place-cat { margin: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; color: var(--c); }
:root[data-theme="dark"] .place-cat { filter: brightness(1.45); }
.place-cat .ic { width: 17px; height: 17px; }
.place-addr { margin: 6px 0 0; color: var(--muted); display: flex; gap: 6px; align-items: flex-start; }
.place-addr .ic { width: 18px; height: 18px; margin-top: 2px; }
.place-desc { margin: 14px 0 16px; font-size: 15.5px; line-height: 1.6; max-width: 62ch; }
.facts { margin: 0 0 18px; }
.fact { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--border); }
.fact:last-child { border-bottom: 1px solid var(--border); }
.fact .ic { color: var(--muted); width: 20px; height: 20px; margin-top: 1px; }
.fact dt { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.fact dd { margin: 0; }
.fact a { color: var(--orange-dark); font-weight: 600; text-decoration: none; word-break: break-word; }
:root[data-theme="dark"] .fact a { color: var(--orange); }
.route-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; border-radius: 14px;
  background: var(--orange); color: #fff;
  font-weight: 700; font-size: 16px; text-decoration: none;
}
.route-btn:active { background: var(--orange-dark); }
.demo-note { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); }

/* ---------- Меню ---------- */
.scrim { position: fixed; inset: 0; z-index: 1100; background: var(--scrim); }
.menu {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 1200;
  width: min(320px, 86vw);
  padding: calc(var(--safe-t) + 8px) 14px calc(var(--safe-b) + 16px);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(105%);
  transition: transform 0.25s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; gap: 6px;
}
.menu.open { transform: none; }
.menu-head { display: flex; align-items: center; justify-content: space-between; height: var(--top-h); padding-left: 6px; }
.menu-title { font-family: var(--display); font-weight: 600; font-size: 18px; }
.menu-close { color: var(--text); }
.menu-close:active { background: var(--surface-2); }
.menu-group { padding: 10px 6px 12px; border-bottom: 1px solid var(--border); }
.menu-lbl { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 10px; }
.mi { color: var(--orange); display: inline-flex; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { height: 38px; border: 0; border-radius: 9px; background: none; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--orange); color: #fff; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 6px;
  border: 0; background: none; text-align: left;
  font-weight: 600; border-bottom: 1px solid var(--border);
}
.menu-item:active { background: var(--surface-2); }

/* ---------- Діалог і тост ---------- */
.dialog-wrap { position: fixed; inset: 0; z-index: 1300; background: var(--scrim); display: grid; place-items: center; padding: 24px; }
.dialog { background: var(--surface); border-radius: 18px; padding: 22px; max-width: 400px; width: 100%; box-shadow: var(--shadow); }
.dialog h2 { font-family: var(--display); font-weight: 600; font-size: 19px; margin: 0 0 10px; }
.dialog p { margin: 0 0 18px; line-height: 1.6; }
.dialog-ok { width: 100%; height: 46px; border: 0; border-radius: 12px; background: var(--orange); color: #fff; font-weight: 700; }
.toast {
  position: fixed; left: 50%; z-index: 1400;
  top: calc(var(--top-h) + var(--safe-t) + 12px);
  transform: translate(-50%, -12px); opacity: 0;
  max-width: calc(100% - 32px);
  background: #202226; color: #fff;
  padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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