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

html, body {
  height: 100%;
  overflow: hidden;
  background: #1a1a1a;
}

/* Sidebar */
#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 320px;
  height: 100vh;
  background: rgba(20, 20, 20, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: #fff;
}

#sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#sidebar-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #888;
}

#search-container {
  padding: 16px;
  position: relative;
}

#address-search {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

#address-search:focus {
  border-color: #00ff88;
  background: rgba(255, 255, 255, 0.12);
}

#address-search::placeholder {
  color: #666;
}

#search-results {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 100%;
  background: rgba(30, 30, 30, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 10;
}

#search-results.visible {
  display: block;
}

.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
  transition: background 0.15s;
}

.search-result-item:hover {
  background: rgba(0, 255, 136, 0.15);
}

.search-result-item:last-child {
  border-bottom: none;
}

#waypoint-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.waypoint-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: grab;
  transition: background 0.15s, transform 0.15s;
}

.waypoint-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.waypoint-item.dragging {
  opacity: 0.5;
  transform: scale(0.98);
}

.waypoint-number {
  width: 24px;
  height: 24px;
  background: #00ff88;
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.waypoint-address {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waypoint-remove {
  width: 28px;
  height: 28px;
  background: rgba(255, 100, 100, 0.2);
  border: none;
  border-radius: 6px;
  color: #ff6666;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.waypoint-remove:hover {
  background: rgba(255, 100, 100, 0.4);
}

.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: #666;
  font-size: 13px;
}

.address-sub {
  color: #888;
  font-weight: 400;
  font-size: 11px;
}

.waypoint-item.is-home {
  border-left: 3px solid #3b82f6;
}

#route-info {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
  color: #888;
}

#route-info.has-route {
  color: #00ff88;
}

#map-wrapper {
  width: calc(100vw - 320px);
  height: 100vh;
  overflow: hidden;
  position: relative;
  margin-left: 320px;
}

#map {
  /* Worst-case: extreme aspect ratio (e.g. 32:9 ultrawide) at 90° rotation
     Make it a square where side = vw + vh to guarantee full coverage
     at any rotation angle and any aspect ratio */
  width: calc(100vw + 100vh);
  height: calc(100vw + 100vh);
  position: absolute;
  /* Center the oversized map within the wrapper */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
}

#app-title {
  position: relative;
  display: inline-block;
  color: #fff;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 20px;
  font-weight: 700;
  text-transform: lowercase;
  letter-spacing: 2px;
}

.title-letter {
  display: inline-block;
  position: relative;
  transition: color 0.1s ease;
}

.title-letter.active {
  color: #00ff88;
}

#scan-box {
  position: absolute;
  width: 8px;
  height: 4px;
  background: #00ff88;
  border-radius: 1px;
  opacity: 0;
  box-shadow: 0 0 8px #00ff88;
  pointer-events: none;
  transition: left 0.15s ease-out, top 0.15s ease-out, bottom 0.15s ease-out;
}

#speed {
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#version-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  padding: 16px;
  border-radius: 8px;
  z-index: 1000;
  min-width: 300px;
  max-width: 400px;
  max-height: 70vh;
  overflow-y: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

#version-panel.hidden {
  display: none;
}

#version-header {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

#version-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.version-item {
  line-height: 1.5;
  color: #c9d1d9;
}

.version-item strong {
  color: #58a6ff;
  font-weight: 600;
}

.inverted-tiles {
  filter: invert(1) hue-rotate(180deg);
}

/* Pulse effect for location marker */
@keyframes pulse-ring-anim {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.7;
  }
  100% {
    transform: translate(-50%, -50%) scale(4);
    opacity: 0;
  }
}

.pulse-marker-container {
  position: relative;
}

.pulse-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  background: #00ff88;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.6);
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 255, 136, 0.5);
  transform: translate(-50%, -50%) scale(1);
  animation: pulse-ring-anim 2s ease-out infinite;
}

.pulse-ring-delayed {
  animation-delay: 1s;
}

/* Waypoint markers on map */
.waypoint-marker {
  background: transparent;
}

.waypoint-marker-dot {
  width: 28px;
  height: 28px;
  background: #00ff88;
  color: #000;
  border: 3px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.leaflet-control-attribution {
  font-size: 9px !important;
}
