:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: #b9cad8;
  --navy: #071522;
  --slate: #26384c;
  --teal: #3ec7ba;
  --cyan: #b7f7ff;
  --green: #83e276;
  --amber: #f7c761;
  --danger: #ff7c7c;
  --glass: rgba(255, 255, 255, 0.13);
  --glass-strong: rgba(255, 255, 255, 0.2);
  --line: rgba(255, 255, 255, 0.24);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(7, 21, 34, 0.95), rgba(28, 53, 74, 0.9)),
    radial-gradient(circle at 20% 20%, rgba(62, 199, 186, 0.24), transparent 32%),
    radial-gradient(circle at 80% 12%, rgba(131, 226, 118, 0.15), transparent 28%),
    #071522;
  overflow-x: hidden;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 88%);
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 14%, rgba(183, 247, 255, 0.13) 14% 15%, transparent 15% 37%, rgba(62, 199, 186, 0.11) 37% 38%, transparent 38% 100%),
    linear-gradient(25deg, transparent 0 48%, rgba(255, 255, 255, 0.08) 48% 49%, transparent 49% 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 5vw, 64px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 21, 34, 0.74);
  backdrop-filter: blur(18px);
}

.brand,
.top-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #071522;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--cyan), var(--green));
}

.top-nav {
  color: var(--muted);
  font-size: 0.94rem;
}

.top-nav a {
  padding: 8px 10px;
  border-radius: var(--radius);
}

.top-nav a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
}

.hero,
.workspace,
.results-section,
.saved-section {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 470px);
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
  min-height: calc(100vh - 70px);
  padding: 44px 0 24px;
}

.hero-copy h1 {
  max-width: 720px;
  margin: 0;
  font-size: 5.8rem;
  line-height: 0.92;
  letter-spacing: 0;
}

.hero-copy p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.glass {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.form-card,
.summary-card,
.directions-card,
.saved-tools,
.modal {
  padding: 22px;
}

.form-head,
.card-head,
.map-toolbar,
.map-footer,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.icon-button,
.map-controls button,
.favorite-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 21, 34, 0.28);
}

.segmented legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: block;
  min-height: 42px;
  padding: 10px;
  color: var(--muted);
  text-align: center;
  border-radius: calc(var(--radius) - 2px);
}

.segmented input:checked + span {
  color: #071522;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  font-weight: 800;
}

.field,
.select-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.select-field select {
  width: 100%;
  min-height: 46px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 21, 34, 0.42);
  padding: 0 12px;
}

.field input::placeholder {
  color: rgba(247, 251, 255, 0.52);
}

.field small {
  min-height: 17px;
  color: var(--muted);
  font-weight: 500;
}

.field small.error {
  color: var(--danger);
}

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

.with-unit {
  position: relative;
}

.with-unit b {
  position: absolute;
  right: 12px;
  top: 50%;
  color: var(--cyan);
  transform: translateY(-50%);
}

.with-unit input {
  padding-right: 46px;
}

.hidden {
  display: none;
}

.preferences {
  margin: 16px 0 20px;
}

.preferences summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  position: relative;
}

.chip input {
  position: absolute;
  opacity: 0;
}

.chip span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 10px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.86rem;
}

.chip input:checked + span {
  color: #071522;
  border-color: transparent;
  background: var(--green);
  font-weight: 800;
}

.preference-profile {
  margin: 12px 0 0;
  color: var(--cyan);
  font-size: 0.86rem;
  line-height: 1.45;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 12px;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 46px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-weight: 850;
}

.primary-button {
  color: #061421;
  border: 0;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 16px 34px rgba(62, 199, 186, 0.22);
}

.ghost-button,
.danger-button {
  color: var(--ink);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
}

.danger-button {
  border-color: rgba(255, 124, 124, 0.42);
  color: #ffd3d3;
}

.workspace {
  padding: 24px 0;
}

.map-shell {
  overflow: hidden;
}

.map-toolbar,
.map-footer {
  padding: 18px 20px;
}

.map-controls {
  display: flex;
  gap: 8px;
}

.leaflet-container {
  color: var(--ink);
  font-family: inherit;
  background: #071522;
}

#routeMap {
  display: block;
  width: 100%;
  height: 520px;
  min-height: 440px;
  background: #122536;
  touch-action: none;
}

