/* ==========================================================================
   VirCity — 3D-карта города (MapLibre GL).
   Отдельный файл: classic.html продолжает использовать css/style.css.
   ========================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: "Segoe UI", system-ui, -apple-system, sans-serif; }
body { overflow: hidden; }

:root {
  --bg:      #141c27;
  --bg2:     #1b2431;
  --bg3:     #263346;
  --line:    #33455e;
  --text:    #e8edf4;
  --muted:   #8fa1ba;
  --accent:  #4da3ff;
  --accent2: #ffb454;
  --ok:      #57c98a;
  --panel-shadow: 0 6px 24px rgba(0,0,0,.45);
  --sb-w: 380px;
}

/* ---------- загрузка ---------- */
#loader {
  position: fixed; inset: 0; z-index: 5000;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
  transition: opacity .45s;
}
#loader.hide { opacity: 0; pointer-events: none; }
.loader-box { text-align: center; color: var(--text); padding: 20px; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 18px;
  border: 4px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-title { font-size: 18px; font-weight: 600; }
.loader-sub { margin-top: 6px; color: var(--muted); font-size: 13px; }
.loader-err { margin-top: 10px; color: #ff9a9a; font-size: 12.5px; max-width: 420px; }

/* ---------- каркас ---------- */
#app { display: flex; height: 100%; overflow: hidden; }

#sidebar {
  width: var(--sb-w); min-width: var(--sb-w); height: 100%;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column;
  box-shadow: 2px 0 14px rgba(0,0,0,.4); z-index: 1200;
  transition: margin-left .25s;
}
#sidebar.collapsed { margin-left: calc(-1 * var(--sb-w)); }

#mapwrap { position: relative; flex: 1; height: 100%; }
#map { position: absolute; inset: 0; }

/* ---------- шапка панели ---------- */
.sb-header { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sb-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sb-header h1 { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.sb-header h1 small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); margin-top: 2px; }

.hdr-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.lang-dd { position: relative; }
#langBtn, .hdr-link {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 9px; font-size: 12px; cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-block; line-height: 1.2;
}
#langBtn:hover, .hdr-link:hover { border-color: var(--accent); }
#langMenu { min-width: 120px; }
#langMenu button { display: block; width: 100%; text-align: left; padding: 7px 10px; background: none; border: none; border-radius: 7px; color: var(--text); font-size: 12.5px; cursor: pointer; }
#langMenu button:hover { background: var(--bg3); }
#langMenu button.on { color: var(--accent); font-weight: 600; }

.dl-menu {
  position: absolute; right: 0; top: 34px; z-index: 1400;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px; min-width: 150px; box-shadow: var(--panel-shadow);
}
.dl-menu.hidden { display: none; }

.sb-stats { display: flex; gap: 14px; margin-top: 10px; flex-wrap: wrap; }
.sb-stats .st { font-size: 11.5px; color: var(--muted); }
.sb-stats .st b { display: block; font-size: 15px; color: var(--text); font-weight: 700; }

/* ---------- поиск и фильтры ---------- */
.sb-search { position: relative; padding: 10px 16px 6px; }
#searchInput {
  width: 100%; padding: 9px 30px 9px 11px;
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; font-size: 13px; outline: none;
}
#searchInput:focus { border-color: var(--accent); }
#searchInput::placeholder { color: var(--muted); }
#searchClear {
  position: absolute; right: 22px; top: 50%; transform: translateY(-30%);
  background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1;
}
#searchClear:hover { color: var(--text); }

.sb-filters { display: flex; gap: 6px; padding: 4px 16px 10px; flex-wrap: wrap; }
.sb-filters select, .sb-filters button {
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px; font-size: 12px; cursor: pointer; outline: none;
}
.sb-filters select { flex: 1; min-width: 110px; }
.sb-filters select:hover, .sb-filters button:hover { border-color: var(--accent); }

