/* Кольори — з теми Telegram юзера (світла/темна/своя), з запасними значеннями
   для відкриття в звичайному браузері під час розробки. Акцент — фірмовий томатний. */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f2f6);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2481cc);
  --sep: var(--tg-theme-section-separator-color, rgba(128, 128, 128, .18));
  --accent: #FF4B2B;
  --accent-soft: rgba(255, 75, 43, .12);
  --open: #22a45d;
  --closed: #e0533d;
  --star: #f5a623;
  --radius: 14px;
  --tabs-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: var(--bg2); color: var(--text); }
body { font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

#app { display: flex; flex-direction: column; height: 100%; }

/* ---------- верх: пошук + чіпи ---------- */
#top { background: var(--bg); padding: 10px 0 6px; border-bottom: 1px solid var(--sep); z-index: 5; }
.search { position: relative; margin: 0 12px 8px; }
.search input { width: 100%; height: 40px; border: 0; border-radius: 12px; background: var(--bg2); color: var(--text);
                padding: 0 36px 0 38px; font-size: 16px; outline: none; -webkit-appearance: none; }
.search input::placeholder { color: var(--hint); }
.search input::-webkit-search-cancel-button { display: none; }
.search-ic { position: absolute; left: 11px; top: 10px; width: 20px; height: 20px; fill: none; stroke: var(--hint); stroke-width: 2.2; stroke-linecap: round; }
.q-clear { position: absolute; right: 6px; top: 6px; width: 28px; height: 28px; border-radius: 50%; color: var(--hint); font-size: 13px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: 16px; background: var(--bg2); color: var(--text);
        font-size: 14px; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
        transition: background .15s, color .15s; }
.chip.on { background: var(--accent); color: #fff; }
.chip .n { opacity: .6; font-size: 12px; }
.filters .chip { height: 30px; font-size: 13px; border: 1px solid var(--sep); background: var(--bg); }
.filters .chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chips.disabled { opacity: .35; pointer-events: none; }

/* ---------- контент ---------- */
main { flex: 1; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
        padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); }
#view-map { overflow: hidden; padding: 0; }
.count { padding: 12px 16px 6px; color: var(--hint); font-size: 13px; }
.count b { color: var(--text); font-weight: 600; }

.row { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 14px; margin: 0 10px 8px;
       background: var(--section); border-radius: var(--radius); cursor: pointer; }
.row:active { opacity: .7; }
.row .ico { flex: none; width: 46px; height: 46px; border-radius: 12px; background: var(--bg2);
            display: grid; place-items: center; font-size: 24px; }
.row .body { flex: 1; min-width: 0; }
.row .name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta, .row .meta2 { font-size: 13px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.star { color: var(--star); font-weight: 600; }
.st-open { color: var(--open); font-weight: 500; }
.st-closed { color: var(--closed); font-weight: 500; }
.rec { display: inline-block; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft);
       padding: 1px 6px; border-radius: 6px; margin-left: 6px; vertical-align: 2px; }
.heart { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; }
.heart svg { width: 22px; height: 22px; fill: none; stroke: var(--hint); stroke-width: 2; }
.heart.on svg { fill: var(--accent); stroke: var(--accent); }
.heart.pop svg { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.35); } }

.empty { text-align: center; color: var(--hint); padding: 48px 28px; }
.empty .big { font-size: 44px; margin-bottom: 10px; }
.empty .btn { margin-top: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px;
       border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: var(--bg2); color: var(--text); }

/* ---------- таби ---------- */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
        display: flex; background: var(--bg); border-top: 1px solid var(--sep); z-index: 10; }
#tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
               font-size: 11px; color: var(--hint); font-weight: 500; }
#tabs button .ti { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .6; }
#tabs button.on { color: var(--accent); }
#tabs button.on .ti { filter: none; opacity: 1; }

/* ---------- карта ---------- */
#map { position: absolute; inset: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); background: var(--bg2); }
.pin { width: 34px; height: 34px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg); background: #fff;
       box-shadow: 0 2px 6px rgba(0,0,0,.3); display: grid; place-items: center; border: 2px solid var(--accent); }
