:root {
  color-scheme: dark;
  --bg: #081116;
  --surface: rgba(10, 22, 28, 0.94);
  --surface-solid: #0d1b22;
  --surface-soft: rgba(17, 36, 44, 0.86);
  --mint: #83e6cf;
  --mint-strong: #4bd6b6;
  --coral: #ef9d96;
  --text: #e7f0ee;
  --muted: #91aaa5;
  --border: rgba(131, 230, 207, 0.2);
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.38);
  --telegram-bg: #081116;
  --telegram-text: #e7f0ee;
  --telegram-hint: #91aaa5;
  --tg-viewport-stable-height: 100dvh;
  --tg-safe-top: 0px;
  --tg-safe-right: 0px;
  --tg-safe-bottom: 0px;
  --tg-safe-left: 0px;
  --tg-content-safe-top: 0px;
  --tg-content-safe-right: 0px;
  --tg-content-safe-bottom: 0px;
  --tg-content-safe-left: 0px;
  --header-height: 64px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 3px solid rgba(131, 230, 207, 0.72);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app {
  position: relative;
  width: 100%;
  height: var(--tg-viewport-stable-height);
  min-height: 320px;
  overflow: hidden;
  background: var(--bg);
}

#map {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 35% 30%, rgba(75, 214, 182, 0.08), transparent 42%),
    #101d23;
  touch-action: none;
}

.topbar {
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  min-height: var(--header-height);
  padding:
    max(12px, env(safe-area-inset-top), var(--tg-safe-top), var(--tg-content-safe-top))
    max(16px, env(safe-area-inset-right), var(--tg-safe-right), var(--tg-content-safe-right))
    10px
    max(16px, env(safe-area-inset-left), var(--tg-safe-left), var(--tg-content-safe-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, rgba(8, 17, 22, 0.98) 0%, rgba(8, 17, 22, 0.84) 72%, rgba(8, 17, 22, 0) 100%);
  pointer-events: none;
}

.brand,
.connection {
  pointer-events: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--mint);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.brand-mark {
  color: var(--coral);
  font-size: 24px;
  line-height: 1;
}

.brand-stage {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.connection {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.connection-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #d9aa6d;
  box-shadow: 0 0 10px rgba(217, 170, 109, 0.48);
}

.connection.is-online {
  color: var(--mint);
}

.connection.is-online .connection-dot {
  background: var(--mint);
  box-shadow: 0 0 10px rgba(131, 230, 207, 0.48);
}

.connection.is-offline {
  color: var(--coral);
}

.connection.is-offline .connection-dot {
  background: var(--coral);
  box-shadow: 0 0 10px rgba(239, 157, 150, 0.48);
}

.fuel-filter {
  position: absolute;
  z-index: 19;
  top: calc(max(12px, env(safe-area-inset-top), var(--tg-safe-top), var(--tg-content-safe-top)) + 55px);
  left: 0;
  right: 0;
  pointer-events: none;
}

.fuel-filter-scroll {
  display: flex;
  gap: 8px;
  padding: 5px max(14px, env(safe-area-inset-right), var(--tg-safe-right), var(--tg-content-safe-right)) 12px max(14px, env(safe-area-inset-left), var(--tg-safe-left), var(--tg-content-safe-left));
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  pointer-events: auto;
}

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

.fuel-chip {
  min-width: 52px;
  min-height: 44px;
  padding: 0 16px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  background: rgba(10, 22, 28, 0.88);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  scroll-snap-align: start;
}

.fuel-chip.is-active {
  border-color: var(--mint);
  background: var(--mint);
  color: #09211b;
  box-shadow: 0 7px 24px rgba(75, 214, 182, 0.22);
}

.map-action {
  position: absolute;
  z-index: 18;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  cursor: pointer;
}

.location-button {
  top: calc(max(12px, env(safe-area-inset-top), var(--tg-safe-top), var(--tg-content-safe-top)) + 116px);
  left: max(12px, env(safe-area-inset-left), var(--tg-safe-left), var(--tg-content-safe-left));
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 0 15px;
  font-size: 13px;
  font-weight: 750;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.location-button:active {
  transform: scale(0.97);
}

.location-button.is-active {
  border-color: var(--mint);
  color: var(--mint);
}

.location-button.is-loading {
  cursor: wait;
  opacity: 0.78;
}

.location-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notice {
  position: absolute;
  z-index: 30;
  top: calc(max(12px, env(safe-area-inset-top), var(--tg-safe-top), var(--tg-content-safe-top)) + 116px);
  left: 50%;
  width: min(calc(100% - 28px), 430px);
  min-height: 44px;
  padding: 12px 16px;
  transform: translateX(-50%);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(9, 20, 25, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
}

.notice.is-error {
  border-color: rgba(239, 157, 150, 0.42);
}

.bottom-sheet {
  position: absolute;
  z-index: 20;
  left: max(10px, env(safe-area-inset-left), var(--tg-safe-left), var(--tg-content-safe-left));
  right: max(10px, env(safe-area-inset-right), var(--tg-safe-right), var(--tg-content-safe-right));
  bottom: max(10px, env(safe-area-inset-bottom), var(--tg-safe-bottom), var(--tg-content-safe-bottom));
  max-height: min(52vh, 430px);
  overflow: hidden auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(120%);
  transition: max-height 220ms ease, background-color 180ms ease, border-color 180ms ease;
}

.sheet-toggle {
  width: 100%;
  min-height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: none;
}

.sheet-toggle:focus-visible {
  outline: 3px solid rgba(131, 230, 207, 0.72);
  outline-offset: -4px;
  border-radius: 20px;
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0;
  border-radius: 999px;
  background: rgba(231, 240, 238, 0.23);
  transition: width 180ms ease, background-color 180ms ease, box-shadow 180ms ease;
}

.bottom-sheet.is-collapsed {
  max-height: 44px;
  overflow: hidden;
  border-color: rgba(131, 230, 207, 0.28);
  background: rgba(9, 20, 25, 0.92);
}

.bottom-sheet.is-collapsed .sheet-content {
  display: none;
}

.bottom-sheet.is-collapsed .sheet-handle {
  width: 54px;
  background: var(--mint);
  box-shadow: 0 0 12px rgba(131, 230, 207, 0.24);
}

.sheet-content {
  padding: 9px 16px 15px;
}

.sheet-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--mint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#station-brand {
  display: flex;
  align-items: center;
  gap: 6px;
}

#station-brand::before {
  width: 8px;
  height: 8px;
  content: "";
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  background: var(--station-color, var(--mint));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--station-color, var(--mint)) 18%, transparent);
}

