:root {
  --bg: #0d1117;
  --panel: #161b22;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --ok: #3fb950;
  --warn: #e6b800;
  --bar-border: #30363d;
  /* Кнопки и поля в шапке (селекты, ?, слои) — те же токены, что и системная тема */
  --control-bg: #0d1117;
  --control-border: #30363d;
  --surface-elevated: #21262d;
  --shadow-popover: 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.bar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding: 0.65rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--bar-border);
}

.title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sub {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  flex: 1 1 auto;
}

.sub a {
  color: var(--accent);
  text-decoration: none;
}

.sub a:hover {
  text-decoration: underline;
}

.bar-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem 1rem;
  margin-left: auto;
}

/* На десктопе не меняет вёрстку: дети участвуют в flex .bar-actions напрямую. */
.bar-actions__cluster {
  display: contents;
}

.about-btn[aria-expanded="true"] {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.55);
}

.about-pop {
  position: absolute;
  right: 0.9rem;
  top: calc(100% - 0.2rem);
  z-index: 45;
  max-width: min(320px, calc(100vw - 24px));
  padding: 0.45rem 0.55rem;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--text);
  background: var(--surface-elevated);
  border: 1px solid var(--bar-border);
  border-radius: 6px;
  box-shadow: var(--shadow-popover);
}

.about-pop a {
  color: var(--accent);
  text-decoration: none;
}

.about-pop a:hover { text-decoration: underline; }

.source-pick {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.source-pick__label {
  white-space: nowrap;
}

.source-pick__select {
  font: inherit;
  font-size: 0.72rem;
  color: var(--text);
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  border-radius: 4px;
  padding: 0.2rem 0.45rem;
  max-width: min(14rem, 42vw);
  cursor: pointer;
}

.source-pick__select:focus-visible {
  outline: 2px solid rgba(88, 166, 255, 0.45);
  outline-offset: 1px;
}

.basemap-pick .source-pick__select {
  max-width: min(16rem, 48vw);
}

/* Настройки карты: кнопка «слои» и выпадающий блок (все ширины экрана). */
.map-prefs {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* Размер и базовые стили наследуются от .bar-tools__btn — здесь только специфика. */

.map-prefs__pop {
  display: none;
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 1200;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 220px;
  max-width: min(280px, calc(100vw - 1rem));
  padding: 0.55rem 0.65rem;
  background: var(--surface-elevated);
  border: 1px solid var(--bar-border);
  border-radius: 8px;
  box-shadow: var(--shadow-popover);
}

.map-prefs.is-open .map-prefs__pop {
  display: flex;
}

.map-prefs__pop .source-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  font-size: 0.72rem;
}

.map-prefs__pop .source-pick__label {
  flex: 0 0 auto;
  min-width: 4.5rem;
}

.map-prefs__pop .source-pick__select {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: none;
}

.basemap-pick .source-pick__select {
  max-width: none;
}

.map-prefs__toggle:hover,
.map-prefs.is-open .map-prefs__toggle {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.55);
}

.map-prefs__toggle svg {
  display: block;
}

/* Режим обновления карты (альтернатива WebSocket). */
.update-prefs {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.update-prefs__pop {
  display: none;
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 1200;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 240px;
  max-width: min(300px, calc(100vw - 1rem));
  padding: 0.55rem 0.65rem;
  background: var(--surface-elevated);
  border: 1px solid var(--bar-border);
  border-radius: 8px;
  box-shadow: var(--shadow-popover);
}

.update-prefs.is-open .update-prefs__pop {
  display: flex;
}

.update-prefs__pop .source-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  font-size: 0.72rem;
}

.update-prefs__hint {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--muted);
}

.update-prefs__toggle:hover,
.update-prefs.is-open .update-prefs__toggle {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.55);
}

.update-prefs__toggle svg {
  display: block;
}

/* Единый стиль stroke-иконок в шапке (кнопки, слои, легенда). */
.ui-ico {
  display: block;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: inherit;
  pointer-events: none;
}

