:root {
  --ink: #1a2332;
  --ink-soft: #4a5568;
  --paper: #f7f4ef;
  --panel: rgba(255, 252, 248, 0.96);
  --line: rgba(26, 35, 50, 0.12);
  --accent: #0d6e6e;
  --shadow: 0 12px 40px rgba(26, 35, 50, 0.14);
  --radius: 14px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(13, 110, 110, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(196, 122, 42, 0.1), transparent),
    var(--paper);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 244, 239, 0.9);
  backdrop-filter: blur(10px);
  z-index: 1000;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.search {
  position: relative;
  display: flex;
  flex: 1;
  max-width: 28rem;
  gap: 0.4rem;
  min-width: 0;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 2.35rem;
  padding: 0 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  outline: none;
}

.search input:focus {
  border-color: rgba(13, 110, 110, 0.55);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.12);
}

.search input::placeholder {
  color: #8a93a3;
}

.search button[type="submit"] {
  height: 2.35rem;
  padding: 0 0.95rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.search button[type="submit"]:hover {
  background: #0a5c5c;
}

.search button[type="submit"]:disabled {
  opacity: 0.65;
  cursor: wait;
}

.search-results {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  max-height: 16rem;
  overflow: auto;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 1100;
}

.search-results li button {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  text-align: left;
  cursor: pointer;
  line-height: 1.35;
}

.search-results li button:hover,
.search-results li button:focus,
.search-results li button.is-active {
  background: rgba(13, 110, 110, 0.1);
  outline: none;
}

.search-results li button .suggest-main {
  display: block;
  font-weight: 600;
}

.search-results li button small {
  display: block;
  margin-top: 0.15rem;
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.search-status {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  color: var(--ink-soft);
  z-index: 1100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #0d6e6e 0%, #1a9a8a 45%, #c47a2a 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.tagline {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.meta-pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(13, 110, 110, 0.1);
  color: var(--accent);
}

.meta-pill-muted {
  background: rgba(26, 35, 50, 0.08);
  color: var(--ink-soft);
  font-weight: 500;
}

.source-tag {
  display: inline-block;
  margin-left: 0.25rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(196, 122, 42, 0.15);
  color: #9a5b12;
  font-size: 0.68rem;
  font-weight: 600;
  vertical-align: middle;
}

.meta-note {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.map-shell {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #d9e2ea;
}

.panel {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: min(340px, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  overflow: auto;
  padding: 1.15rem 1.25rem 1.35rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 900;
  animation: panel-in 180ms ease-out;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.panel-close:hover {
  background: rgba(26, 35, 50, 0.06);
  color: var(--ink);
}

.panel-eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.panel h2 {
  margin: 0 2rem 0.85rem 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.speed-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: #fff;
  background: #6b7280;
}

.speed-badge small {
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.9;
}

.panel-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem 0;
  margin: 0;
}

.panel-fields > div {
  display: grid;
  grid-template-columns: 42% 1fr;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
}

.panel-fields dt {
  margin: 0;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.panel-fields dd {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 500;
  word-break: break-word;
}

.legend {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  width: max-content;
  max-width: 7.25rem;
  padding: 0.5rem 0.6rem 0.55rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(26, 35, 50, 0.12);
  z-index: 900;
}

.legend h3 {
  margin: 0 0 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.12rem 0;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 500;
  line-height: 1.2;
}

.swatch {
  width: 0.95rem;
  height: 0.28rem;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-source {
  margin: 0.4rem 0 0;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
  font-size: 0.58rem;
  line-height: 1.3;
  color: var(--ink-soft);
  white-space: nowrap;
}

.legend-source a {
  color: var(--accent);
  text-decoration: none;
}

.legend-source a:hover {
  text-decoration: underline;
}

.zoom-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  background: rgba(26, 35, 50, 0.88);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 850;
  pointer-events: none;
}

.leaflet-container {
  font-family: var(--font);
}

.leaflet-control-attribution {
  font-size: 0.65rem !important;
  background: rgba(255, 252, 248, 0.85) !important;
}

.road-highlight {
  filter: drop-shadow(0 0 4px rgba(26, 35, 50, 0.45));
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search {
    max-width: none;
    order: 2;
  }

  .topbar-meta {
    order: 3;
    justify-content: flex-start;
  }

  .panel {
    top: auto;
    bottom: 5.5rem;
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    max-height: 42vh;
  }

  .legend {
    left: 0.5rem;
    bottom: 0.5rem;
    max-width: 6.75rem;
    padding: 0.4rem 0.5rem;
  }

  .meta-note {
    display: none;
  }
}