.sheet-heading-row h2 {
  margin: 0;
  color: var(--text);
  font-size: 21px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.station-count {
  padding: 7px 10px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.data-state {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  margin-top: 13px;
  padding: 12px;
  border: 1px solid rgba(239, 157, 150, 0.18);
  border-radius: 14px;
  background: rgba(239, 157, 150, 0.065);
}

.data-state.has-data {
  border-color: rgba(131, 230, 207, 0.2);
  background: rgba(131, 230, 207, 0.06);
}

.state-icon {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  background: rgba(239, 157, 150, 0.13);
  color: var(--coral);
  font-size: 18px;
  font-weight: 700;
}

.data-state.has-data .state-icon {
  background: rgba(131, 230, 207, 0.12);
  color: var(--mint);
}

.data-state strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.3;
}

.data-state p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.42;
}

.update-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 10px;
}

.update-row time {
  color: var(--telegram-hint, var(--muted));
  text-align: right;
}

.source-attributions {
  margin-top: 8px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.source-attributions a {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  color: var(--mint);
  text-decoration: underline;
  text-decoration-color: rgba(131, 230, 207, 0.35);
  text-underline-offset: 2px;
}

.source-attributions a + a::before {
  margin: 0 6px;
  color: var(--muted);
  content: "·";
  text-decoration: none;
}

.nearest-section {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nearest-section h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 12px;
}

.nearest-list {
  display: grid;
  gap: 7px;
}

.nearest-item {
  min-height: 44px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.nearest-name {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.station-color-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
}

.availability-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.availability-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.32);
  border-radius: 50%;
}

.legend-dot.is-available {
  background: var(--mint-strong);
  box-shadow: 0 0 8px rgba(75, 214, 182, 0.38);
}

.legend-dot.is-uncertain {
  background: #e6c95d;
  box-shadow: 0 0 8px rgba(230, 201, 93, 0.3);
}

.nearest-distance {
  flex: 0 0 auto;
  color: var(--mint);
  font-size: 11px;
  font-weight: 750;
}

