:root {
  color-scheme: dark;
  --bg: #10130f;
  --panel: #171c15;
  --panel-soft: #20271c;
  --text: #f2f6e9;
  --muted: #aeb8a4;
  --line: rgba(242, 246, 233, 0.12);
  --accent: #d9ff66;
  --accent-2: #4be6a7;
  --danger: #ff766b;
  --unknown: #8c9387;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 410px) 1fr;
  height: 100vh;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(217, 255, 102, 0.16), transparent 34%),
    linear-gradient(180deg, #1b2118 0%, var(--panel) 100%);
  border-right: 1px solid var(--line);
}

.hero h1 {
  margin: 6px 0 10px;
  font-size: clamp(32px, 4vw, 46px);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.eyebrow,
.subtitle,
.stat-label,
.search-label {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.subtitle {
  margin: 0;
  line-height: 1.45;
}

.city-switch {
  display: grid;
  gap: 10px;
}

.city-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* A chip is an <a> (crawlable, middle-clickable) except for the current city,
   which is a <span> -- both have to look and sit exactly the same. */
.city-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  text-decoration: none;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.city-chip:hover {
  border-color: rgba(217, 255, 102, 0.4);
}

.city-chip:active {
  transform: scale(0.96);
}

.city-chip.active {
  border-color: transparent;
  background: var(--accent);
  color: #1a200d;
}

.city-chip .city-count {
  font-size: 12px;
  font-weight: 700;
  opacity: 0.65;
}

.locate-button {
  justify-self: start;
  padding: 7px 12px;
  border: 1px dashed var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.locate-button:hover {
  border-color: rgba(217, 255, 102, 0.5);
  color: var(--text);
}

.locate-button[disabled] {
  opacity: 0.55;
  cursor: progress;
}

.controls {
  display: grid;
  gap: 12px;
}

.search-label {
  font-size: 13px;
  font-weight: 700;
}

#station-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 15px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  outline: none;
}

#station-search:focus {
  border-color: rgba(217, 255, 102, 0.65);
  box-shadow: 0 0 0 4px rgba(217, 255, 102, 0.1);
}

.fuel-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip,
.fuel-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 800;
}

/* A chip is an <a> to the fuel's landing page that filters in place instead
   of navigating -- it has to read as a control, not as body-text link. */
.filter-chip {
  display: inline-block;
  padding: 8px 11px;
  background: var(--panel-soft);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.filter-chip:hover {
  border-color: rgba(217, 255, 102, 0.4);
}

.filter-chip:active {
  transform: scale(0.96);
}

.filter-chip.active {
  border-color: transparent;
  background: var(--accent);
  color: #1a200d;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats > div,
.station-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.045);
}

.stats > div {
  padding: 14px;
}

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.stat-label {
  display: block;
  margin-top: 3px;
  font-size: 12px;
}

.station-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 255, 102, 0.3) transparent;
}

.station-list::-webkit-scrollbar {
  width: 6px;
}

.station-list::-webkit-scrollbar-thumb {
  background: rgba(217, 255, 102, 0.3);
  border-radius: 999px;
}

/* Server-rendered table: only ever seen before app.js replaces #station-list
   with the real cards, or by a crawler that doesn't run JS at all. */
.ssr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ssr-table th,
.ssr-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.ssr-table th {
  color: var(--muted);
  font-weight: 600;
}

.ssr-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Breadcrumbs and the section nav: the only links between the city, brand and
   fuel pages -- without them each is an island reachable only from search. */
.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.breadcrumbs a:hover {
  color: var(--text);
  border-bottom-color: var(--line);
}