.leaflet-tile {
  filter: saturate(0.82) contrast(1.08) brightness(0.92);
}

.leaflet-control-zoom {
  overflow: hidden;
  border: 1px solid rgba(183, 247, 255, 0.26) !important;
  border-radius: var(--radius) !important;
  background: rgba(7, 21, 34, 0.72);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28) !important;
  backdrop-filter: blur(14px);
}

.leaflet-control-zoom a {
  width: 36px !important;
  height: 36px !important;
  color: var(--ink) !important;
  border: 0 !important;
  background: rgba(255, 255, 255, 0.1) !important;
  line-height: 34px !important;
}

.leaflet-control-zoom a:hover {
  color: #071522 !important;
  background: var(--cyan) !important;
}

.leaflet-control-attribution {
  color: rgba(247, 251, 255, 0.72) !important;
  border: 1px solid rgba(183, 247, 255, 0.18);
  border-radius: var(--radius) 0 0 0;
  background: rgba(7, 21, 34, 0.72) !important;
  font-size: 0.72rem;
  backdrop-filter: blur(12px);
}

.leaflet-control-attribution a {
  color: var(--cyan) !important;
}

.mile-marker {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid rgba(183, 247, 255, 0.85);
  border-radius: 50%;
  background: rgba(7, 21, 34, 0.92);
  box-shadow: 0 0 0 3px rgba(7, 21, 34, 0.5), 0 5px 14px rgba(0, 0, 0, 0.38);
}

.mile-marker span {
  color: var(--cyan);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 1px 4px #071522;
}

.route-pin {
  display: grid;
  width: 34px;
  height: 42px;
  place-items: center;
  border-radius: 18px 18px 18px 4px;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(7, 21, 34, 0.68);
  transform: rotate(-45deg);
}

.route-pin span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #071522;
  font-size: 0.78rem;
  font-weight: 900;
  transform: rotate(45deg);
}

.route-pin-end {
  background: linear-gradient(135deg, var(--amber), var(--green));
}

.leaflet-marker-icon {
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.42));
}

.map-footer {
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.summary-list {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

dt,
.summary-list dt {
  color: var(--muted);
}

dd,
.summary-list dd {
  margin: 0;
  font-weight: 850;
}

.note,
.empty-state {
  color: var(--muted);
  line-height: 1.55;
}

.results-section,
.saved-section {
  padding: 42px 0;
}

.section-title {
  margin-bottom: 18px;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: 20px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#directionsList {
  display: grid;
  gap: 12px;
  padding-left: 22px;
  color: var(--muted);
}

#directionsList li::marker {
  color: var(--green);
  font-weight: 900;
}

.saved-tools {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 16px;
  margin-bottom: 18px;
}

.saved-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.saved-card {
  padding: 18px;
}

.saved-card h3 {
  margin-bottom: 8px;
}

.saved-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.saved-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

dialog {
  border: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
}

.modal {
  max-width: 520px;
  color: var(--ink);
}

.modal p {
  color: var(--muted);
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 40px));
  padding: 14px 16px;
  color: #071522;
  border-radius: var(--radius);
  background: var(--cyan);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.marker {
  cursor: grab;
}

.marker:active {
  cursor: grabbing;
}

@media (max-width: 900px) {
  .hero,
  .workspace,
  .results-grid,
  .saved-tools {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .workspace {
    padding-top: 10px;
  }

  .saved-list {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 8px;
  }

  .saved-card {
    min-width: 290px;
    scroll-snap-align: start;
  }

  .hero-copy h1 {
    font-size: 4.2rem;
  }
}

@media (max-width: 620px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero,
  .workspace,
  .results-section,
  .saved-section {
    width: min(100% - 20px, 1180px);
  }

  .field-grid,
  .form-actions,
  .modal-actions,
  .saved-actions {
    grid-template-columns: 1fr;
  }

  .form-card {
    position: relative;
    padding-bottom: 78px;
  }

  .form-actions .primary-button {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 15;
  }

  #routeMap {
    height: 380px;
    min-height: 360px;
  }

  .hero-copy h1 {
    font-size: 3rem;
  }

  .hero-copy p:not(.eyebrow) {
    font-size: 1.05rem;
  }
}

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