.ui-ico path,
.ui-ico circle,
.ui-ico line,
.ui-ico polyline,
.ui-ico rect {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ui-ico circle[fill="currentColor"] {
  fill: currentColor;
  stroke: none;
}

.map-prefs__toggle .ui-ico {
  width: 16px;
  height: 16px;
}

/* Кнопка легенды условных обозначений карты. Попап — absolute под кнопкой (.legend). */
.legend {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* Базовые стили — от .bar-tools__btn. Здесь только дополнения. */

.legend-btn:hover,
.legend.is-open .legend-btn {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.55);
}

.legend-pop {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 1200;
  width: min(360px, calc(100vw - 1rem));
  max-height: min(70vh, calc(100vh - 5rem));
  overflow-y: auto;
  padding: 0.7rem 0.85rem 0.75rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text);
  background: var(--surface-elevated);
  border: 1px solid var(--bar-border);
  border-radius: 8px;
  box-shadow: var(--shadow-popover);
}

.legend-pop[hidden] {
  display: none !important;
}

.legend-pop__title {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.legend-pop__section + .legend-pop__section {
  margin-top: 0.55rem;
}

.legend-pop__h {
  margin: 0 0 0.3rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.legend-pop__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.legend-pop__list li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.18rem 0;
}

.legend-pop__list li > span:last-child {
  flex: 1 1 auto;
  color: var(--text);
}

.legend-swatch {
  flex: 0 0 auto;
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 3px;
  border: 1px solid var(--control-border);
}

/* Иконки на самой карте чёрные / тёмные и рисуются поверх светлой подложки
   (CARTO Positron / OSM). На тёмном фоне попапа они сливались — поэтому даём
   им светлую плашку-«мини-карту», как на реальной карте.
   Плашка-обёртка (span) держит фон и рамку, а opacity для «приглушённого»
   варианта применяется только к img внутри, чтобы плашка не становилась серой. */
.legend-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0.18rem;
  background: #eef2f6;
  border: 1px solid #cdd5dd;
  border-radius: 4px;
  box-sizing: border-box;
}

.legend-icon__img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}

.legend-icon__img--dim {
  opacity: 0.5;
}

.legend-pop__hint {
  margin: 0.6rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid var(--bar-border);
  font-size: 0.66rem;
  color: var(--muted);
}

.feed__source {
  display: block;
  font-size: 0.65rem;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.report-link {
  font-size: 0.72rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.report-link:hover {
  text-decoration: underline;
}

.report-link__ico {
  display: none;
  width: 16px;
  height: 16px;
}

.bar-tools__link-sep {
  flex-shrink: 0;
  width: 1px;
  height: 1.05em;
  align-self: center;
  background: var(--bar-border);
}

/* Иконка чашки кофе остаётся в общем stroke-стиле, как остальные иконки в шапке. */

.conn-stats-tip {
  position: fixed;
  min-width: 0;
  max-width: min(18rem, calc(100vw - 16px));
  padding: 0.35rem 0.55rem;
  font-size: 0.68rem;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background: var(--surface-elevated);
  border: 1px solid var(--bar-border);
  border-radius: 6px;
  box-shadow: var(--shadow-popover);
  z-index: 10050;
  pointer-events: none;
  user-select: none;
}

.conn-stats-tip[hidden] {
  display: none !important;
}

.conn-stats-tip #stat-line {
  font-variant-numeric: tabular-nums;
  color: var(--ok);
  font-weight: 600;
}

.conn {
  outline: none;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--control-border);
  cursor: default;
}

.conn:focus-visible {
  border-radius: 6px;
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.45);
}

.conn--ok {
  color: var(--ok);
  border-color: rgba(63, 185, 80, 0.35);
}

.conn--wait {
  color: var(--muted);
}

.conn--err {
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.35);
}

.main {
  flex: 1 1 auto;
  min-height: 0;
}