.sb-breadcrumb { padding: 0 16px 8px; font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.sb-breadcrumb a { color: var(--accent); cursor: pointer; text-decoration: none; }
.sb-breadcrumb a:hover { text-decoration: underline; }

/* ---------- список ---------- */
.sb-content { flex: 1; overflow-y: auto; padding: 0 10px 16px; }
.sb-content::-webkit-scrollbar { width: 9px; }
.sb-content::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
.sb-content::-webkit-scrollbar-thumb:hover { background: #44597a; }

.grp-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); padding: 12px 6px 6px; font-weight: 700;
}
.row {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent;
}
.row:hover { background: var(--bg2); border-color: var(--line); }
.row.on { background: var(--bg3); border-color: var(--accent); }
.row .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.row .tx { flex: 1; min-width: 0; }
.row .nm { font-size: 13px; line-height: 1.3; word-break: break-word; }
.row .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.row .val { font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.row .orig { font-size: 11px; color: #6f819b; margin-top: 1px; font-style: italic; }
.row .poi-ic { font-size: 17px; line-height: 1; flex-shrink: 0; width: 22px; text-align: center; }

.empty { padding: 22px 12px; color: var(--muted); font-size: 12.5px; text-align: center; line-height: 1.5; }
.more-btn {
  display: block; width: 100%; margin-top: 8px; padding: 8px;
  background: var(--bg2); color: var(--accent); border: 1px solid var(--line);
  border-radius: 9px; font-size: 12px; cursor: pointer;
}
.more-btn:hover { border-color: var(--accent); }

/* ---------- панели на карте ---------- */
.map-panel {
  position: absolute; z-index: 900;
  background: rgba(20,28,39,.93); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 13px; font-size: 12.5px;
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(6px);
}
.map-panel.hidden { display: none; }

/* Ширина фиксирована: иначе ряд категорий объектов растягивает панель на всю
   карту. Высота ограничена так, чтобы панель не доходила до легенды и карточки
   факта в левом нижнем углу — при нехватке места она прокручивается. */
#layersPanel { top: 12px; left: 12px; width: 246px; max-height: calc(100% - 340px); overflow-y: auto; }
#layersPanel::-webkit-scrollbar { width: 7px; }
#layersPanel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.lg-title { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 8px; }
.lyr { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.lyr input { accent-color: var(--accent); cursor: pointer; width: 15px; height: 15px; }
.lyr span { font-size: 12.5px; }
.lyr-hint { color: var(--muted); font-size: 11px; margin-top: 6px; line-height: 1.45; }
.lyr-sep { border: none; border-top: 1px solid var(--line); margin: 9px 0; }

.seg { display: flex; gap: 0; margin-bottom: 9px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  flex: 1; background: var(--bg2); color: var(--muted); border: none;
  padding: 6px 4px; font-size: 12px; cursor: pointer; font-weight: 600;
}
.seg button.on { background: var(--accent); color: #06294d; }
.seg button:not(.on):hover { background: var(--bg3); color: var(--text); }

.metric-select {
  width: 100%; padding: 6px 8px; margin-top: 2px;
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; outline: none; cursor: pointer;
}
.metric-select:hover { border-color: var(--accent); }

/* цветовая шкала показателя в легенде */
.ramp { display: flex; height: 9px; border-radius: 5px; overflow: hidden; margin: 6px 0 4px; }
.ramp i { flex: 1; display: block; }
.ramp-ends { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); }

.basemap-row { display: flex; gap: 5px; margin-top: 4px; }
.basemap-row button {
  flex: 1; background: var(--bg2); color: var(--muted); border: 1px solid var(--line);
  border-radius: 7px; padding: 5px 3px; font-size: 11px; cursor: pointer;
}
.basemap-row button.on { border-color: var(--accent); color: var(--accent); }
.basemap-row button:hover { color: var(--text); }

/* категории объектов в панели слоёв */
.poi-cats { display: flex; flex-wrap: wrap; gap: 4px; margin: 7px 0 2px; }
.poi-cats button {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg2); color: var(--muted); border: 1px solid var(--line);
  border-radius: 20px; padding: 3px 8px 3px 6px; font-size: 11px; cursor: pointer;
}
.poi-cats button i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; opacity: .35; }
.poi-cats button.on { color: var(--text); border-color: #4a5f80; }
.poi-cats button.on i { opacity: 1; }
.poi-cats button:hover { border-color: var(--accent); }

/* кнопки действий на карте */
#mapActions {
  position: absolute; left: 12px; bottom: 12px; z-index: 950;
  display: flex; gap: 6px;
}
#mapActions button {
  background: rgba(20,28,39,.93); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
  box-shadow: var(--panel-shadow);
}
#mapActions button:hover { border-color: var(--accent); }
#mapActions button.on { border-color: var(--accent2); color: var(--accent2); }

