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

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f1a;
  color: #fff;
  overflow: hidden;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: #1a1a2e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  height: 48px;
  z-index: 100;
  position: relative;
}

.header-title {
  font-size: 1rem;
  font-weight: 600;
}

.header-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.group-label {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
}

.group-input {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #fff;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  width: 9rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.group-input:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.6);
}

.group-join-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.7);
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.group-join-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.header-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

.connection-status {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.1);
}

.connection-status.connected {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.connection-status.disconnected {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* Map */
#map {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  bottom: 0;
}

/* Status toast */
.status-message {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 1000;
  pointer-events: none;
}

/* Base layer control */
.base-layer-ctrl {
  position: relative;
  background: none !important;
  box-shadow: none !important;
  border: none !important;
}

.base-layer-toggle {
  width: 30px;
  height: 30px;
  border: none;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 30px;
  text-align: center;
  padding: 0;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
  transition: background 0.15s;
}

.base-layer-toggle:hover {
  background: #e8e8e8;
}

.base-layer-list {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 36px;
  background: rgba(20, 20, 40, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  overflow: hidden;
  min-width: 150px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.base-layer-item {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.75);
  padding: 10px 16px;
  font-size: 0.8rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.base-layer-item + .base-layer-item {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.base-layer-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.base-layer-item.active {
  background: rgba(99, 102, 241, 0.25);
  color: #fff;
  font-weight: 600;
  position: relative;
}

.base-layer-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: rgb(99, 102, 241);
  border-radius: 0 2px 2px 0;
}

/* Tile badge markers */
.tile-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(30, 30, 60, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.75rem;
  color: #fff;
  transition: background 0.15s;
}

.tile-badge:hover {
  background: rgba(50, 50, 90, 0.95);
  border-color: rgba(255, 255, 255, 0.4);
}

.tile-badge-count {
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 1.2em;
  text-align: center;
}

.tile-badge-eye {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 2px;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.tile-badge-eye:hover {
  opacity: 1;
}

.tile-badge-ungranted {
  font-weight: 400;
  font-size: 0.7rem;
  opacity: 0.6;
  white-space: nowrap;
}

/* Camera markers (post-permission) */
.camera-marker {
  position: relative;
  width: 0;
  height: 0;
  cursor: pointer;
}

.camera-dot {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.camera-frustum {
  position: absolute;
  top: -15px;
  left: -12px;
  transform-origin: 12px 15px;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 30px solid rgba(34, 197, 94, 0.4);
  pointer-events: none;
}

/* Camera picker popup (co-located markers) */
.camera-picker-popup .maplibregl-popup-content {
  background: rgba(20, 20, 40, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 4px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.camera-picker-popup .maplibregl-popup-close-button {
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  right: 4px;
  top: 2px;
}

.camera-picker-popup .maplibregl-popup-tip {
  border-top-color: rgba(20, 20, 40, 0.95);
}

.camera-picker {
  display: flex;
  flex-direction: column;
  min-width: 120px;
}

.camera-picker-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  border-radius: 4px;
  transition: background 0.12s;
  font-family: inherit;
}

.camera-picker-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.picker-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