.map-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.main__map {
  width: 100%;
  height: 100%;
  background: #eef1f5;
}

.main__map .ol-viewport {
  font-family: inherit;
}

.map-updating {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  background: rgba(13, 17, 23, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

.map-updating--visible {
  display: flex;
}

.map-updating__text {
  margin: 0;
  max-width: 20rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--text);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.45);
}

.feed--overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  width: min(360px, 42vw);
  max-width: 420px;
  padding: 0.55rem 0.75rem 0.85rem;
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(13, 17, 23, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-left: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
}

.feed__title {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.feed__meta {
  margin: 0 0 0.6rem;
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.9;
}

.feed__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.feed__item {
  margin: 0 0 0.65rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.12);
  transition: background 0.22s ease, box-shadow 0.22s ease;
}

.feed-resize-handle {
  display: none;
}

.feed__time {
  display: block;
  font-size: 0.62rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.feed__text {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 760px) {
  .bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.45rem;
    padding: 0.55rem 0.75rem;
  }

  .title,
  .sub {
    display: none;
  }

  .bar-actions {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.35rem;
    /* overflow:visible важно, чтобы попап «Настройки карты» не обрезался */
    overflow: visible;
  }

  .bar-actions__cluster {
    display: contents;
  }

  /* Плотная сетка иконок: заполняет строку целиком, без «дыр» от flex-wrap. */
  .bar-tools {
    display: grid;
    grid-column: 1;
    grid-template-columns: repeat(auto-fill, minmax(1.7rem, 1.7rem));
    gap: 0.35rem;
    justify-content: start;
    min-width: 0;
    width: 100%;
  }

  .bar-tools datalist {
    display: none;
  }

  .bar-tools__link-sep {
    display: none;
  }

  .bar-tools > .legend,
  .bar-tools > .map-prefs,
  .bar-tools > .update-prefs,
  .bar-tools > .bar-tools__search-wrap {
    width: 1.7rem;
    height: 1.7rem;
    box-sizing: border-box;
  }

  .bar-actions > .conn {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: end;
    align-self: center;
    margin-left: 0;
    flex-shrink: 0;
  }

  /* Компактный единый размер всех кнопок-иконок для мобильных. */
  .about-btn,
  .legend-btn,
  .map-prefs__toggle,
  .update-prefs__toggle,
  .bar-tools__btn,
  .report-link {
    width: 1.7rem;
    height: 1.7rem;
  }

  .bar-tools__btn svg {
    width: 15px;
    height: 15px;
  }

  /* На мобиле попап «слоёв» приклеиваем под шапку по всей ширине экрана,
     иначе на узких шапках он уезжает за левый край. */
  .map-prefs__pop,
  .update-prefs__pop {
    position: fixed;
    top: calc(var(--bar-h, 5rem) + 0.3rem);
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: calc(100vh - var(--bar-h, 5rem) - 1rem);
    overflow-y: auto;
  }

  .report-link--report {
    display: none;
  }

  .report-link {
    box-sizing: border-box;
    width: 1.7rem;
    height: 1.7rem;
    padding: 0;
    border: 1px solid var(--control-border);
    border-radius: 6px;
    background: var(--control-bg);
    color: var(--muted);
    justify-content: center;
    gap: 0;
    font-size: 0;
    line-height: 0;
  }

  .report-link:hover {
    text-decoration: none;
    color: var(--accent);
    border-color: rgba(88, 166, 255, 0.55);
  }

  .report-link__ico {
    display: block;
  }

  .report-link__text {
    display: none;
  }

  .about-pop {
    right: 0.55rem;
    top: calc(100% - 0.1rem);
    font-size: 0.66rem;
  }

  /* То же самое для легенды — fixed по всей ширине экрана под шапкой. */
  .legend-pop {
    position: fixed;
    top: calc(var(--bar-h, 5rem) + 0.3rem);
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    max-width: none;
    max-height: calc(100vh - var(--bar-h, 5rem) - 1rem);
    overflow-y: auto;
  }

  .conn {
    font-size: 0.6rem;
    letter-spacing: 0.04em;
    padding: 0.12rem 0.38rem;
    white-space: nowrap;
  }

  .feed--overlay {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: var(--feed-mobile-height, 15vh);
    min-height: 12vh;
    max-height: 70vh;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.35);
  }

  .feed-resize-handle {
    display: block;
    width: 56px;
    height: 6px;
    border-radius: 999px;
    background: rgba(139, 148, 158, 0.7);
    margin: 0.1rem auto 0.45rem;
    touch-action: none;
    cursor: ns-resize;
  }
}

