:root {
  color-scheme: dark;
  --ink: #f4f7fb;
  --muted: #9aa9ba;
  --dim: #6d7b8d;
  --canvas: #08111f;
  --canvas-raised: #0d1929;
  --panel: rgba(17, 30, 47, 0.96);
  --panel-soft: #142238;
  --border: rgba(176, 197, 219, 0.16);
  --border-strong: rgba(176, 197, 219, 0.28);
  --lime: #95f169;
  --lime-dark: #54bd54;
  --cyan: #77d9ff;
  --amber: #f6b94b;
  --red: #ff7d69;
  --purple: #a99cff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-md: 13px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 4%, rgba(119, 217, 255, 0.09), transparent 28rem),
    radial-gradient(circle at 84% 94%, rgba(149, 241, 105, 0.08), transparent 26rem),
    var(--canvas);
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(119, 217, 255, 0.65);
  outline-offset: 3px;
}

.app-header {
  width: min(1180px, calc(100% - 40px));
  min-height: 74px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 780;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(149, 241, 105, 0.2), rgba(119, 217, 255, 0.08));
  border: 1px solid rgba(149, 241, 105, 0.26);
}

.brand-mark svg {
  width: 29px;
  fill: none;
  stroke: var(--lime);
  stroke-width: 3;
  stroke-linecap: round;
}

.brand-mark circle:last-child {
  fill: var(--cyan);
  stroke: none;
}

.brand-mark circle:first-of-type {
  fill: var(--amber);
  stroke: none;
}

.estimate-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid rgba(149, 241, 105, 0.25);
  border-radius: 999px;
  background: rgba(149, 241, 105, 0.08);
  color: #c8ffb0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.estimate-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(149, 241, 105, 0.09);
}

.estimate-chip.subtle {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
}

.estimate-chip.subtle::before {
  background: var(--dim);
  box-shadow: none;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 50px 0 30px;
}

.intro {
  max-width: 760px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--lime);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(2.35rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: -0.065em;
}

.intro > p:last-child {
  max-width: 650px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.6;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 0.78fr) minmax(500px, 1.22fr);
  gap: 18px;
  align-items: start;
}

.planner-card,
.route-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(160deg, rgba(18, 32, 50, 0.98), rgba(11, 23, 38, 0.98));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.planner-card {
  padding: 24px;
}

.section-heading,
.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-heading {
  justify-content: flex-start;
  margin-bottom: 22px;
}

.section-heading h2,
.result-heading h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.section-heading p,
.result-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.step {
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--lime);
  background: rgba(149, 241, 105, 0.1);
  font-size: 0.72rem;
  font-weight: 850;
}

.route-fields {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr 40px;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(5, 13, 24, 0.45);
}

.route-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 33px 0 16px;
}

.route-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.route-dot.start {
  border: 2px solid var(--lime);
}

.route-dot.end {
  background: var(--cyan);
  box-shadow: 0 0 0 4px rgba(119, 217, 255, 0.1);
}

.route-line {
  width: 1px;
  height: 51px;
  background: repeating-linear-gradient(to bottom, var(--dim) 0 4px, transparent 4px 8px);
}

.route-inputs {
  display: grid;
  gap: 6px;
}

.autocomplete-field {
  position: relative;
  min-width: 0;
}

.autocomplete-list {
  position: absolute;
  z-index: 1200;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 225px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid rgba(119, 217, 255, 0.28);
  border-radius: 12px;
  background: rgba(8, 17, 31, 0.98);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(14px);
}

.autocomplete-list[hidden] {
  display: none;
}

.autocomplete-option,
.autocomplete-status {
  width: 100%;
  padding: 10px 11px;
  border: 0;
  border-radius: 9px;
  color: #dce6ef;
  background: transparent;
  text-align: left;
  font: inherit;
  line-height: 1.35;
}

.autocomplete-option {
  display: block;
  cursor: pointer;
}

.autocomplete-option:hover,
.autocomplete-option:focus-visible {
  outline: none;
  color: #ffffff;
  background: rgba(119, 217, 255, 0.11);
}

.autocomplete-option strong,
.autocomplete-option small {
  display: block;
}

.autocomplete-option strong {
  font-size: 0.76rem;
}

.autocomplete-option small,
.autocomplete-status {
  color: var(--muted);
  font-size: 0.68rem;
}

label,
legend {
  color: #c5d0dc;
  font-size: 0.79rem;
  font-weight: 700;
}

.route-inputs label:nth-of-type(2) {
  margin-top: 8px;
}

input[type="search"],
input[type="number"],
select {
  width: 100%;
  min-height: 45px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(14, 27, 43, 0.94);
  font-size: 0.92rem;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input[type="search"] {
  padding: 0 13px;
}

select {
  appearance: none;
  padding: 0 38px 0 13px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 19px,
    calc(100% - 12px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select option {
  color: #08111f;
  background-color: #ffffff;
}

input::placeholder {
  color: #637286;
}

input:hover,
input:focus,
select:hover,
select:focus {
  border-color: rgba(119, 217, 255, 0.55);
}

input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(119, 217, 255, 0.1);
}

select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(119, 217, 255, 0.1);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel-soft);
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(149, 241, 105, 0.4);
  background: rgba(149, 241, 105, 0.08);
}

