:root {
  color-scheme: light;
  --bg: #ffffff;
  --text: #007000;
  --muted: rgba(0, 112, 0, 0.62);
  --line: rgba(0, 112, 0, 0.3);
  --line-soft: rgba(0, 112, 0, 0.12);
  --panel: rgba(255, 255, 255, 0.96);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
[role="option"]:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: -4rem;
  left: 1rem;
  z-index: 20;
  padding: 0.35rem 0.5rem;
  background: var(--panel);
  color: var(--text);
}

.skip-link:focus {
  top: 1rem;
}

.display-shell {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(44rem, calc(100vw - 1.5rem));
  aspect-ratio: 16 / 9;
  transform: translate(-50%, -50%);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

body.road-context .display-shell {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.map-app {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 1px solid var(--text);
  border-radius: clamp(2rem, 7vw, 4rem);
  background: var(--bg);
}

#map {
  position: absolute;
  inset: 0;
}

#map {
  background: var(--bg);
}

.route-panel {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 5;
  width: min(22rem, calc(50vw - 0.75rem));
}

.route-inputs {
  display: grid;
  gap: 0.3rem;
}

.search-field {
  position: relative;
}

.search-field input {
  width: 100%;
  height: 2.7rem;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0 0.25rem;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
}

.search-field input::-webkit-search-cancel-button {
  display: none;
}

.search-field input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.search-field input:focus {
  border-bottom-color: var(--text);
  outline: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 0.2rem);
  right: 0;
  left: 0;
  z-index: 8;
  max-height: min(15rem, 42vh);
  margin: 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  padding: 0;
  background: var(--bg);
  list-style: none;
}

.search-results li {
  display: grid;
  gap: 0.05rem;
  padding: 0.55rem 0.65rem;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
}

.search-results li:first-child {
  border-top: 0;
}

.search-results li:hover,
.search-results li[aria-selected="true"] {
  background: var(--text);
  color: var(--bg);
}

.result-name,
.result-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-detail {
  color: var(--muted);
  font-size: 0.76rem;
}

.search-results li:hover .result-detail,
.search-results li[aria-selected="true"] .result-detail {
  color: inherit;
  opacity: 0.72;
}

.route-result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.route-result:has(output:empty),
.map-status:empty {
  display: none;
}

.route-result output {
  white-space: nowrap;
}

.route-result button {
  flex: none;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.route-result button:hover {
  color: var(--text);
}

body.route-ready .route-panel {
  width: min(18rem, calc(50vw - 0.75rem));
  border: 1px solid var(--line);
  padding: 0.6rem;
  background: var(--panel);
}

body.route-ready #route-form {
  display: none;
}

body.route-ready .route-result {
  gap: 0.5rem;
}

.map-status {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.page-attribution {
  position: fixed;
  right: 0.75rem;
  bottom: 0.5rem;
  z-index: 10;
  margin: 0;
  visibility: hidden;
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
  opacity: 0;
}

body.road-context .page-attribution {
  visibility: visible;
  opacity: 1;
}

.page-attribution a {
  color: inherit;
}

noscript {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 10;
  padding: 0.5rem;
  background: var(--panel);
}

@media (max-width: 640px) {
  .route-panel {
    top: 0.75rem;
    left: 0.75rem;
  }
}

@media (max-height: 560px) {
  .search-results {
    max-height: 48vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
