/* Falls back to a fixed dark palette (matches the Android app's own icon
   background, #030F1E) when Telegram doesn't hand us theme colors — app.js
   overwrites these custom properties from Telegram.WebApp.themeParams when
   they're available, so the page follows the user's actual Telegram theme
   instead of clashing with it. */
:root {
  --tg-bg: #0b1220;
  --tg-text: #f0f2f5;
  --tg-hint: #93a0b4;
  --tg-link: #5eb2ff;
  --tg-button: #2f80ed;
  --tg-button-text: #ffffff;
  --tg-secondary-bg: #131c2e;
}

* { box-sizing: border-box; }

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

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

/* MapLibre's own attribution control stays readable on a dark basemap tile
   without hiding the required OpenFreeMap/OSM credit. */
.maplibregl-ctrl-attrib {
  background: rgba(11, 18, 32, 0.65) !important;
  color: var(--tg-hint) !important;
}
.maplibregl-ctrl-attrib a { color: var(--tg-link) !important; }

#top-bar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}
#top-bar .pill { pointer-events: auto; }

.pill {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  background: var(--tg-secondary-bg);
  color: var(--tg-text);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill.icon-only {
  padding: 10px 12px;
}

/* Groups the icon-only buttons (summary/fit/filter) against the right edge,
   next to the alerts pill on the left — same relative layout as the
   Android app's own stacked FABs (Assessment / MyLocation) top-right. */
#icon-group {
  margin-left: auto;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

#backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--tg-bg);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
  max-height: 70vh;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--tg-hint);
  opacity: 0.4;
  border-radius: 2px;
  margin: 6px auto 12px;
}

.sheet h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.hint {
  color: var(--tg-hint);
  font-size: 13px;
  margin: 0 0 12px;
  line-height: 1.4;
}

.scroll-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--tg-secondary-bg);
  border-radius: 10px;
  font-size: 14px;
}
.alert-row .dot { font-size: 16px; line-height: 1; }
.alert-row .where { font-weight: 600; flex: 1; }
.alert-row .what { color: var(--tg-hint); font-size: 13px; }

.empty-note {
  color: var(--tg-hint);
  font-size: 14px;
  padding: 8px 0;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--tg-secondary-bg);
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.filter-row.selected { outline: 2px solid var(--tg-button); }
.filter-row .check { width: 20px; text-align: center; }

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--tg-secondary-bg);
  border-radius: 10px;
  font-size: 14px;
}
.summary-total {
  margin-top: 10px;
  padding: 0 2px;
  font-size: 14px;
  font-weight: 600;
}

.attribution {
  color: var(--tg-hint);
  font-size: 12px;
  text-align: center;
  margin: 12px 0 0;
}
.attribution a { color: var(--tg-link); }

#detail-content h3 {
  margin: 4px 0 10px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
#detail-content .field {
  font-size: 14px;
  margin: 4px 0;
  color: var(--tg-text);
}
#detail-content .field .k { color: var(--tg-hint); margin-right: 6px; }
#detail-content .note {
  margin-top: 10px;
  font-size: 13px;
  color: var(--tg-hint);
  font-style: italic;
}