.icon-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.swap-button {
  align-self: center;
  margin-top: 21px;
}

.sample-button {
  padding: 10px 2px;
  border: 0;
  color: var(--cyan);
  background: transparent;
  font-size: 0.77rem;
  font-weight: 700;
  cursor: pointer;
}

.sample-button:hover {
  color: #b8ebff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.vehicle-fieldset {
  margin: 10px 0 18px;
  padding: 0;
  border: 0;
}

.vehicle-fieldset legend {
  margin-bottom: 8px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(5, 13, 24, 0.55);
}

.segmented-control label {
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 9px;
  color: var(--muted);
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
  font-size: 0.75rem;
}

.segmented-control input:checked + span {
  color: var(--ink);
  background: var(--panel-soft);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.18);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid rgba(119, 217, 255, 0.65);
  outline-offset: 1px;
}

.segmented-control svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.field-group {
  min-width: 0;
}

.field-group > label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.field-group > label span {
  color: var(--dim);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit input {
  padding: 0 58px 0 13px;
}

.input-with-unit > span:last-child {
  position: absolute;
  right: 12px;
  color: var(--muted);
  font-size: 0.76rem;
  pointer-events: none;
}

.price-input input {
  padding-left: 60px;
}

.price-input .currency-select {
  position: absolute;
  left: 5px;
  z-index: 2;
  width: 48px;
  min-height: 35px;
  padding: 0 17px 0 10px;
  border: 0;
  border-radius: 9px;
  color: #dce6ef;
  background-color: transparent;
  background-position: calc(100% - 11px) 15px, calc(100% - 7px) 15px;
  font-size: 0.86rem;
  box-shadow: none;
}

.price-input .currency-select:hover,
.price-input .currency-select:focus {
  border: 0;
  background-color: rgba(119, 217, 255, 0.08);
  box-shadow: none;
}

.field-help {
  min-height: 34px;
  margin: 7px 2px 0;
  color: var(--dim);
  font-size: 0.68rem;
  line-height: 1.45;
}

.price-group {
  grid-column: 1 / -1;
}

.advanced-settings {
  margin-top: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(5, 13, 24, 0.36);
}

.advanced-settings summary {
  padding: 13px 14px;
  color: #c8d2dd;
  font-size: 0.78rem;
  font-weight: 720;
  cursor: pointer;
  list-style-position: inside;
}

.advanced-settings[open] summary {
  border-bottom: 1px solid var(--border);
}

.advanced-content {
  padding: 14px;
}

.advanced-content .field-help {
  min-height: 0;
}

.form-message {
  margin-top: 14px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 0.78rem;
  line-height: 1.45;
}

.error-message {
  color: #ffd1ca;
  border: 1px solid rgba(255, 125, 105, 0.35);
  background: rgba(255, 125, 105, 0.1);
}

.primary-button {
  width: 100%;
  min-height: 52px;
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 13px;
  color: #07120b;
  background: linear-gradient(135deg, var(--lime), #65d56c);
  box-shadow: 0 12px 28px rgba(84, 189, 84, 0.18);
  font-size: 0.9rem;
  font-weight: 850;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(84, 189, 84, 0.26);
  filter: brightness(1.04);
}

.primary-button:active {
  transform: translateY(0);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.78;
}

.primary-button svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-loader {
  width: 18px;
  height: 18px;
  display: none;
  border: 2px solid rgba(7, 18, 11, 0.28);
  border-top-color: #07120b;
  border-radius: 50%;
  animation: spin 720ms linear infinite;
}

.primary-button.loading .button-loader {
  display: block;
}

.primary-button.loading svg {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.route-card {
  min-width: 0;
}

.map-wrap {
  position: relative;
  min-height: 390px;
  margin: 12px;
  border: 1px solid var(--border);
  border-radius: 19px;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(255,255,255,0.018) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.018) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.018) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.018) 75%),
    #0b1726;
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #0b1726;
}

.map-overlay {
  position: absolute;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 30px;
  text-align: center;
  background: rgba(11, 23, 38, 0.9);
  backdrop-filter: blur(3px);
  pointer-events: none;
}

.map-overlay[hidden] {
  display: none;
}

.map-empty-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  margin-bottom: 7px;
  border: 1px solid rgba(119, 217, 255, 0.24);
  border-radius: 15px;
  color: var(--cyan);
  background: rgba(119, 217, 255, 0.08);
}

