:root {
  --ink: #1d1a3a;
  --muted: #6d6a85;
  --line: #ece8f3;
  --paper: #ffffff;
  --sand: #fff8ef;
  --coral: #ff5a4e;
  --mango: #ffb627;
  --teal: #12b5a6;
  --shadow: 0 10px 34px rgba(29, 26, 58, .18);
  --display: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--body); color: var(--ink); background: #cfe8ee; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .35; cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--mango); outline-offset: 2px; }

#map { position: fixed; inset: 0; z-index: 0; background: #cfe8ee; }
.leaflet-container { font-family: var(--body); }
.leaflet-control-zoom a { border-radius: 12px !important; color: var(--ink) !important; border: 0 !important; margin-bottom: 6px; box-shadow: var(--shadow); width: 38px !important; height: 38px !important; line-height: 38px !important; }
.leaflet-control-zoom { border: 0 !important; box-shadow: none !important; }

/* ---------- pins ---------- */
.pin-wrap { background: none; border: 0; }
.pin {
  width: 36px; height: 36px; margin: 2px auto 0;
  border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  background: #fff; border: 3px solid var(--c);
  box-shadow: 0 5px 12px rgba(29, 26, 58, .3);
  display: grid; place-items: center;
  transition: transform .18s ease;
}
.pin span { transform: rotate(45deg); font-size: 17px; line-height: 1; font-family: var(--display); font-weight: 800; }
.pin.on-route { border-width: 4px; }
.pin.in-trip { background: var(--c); }
.pin.in-trip span { color: #fff; font-size: 15px; }
.pin.active { transform: rotate(-45deg) scale(1.28); box-shadow: 0 0 0 5px rgba(255, 255, 255, .85), 0 8px 18px rgba(29, 26, 58, .4); }
.pin-wrap:hover .pin:not(.active) { transform: rotate(-45deg) scale(1.12); }
.pin-tip { background: var(--ink); color: #fff; border: 0; border-radius: 999px; padding: 4px 11px; font-weight: 700; font-size: 12.5px; box-shadow: none; }
.pin-tip::before { display: none; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; z-index: 500; top: 14px; left: 14px; right: 14px;
  display: flex; align-items: center; gap: 12px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 10px; background: var(--paper);
  padding: 8px 16px 8px 10px; border-radius: 999px; box-shadow: var(--shadow); flex: none;
}
.logo { width: 36px; height: 36px; display: grid; place-items: center; font-size: 19px; border-radius: 50%; background: linear-gradient(135deg, var(--mango), var(--coral)); }
.brand strong { display: block; font-family: var(--display); font-weight: 800; font-size: 18px; line-height: 1; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 11.5px; }
.chips { display: flex; gap: 6px; background: var(--paper); padding: 6px; border-radius: 999px; box-shadow: var(--shadow); overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { padding: 7px 13px; border-radius: 999px; font-weight: 700; font-size: 13.5px; white-space: nowrap; color: var(--muted); }
.chips button:hover { background: var(--sand); }
.chips button.on { background: var(--c, var(--ink)); color: #fff; }
.trip-pill {
  margin-left: auto; flex: none; background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 999px; box-shadow: var(--shadow); font-size: 14px; white-space: nowrap;
}
.trip-pill b { color: var(--mango); }

/* ---------- panels ---------- */
.panel {
  position: fixed; z-index: 600; top: 78px; bottom: 14px; width: 410px; max-width: calc(100vw - 28px);
  background: var(--paper); border-radius: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .32s cubic-bezier(.2, .8, .2, 1), opacity .2s;
  opacity: 0; pointer-events: none;
}
.panel.open { transform: none; opacity: 1; pointer-events: auto; }
.city-panel { left: 14px; transform: translateX(-112%); }
.trip-panel { right: 14px; width: 370px; transform: translateX(112%); }
.panel .body { flex: 1; overflow-y: auto; padding: 18px 20px 22px; }

.x {
  width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, .25); color: #fff;
  font-size: 15px; display: grid; place-items: center; flex: none;
}
.x:hover { background: rgba(255, 255, 255, .4); }
.x.dark { background: var(--sand); color: var(--ink); }

/* city hero */
.hero {
  position: relative; padding: 20px 20px 18px; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--c) 10%, color-mix(in srgb, var(--c) 45%, var(--mango)) 100%);
}
.hero .x { position: absolute; top: 12px; right: 12px; z-index: 2; width: 40px; height: 40px; font-size: 17px; background: rgba(29, 26, 58, .28); }
.hero .x:hover { background: rgba(29, 26, 58, .45); }
.hero-emoji { font-size: 44px; line-height: 1; margin-bottom: 10px; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .2)); }
.hero-meta { font-size: 13px; font-weight: 700; opacity: .95; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero h1 { font-family: var(--display); font-weight: 800; font-size: 31px; line-height: 1.05; letter-spacing: -.03em; margin: 6px 0 6px; padding-right: 30px; }
.hero p { margin: 0; font-size: 15px; font-weight: 500; opacity: .96; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.badge.yes { background: #fff; color: var(--ink); }
.badge.opt { background: rgba(255, 255, 255, .25); color: #fff; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tags span { background: var(--sand); border-radius: 999px; padding: 5px 11px; font-size: 12.5px; font-weight: 700; }
.note { background: #fff4d6; border-radius: 14px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; margin-bottom: 14px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--sand); border-radius: 16px; padding: 12px 8px 10px; text-align: center; }
.stat b { display: block; font-family: var(--display); font-weight: 800; font-size: 25px; letter-spacing: -.02em; line-height: 1; }
.stat small { display: block; font-size: 11.5px; font-weight: 700; margin-top: 5px; line-height: 1.2; }
.stat em { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-top: 3px; }
.source { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }
.source.warn { color: #b45309; font-weight: 700; }

.body h3 { font-family: var(--display); font-weight: 800; font-size: 17px; letter-spacing: -.01em; margin: 22px 0 7px; }
.body p { margin: 0; font-size: 15px; line-height: 1.6; }

.top5 { list-style: none; counter-reset: n; margin: 0; padding: 0; display: grid; gap: 7px; }
.top5 li { counter-increment: n; display: flex; gap: 11px; align-items: center; font-size: 14.5px; font-weight: 500; line-height: 1.35; }
.top5 li::before {
  content: counter(n); flex: none; width: 27px; height: 27px; border-radius: 50%;
  background: var(--ink); color: #fff; display: grid; place-items: center;
  font-family: var(--display); font-weight: 800; font-size: 13px;
}
.picks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.picks li { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 14.5px; padding: 8px 12px; background: var(--sand); border-radius: 12px; }
.picks b { background: var(--teal); color: #fff; border-radius: 8px; padding: 2px 8px; font-size: 13px; }

.foot { flex: none; display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--paper); }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--sand); border-radius: 999px; padding: 4px; flex: none; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; background: #fff; font-size: 18px; font-weight: 700; line-height: 1; box-shadow: 0 1px 3px rgba(29, 26, 58, .15); }
.stepper span { min-width: 68px; text-align: center; font-size: 14px; }
.stepper.sm button { width: 26px; height: 26px; font-size: 15px; }
.stepper.sm span { min-width: 30px; font-size: 13px; }
.btn {
  flex: 1; background: var(--c, var(--coral)); color: #fff; font-weight: 700; font-size: 15px;
  padding: 13px 14px; border-radius: 999px; transition: transform .12s, filter .12s;
}
.btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn.ghost { background: var(--sand); color: var(--ink); }

/* ---------- trip panel ---------- */
.trip-head { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 12px 20px; border-bottom: 1px solid var(--line); }
.trip-head h2 { font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: -.02em; margin: 0; }
.trip-head small { color: var(--muted); font-size: 12.5px; }
.trip-panel .body { padding: 14px 14px 10px; }
.empty { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.empty .big { font-size: 54px; }
.empty p { color: var(--muted); max-width: 260px; }
.empty .btn { flex: none; background: var(--ink); }

.seg { display: flex; background: var(--sand); border-radius: 999px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; padding: 8px; border-radius: 999px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(29, 26, 58, .15); }

.stop { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-radius: 14px; }
.stop:hover { background: #faf7ff; }
.num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: #fff; font-family: var(--display); font-weight: 800; font-size: 14px; }
.stop-name { flex: 1; min-width: 0; text-align: left; }
.stop-name b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-name small { display: block; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.moves { display: flex; flex: none; }
.moves button { width: 22px; height: 28px; color: var(--muted); font-size: 13px; border-radius: 6px; }
.moves button:hover:not(:disabled) { background: var(--line); color: var(--ink); }

.leg { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 6px 0 20px; padding: 5px 0 5px 20px; border-left: 2px dashed #cfc9e2; font-size: 12px; color: var(--muted); }
.leg label { flex: none; display: flex; align-items: center; gap: 2px; font-weight: 700; color: var(--ink); }
.leg input { width: 54px; font: inherit; font-weight: 700; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 3px 5px; background: #fff; }

.trip-actions { display: flex; justify-content: space-between; padding: 10px 6px 0; }
.link { font-size: 13px; font-weight: 700; color: var(--ink); padding: 6px 10px; border-radius: 999px; background: var(--sand); }
.link.danger { background: none; color: var(--muted); }
.link:hover:not(:disabled) { filter: brightness(.96); }

.summary { flex: none; padding: 14px 20px 16px; border-top: 1px solid var(--line); background: var(--sand); }
.country-days { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.country-days span { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #fff; border: 2px solid var(--c); }
.bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: #fff; margin-bottom: 10px; }
.bar i { display: block; height: 100%; }
.summary dl { margin: 0; display: grid; gap: 5px; }
.summary dl div { display: flex; justify-content: space-between; font-size: 14px; }
.summary dt { display: flex; align-items: center; gap: 8px; }
.summary dt i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.summary dd { margin: 0; font-weight: 700; }
.summary .total { border-top: 1px solid #eadfce; margin-top: 5px; padding-top: 8px; font-weight: 700; align-items: baseline; }
.summary .total dd { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -.02em; }
.summary > small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.4; }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 8px; top: 10px; left: 10px; right: 10px; }
  .brand small { display: none; }
  .brand { padding: 6px 14px 6px 6px; }
  .trip-pill { padding: 10px 14px; font-size: 13px; }
  .chips { order: 3; width: 100%; }
  .chips button span { display: none; }
  .chips button { flex: 1; }
  .panel { left: 0; right: 0; width: 100%; max-width: none; bottom: 0; border-radius: 22px 22px 0 0; }
  .city-panel { top: auto; height: 64vh; transform: translateY(105%); }
  .trip-panel { top: 60px; transform: translateY(105%); }
  .hero { padding: 16px 18px 14px; }
  .hero-emoji { font-size: 32px; margin-bottom: 6px; }
  .hero h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .panel, .pin, .btn { transition: none; }
}