/* ползунок времени суток */
.light-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; }
.light-row input { flex: 1; accent-color: var(--accent2); cursor: pointer; }
.light-row span { font-size: 12px; font-weight: 700; color: var(--accent2); min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
#lightNow { width: 100%; }

/* компас солнца: показывает, откуда светит и как высоко */
.sun-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; }
.sun-dial {
  position: relative; width: 46px; height: 46px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255,180,84,.10), transparent 70%);
}
.sun-dial .sun-n {
  position: absolute; top: 1px; left: 50%; transform: translateX(-50%);
  font-size: 8.5px; color: var(--muted); font-style: normal;
}
/* точка солнца: ставится по азимуту, ближе к центру — выше над горизонтом */
.sun-dial b {
  position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent2); box-shadow: 0 0 8px var(--accent2);
  transform: translate(-50%, -50%); transition: left .25s, top .25s, opacity .25s;
}
.sun-dial b.below { background: #5a6478; box-shadow: none; opacity: .6; }
.sun-info { min-width: 0; }
#sunDir { font-size: 12.5px; font-weight: 600; }
.sun-info .lyr-hint { margin-top: 2px; }

/* карточка «Факт о городе» — в левой колонке над легендой */
#factCard { position: static; max-width: 246px; padding: 12px 14px; }
#factCard.hidden { display: none; }
.fact-head {
  font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--accent2); font-weight: 700; margin-bottom: 6px; padding-right: 18px;
}
.fact-text { font-size: 12.5px; line-height: 1.5; }
.fact-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.fact-foot span { font-size: 11px; color: var(--muted); }
#factNext {
  background: none; border: 1px solid var(--line); border-radius: 7px;
  color: var(--accent); padding: 4px 9px; font-size: 11.5px; cursor: pointer;
}
#factNext:hover { border-color: var(--accent); }

/* ---------- лента времени ---------- */
#timePanel {
  left: 50%; transform: translateX(-50%); bottom: 12px;
  width: 380px; max-width: calc(100% - 24px); z-index: 960;
}
#timePanel.hidden { display: none; }
.tp-row { display: flex; align-items: center; gap: 10px; }
.tp-year {
  font-size: 15px; font-weight: 700; min-width: 96px; color: var(--accent2);
  font-variant-numeric: tabular-nums;
}
#tpSlider { flex: 1; accent-color: var(--accent); cursor: pointer; }
.tp-controls { margin-top: 8px; }
.tp-sel { width: auto; flex-shrink: 0; padding: 4px 7px; font-size: 11.5px; }

/* вторая карта для сравнения — поверх основной, обрезана по разделителю */
#cmpMap { position: absolute; inset: 0; z-index: 400; pointer-events: none; }
#cmpHandle {
  position: absolute; top: 0; bottom: 0; width: 3px; z-index: 500;
  background: rgba(255,255,255,.9); cursor: ew-resize; transform: translateX(-1.5px);
}
#cmpHandle span {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(20,28,39,.95); color: var(--text);
  border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 9px; font-size: 11px; white-space: nowrap; user-select: none;
}

