*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  background: #1a1a2e;
  color: #e0e0e0;
}

/* ── Splash ──────────────────────────────────────── */

#splash {
  position: fixed;
  inset: 0;
  background: #1a1a2e;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease;
}
#splash.hidden {
  opacity: 0;
  pointer-events: none;
}

.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.splash-logo {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #e94560;
}

.splash-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #0f3460;
  border-top-color: #e94560;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Layout ─────────────────────────────────────── */

#topbar {
  position: relative;
  z-index: 1000;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  padding: 6px 10px 4px;
}

#map {
  /* height set by JS to fill remaining viewport */
  min-height: 200px;
}

/* ── Search row ──────────────────────────────────── */

#search-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

#tracker-input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid #0f3460;
  border-radius: 6px;
  background: #0f3460;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
#tracker-input:focus { border-color: #e94560; }
#tracker-input::placeholder { color: #7a8cb0; }

.primary-btn {
  padding: 6px 14px;
  background: #e94560;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
  transition: background .2s;
}
.primary-btn:hover { background: #c73652; }

/* ── Filter row ──────────────────────────────────── */

#filter-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
}
#filter-row::-webkit-scrollbar { display: none; }

.filter-btn {
  padding: 4px 10px;
  border: 1px solid #0f3460;
  border-radius: 14px;
  background: transparent;
  color: #9ab;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.filter-btn:hover { background: #0f3460; color: #e0e0e0; }
.filter-btn.active { background: #0f3460; color: #e94560; border-color: #e94560; }

/* ── Control buttons ─────────────────────────────── */

.ctrl-btn {
  padding: 4px 8px;
  border: 1px solid #0f3460;
  border-radius: 6px;
  background: transparent;
  color: #7a8cb0;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.ctrl-btn:hover { color: #e0e0e0; background: #0f3460; }
.ctrl-btn.active { color: #e0e0e0; }

/* ── Connection dot ──────────────────────────────── */

.conn {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #555;
  transition: background .3s;
}
.conn.connected    { background: #2ecc71; box-shadow: 0 0 6px #2ecc71; }
.conn.disconnected { background: #e74c3c; }

/* ── Tags row (previous IDs) ─────────────────────── */

#tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
#tags-row:empty { margin-top: 0; }

.id-tag {
  padding: 2px 10px;
  border-radius: 12px;
  background: #0f3460;
  color: #9ab;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color .15s, color .15s;
}
.id-tag:hover { color: #e0e0e0; }
.id-tag.active { border-color: #e94560; color: #e94560; }

/* ── Mobile: 2× controls ─────────────────────────── */

@media (max-width: 600px) {
  #tracker-input {
    padding: 12px 18px;
    font-size: 18px;
    border-radius: 10px;
  }

  .primary-btn {
    padding: 12px 24px;
    font-size: 18px;
    border-radius: 10px;
  }

  .filter-btn {
    padding: 8px 18px;
    font-size: 18px;
    border-radius: 20px;
  }

  .ctrl-btn {
    padding: 8px 14px;
    font-size: 18px;
    border-radius: 10px;
  }

  .conn {
    width: 16px;
    height: 16px;
  }

  .id-tag {
    padding: 4px 16px;
    font-size: 16px;
    border-radius: 16px;
  }

  #search-row { gap: 10px; margin-bottom: 8px; }
  #filter-row { gap: 8px; }
  #tags-row   { gap: 8px; margin-top: 8px; }
  #topbar     { padding: 10px 14px 8px; }

  /* layer selector toggle and list */
  .leaflet-control-layers-toggle {
    width: 44px !important;
    height: 44px !important;
    background-size: 26px 26px !important;
  }
  .leaflet-control-layers label {
    font-size: 18px !important;
    padding: 4px 0 !important;
  }
  .leaflet-control-layers {
    padding: 8px 12px !important;
  }

  /* zoom +/- buttons */
  .leaflet-bar a {
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    font-size: 22px !important;
  }

  /* stretch right corner container full height so zoom can be centered */
  .leaflet-bottom.leaflet-right {
    top: 0;
  }
  /* zoom at vertical center, attribution pinned to bottom */
  .leaflet-bottom.leaflet-right .leaflet-control-zoom {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
  }
  .leaflet-bottom.leaflet-right .leaflet-control-attribution {
    position: absolute;
    bottom: env(safe-area-inset-bottom, 0px);
    right: 0;
    white-space: nowrap;
  }
}

/* ── Welcome bottom sheet ────────────────────────── */

#welcome-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
#welcome-sheet.visible {
  transform: translateY(0);
}

#welcome-sheet-inner {
  background: #16213e;
  border-top: 1px solid #0f3460;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#welcome-sheet h2 {
  font-size: 1.1rem;
  color: #e94560;
}

#welcome-sheet p {
  font-size: 14px;
  line-height: 1.5;
  color: #c0c8d8;
}

.welcome-cookies {
  font-size: 12px !important;
  color: #7a8cb0 !important;
  border-top: 1px solid #0f3460;
  padding-top: 10px;
}

#welcome-ok {
  align-self: flex-end;
}

/* ── Leaflet overrides ───────────────────────────── */

.leaflet-container { background: #1a1a2e; }
.leaflet-control-attribution { font-size: 10px !important; }
.leaflet-bar a {
  background: #16213e !important;
  color: #e0e0e0 !important;
  border-color: #0f3460 !important;
}
.leaflet-bar a:hover { background: #0f3460 !important; }
.leaflet-control-layers {
  background: #16213e !important;
  border-color: #0f3460 !important;
  color: #e0e0e0 !important;
}
.leaflet-control-layers-separator { border-color: #0f3460 !important; }
