:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #66736d;
  --panel: #fffdf8;
  --paper: #f4f1eb;
  --line: rgba(23, 32, 29, 0.12);
  --green: #153f35;
  --green-soft: #e8eee9;
  --gold: #9d6b32;
  --gold-soft: #e7dccb;
  --red: #b84032;
  --shadow: 0 16px 36px rgba(18, 24, 21, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px 30px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

h1 {
  margin: 6px 0 0;
  font-size: 28px;
  line-height: 1.15;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.route-panel,
.route-options-panel,
.selected-panel {
  padding: 16px;
}

.route-panel,
.route-options-panel,
.selected-panel,
.results {
  grid-column: 1;
}

.map-shell {
  position: sticky;
  top: 12px;
  grid-column: 2;
  grid-row: 1 / span 4;
  padding: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

label span,
.filter-title,
.section-sub {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  height: 42px;
  margin-top: 6px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f5ef;
  color: var(--ink);
  outline: none;
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 63, 53, 0.12);
}

.toolbar,
.chips,
.dialog-actions,
.section-head,
.map-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar {
  justify-content: space-between;
  margin-top: 6px;
}

.point-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -2px 0 14px;
}

.point-summary {
  color: var(--muted);
  font-size: 13px;
}

.filter-block {
  margin-top: 14px;
}

.chips {
  flex-wrap: wrap;
  margin-top: 8px;
}

.primary,
.secondary,
.accent,
.ghost,
.chip,
.icon-button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.primary {
  background: var(--green);
  color: #fffdf8;
  font-weight: 800;
}

.accent {
  background: var(--gold);
  color: #fffdf8;
  font-weight: 800;
}

.secondary,
.ghost,
.chip,
.icon-button {
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
}

.chip.active {
  border-color: var(--green);
  background: var(--green);
  color: #fffdf8;
}

.icon-button {
  min-width: 62px;
}

.section-title {
  font-size: 17px;
  font-weight: 800;
}

.map-head {
  justify-content: space-between;
  margin-bottom: 10px;
}

.map-canvas {
  position: relative;
  height: 560px;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(rgba(23, 32, 29, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 29, 0.05) 1px, transparent 1px),
    #f8f5ef;
  background-size: 34px 34px;
}

.map-notice {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  border-radius: 8px;
  padding: 12px 14px;
  background: rgba(255, 253, 248, 0.94);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 10px 28px rgba(18, 24, 21, 0.12);
}

.amap-canvas,
.svg-map-layer {
  position: absolute;
  inset: 0;
}

.amap-canvas {
  z-index: 1;
  width: 100%;
  height: 100%;
  background: #edf1ee;
}

.svg-map-layer {
  z-index: 2;
  pointer-events: none;
}

.svg-map-layer.fallback {
  pointer-events: auto;
}

.map-canvas.has-amap {
  background: #edf1ee;
}

.map-canvas.has-amap .svg-map-layer {
  display: none;
}

.svg-map-layer svg {
  width: 100%;
  height: 100%;
  display: block;
}

.map-pin {
  position: absolute;
  max-width: 150px;
  transform: translate(-50%, -100%);
  border-radius: 999px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 253, 248, 0.55);
  color: #fffdf8;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  box-shadow: 0 8px 20px rgba(18, 24, 21, 0.16);
  cursor: pointer;
}

.map-pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 10px;
  height: 10px;
  transform: translateX(-50%) rotate(45deg);
  background: inherit;
}

.map-pin.red {
  background: var(--red);
}

.map-pin.green {
  background: var(--green);
}

.map-pin.gold {
  background: var(--gold);
}

.map-pin.active {
  outline: 3px solid rgba(21, 63, 53, 0.2);
  z-index: 5;
}

.amap-marker-shell {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  white-space: nowrap;
}