/* ---------- помощник по городу ---------- */
#aiBtn.on { border-color: var(--accent2) !important; color: var(--accent2) !important; }

#aiPanel {
  position: static; width: 330px; max-width: calc(100vw - 24px);
  display: flex; flex-direction: column;
}
#aiPanel.hidden { display: none; }
.ai-head {
  font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--accent2); font-weight: 700; margin-bottom: 8px; padding-right: 18px;
}
.ai-log {
  flex: 1; overflow-y: auto; min-height: 90px; max-height: 46vh;
  display: flex; flex-direction: column; gap: 7px; margin-bottom: 9px;
}
.ai-log::-webkit-scrollbar { width: 7px; }
.ai-log::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.ai-msg { font-size: 12.5px; line-height: 1.5; padding: 7px 10px; border-radius: 10px; }
.ai-msg.me { background: var(--accent); color: #06294d; align-self: flex-end; max-width: 88%; }
.ai-msg.ai { background: var(--bg3); align-self: flex-start; max-width: 95%; white-space: pre-wrap; }
.ai-msg.wait { color: var(--muted); font-style: italic; }
.ai-msg.err { background: rgba(229,57,53,.16); color: #ffb3b3; }

.ai-suggest { display: flex; flex-direction: column; gap: 5px; }
.ai-suggest button {
  text-align: left; background: var(--bg2); color: var(--accent);
  border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 10px; font-size: 12px; cursor: pointer;
}
.ai-suggest button:hover { border-color: var(--accent); }

.ai-row { display: flex; gap: 6px; }
#aiInput {
  flex: 1; min-width: 0; padding: 8px 10px;
  background: var(--bg3); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; font-size: 12.5px; outline: none;
}
#aiInput:focus { border-color: var(--accent); }
#aiSend {
  background: var(--accent); color: #06294d; border: none; border-radius: 9px;
  padding: 8px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
#aiSend:disabled { opacity: .5; cursor: default; }
.ai-note { font-size: 10.5px; color: #6f819b; margin-top: 8px; line-height: 1.4; }

/* готовое описание махалли в карточке объекта */
#infobox .ib-summary {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line);
  font-size: 12px; line-height: 1.5; white-space: pre-wrap;
}
#infobox .ib-summary-head {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--accent2); font-weight: 700; margin-bottom: 4px;
}

/* всплывающее сообщение (скопирована ссылка, ошибка геолокации) */
#toast {
  position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%);
  background: rgba(20,28,39,.96); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 15px; font-size: 12.5px; z-index: 1500;
  box-shadow: var(--panel-shadow); max-width: 84%; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
#toast.show { opacity: 1; }

/* легенда */
/* Левая колонка: легенда и «Факт о городе» друг над другом.
   Раньше факт стоял справа и налезал на карточку объекта. */
#leftStack {
  position: absolute; left: 12px; bottom: 62px; z-index: 900;
  display: flex; flex-direction: column-reverse; gap: 8px;
  max-height: calc(100% - 130px);
}
#legend { position: static; min-width: 170px; max-width: 246px; }
#legend .li { display: flex; align-items: center; gap: 8px; padding: 2.5px 0; font-size: 12px; }
#legend .li i { width: 16px; height: 3.5px; border-radius: 2px; display: inline-block; flex-shrink: 0; }

