/* Colours come from Telegram's theme (it sets the --tg-theme-* variables); the fallbacks are for a plain browser. */
:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #888);
  --link: var(--tg-theme-link-color, #2a7de1);
  --button: var(--tg-theme-button-color, #2a7de1);
  --button-text: var(--tg-theme-button-text-color, #fff);
  --bg2: var(--tg-theme-secondary-bg-color, #f0f0f0);
  --line: var(--tg-theme-section-separator-color, #ddd);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--tg-viewport-stable-height, 100%);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }

#top {
  padding: 8px 8px 6px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 1100;
}

#fuels { display: flex; gap: 6px; }

#fuels button {
  flex: 1;
  padding: 6px 0;
  border: 0;
  border-radius: 8px;
  background: var(--bg2);
}

#fuels button.on { background: var(--button); color: var(--button-text); font-weight: 600; }

#chips { display: flex; justify-content: space-between; margin-top: 6px; }

.chip {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
}

.chip[aria-pressed="true"] { background: var(--button); border-color: var(--button); color: var(--button-text); }
.chip[aria-pressed="true"]::before { content: "✓ "; }

#stage { position: relative; flex: 1; overflow: hidden; }

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

.pill {
  position: absolute;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  padding: 8px 16px;
  border: 0;
  border-radius: 18px;
  background: var(--button);
  color: var(--button-text);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  white-space: nowrap;
}

.pill:disabled { background: var(--bg); color: var(--hint); cursor: default; }

#toast {
  position: absolute;
  top: 56px; left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  max-width: 90%;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 14px;
  text-align: center;
}

[hidden] { display: none !important; }

#sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  max-height: 75%;
  padding: 0 12px env(safe-area-inset-bottom, 0);
  background: var(--bg);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .2);
}

#handle { flex: none; padding: 8px 0 6px; touch-action: none; cursor: grab; }
#handle span { display: block; width: 40px; height: 5px; margin: 0 auto; border-radius: 3px; background: var(--line); }

#hint { margin: 0 0 6px; color: var(--hint); font-size: 13px; }

#list, #card { overflow-y: auto; overscroll-behavior: contain; padding-bottom: 10px; }
#sheet.collapsed #list { min-height: 100px; }   /* room for two rows, so the sheet doesn't jump */
#sheet.expanded #list { min-height: 40vh; }

.row { padding: 7px 0; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row .title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.row .meta, .empty, #card .addr { color: var(--hint); font-size: 13px; }
.empty { padding: 8px 0; }

#card h2 { margin: 0 28px 2px 0; font-size: 17px; }
#card p { margin: 6px 0; }
#card .close {
  position: absolute;
  top: 10px; right: 10px;
  width: 28px; height: 28px;
  border: 0; border-radius: 14px;
  background: var(--bg2);
  color: var(--hint);
}

.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions button { flex: 1; padding: 10px 0; border: 0; border-radius: 10px; background: var(--button); color: var(--button-text); }
.actions button.second { background: var(--bg2); color: var(--text); }

/* Station markers: a tier-coloured circle, ⭐ badge on favourites. */
.st { position: relative; }
.st .dot {
  display: block;
  width: 18px; height: 18px;
  margin: 2px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}
.st.sel .dot { width: 22px; height: 22px; margin: 0; border-color: #222; }
.st .star { position: absolute; top: -9px; right: -9px; font-size: 12px; line-height: 1; }

#blocker {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  font-size: 16px;
}
