* {
  box-sizing: border-box;
}

:root {
  --forest-dark: #0b3d2e;
  --forest: #14532d;
  --forest-light: #1f7a4d;
  --accent: #7be495;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1a1a1a;
  background: #fff;
}

header.hero {
  padding: 36px 20px 28px;
  background: radial-gradient(circle at 15% 20%, rgba(123, 228, 149, 0.25), transparent 55%),
    linear-gradient(160deg, var(--forest-dark), var(--forest) 60%, var(--forest-light));
  color: #fff;
  text-align: center;
}

.hero-inner {
  max-width: 640px;
  margin: 0 auto;
}

header.hero h1 {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header.hero .tagline {
  margin: 10px 0 22px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.05rem;
  line-height: 1.4;
}

#address-search {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 420px;
}

#address-input {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

#address-input:focus {
  outline: 3px solid var(--accent);
}

#address-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  width: 100%;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  background: #fff;
  color: #1a1a1a;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-height: 220px;
  overflow-y: auto;
  text-align: left;
}

#address-suggestions li {
  padding: 9px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}

#address-suggestions li:hover,
#address-suggestions li.active {
  background: #eef5ff;
}

#analyze-btn {
  margin-top: 14px;
  padding: 12px 32px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #0b3d2e;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

#analyze-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

#analyze-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#status-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  min-height: 1.2em;
}

#status {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
}

.progress-dots {
  display: inline-flex;
  gap: 4px;
}

.progress-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: dot-pulse 1.1s infinite ease-in-out;
}

.progress-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.progress-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes dot-pulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress-dots span {
    animation: none;
    opacity: 0.7;
  }
}

.scope-note {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
}

#results-toolbar {
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f4f7f5;
  border-bottom: 1px solid #dde3df;
}

#legend {
  font-size: 0.85rem;
}

#legend summary {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

#legend summary::-webkit-details-marker {
  display: none;
}

#legend summary::after {
  content: "?";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #888;
  font-size: 0.7rem;
  color: #666;
}

.legend-details {
  margin: 10px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid #dde3df;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 20px;
}

.legend-details div {
  margin: 0;
}

.legend-details dt {
  font-weight: 600;
  font-size: 0.85rem;
}

.legend-details dd {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: #444;
  line-height: 1.3;
}

#selection-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#selection-actions button {
  padding: 8px 14px;
  border: 1px solid #333;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}

#selection-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

.swatch.safe {
  background: #2ecc71;
}

.swatch.caution {
  background: #f1c40f;
}

.swatch.critical {
  background: #e74c3c;
}

.swatch.core {
  background: #3498db;
}

.line {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top: 3px dashed;
  margin-right: 4px;
  vertical-align: middle;
}

.line.reconnect {
  border-color: #ff00c8;
}

.line.near-miss {
  border-color: #ff8c00;
}

.bridge-tag {
  font-weight: 600;
}

#map {
  flex: 1 1 auto;
  min-height: 320px;
  width: 100%;
}

@media (max-width: 600px) {
  header.hero h1 {
    font-size: 1.8rem;
  }
  header.hero {
    padding: 28px 16px 22px;
  }
  #results-toolbar {
    padding: 10px 16px;
  }
}
