:root {
  --navy: #081b2a;
  --navy-soft: #102d42;
  --route: #2f8cff;
  --amber: #f2ae49;
  --ice: #edf6f8;
  --ink: #10212d;
  --muted: #637985;
  --line: #cbdadd;
  --danger: #bd3f4b;
  --white: #ffffff;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--navy);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(115deg, rgba(47, 140, 255, 0.08), transparent 42%),
    var(--navy);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: clamp(10px, 1.5vw, 22px);
}

.route-console {
  position: absolute;
  z-index: 500;
  top: 72px;
  left: 20px;
  width: min(350px, calc(100% - 40px));
  max-height: calc(100% - 92px);
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ice);
  box-shadow: 0 18px 40px rgba(8, 27, 42, 0.28);
}

.route-console::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -60px;
  width: 170px;
  height: 170px;
  border: 1px solid rgba(47, 140, 255, 0.18);
  border-radius: 50%;
  box-shadow: 0 0 0 28px rgba(47, 140, 255, 0.05), 0 0 0 56px rgba(47, 140, 255, 0.035);
  pointer-events: none;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--navy);
  border: 2px solid var(--navy);
  border-radius: 50% 50% 50% 8px;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  transform: rotate(-10deg);
}

.brand-mark::first-letter {
  transform: rotate(10deg);
}

.eyebrow,
.map-heading,
.metric-label,
.waypoint label span {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
  font-weight: 600;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--route);
}

h1 {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: clamp(2rem, 3vw, 2.65rem);
  line-height: 0.78;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}

.intro {
  max-width: 32ch;
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.route-form,
.waypoint {
  position: relative;
}

.waypoint {
  margin: 0;
  padding: 0 0 0 22px;
  border: 0;
}

.waypoint legend {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
}

.waypoint-dot {
  position: absolute;
  left: 0;
  width: 10px;
  height: 10px;
  border: 3px solid var(--route);
  border-radius: 50%;
  background: var(--ice);
  z-index: 1;
}

.waypoint--end .waypoint-dot {
  border-color: var(--amber);
  border-radius: 2px;
}

.coordinate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.waypoint label span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
}

.waypoint input {
  width: 100%;
  min-height: 40px;
  padding: 7px 9px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: 0;
  background: var(--white);
  font-variant-numeric: tabular-nums;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.waypoint input:focus-visible {
  border-color: var(--route);
  box-shadow: 0 0 0 3px rgba(47, 140, 255, 0.2);
}

.route-rail {
  height: 24px;
  margin-left: 4px;
  border-left: 2px dotted #9bb0b8;
}

.route-examples {
  margin: 14px 0 0;
  padding: 0;
  border: 0;
}

.route-examples legend {
  padding: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.example-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

.route-example {
  min-height: 38px;
  padding: 6px 8px;
  color: var(--navy-soft);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--white);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.route-example:hover {
  border-color: var(--route);
}

.route-example:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

.route-option {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 9px;
  align-items: center;
  margin-top: 14px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.62);
  cursor: pointer;
}

.route-option + .route-option {
  margin-top: 7px;
}

.route-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.option-control {
  position: relative;
  width: 22px;
  height: 22px;
  border: 2px solid var(--navy-soft);
  border-radius: 2px;
  background: var(--white);
  transition: background 160ms ease, border-color 160ms ease;
}

.route-option input:checked + .option-control {
  border-color: var(--route);
  background: var(--route);
}

.route-option input:checked + .option-control::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid var(--white);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.route-option input:focus-visible + .option-control {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.option-copy {
  display: grid;
  gap: 2px;
}

.option-copy strong {
  font-size: 0.88rem;
}

.option-copy small {
  color: var(--muted);
  font-size: 0.72rem;
}

#route-submit {
  display: flex;
  width: 100%;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 0 14px 0 16px;
  color: var(--white);
  border: 0;
  border-radius: 2px;
  background: var(--navy-soft);
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

#route-submit:hover {
  background: #17425f;
}

#route-submit:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

#route-submit:active {
  transform: translateY(1px);
}