/* правая колонка: карточка объекта и помощник друг над другом */
#rightStack {
  position: absolute; right: 12px; bottom: 12px; z-index: 1000;
  display: flex; flex-direction: column-reverse; gap: 8px; align-items: flex-end;
  max-height: calc(100% - 150px);
}
/* карточка объекта */
#infobox { position: static; max-width: 300px; max-height: 52vh; overflow-y: auto; }
#infobox::-webkit-scrollbar { width: 7px; }
#infobox::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
#infobox .ib-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
#infobox .ib-sub { color: var(--muted); font-size: 11.5px; margin-bottom: 8px; }
#infobox .ib-orig { color: #6f819b; font-size: 11px; font-style: italic; margin-bottom: 8px; }
#infobox .ib-note { color: #6f819b; font-size: 10.5px; margin-top: 9px; line-height: 1.4; border-top: 1px solid var(--line); padding-top: 7px; }
#infobox .kv { display: flex; justify-content: space-between; gap: 14px; padding: 2.5px 0; font-size: 12px; }
#infobox .kv span { color: var(--muted); }
/* общая для карточки объекта и карточки факта */
.map-panel .ib-close {
  position: absolute; top: 6px; right: 9px; background: none; border: none;
  color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 0 2px;
}
.map-panel .ib-close:hover { color: var(--text); }

/* кнопка сворачивания панели */
#sbToggle {
  position: absolute; top: 12px; left: 12px; z-index: 950;
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(20,28,39,.93); color: var(--text);
  border: 1px solid var(--line); font-size: 16px; cursor: pointer;
  display: none; box-shadow: var(--panel-shadow);
}
#sidebar.collapsed ~ #mapwrap #sbToggle,
#app.sb-hidden #sbToggle { display: block; }