@media (max-width: 380px) {
  .about-btn,
  .legend-btn,
  .map-prefs__toggle,
  .update-prefs__toggle,
  .bar-tools__btn,
  .report-link {
    width: 1.55rem;
    height: 1.55rem;
  }
  .bar-actions {
    column-gap: 0.25rem;
  }
  .bar-tools {
    grid-template-columns: repeat(auto-fill, minmax(1.55rem, 1.55rem));
    gap: 0.25rem;
  }
  .bar-tools > .legend,
  .bar-tools > .map-prefs,
  .bar-tools > .update-prefs,
  .bar-tools > .bar-tools__search-wrap {
    width: 1.55rem;
    height: 1.55rem;
  }
}

.map-tooltip {
  display: none;
  max-width: min(380px, 92vw);
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  background: rgba(22, 27, 34, 0.96);
  border: 1px solid #30363d;
  border-radius: 4px;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.map-tooltip--visible {
  display: block;
}

.map-pvo-gif {
  display: block;
  user-select: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

/* === Инструменты карты в шапке ============================================ */
.bar-tools {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.4rem;
  font-size: 0.72rem;
  color: var(--text);
}

.bar-tools__btn svg {
  display: block;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  color: inherit;
  pointer-events: none;
}

/* hidden иначе перебивается display: block выше — нужно явно скрыть. */
.bar-tools__btn svg[hidden] {
  display: none;
}

.bar-tools__btn svg path,
.bar-tools__btn svg circle,
.bar-tools__btn svg line,
.bar-tools__btn svg polyline,
.bar-tools__btn svg rect {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bar-tools__btn--heat .ico-heat rect {
  fill: currentColor;
  stroke: none;
}

.bar-tools__btn--heat[aria-pressed="true"] .ico-heat rect {
  opacity: 1;
}

.bar-tools__btn--heat[aria-pressed="false"] .ico-heat rect {
  opacity: 0.88;
}

.bar-tools__btn svg circle[fill="currentColor"] {
  fill: currentColor;
  stroke: none;
}

.bar-tools__btn--cluster .ico-markers-bpla,
.bar-tools__btn--cluster .ico-markers-digit {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.bar-tools__btn--cluster .ico-markers-bpla {
  display: none;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}

.bar-tools__btn--cluster .ico-markers-digit {
  display: none;
}

.bar-tools__btn--cluster.is-marker-cluster .ico-markers-bpla {
  display: block;
}

.bar-tools__btn--cluster.is-marker-ungrouped .ico-markers-digit {
  display: block;
}

.bar-tools__btn--cluster .ico-markers-digit circle {
  vector-effect: non-scaling-stroke;
}

.bar-tools__btn--cluster .ico-markers-digit text {
  fill: currentColor;
  stroke: none;
}

.bar-tools__btn--feed .ico-feed {
  transition: transform 0.18s ease;
}

.bar-tools__btn--feed.is-collapsed .ico-feed {
  transform: rotate(180deg);
}

.bar-tools__btn--sound .ico-sound__slash {
  transition: opacity 0.15s ease;
}

.bar-tools__btn--sound[aria-pressed="true"] .ico-sound__slash {
  opacity: 0;
}

.bar-tools__btn--sound[aria-pressed="false"] .ico-sound__waves {
  opacity: 0.35;
}

.bar-tools__btn {
  appearance: none;
  box-sizing: border-box;
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--muted);
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 6px;
  font-size: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.bar-tools__btn:hover {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.55);
}

.bar-tools__btn:active {
  transform: translateY(1px);
}

.bar-tools__btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.55);
  background: rgba(88, 166, 255, 0.14);
}

.bar-tools__search-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.bar-tools__search-wrap.is-open .bar-tools__btn--search {
  color: var(--accent);
  border-color: rgba(88, 166, 255, 0.55);
}

.bar-tools__search-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.45rem;
  background: var(--surface-elevated);
  border: 1px solid var(--bar-border);
  border-radius: 8px;
  box-shadow: var(--shadow-popover);
}