.amap-label {
  position: relative;
  border-radius: 999px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 253, 248, 0.55);
  color: #fffdf8;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  box-shadow: 0 8px 20px rgba(18, 24, 21, 0.16);
}

.amap-marker-dot {
  width: 8px;
  height: 8px;
  margin-top: -1px;
  border: 1px solid rgba(255, 253, 248, 0.72);
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(18, 24, 21, 0.18);
}

.amap-marker-shell.red .amap-label,
.amap-marker-shell.red .amap-marker-dot {
  background: var(--red);
}

.amap-marker-shell.green .amap-label,
.amap-marker-shell.green .amap-marker-dot {
  background: var(--green);
}

.amap-marker-shell.gold .amap-label,
.amap-marker-shell.gold .amap-marker-dot {
  background: var(--gold);
}

.route-options {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  margin-top: 10px;
}

.route-card-item {
  min-width: 170px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  cursor: pointer;
}

.route-card-item.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.route-title,
.station-name,
.selected-name {
  font-weight: 800;
}

.route-meta,
.station-meta,
.selected-address {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.selected-list,
.station-list {
  margin-top: 12px;
}

.selected-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #f4f1eb;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.station-card {
  padding: 16px;
}

.station-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21, 63, 53, 0.14), var(--shadow);
}

.station-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.tag-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.tag.provider {
  background: var(--green);
  color: #fffdf8;
}

.tag.band {
  background: var(--gold-soft);
}

.tag.precision {
  background: #edf1ee;
  color: var(--muted);
}

.tag.precision.amap {
  background: var(--green);
  color: #fffdf8;
}

.detour-pill {
  min-width: 62px;
  height: 44px;
  border-radius: 8px;
  background: var(--gold-soft);
  font-size: 18px;
  font-weight: 900;
  line-height: 44px;
  text-align: center;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.metric {
  min-height: 64px;
  padding: 8px;
  border-radius: 8px;
  background: #f4f1eb;
  text-align: center;
}

.metric strong {
  display: block;
  font-size: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.station-access {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-top: 10px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}

.station-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.station-actions button {
  flex: 1;
}

.empty {
  padding: 22px;
}

.empty-title {
  font-size: 17px;
  font-weight: 800;
}

.empty-text,
.empty-list {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 32px);
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  padding: 11px 14px;
  background: rgba(23, 32, 29, 0.94);
  color: #fffdf8;
  font-size: 14px;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.dialog {
  width: min(560px, calc(100% - 28px));
  border: 0;
  border-radius: 10px;
  padding: 0;
  background: transparent;
}

.dialog::backdrop {
  background: rgba(11, 15, 13, 0.42);
}

.dialog-card {
  padding: 18px;
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
}

.dialog-title {
  margin-bottom: 14px;
  font-size: 19px;
  font-weight: 900;
}

.dialog-content {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
}

.poi-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
  margin-top: 14px;
}

.poi-option {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f5ef;
  color: var(--ink);
  text-align: left;
}

.poi-option strong {
  display: block;
  font-size: 15px;
}

.poi-option span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 16px;
}

.dialog-actions.wrap {
  flex-wrap: wrap;
}

@media (max-width: 860px) {
  .app {
    padding-inline: 12px;
  }

  .layout {
    display: flex;
    flex-direction: column;
  }

  .map-shell,
  .route-panel,
  .route-options-panel,
  .selected-panel,
  .results {
    width: 100%;
  }

  .map-shell {
    position: static;
    order: 2;
  }

  .route-options-panel {
    order: 3;
  }

  .selected-panel {
    order: 4;
  }

  .results {
    order: 5;
  }

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

  .field-grid label:first-child {
    grid-column: 1 / -1;
  }

  .map-canvas {
    height: 430px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 24px;
  }

  .toolbar,
  .point-actions,
  .station-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .primary,
  .secondary,
  .accent,
  .ghost {
    width: 100%;
  }

  .metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .map-canvas {
    height: 390px;
  }
}