.map-empty-icon svg {
  width: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-overlay strong {
  font-size: 0.95rem;
}

.map-overlay > span:last-child {
  color: var(--muted);
  font-size: 0.78rem;
}

.distance-badge {
  position: absolute;
  z-index: 600;
  left: 14px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(8, 17, 31, 0.9);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
}

.map-click-status {
  position: absolute;
  z-index: 600;
  right: 14px;
  top: 14px;
  max-width: 230px;
  padding: 9px 12px;
  border: 1px solid rgba(119, 217, 255, 0.24);
  border-radius: 11px;
  color: #c8eeff;
  background: rgba(8, 17, 31, 0.9);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  font-size: 0.7rem;
  font-weight: 720;
  line-height: 1.35;
  pointer-events: none;
}

.leaflet-container {
  cursor: crosshair;
}

.distance-badge span {
  font-size: 0.92rem;
  font-weight: 850;
}

.distance-badge small {
  color: var(--muted);
  font-size: 0.66rem;
}

.leaflet-control-zoom a {
  color: #142238 !important;
}

.leaflet-control-attribution {
  font-size: 9px !important;
}

.route-marker {
  width: 18px;
  height: 18px;
  border: 3px solid #07111f;
  border-radius: 50%;
  box-shadow: 0 5px 12px rgba(0,0,0,.32);
}

.route-marker.start { background: var(--lime); }
.route-marker.end { background: var(--cyan); }

.results-panel {
  padding: 18px 24px 24px;
  border-top: 1px solid var(--border);
}

.result-heading .eyebrow {
  margin-bottom: 5px;
  font-size: 0.66rem;
}

.empty-result {
  min-height: 145px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 15px;
  color: var(--muted);
  text-align: center;
}

.empty-result p {
  max-width: 340px;
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
}

.empty-bars {
  height: 30px;
  display: flex;
  align-items: flex-end;
  gap: 7px;
}

.empty-bars span {
  width: 27px;
  border-radius: 5px 5px 2px 2px;
  background: var(--panel-soft);
}

.empty-bars span:nth-child(1) { height: 12px; }
.empty-bars span:nth-child(2) { height: 20px; }
.empty-bars span:nth-child(3) { height: 28px; }

.result-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.result-grid:not([hidden]) {
  display: grid;
}

.result-card {
  position: relative;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(6, 15, 27, 0.54);
  overflow: hidden;
}

.result-card::after {
  content: "";
  position: absolute;
  height: 3px;
  inset: auto 0 0;
  background: var(--card-color);
}

.result-card.clear { --card-color: var(--lime); }
.result-card.minor { --card-color: var(--amber); }
.result-card.major { --card-color: var(--red); }

.traffic-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #cbd5df;
  font-size: 0.71rem;
  font-weight: 750;
}

.traffic-label span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--card-color);
}

.result-card strong {
  display: block;
  margin-top: 17px;
  font-size: clamp(1.42rem, 2.3vw, 2rem);
  letter-spacing: -0.055em;
  white-space: nowrap;
}

.result-card p {
  margin: 5px 0 0;
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 750;
}

.result-card small {
  display: block;
  min-height: 31px;
  margin-top: 16px;
  color: var(--dim);
  font-size: 0.64rem;
  line-height: 1.45;
}

.method-note {
  margin-top: 13px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.method-note summary {
  width: fit-content;
  color: #c9d2dd;
  font-weight: 700;
  cursor: pointer;
}

.method-note p {
  margin: 9px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(5, 13, 24, 0.45);
  line-height: 1.55;
}

footer {
  width: min(1180px, calc(100% - 40px));
  min-height: 80px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  color: var(--dim);
  border-top: 1px solid var(--border);
  font-size: 0.68rem;
}

footer span {
  color: #cad4de;
  font-weight: 800;
}

footer p {
  margin: 0;
  text-align: center;
}

footer a {
  color: var(--muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--cyan);
}

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

  .map-wrap {
    min-height: 350px;
  }
}

@media (max-width: 620px) {
  .app-header,
  .app-shell,
  footer {
    width: min(100% - 24px, 1180px);
  }

  .app-header {
    min-height: 64px;
  }

  .app-shell {
    padding-top: 34px;
  }

  .intro {
    margin-bottom: 22px;
  }

  .intro h1 {
    font-size: clamp(2.25rem, 13vw, 3.4rem);
  }

  .intro > p:last-child {
    font-size: 0.92rem;
  }

  .planner-card {
    padding: 18px;
    border-radius: 21px;
  }

  .route-card {
    border-radius: 21px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .price-group {
    grid-column: auto;
  }

  .field-help {
    min-height: 0;
    margin-bottom: 6px;
  }

  .map-wrap {
    min-height: 300px;
    margin: 8px;
  }

  .results-panel {
    padding: 18px;
  }

  .result-heading {
    align-items: center;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 14px;
  }

  .result-card strong {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
  }

  .result-card p {
    grid-column: 1;
  }

  .result-card small {
    grid-column: 1 / -1;
    min-height: 0;
    margin-top: 11px;
  }

  footer {
    grid-template-columns: 1fr;
    gap: 7px;
    padding: 24px 0;
    text-align: center;
  }

  footer p {
    order: 3;
  }
}

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