:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --accent-soft: #fff4e6;
  --teal: #0d9488;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 55%, #334155 100%);
  padding: 26px 20px 22px;
  text-align: center;
  border-bottom: 3px solid var(--accent);
}

.hero-inner { max-width: 1080px; margin: 0 auto; }

.logo {
  margin: 0;
  font-size: 2.1rem;
  letter-spacing: -.03em;
  color: #fff;
  font-weight: 800;
}

.tagline {
  margin: 6px 0 0;
  color: #cbd5e1;
  font-size: .98rem;
}

.controls {
  max-width: 1080px;
  margin: -30px auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  position: relative;
  z-index: 10;
}

.grid-line {
  display: grid;
  gap: 14px;
}

.line-main {
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}

.line-opts {
  grid-template-columns: 1.5fr 1fr;
  align-items: start;
  margin-top: 14px;
  gap: 22px;
}

.field { position: relative; display: flex; flex-direction: column; gap: 6px; }

.field label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
}

.field input, .opts input[type="number"] {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: .95rem;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus, .opts input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .15);
}

.suggest {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 10px 10px;
  box-shadow: var(--shadow);
  max-height: 240px;
  overflow-y: auto;
  z-index: 40;
  display: none;
}

.suggest.open { display: block; }

.suggest div {
  padding: 9px 12px;
  font-size: .88rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}

.suggest div:last-child { border-bottom: none; }

.suggest div:hover, .suggest div.sel { background: var(--accent-soft); }

.btn-go {
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-weight: 700;
  font-size: .98rem;
  padding: 11px 20px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(234, 88, 12, .35);
  transition: transform .1s, box-shadow .15s, filter .15s;
  white-space: nowrap;
}

.btn-go:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-go:active { transform: translateY(0); }
.btn-go:disabled { opacity: .6; cursor: wait; }

.opts { border: none; margin: 0; padding: 0; }

.opts legend {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 8px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: .86rem;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
  color: var(--ink);
  background: #fff;
}

.chip input { display: none; }

.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 600;
}

.chip:hover { border-color: var(--accent); }

.num-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.num-row label { font-size: .86rem; color: var(--ink); }
.num-row label b { color: var(--accent-dark); }

.num-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.num-row.small { flex-direction: row; gap: 16px; margin-bottom: 0; }
.num-row.small > div { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.num-row.small label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.ckpt-box {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1.5px dashed var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ckpt-hint { font-size: .78rem; font-weight: 600; color: var(--accent-dark); }

.ckpt-strip { display: flex; flex-wrap: wrap; gap: 8px; }

.ckpt-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 5px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  font-size: .84rem;
  font-weight: 600;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.ckpt-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  color: #fff;
  font-size: .78rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-ckpt {
  border: none;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 700;
  font-size: .92rem;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(234, 88, 12, .35);
  transition: transform .1s, box-shadow .15s, filter .15s;
  align-self: flex-start;
}

.btn-ckpt:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn-ckpt:active { transform: translateY(0); }
.btn-ckpt:disabled { opacity: .6; cursor: wait; }

.summary {
  max-width: 1080px;
  margin: 14px auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: .92rem;
  position: relative;
  z-index: 5;
}

.summary .stat { display: flex; align-items: center; gap: 8px; }
.summary .stat b { color: var(--teal); }
.summary.hidden { display: none; }

.content {
  max-width: 1080px;
  margin: 14px auto 30px;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 14px;
  height: 72vh;
  min-height: 480px;
}

.map-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: #e8eef5;
}

#map { position: absolute; inset: 0; }
.map-wrap .leaflet-container { background: #e8eef5; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 500;
  text-align: center;
  padding: 0 20px;
}

.overlay.hidden { display: none; }

.overlay #overlayText { font-weight: 700; font-size: 1.02rem; }
.overlay-note { font-size: .8rem; color: var(--muted); max-width: 420px; }

.spinner {
  width: 46px; height: 46px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #b91c1c;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 600;
  max-width: 90%;
}

.toast.hidden { display: none; }

.legend {
  position: absolute;
  bottom: 14px;
  left: 14px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: .74rem;
  box-shadow: var(--shadow);
  z-index: 500;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 12px;
}

.legend.hidden { display: none; }
.legend div { display: flex; align-items: center; gap: 6px; }

.pin {
  width: 14px; height: 14px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: inline-block;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.weather {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}

.weather-title { font-size: .95rem; font-weight: 700; margin-bottom: 10px; }

.weather-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }

.wchip {
  flex: 0 0 auto;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 84px;
  font-size: .8rem;
}

.wchip .wh { font-size: 1.15rem; }
.wchip .wt { font-weight: 700; font-size: .86rem; }
.wchip .wn { color: var(--muted); font-size: .7rem; }

.stops {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.stops-title { font-weight: 700; font-size: .95rem; margin-bottom: 10px; }
.stops-title span { color: var(--muted); font-weight: 600; font-size: .78rem; }

.empty {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
  padding: 26px 6px;
  text-align: center;
}

.stop {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}

.stop:last-child { border-bottom: none; }
.stop:hover { background: #f8fafc; }

.stop .ico {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex: none;
}

.stop .meta { flex: 1; min-width: 0; }

.stop .name {
  font-weight: 650;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stop .sub { font-size: .76rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.stop .sub .cat { font-weight: 700; }

.stop a {
  font-size: .76rem;
  color: var(--teal);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.stop a:hover { text-decoration: underline; }

.stop .off {
  background: #fff7ed;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}

.stop.ckpt { align-items: flex-start; padding-top: 12px; padding-bottom: 12px; }

.num-badge {
  width: 30px; height: 30px;
  border-radius: 50%;
  flex: none;
  color: #fff;
  font-weight: 800;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
  margin-top: 2px;
}

.stop-name { display: block; font-size: .92rem; font-weight: 700; margin-top: 2px; }

.alt-row { padding: 4px 0 2px; }
.alt-row a { margin-left: 8px; }

.alt-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: var(--muted); margin-top: 8px; }

.ckpt-note {
  font-size: .82rem;
  color: var(--accent-dark);
  font-weight: 600;
  padding: 8px 4px 4px;
  border-top: 1px dashed var(--line);
  margin-top: 4px;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  padding: 22px 16px 30px;
}

footer a { color: var(--accent-dark); text-decoration: none; }
footer a:hover { text-decoration: underline; }

.c-food   { background: #fff0f0; } .c-food .ico-c  { color: #e11d48; }
.c-sights { background: #fff7ed; } .c-sights .ico-c { color: #ea580c; }
.c-scenic { background: #ecfeff; } .c-scenic .ico-c { color: #0891b2; }
.c-nature { background: #ecfdf5; } .c-nature .ico-c { color: #059669; }
.c-culture{ background: #f5f3ff; } .c-culture .ico-c{ color: #7c3aed; }
.c-fuel  { background: #fefce8; } .c-fuel .ico-c   { color: #a16207; }

.mark { text-shadow: 0 1px 2px rgba(0,0,0,.6); }

@media (max-width: 900px) {
  .line-main { grid-template-columns: 1fr; }
  .line-opts { grid-template-columns: 1fr; gap: 14px; }
  .content { grid-template-columns: 1fr; height: auto; }
  .map-wrap { height: 55vh; }
  .panel { height: auto; }
}