.close-button {
  width: 44px;
  height: 44px;
  margin: -4px -5px 0 0;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.station-address,
.station-distance {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.station-distance {
  color: var(--mint);
  font-weight: 700;
}

.station-fuels {
  display: grid;
  gap: 6px;
  margin-top: 13px;
}

.fuel-row {
  min-height: 40px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  background: var(--surface-soft);
}

.fuel-row > strong {
  color: var(--text);
  font-size: 13px;
}

.fuel-row-status {
  color: var(--muted);
  font-size: 11px;
}

.fuel-row b {
  color: var(--mint);
  font-size: 13px;
}

.fuel-row.is-available {
  border-color: rgba(75, 214, 182, 0.2);
}

.fuel-row.is-uncertain {
  border-color: rgba(230, 201, 93, 0.24);
}

.fuel-row.is-available .fuel-row-status {
  color: var(--mint);
}

.fuel-row.is-uncertain .fuel-row-status {
  color: #e6c95d;
}

.fuel-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.verification-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 11px;
  color: var(--coral);
  font-size: 11px;
}

.verification-note > span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-weight: 800;
}

.verification-note p {
  margin: 0;
}

.source-details-toggle {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 1px solid rgba(131, 230, 207, 0.2);
  border-radius: 11px;
  background: rgba(131, 230, 207, 0.07);
  color: var(--mint);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.source-details {
  display: grid;
  gap: 10px;
  margin-top: 9px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(5, 14, 18, 0.55);
}

.source-details[hidden] {
  display: none;
}

.source-fuel-group h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 11px;
}

.source-row {
  min-height: 38px;
  padding: 6px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.source-row:first-of-type {
  border-top: 0;
}

.source-row strong,
.source-row span,
.source-row-result b,
.source-row-result time {
  display: block;
}

.source-row strong {
  color: var(--text);
  font-size: 11px;
}

.source-row span,
.source-row-result time {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.source-row-result {
  flex: 0 0 auto;
  text-align: right;
}

.source-row-result b {
  color: var(--mint);
  font-size: 10px;
}

.source-row.is-conflict .source-row-result b,
.source-row.is-unavailable .source-row-result b {
  color: #e6c95d;
}

.source-policy-note {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.map-error {
  position: absolute;
  z-index: 25;
  inset: 50% auto auto 50%;
  width: min(calc(100% - 36px), 360px);
  padding: 18px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(239, 157, 150, 0.3);
  border-radius: 16px;
  background: rgba(9, 20, 25, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
}

.map-error strong,
.map-error span {
  display: block;
}

.map-error span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.user-location-marker {
  width: 22px;
  height: 22px;
  border: 4px solid #ffffff;
  border-radius: 50%;
  background: #38a7ff;
  box-shadow: 0 0 0 8px rgba(56, 167, 255, 0.18), 0 4px 13px rgba(0, 0, 0, 0.35);
}

.maplibregl-control-container {
  font-family: inherit;
}

.maplibregl-ctrl-top-right {
  top: calc(max(12px, env(safe-area-inset-top), var(--tg-safe-top), var(--tg-content-safe-top)) + 116px);
  right: max(8px, env(safe-area-inset-right), var(--tg-safe-right), var(--tg-content-safe-right));
}

.maplibregl-ctrl-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.maplibregl-ctrl-group button {
  width: 44px;
  height: 44px;
}

.maplibregl-ctrl button .maplibregl-ctrl-icon {
  filter: invert(88%) sepia(12%) saturate(295%) hue-rotate(118deg) brightness(105%);
}

.maplibregl-ctrl-attrib {
  max-width: 58vw;
  background: rgba(8, 17, 22, 0.72) !important;
  color: var(--muted);
}

.maplibregl-ctrl-attrib a {
  color: var(--mint);
}

.maplibregl-popup-content {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
}

@media (max-width: 390px) {
  .connection {
    max-width: 118px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

}

@media (min-width: 720px) {
  .topbar {
    padding-left: max(24px, env(safe-area-inset-left), var(--tg-safe-left), var(--tg-content-safe-left));
    padding-right: max(24px, env(safe-area-inset-right), var(--tg-safe-right), var(--tg-content-safe-right));
  }

  .fuel-filter-scroll {
    padding-left: max(22px, env(safe-area-inset-left), var(--tg-safe-left), var(--tg-content-safe-left));
    padding-right: max(22px, env(safe-area-inset-right), var(--tg-safe-right), var(--tg-content-safe-right));
  }

  .bottom-sheet {
    right: auto;
    left: max(20px, env(safe-area-inset-left), var(--tg-safe-left), var(--tg-content-safe-left));
    bottom: max(20px, env(safe-area-inset-bottom), var(--tg-safe-bottom), var(--tg-content-safe-bottom));
    width: 380px;
    max-height: min(64vh, 520px);
  }

  .location-button {
    top: auto;
    left: auto;
    right: max(20px, env(safe-area-inset-right), var(--tg-safe-right), var(--tg-content-safe-right));
    bottom: max(24px, env(safe-area-inset-bottom), var(--tg-safe-bottom), var(--tg-content-safe-bottom));
  }
}

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