.seo-nav {
  display: grid;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.seo-group h2 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.seo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seo-link {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.seo-link:hover {
  border-color: rgba(217, 255, 102, 0.4);
}

.seo-link.active {
  border-color: transparent;
  background: var(--accent);
  color: #1a200d;
}

.station-card {
  padding: 14px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

.station-card:hover,
.station-card:focus-visible {
  border-color: rgba(217, 255, 102, 0.55);
  background: rgba(255, 255, 255, 0.075);
  transform: translateY(-1px);
  outline: none;
}

.station-card:active {
  transform: translateY(0);
}

.station-card strong {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.station-card address,
.popup-address {
  color: var(--muted);
  font-style: normal;
  line-height: 1.35;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.fuel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 8px;
  background: rgba(75, 230, 167, 0.14);
  color: #b9ffe4;
  font-size: 11px;
}

.fuel-price {
  border-radius: 999px;
  padding: 2px 6px;
  background: var(--accent);
  color: #1a200d;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
}

.fuel-badge.no-fuel .fuel-price {
  background: #ffc2bd;
  color: #451512;
}

.fuel-status {
  opacity: 0.8;
}

.fuel-badge.unknown {
  background: rgba(140, 147, 135, 0.2);
  color: #d6dbd0;
}

.fuel-badge.no-fuel {
  background: rgba(255, 118, 107, 0.12);
  color: #ffc2bd;
}

.freshness-line {
  margin-top: 8px;
  color: #d9ff66;
  font-size: 12px;
  font-weight: 800;
}

.freshness-line.stale {
  color: var(--muted);
}

.map-wrap {
  position: relative;
  min-width: 0;
  height: 100vh;
}

#map {
  width: 100%;
  height: 100vh;
  background: #d8dccf;
}

.basemap {
  filter: none;
}

.status {
  position: absolute;
  top: 18px;
  left: 50%;
  z-index: 500;
  max-width: calc(100% - 32px);
  transform: translateX(-50%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(16, 19, 15, 0.86);
  color: var(--text);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.status.hidden {
  display: none;
}

.list-brand-icon img {
  display: block;
  width: 72%;
  height: 72%;
  object-fit: contain;
}

.brand-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  /* White tile so the per-brand coloured initials (inline style) read clearly. */
  background: #f7faee;
  color: #2a3326;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: -0.04em;
}

.list-brand-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #f7faee;
  overflow: hidden;
}

.list-brand-icon .brand-fallback {
  font-size: 8px;
}

/* OpenLayers popup theming */
.ol-custom-popup {
  position: relative;
  background: linear-gradient(180deg, rgba(31, 38, 27, 0.96), rgba(19, 24, 16, 0.96));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text);
  border: 1px solid rgba(217, 255, 102, 0.22);
  border-radius: 18px;
  padding: 15px 17px;
  min-width: 220px;
  max-width: 320px;
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.4);
  font-family: inherit;
  animation: popup-in 0.16s ease-out;
}

@keyframes popup-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

.ol-custom-popup::after {
  content: "";
  position: absolute;
  bottom: -9px;
  left: 50%;
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-top-color: rgba(19, 24, 16, 0.96);
  border-bottom: none;
}

.ol-popup-closer {
  position: absolute;
  top: 4px;
  right: 6px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.ol-popup-closer:hover {
  color: var(--text);
}

.ol-popup-content .popup-title {
  margin: 0 0 4px;
  font-size: 16px;
  padding-right: 20px;
}

/* OpenLayers zoom controls theming */
.ol-zoom {
  left: auto !important;
  right: 14px !important;
  top: auto !important;
  bottom: 40px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  padding: 0 !important;
  border-radius: 14px !important;
  overflow: hidden !important;
  background: rgba(19, 24, 16, 0.7) !important;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line) !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4) !important;
}

.ol-zoom button {
  background: transparent !important;
  color: var(--text) !important;
  border: 0 !important;
  border-radius: 0 !important;
  width: 38px !important;
  height: 38px !important;
  font-size: 20px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  margin: 0 !important;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.ol-zoom .ol-zoom-in {
  border-bottom: 1px solid var(--line) !important;
}

.ol-zoom button:hover {
  background: var(--accent) !important;
  color: #1a200d !important;
}

/* OpenLayers attribution theming */
.ol-attribution {
  background: rgba(16, 19, 15, 0.75) !important;
  color: var(--muted) !important;
}

.ol-attribution button {
  background: transparent !important;
}

.ol-attribution li,
.ol-attribution a {
  color: var(--text) !important;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    /* No station list on a phone: the map takes everything the controls
       do not need. dvh keeps it honest when the browser chrome shows/hides. */
    grid-template-rows: 1fr auto;
    height: 100vh;
    height: 100dvh;
  }

  .panel {
    order: 2;
    gap: 10px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .map-wrap {
    order: 1;
    height: 100%;
  }

  #map {
    height: 100%;
  }

  .hero,
  .stats,
  .search-label,
  /* Same reason the list goes: the panel on a phone only has room for the
     controls. Crawlers see the desktop layout, where the nav is visible. */
  .seo-nav,
  /* The map itself is the list on a phone -- tap a marker for its prices. */
  .station-list {
    display: none;
  }

  /* The city switcher rides on top of the map instead of eating the panel,
     which on a phone is the only place the station list can live. */
  .city-switch {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    left: 10px;
    z-index: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    width: auto;
  }

  .city-chip,
  .locate-button {
    padding: 7px 11px;
    background: rgba(16, 19, 15, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-color: rgba(242, 246, 233, 0.18);
    font-size: 13px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  }

  .city-chip.active {
    background: var(--accent);
    color: #1a200d;
  }

  /* Counts are panel-sized detail; over the map only the name has to read. */
  .city-chip .city-count {
    display: none;
  }

  /* Icon-only: the label stays in the DOM for screen readers. */
  .locate-button {
    border-style: solid;
    font-size: 0;
    line-height: 1;
  }

  .locate-button span {
    font-size: 15px;
  }

  #station-search {
    padding: 10px 13px;
    border-radius: 14px;
  }

  /* One swipeable row instead of two wrapped ones -- "Газ" used to sit below
     the fold, and the wrap left the station list zero height. */
  .fuel-filter {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .fuel-filter::-webkit-scrollbar {
    display: none;
  }

  .filter-chip {
    flex: 0 0 auto;
  }

  .status {
    top: calc(58px + env(safe-area-inset-top));
  }
}
