:root {
  --bg: #0f1626;
  --panel: #161e30;
  --card: #1b2438;
  --border: #26314a;
  --text: #e8edf7;
  --muted: #93a1bb;
  --accent: #4f9dff;
  --accent2: #37c7a5;
  --orange: #ff9f43;
  --danger: #ff6b6b;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

body { display: flex; flex-direction: column; overflow: hidden; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  padding-top: calc(10px + var(--safe-top));
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--accent2); font-size: 22px; line-height: 1; }
.brand-text h1 { font-size: 17px; margin: 0; font-weight: 700; }
.tagline { font-size: 12px; margin: 1px 0 0; color: var(--muted); }

/* ---------- controls ---------- */
.controls {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
}
.search-wrap { display: flex; }
.search-wrap input {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
  outline: none;
  min-height: 44px;
}
.search-wrap input:focus { border-color: var(--accent); }

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.chip.active {
  background: var(--accent2);
  color: #0f1626;
  border-color: var(--accent2);
  font-weight: 600;
}

/* ---------- map ---------- */
#map { flex: 1; width: 100%; position: relative; min-height: 0; }

.status {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 20px; box-shadow: var(--shadow); z-index: 20;
  display: flex; align-items: center; gap: 10px; font-size: 14px;
  max-width: 90vw;
}
.status.hidden { display: none; }
.spin {
  width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- FABs ---------- */
.fab {
  position: absolute;
  right: 16px;
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--accent2);
  font-size: 22px;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 15;
  display: flex; align-items: center; justify-content: center;
}
.fab:active { transform: scale(0.96); }
#geolocate { bottom: calc(150px + var(--safe-bottom)); }
.fab-online { bottom: calc(88px + var(--safe-bottom)); color: var(--accent); }

/* ---------- bottom sheet ---------- */
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 72vh;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.45);
  z-index: 30;
  padding: 8px 16px calc(16px + var(--safe-bottom));
  overflow-y: auto;
  touch-action: pan-y;
}
.sheet-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: var(--border);
  margin: 4px auto 12px;
}
.sheet[hidden] { display: none; }
.sheet-close {
  float: right;
  background: none; border: none; color: var(--muted);
  font-size: 24px; cursor: pointer; line-height: 1; padding: 4px;
}
.sheet h2 { margin: 4px 0 6px; font-size: 17px; padding-right: 28px; }
.sheet .row { font-size: 14.5px; margin: 5px 0; color: var(--text); }
.sheet .row b { color: var(--text); }
.sheet .muted { color: var(--muted); font-size: 13px; }
.sheet .fmts { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.sheet .fmt { background: #22304d; color: var(--accent2); border-radius: 5px; padding: 3px 9px; font-size: 12px; }
.sheet a.btn {
  display: block; text-align: center; margin-top: 10px;
  padding: 13px; border-radius: 10px; background: var(--accent);
  color: #0f1626; font-weight: 600; text-decoration: none; font-size: 15px;
}
.sheet a.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.sheet .list-note { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }

.online-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; font-size: 14px; margin-bottom: 8px;
}
.online-item h3 { margin: 0 0 4px; font-size: 15px; }
.online-item .meta { color: var(--muted); font-size: 12.5px; margin: 2px 0; }
.online-item a { color: var(--accent); text-decoration: none; word-break: break-all; }
.online-item a:hover { text-decoration: underline; }

/* ---------- banners / footer ---------- */
.aa-banner {
  padding: 9px 14px; background: #1a2438; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted); text-align: center;
}
.aa-banner a { color: var(--accent); }
.foot {
  padding: 10px 14px;
  padding-bottom: calc(10px + var(--safe-bottom));
  background: var(--panel); border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted);
}
.foot p { margin: 0; }
.foot strong { color: var(--text); }

/* info window (desktop fallback) */
.gm-style .iw-card { max-width: 280px; color: #1b2438; }
.gm-style .iw-card h3 { margin: 0 0 6px; font-size: 15px; color: #0f1626; }
.gm-style .iw-card .row { font-size: 13px; margin: 3px 0; color: #2a3550; }
.gm-style .iw-card a { color: #1f4fbf; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .brand-text h1 { font-size: 15px; }
  .tagline { display: none; }
  .controls { padding: 6px 10px; }
  .aa-banner { font-size: 12px; }
  #geolocate { bottom: calc(140px + var(--safe-bottom)); }
}