.pin span { transform: rotate(45deg); font-size: 17px; line-height: 1; }
.pin.fav { border-color: #e91e63; }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2481cc; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(36,129,204,.25); }
.marker-cluster { background: rgba(255, 75, 43, .25); border-radius: 50%; }
.marker-cluster div { width: 32px; height: 32px; margin: 4px; border-radius: 50%; background: var(--accent); color: #fff;
                      font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.leaflet-popup-content-wrapper { border-radius: 12px; background: var(--bg); color: var(--text); }
.leaflet-popup-tip { background: var(--bg); }
.leaflet-popup-content { margin: 10px 12px; font: 14px/1.3 -apple-system, sans-serif; }
.pop-name { font-weight: 600; font-size: 15px; }
.pop-meta { color: var(--hint); font-size: 12px; margin: 2px 0 8px; }
.pop-open { color: var(--link); font-weight: 600; }
.leaflet-container a.leaflet-popup-close-button { display: none; }
.fab { position: absolute; right: 12px; bottom: calc(var(--tabs-h) + var(--safe-b) + 14px); z-index: 500; width: 46px; height: 46px;
       border-radius: 50%; background: var(--bg); box-shadow: 0 2px 10px rgba(0,0,0,.2); display: grid; place-items: center; }
.fab svg { width: 24px; height: 24px; fill: none; stroke: var(--link); stroke-width: 2; }
.fab svg .fill { fill: var(--link); }

.map-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9); }

/* ---------- картка закладу ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; background: var(--bg2); animation: slideUp .22s ease; }
.sheet.closing { animation: slideDown .18s ease forwards; }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
@keyframes slideDown { to { transform: translateY(40px); opacity: 0; } }
.sheet-scroll { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(24px + var(--safe-b)); }
.d-hero { background: var(--bg); padding: 18px 16px 16px; position: relative; }
.d-close { position: absolute; right: 12px; top: 12px; width: 32px; height: 32px; border-radius: 50%; background: var(--bg2); color: var(--hint); font-size: 14px; }
.d-cats { font-size: 13px; color: var(--hint); margin-bottom: 6px; padding-right: 40px; }
.d-name { font-size: 24px; font-weight: 700; line-height: 1.15; padding-right: 40px; }
.d-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge { height: 26px; padding: 0 10px; border-radius: 13px; background: var(--bg2); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.badge.open { background: rgba(34,164,93,.14); color: var(--open); }
.badge.closed { background: rgba(224,83,61,.12); color: var(--closed); }
.badge.rec { background: var(--accent-soft); color: var(--accent); }

.d-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 12px 12px 4px; }
.act { background: var(--section); border-radius: var(--radius); height: 64px; display: flex; flex-direction: column;
       align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--link); }
.act .ai { font-size: 20px; line-height: 1; }
.act.on { color: var(--accent); }
.act:active { opacity: .6; }

.group { background: var(--section); border-radius: var(--radius); margin: 10px 12px 0; overflow: hidden; }
.gi { display: flex; gap: 12px; padding: 12px 14px; align-items: flex-start; }
.gi + .gi { border-top: 1px solid var(--sep); }
.gi .gic { width: 22px; flex: none; text-align: center; }
.gi .gv { flex: 1; min-width: 0; }
.gi .gh { color: var(--hint); font-size: 12px; margin-bottom: 1px; }
.gi.tap { cursor: pointer; }
.gi.tap .gv { color: var(--link); }
.hours-line { display: flex; justify-content: space-between; gap: 10px; }
.hours-line + .hours-line { margin-top: 2px; }

.votes { display: flex; gap: 8px; margin: 10px 12px 0; }
.vote { flex: 1; height: 46px; border-radius: var(--radius); background: var(--section); font-size: 16px; font-weight: 600;
        display: flex; align-items: center; justify-content: center; gap: 6px; }
.vote.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.vote-hint { text-align: center; color: var(--hint); font-size: 12px; margin: 8px 0 0; }

/* ---------- модалка району ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal-card { width: 100%; max-height: 75%; overflow-y: auto; background: var(--bg); border-radius: 18px 18px 0 0;
              padding: 8px 0 calc(12px + var(--safe-b)); animation: slideUp .2s ease; }
.modal-title { text-align: center; font-weight: 700; padding: 10px 0 8px; }
.opt { display: flex; justify-content: space-between; width: 100%; padding: 13px 18px; text-align: left; font-size: 16px; }
.opt + .opt { border-top: 1px solid var(--sep); }
.opt .n { color: var(--hint); }
.opt.on { color: var(--accent); font-weight: 600; }

/* ---------- службове ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 100;
         background: rgba(30,30,30,.92); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 86%; text-align: center; }
#loading { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--bg2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