/* ---------- виджеты погоды и воздуха ---------- */
#widgets {
  position: absolute; top: 12px; right: 52px; z-index: 900;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  max-width: calc(100% - 64px);
}
.wg {
  background: rgba(20,28,39,.93); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--panel-shadow); backdrop-filter: blur(6px);
  overflow: hidden; min-width: 150px; max-width: 290px;
}
.wg-head {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; cursor: pointer; user-select: none;
}
.wg-head:hover { background: rgba(255,255,255,.04); }
.wg-ico { font-size: 20px; line-height: 1; flex-shrink: 0; }
.wg-dot { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 8px currentColor; }
.wg-main { flex: 1; min-width: 0; }
.wg-val { font-size: 17px; font-weight: 700; line-height: 1.15; }
.wg-cap { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.wg-chev { color: var(--muted); font-size: 11px; transition: transform .2s; flex-shrink: 0; }
.wg.open .wg-chev { transform: rotate(180deg); }

.wg-body { display: none; padding: 2px 12px 11px; border-top: 1px solid var(--line); }
.wg.open .wg-body { display: block; }
.wg-kv { display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; font-size: 12px; }
.wg-kv span { color: var(--muted); }
.wg-advice {
  font-size: 12px; line-height: 1.45; color: var(--text);
  border-left: 3px solid var(--accent); padding: 6px 0 6px 9px; margin: 9px 0 6px;
}
.wg-note { font-size: 10.5px; color: #6f819b; margin-top: 9px; line-height: 1.4; }
.wg-err .wg-cap { color: #ff9a9a; }

.wg-days { display: flex; gap: 3px; margin-top: 10px; }
.wg-day { flex: 1; text-align: center; padding: 5px 1px; border-radius: 7px; background: rgba(255,255,255,.04); }
.wg-day .d-n { font-size: 9.5px; color: var(--muted); }
.wg-day .d-i { font-size: 14px; margin: 2px 0; line-height: 1; }
.wg-day .d-t { font-size: 11px; font-weight: 700; }
.wg-day .d-b { font-size: 10px; color: var(--muted); }

/* ---------- элементы MapLibre под тёмную тему ---------- */
.maplibregl-ctrl-group {
  background: rgba(20,28,39,.93) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--panel-shadow) !important;
}
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(88%) hue-rotate(180deg); }
.maplibregl-ctrl-group button:hover { background: var(--bg3) !important; }
.maplibregl-ctrl-scale {
  background: rgba(20,28,39,.8) !important; border-color: var(--line) !important;
  color: var(--text) !important; font-size: 10px !important;
}
.maplibregl-ctrl-attrib {
  background: rgba(20,28,39,.85) !important; font-size: 10px !important;
}
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-popup-content {
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 13px;
  box-shadow: var(--panel-shadow); font-size: 12.5px;
}
.maplibregl-popup-tip { border-top-color: var(--bg2) !important; border-bottom-color: var(--bg2) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 16px; padding: 2px 6px; }
.maplibregl-popup-close-button:hover { background: none; color: var(--text); }

/* кнопка «Слои» — только на телефоне, встаёт в ряд с остальными действиями */
#layersBtn { display: none; }
#layersBtn.on { border-color: var(--accent) !important; color: var(--accent) !important; }

/* ручка шторки — только на телефоне */
#sheetHandle { display: none; }

/* ---------- телефон: панель превращается в шторку снизу ---------- */
@media (max-width: 760px) {
  #app { display: block; position: relative; height: 100%; }

  #mapwrap { position: absolute; inset: 0; }

  /* карта занимает весь экран, панель — шторка поверх неё */
  #sidebar {
    position: absolute; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; min-width: 0; height: 70vh;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 24px rgba(0,0,0,.5);
    margin-left: 0 !important;
    transition: transform .28s ease;
    z-index: 1200;
  }
  /* по умолчанию свёрнута: видны только ручка, заголовок и поиск */
  #sidebar.collapsed { transform: translateY(calc(70vh - 178px)); }

  #sheetHandle {
    display: block; width: 100%; padding: 0; border: none; background: none;
    cursor: pointer; flex-shrink: 0; height: 22px; position: relative;
  }
  #sheetHandle::before {
    content: ''; position: absolute; left: 50%; top: 9px; transform: translateX(-50%);
    width: 44px; height: 4px; border-radius: 3px; background: var(--line);
  }
  #sheetHandle:active::before { background: var(--accent); }

  .sb-header { padding: 4px 14px 8px; }
  .sb-header h1 { font-size: 14.5px; }
  .sb-stats { gap: 14px; margin-top: 7px; }
  .sb-stats .st b { font-size: 13.5px; }
  .sb-search { padding: 8px 14px 6px; }
  .sb-filters { padding: 2px 14px 8px; }
  .sb-breadcrumb { padding: 0 14px 6px; }

  /* панель слоёв скрыта, открывается кнопкой «Слои» */
  #layersBtn { display: block; }
  #layersPanel {
    display: none;
    top: 54px; left: 10px; right: 10px; width: auto; padding: 10px 12px;
    max-height: calc(100% - 200px); overflow-y: auto;
  }
  /* все кнопки одним рядом сверху слева, виджеты — справа */
  #mapActions { left: 10px; bottom: auto; top: 10px; }
  #mapActions button { padding: 7px 9px; font-size: 11.5px; }
  #layersBtn { display: block; }
  #layersPanel.open { display: block; }

  #legend { display: none; }
  #rightStack { right: 10px; left: 10px; bottom: 190px; max-height: none; align-items: stretch; }
  #infobox { max-width: none; max-height: 40vh; }
  #aiPanel { width: auto; }
  /* карточка факта — над свёрнутой шторкой, на всю ширину */
  #leftStack { left: 10px; right: 10px; bottom: 190px; max-height: none; }
  #factCard { max-width: none; }
  #timePanel { bottom: 190px; }
  #widgets { top: 10px; right: 10px; }
  #sbToggle { display: none !important; }

  /* родные контролы MapLibre мельче и выше шторки */
  .maplibregl-ctrl-top-right { top: 4px; }
  .maplibregl-ctrl-bottom-left { display: none; }
  .maplibregl-ctrl-bottom-right { bottom: 2px; }
  .maplibregl-ctrl-attrib.maplibregl-compact { margin: 0 6px 6px 0; }
}

/* очень узкие экраны */
@media (max-width: 380px) {
  .sb-stats .st { font-size: 10.5px; }
  #langBtn, .hdr-link { padding: 5px 7px; font-size: 11px; }
}
