:root {
  --bg: #1b1f27;
  --panel-bg: rgba(27, 31, 39, 0.92);
  --panel-fg: #f4f5f7;
  --accent: #4da3ff;
  --border: rgba(255, 255, 255, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--panel-fg);
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #0e1014;
}

#app-header {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 12px;
  z-index: 900;
  pointer-events: none;
}

#app-header h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--panel-bg);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-transform: uppercase;
  backdrop-filter: blur(6px);
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-bg);
  color: var(--panel-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(6px);
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active {
  transform: scale(0.94);
}

#controls {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  right: 12px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(78vw, 320px);
}

#search-widget {
  position: absolute;
  top: calc(var(--safe-top) + 64px);
  left: 12px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(78vw, 320px);
}

.panel-body {
  display: none;
  flex-direction: column;
  gap: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  width: 100%;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

#controls.open .panel-body,
#search-widget.open .panel-body {
  display: flex;
}

.search-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--panel-fg);
  font-size: 14px;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 45vh;
  overflow-y: auto;
}

.search-results li button {
  appearance: none;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--panel-fg);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  cursor: pointer;
}

.search-results li button:active {
  background: rgba(255, 255, 255, 0.12);
}

.search-message {
  font-size: 12.5px;
  opacity: 0.75;
  padding: 4px 2px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group + .control-group {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.control-group-title {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.6;
}

.switch-row,
.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
}

.switch-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.slider-row input[type="range"] {
  flex: 1;
  max-width: 140px;
  accent-color: var(--accent);
}

.text-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--panel-fg);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}

.text-btn:active {
  background: rgba(255, 255, 255, 0.12);
}

.text-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.fab {
  position: absolute;
  right: 12px;
  bottom: calc(var(--safe-bottom) + 54px);
  z-index: 900;
}

#attribution-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 5px 10px calc(var(--safe-bottom) + 5px);
  background: rgba(15, 17, 22, 0.72);
  font-size: 10.5px;
  color: rgba(244, 245, 247, 0.85);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

#attribution-bar a {
  color: rgba(244, 245, 247, 0.85);
  pointer-events: auto;
}

/* Leaflet side-by-side divider styling tweak for touch */
.leaflet-sbs-divider {
  z-index: 999;
}

.leaflet-sbs-range {
  z-index: 1000;
}

.vici-popup h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.vici-popup p {
  margin: 0 0 8px;
  font-size: 12.5px;
  line-height: 1.4;
}

.vici-popup a {
  font-size: 12.5px;
  font-weight: 600;
}

.vici-kind {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
}

.locate-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(77, 163, 255, 0.4);
}

@media (min-width: 640px) {
  #controls {
    max-width: 300px;
  }
}