#route-submit:disabled {
  cursor: wait;
  opacity: 0.7;
}

.button-arrow {
  color: var(--amber);
  font-size: 1.45rem;
}

.route-status {
  min-height: 34px;
  margin: 10px 0 0;
  padding: 7px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
  line-height: 1.45;
}

.route-status[data-state="error"] {
  color: var(--danger);
  border-color: rgba(189, 63, 75, 0.4);
}

.route-status[data-state="loading"] {
  color: var(--route);
}

.route-status[data-state="warning"] {
  color: #8a5a00;
  border-color: rgba(227, 169, 56, 0.55);
}

.route-console[hidden],
.route-panel-toggle[hidden],
.route-summary[hidden] {
  display: none;
}

.route-summary {
  position: absolute;
  z-index: 500;
  right: 20px;
  bottom: 36px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 10px;
  background: rgba(237, 246, 248, 0.9);
  box-shadow: 0 14px 32px rgba(8, 27, 42, 0.24);
}

.route-summary > div + div {
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.route-warning {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 12px;
  color: #6e4900;
  border-top: 1px solid rgba(227, 169, 56, 0.5);
  font-size: 0.82rem;
  line-height: 1.4;
}

.route-warning[hidden] {
  display: none;
}

.metric-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
}

.route-summary strong {
  font-family: "Barlow Condensed", sans-serif;
  font-size: clamp(1.8rem, 3vw, 2.45rem);
  font-variant-numeric: tabular-nums;
}

.map-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: calc(100vh - clamp(20px, 3vw, 44px));
  overflow: hidden;
  border: 1px solid rgba(237, 246, 248, 0.16);
  background: var(--navy-soft);
}

.map-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 18px;
  color: var(--ice);
}

.map-coordinate-order {
  color: var(--amber);
}

#map {
  min-height: 0;
  background: #dce7e8;
  isolation: isolate;
}

.route-panel-close,
.route-panel-toggle {
  cursor: pointer;
}

.route-panel-close {
  position: absolute;
  z-index: 1;
  top: 12px;
  right: 12px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  color: var(--navy);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  font-size: 1.3rem;
  line-height: 1;
}

.route-panel-close:focus-visible,
.route-panel-toggle:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

.route-panel-toggle {
  position: absolute;
  z-index: 500;
  top: 72px;
  left: 20px;
  min-height: 44px;
  padding: 0 18px;
  color: var(--white);
  border: 0;
  border-radius: 4px;
  background: var(--navy);
  box-shadow: 0 10px 24px rgba(8, 27, 42, 0.28);
  font-weight: 600;
}

.map-fallback,
.noscript-message {
  padding: 16px;
  color: var(--muted);
}

.leaflet-container {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}

.leaflet-container .leaflet-tile {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-control-zoom a {
  color: var(--ink);
}

@media (max-width: 760px) {
  .app-shell {
    min-height: 100dvh;
    padding: 0;
  }

  .map-panel {
    min-height: 100dvh;
    border: 0;
  }

  .route-console {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(62dvh, 540px);
    border-radius: 14px 14px 0 0;
  }

  .route-panel-toggle {
    top: 64px;
    left: 12px;
  }

  .route-summary {
    right: 76px;
    bottom: calc(min(62dvh, 540px) + 12px);
    left: 12px;
  }

  #route-panel[hidden] ~ .route-summary {
    right: 12px;
    bottom: 28px;
  }
}

@media (max-width: 760px) and (max-height: 500px) {
  .route-console {
    max-height: 50dvh;
  }

  .route-summary {
    bottom: calc(50dvh + 12px);
  }

  #route-panel[hidden] ~ .route-summary {
    bottom: 28px;
  }
}

@media (max-width: 430px) {
  .coordinate-grid {
    grid-template-columns: 1fr;
  }

  .route-rail {
    height: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