.bar-tools__search-panel[hidden] {
  display: none !important;
}

.bar-tools__btn--star {
  color: var(--warn);
}

.bar-tools__search {
  appearance: none;
  border: 1px solid var(--control-border);
  background: var(--control-bg);
  color: var(--text);
  font: inherit;
  font-size: 0.72rem;
  padding: 0.28rem 0.45rem;
  border-radius: 6px;
  width: min(18rem, 70vw);
  min-width: 10rem;
}

.bar-tools__search:focus {
  outline: none;
  border-color: rgba(88, 166, 255, 0.65);
  box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.25);
}

.bar-tools__summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  padding: 0 0.2rem;
  border-left: 1px solid var(--bar-border);
  margin-left: 0.1rem;
}

.threat-summary__item {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
}

.threat-summary__ico {
  display: block;
  width: 14px;
  height: 14px;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: -webkit-optimize-contrast;
}

.threat-summary__n {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.threat-summary__sep {
  opacity: 0.55;
  user-select: none;
}

.bar-tools__tl {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.65rem;
  color: var(--muted);
  padding-left: 0.35rem;
  border-left: 1px solid var(--bar-border);
}

.bar-tools__btn--tl-play {
  width: 1.55rem;
  height: 1.55rem;
  flex-shrink: 0;
}

.bar-tools__btn--tl-play .ico-tl-play__tri {
  fill: currentColor;
  stroke: none;
}

.bar-tools__btn--tl-play .ico-tl-play__pause {
  display: none;
  fill: currentColor;
  stroke: none;
}

.bar-tools__btn--tl-play.is-playing .ico-tl-play__tri {
  display: none;
}

.bar-tools__btn--tl-play.is-playing .ico-tl-play__pause {
  display: block;
}

.bar-tools__tl-time {
  min-width: 6.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 0.62rem;
  line-height: 1.2;
  white-space: nowrap;
}

.bar-tools__tl input[type="range"] {
  width: 6.5rem;
  accent-color: var(--accent);
}

.bar-tools__tl input[type="range"]:disabled {
  opacity: 0.4;
}

/* === Свёрнутая лента (п. 22) ============================================= */
.feed--collapsed {
  width: 2.4rem !important;
  padding: 0.3rem 0.2rem !important;
  overflow: hidden !important;
}

.feed--collapsed .feed__title,
.feed--collapsed .feed__meta,
.feed--collapsed .feed__list {
  display: none !important;
}

/* === Скелетон ленты (п. 25) ============================================== */
.feed__item--skeleton {
  background: rgba(255, 255, 255, 0.04);
}

.feed__sk-line {
  height: 0.6rem;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.16) 40%,
    rgba(255, 255, 255, 0.05) 80%
  );
  background-size: 220% 100%;
  animation: feedSkShimmer 1.4s linear infinite;
}

.feed__sk-line--t {
  width: 38%;
  margin-bottom: 0.3rem;
}

.feed__sk-line--b {
  width: 92%;
  height: 0.5rem;
}

@keyframes feedSkShimmer {
  0% { background-position: 0% 0; }
  100% { background-position: -220% 0; }
}

.feed__item--flash {
  animation: feedItemFlash 1.2s ease-out;
}

@keyframes feedItemFlash {
  0% { background: rgba(88, 166, 255, 0.42); }
  100% { background: rgba(0, 0, 0, 0.12); }
}

/* === Анимация LIVE при подгрузке (п. 21) ================================= */
.conn--live-updating::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 0.4rem;
  border-radius: 999px;
  background: var(--ok);
  vertical-align: middle;
  animation: livePulse 1.1s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.15); }
}

@media (max-width: 760px) {
  .bar-tools__search-panel {
    left: auto;
    right: 0;
    max-width: calc(100vw - 1.5rem);
  }

  .bar-tools__search {
    width: min(16rem, calc(100vw - 5rem));
    min-width: 0;
  }

  .bar-tools__tl {
    display: none;
  }

  .bar-tools__summary {
    display: none;
  }

  /* На мобиле лента — нижняя панель, поэтому сворачиваем её по высоте, а не в
     узкую колонку слева. */
  .feed--overlay.feed--collapsed {
    width: 100% !important;
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border-top-width: 0 !important;
    overflow: hidden !important;
  }

  .feed--overlay.feed--collapsed .feed-resize-handle {
    display: none !important;
  }

  /* Скрываем стандартную «i»-кнопку OpenLayers в мобильной вёрстке. */
  .ol-attribution {
    display: none !important;
  }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa;
    --panel: #ffffff;
    --text: #1f2328;
    --muted: #656d76;
    --accent: #0969da;
    --ok: #1a7f37;
    --warn: #9a6700;
    --bar-border: #d0d7de;
    --control-bg: #ffffff;
    --control-border: #d0d7de;
    --surface-elevated: #ffffff;
    --shadow-popover: 0 8px 24px rgba(31, 35, 40, 0.12);
    color-scheme: light;
  }

  .bar {
    background: var(--panel);
    border-bottom-color: var(--bar-border);
  }

  .main__map {
    background: #e1e4e8;
  }

  .map-updating {
    background: rgba(255, 255, 255, 0.82);
  }

  .map-updating__text {
    color: var(--text);
    text-shadow: none;
  }

  .feed--overlay {
    background: rgba(255, 255, 255, 0.72);
    border-left-color: rgba(0, 0, 0, 0.08);
    box-shadow: -6px 0 20px rgba(0, 0, 0, 0.08);
  }

  .map-tooltip {
    background: rgba(255, 255, 255, 0.97);
    border-color: var(--bar-border);
    box-shadow: 0 4px 16px rgba(31, 35, 40, 0.12);
  }

  .feed__item {
    background: rgba(0, 0, 0, 0.04);
  }

  @keyframes feedItemFlash {
    0% { background: rgba(9, 105, 218, 0.22); }
    100% { background: rgba(0, 0, 0, 0.04); }
  }
}

/* —— Страница /stats —— */
.stats-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.stats-page__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--bar-border);
}

.stats-page__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.stats-page__back {
  margin-left: auto;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.stats-page__back:hover {
  text-decoration: underline;
}

.stats-page__main {
  flex: 1;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.stats-page .panel {
  background: var(--panel);
  border: 1px solid var(--bar-border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.stats-page__h2 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 500;
}

.stats-page__meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.stats-page__controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stats-page__days {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.stats-page__days-label {
  color: var(--muted);
}

.stats-page__days input[type="range"] {
  width: min(220px, 50vw);
  accent-color: var(--accent);
}

.stats-page__days output {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 1.5rem;
  text-align: right;
}

.stats-page__days-suffix {
  color: var(--muted);
}

.stats-page canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
}

.stats-page__table-wrap {
  max-height: 280px;
  overflow: auto;
}

.stats-page__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.stats-page__table th,
.stats-page__table td {
  text-align: left;
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid var(--bar-border);
}

.stats-page__table th {
  color: var(--muted);
  font-weight: 500;
}
