:root {
  --ink: #101A4D;
  --ink-2: #1C2766;
  --paper: #FFFFFF;
  --mist: #EEF1F7;
  --rule: #D5DAE6;
  --muted: #59627F;
  --d1: #D7261E;
  --d2: #0B7A3E;
  --d3: #7A3DA8;
  --d4: #E98300;
  --c: var(--d1);
  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tab-h: 64px;
  --days-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
}
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid #3D6BFF; outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); line-height: 1.05; margin: 0; }
.muted { color: var(--muted); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 28px) 22px 92px;
}
.hero-lines {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  height: 88px;
  fill: none;
  stroke-width: 7;
  stroke-linecap: round;
}
.hero-lines path { vector-effect: non-scaling-stroke; }
.hero-inner { position: relative; max-width: 1180px; margin: 0 auto; }
.hero h1 {
  font-size: clamp(3.6rem, 17vw, 7.5rem);
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: .88;
  margin: 4px 0 10px;
}
.hero-who { margin: 0; font-weight: 600; font-size: 1.05rem; color: #C9D0EE; }
.hero-dates { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.25rem; }
.hero-status {
  margin: 14px 0 0;
  max-width: 30ch;
  font-size: .98rem;
  color: #fff;
  min-height: 1.5em;
}
.hero-status strong { font-weight: 700; }

/* ---------- Day selector ---------- */
.days {
  position: sticky;
  top: 0;
  z-index: 500;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  height: var(--days-h);
}
.day-tab {
  position: relative;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 10px 4px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
}
.day-tab .n { font-family: var(--display); font-weight: 800; font-size: 1.15rem; line-height: 1; }
.day-tab .d { font-size: .8rem; font-weight: 600; }
.day-tab::after {
  content: "";
  position: absolute;
  left: 14%; right: 14%; bottom: 0;
  height: 6px;
  border-radius: 6px 6px 0 0;
  background: var(--tc);
  transform: scaleY(.34);
  transform-origin: bottom;
  transition: transform .2s ease;
}
.day-tab[aria-selected="true"] { color: var(--ink); }
.day-tab[aria-selected="true"]::after { transform: none; }
.day-tab .today {
  position: absolute; top: 7px; right: 18%;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--tc);
}

/* ---------- Layout ---------- */
body { background: var(--mist); }
.layout { max-width: 1180px; margin: 0 auto; }
.view { display: none; }
body.view-plan .view-plan,
body.view-map .view-map,
body.view-info .view-info { display: block; }
body.view-map .hero { display: none; }
.view-plan { padding: 16px 14px 8px; }

/* ---------- Cabecera del día: bloque de color ---------- */
.day-card {
  position: relative;
  overflow: hidden;
  background: var(--c);
  color: #fff;
  border-radius: 22px;
  padding: 18px 18px 16px;
}
.day-card::after {
  content: "";
  position: absolute;
  right: -34px; top: -34px;
  width: 128px; height: 128px;
  border: 16px solid rgba(255, 255, 255, .16);
  border-radius: 50%;
}
.day-date { margin: 0 0 6px; font-weight: 600; font-size: .92rem; opacity: .92; }
.day-card h2 { position: relative; font-size: clamp(1.6rem, 6.6vw, 2.2rem); font-weight: 800; letter-spacing: -.02em; max-width: 17ch; }
.day-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.dchip { background: rgba(255, 255, 255, .2); padding: 5px 11px; border-radius: 999px; font-size: .86rem; font-weight: 600; }
.day-note { margin: 12px 0 0; font-size: .92rem; line-height: 1.45; background: rgba(0, 0, 0, .16); padding: 9px 12px; border-radius: 12px; }

/* ---------- Timeline: el día como una línea de metro ---------- */
.timeline { list-style: none; margin: 18px 0 0; padding: 0; }
.timeline > li {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: 10px;
}
.timeline > li::before {
  content: "";
  position: absolute;
  left: 16px; top: 0; bottom: 0;
  width: 8px;
  background: var(--c);
}
.timeline > li:first-child::before { top: 26px; }
.timeline > li:last-child::before { bottom: calc(100% - 26px); }

.stop-dot {
  grid-column: 1;
  position: relative;
  z-index: 1;
  margin-top: 6px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid var(--c);
  display: grid; place-items: center;
  font: 800 1.02rem/1 var(--display);
  color: var(--ink);
}
.stop.logistics .stop-dot { border-color: var(--ink); font-size: 1rem; }
.stop.done .stop-dot { background: var(--c); color: #fff; }
.stop.done.logistics .stop-dot { background: var(--ink); }
.stop.next .stop-dot { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 60%, transparent); animation: ping 1.8s ease-out infinite; }
@keyframes ping { to { box-shadow: 0 0 0 14px transparent; } }

/* tarjeta de cada sitio */
.card {
  grid-column: 2;
  min-width: 0;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 26, 77, .06), 0 8px 24px rgba(16, 26, 77, .07);
}
.card-open { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 0; cursor: pointer; }
.card-img { display: block; aspect-ratio: 16 / 8; background: #DDE2EC; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { display: block; padding: 14px 16px 2px; }
.card-name {
  display: flex; align-items: baseline; gap: 8px;
  font-family: var(--display); font-weight: 700;
  font-size: 1.3rem; line-height: 1.15; letter-spacing: -.01em;
}
.card-emoji { font-size: 1.1rem; }
.card-desc { display: block; margin-top: 5px; color: #2E3760; font-size: .95rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { padding: 3px 10px; border-radius: 999px; background: var(--mist); font-size: .8rem; font-weight: 700; color: var(--ink); }
.chip-next { background: var(--c); color: #fff; }
.chip-book { background: #FFF2D6; color: #7A4B00; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 12px 16px; }
.card-more { border: 0; background: none; padding: 6px 0; color: #2D5BD7; font-weight: 700; cursor: pointer; font-size: .92rem; }

.check {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1.5px solid var(--rule); background: #fff;
  border-radius: 999px; padding: 7px 14px 7px 9px;
  font-weight: 700; font-size: .88rem; color: var(--ink);
  cursor: pointer;
}
.check-ico { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--rule); display: grid; place-items: center; }
.check-ico::after { content: ""; width: 5px; height: 9px; margin-top: -2px; border: solid transparent; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.check[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.check[aria-pressed="true"] .check-ico { border-color: #fff; background: #fff; }
.check[aria-pressed="true"] .check-ico::after { border-color: var(--c); }
.stop.done .card-img img { filter: grayscale(1); opacity: .55; }
.stop.done .card-name { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }

/* trámites (vuelo, consigna, Airbnb): tarjeta compacta y discreta */
.stop.logistics .card { background: #F8F9FC; box-shadow: none; border: 1.5px dashed #C3CADB; }
.stop.logistics .card-body { padding: 12px 14px 0; }
.stop.logistics .card-name { font-size: 1.05rem; }
.stop.logistics .card-desc { font-size: .9rem; }
.stop.logistics .card-foot { padding: 6px 10px 10px 14px; }
.stop.logistics .check { padding: 5px 12px 5px 7px; font-size: .82rem; }
.card-mini .card-body { padding: 12px 14px; }

/* tramos entre paradas */
.leg-body { grid-column: 2; padding: 10px 0 14px; min-width: 0; }
.leg-steps .s { min-width: 0; overflow-wrap: anywhere; }
.leg-chip {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px;
  border: 1.5px solid var(--rule);
  background: #fff;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: .88rem;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}
.leg-chip:hover { border-color: var(--muted); }
.leg-chip .mins { font-weight: 700; color: var(--ink); }
.leg-ico { font-size: 1rem; }
.leg-txt { color: var(--ink); }
.leg-more { color: #2D5BD7; font-weight: 700; margin-left: 2px; }
.leg-steps { margin: 10px 0 0; padding: 0; list-style: none; font-size: .9rem; color: #2E3760; }
.leg-steps > li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--mist); }
.leg-steps > li:first-child { border-top: 0; }
.leg-steps .t { font-size: 1rem; }
.leg-steps .d { color: var(--muted); white-space: nowrap; }
.leg-steps strong { font-weight: 700; color: var(--ink); }
.leg-steps details { margin-top: 6px; }
.leg-steps summary { cursor: pointer; color: #2D5BD7; font-weight: 600; font-size: .86rem; }
.walk-dirs { margin: 6px 0 2px; padding-left: 18px; font-size: .86rem; color: #2E3760; }
.walk-dirs li { padding: 2px 0; }
.maplink { display: inline-block; margin-top: 6px; font-size: .86rem; font-weight: 600; color: #2D5BD7; }

/* trayecto desplegado: panel blanco */
.leg-body.open {
  margin: 8px 0 14px;
  padding: 12px 14px 14px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(16, 26, 77, .06), 0 8px 24px rgba(16, 26, 77, .07);
}
.leg-body.open .leg-chip { border: 0; padding: 2px 0; border-radius: 0; }

/* las tres opciones: metro, bus, andando */
.opts {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  gap: 6px;
  margin: 10px 0 4px;
}
.opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  border: 1.5px solid var(--rule);
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  min-width: 0;
}
.opt-l { font-size: .84rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.opt-t { font-family: var(--display); font-weight: 700; font-size: 1.02rem; color: var(--ink); }
.opt[aria-pressed="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, #fff); }
.opt[aria-pressed="true"] .opt-l { color: var(--ink); }
.route-title { margin: 0 0 4px; font-weight: 700; }
.leg-note { margin: 8px 0 0; font-size: .86rem; color: var(--muted); }

.line-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: .76rem;
  font-weight: 700;
  color: #fff;
  background: var(--lc, var(--ink));
  white-space: nowrap;
}
.line-pill.walk { background: var(--mist); color: var(--ink); }

.add-btn {
  display: block;
  margin: 14px 0 26px 50px;
  padding: 14px 16px;
  border: 2px dashed #C3CADB;
  border-radius: 18px;
  background: rgba(255, 255, 255, .6);
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  width: calc(100% - 50px);
  text-align: left;
}
.add-btn::before { content: "+"; display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 10px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 800; }
.add-btn:hover { border-color: var(--c); background: #fff; }
.pin.logi { border-color: var(--ink); font-size: 13px; }
.pin.dim.logi { font-size: 0; }
.sheet-img { margin: 0 -22px 16px; }
.sheet-img img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.sheet-img figcaption { padding: 4px 22px 0; font-size: .75rem; color: var(--muted); }
.sheet-img figcaption a { color: inherit; }

/* ---------- Map ---------- */
.view-map { position: relative; }
.map {
  height: calc(100dvh - var(--days-h) - var(--tab-h) - var(--safe-b));
  min-height: 320px;
  background: var(--mist);
}
.map-tools {
  position: absolute; z-index: 450;
  right: 12px; bottom: 16px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.map-btn {
  border: 0; border-radius: 999px;
  padding: 11px 16px;
  background: var(--ink); color: #fff;
  font-weight: 700; font-size: .92rem;
  box-shadow: 0 2px 10px rgba(16, 26, 77, .25);
  cursor: pointer;
}
.map-btn.light { background: #fff; color: var(--ink); }
.pin {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; border: 5px solid var(--pc);
  font: 800 13px/1 var(--display);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}
.pin.dim { width: 22px; height: 22px; border-width: 4px; font-size: 0; opacity: .7; }
.pin.done { background: var(--pc); color: #fff; }
.pin.home { border-color: var(--ink); background: var(--ink); color: #fff; font-size: 14px; }
.me-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: #2D7CF6; border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(45,124,246,.25);
}
.leaflet-container { font-family: var(--body); }
.leaflet-tile-pane { filter: saturate(.45) brightness(1.04); }
.leaflet-popup-content { margin: 10px 12px; }
.popup-name { font-family: var(--display); font-weight: 700; font-size: 1.05rem; display: block; }
.popup-btn { margin-top: 6px; border: 0; background: var(--ink); color: #fff; padding: 6px 10px; border-radius: 8px; font-weight: 600; cursor: pointer; }

/* ---------- Info ---------- */
.info { padding: 26px 22px 30px; max-width: 680px; }
.info h2 { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 18px; }
.info-block { padding: 16px 18px; margin-bottom: 12px; background: #fff; border-radius: 18px; box-shadow: 0 1px 2px rgba(16, 26, 77, .06); }
.info-block h3 { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.info-block p { margin: 0 0 10px; }
.info-alert { border-top: 0; background: #FFF2D6; border-radius: 16px; padding: 18px; margin-bottom: 8px; }
.facts { margin: 0 0 10px; }
.facts div { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 4px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.tips { margin: 0; padding-left: 20px; }
.tips li { margin-bottom: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px;
  padding: 12px 16px;
  background: var(--ink); color: #fff;
  font-weight: 700; text-decoration: none; cursor: pointer;
  min-height: 46px;
}
.btn-small { padding: 9px 14px; min-height: 40px; font-size: .92rem; }
.btn-ghost { background: var(--mist); color: var(--ink); }
.btn-line { background: var(--c); }
.btn-danger { background: #FDE8E7; color: #A11A13; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; z-index: 900;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--ink);
}
.tabbar button {
  border: 0; background: none; cursor: pointer;
  color: #AEB6DA; font-weight: 700; font-size: 1rem;
  position: relative;
}
.tabbar button[aria-current="page"] { color: #fff; }
.tabbar button[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%;
  height: 4px; border-radius: 0 0 4px 4px; background: var(--c);
}

/* ---------- Sheet ---------- */
.sheet {
  border: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 640px;
  max-height: 88dvh;
  border-radius: 22px 22px 0 0;
  background: #fff;
  color: var(--ink);
  overflow: auto;
  overscroll-behavior: contain;
}
.sheet::backdrop { background: rgba(16, 26, 77, .45); }
.sheet[open] { animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(40px); opacity: .4; } }
.sheet-inner { padding: 10px 22px calc(26px + var(--safe-b)); }
.sheet-grab { width: 44px; height: 5px; border-radius: 5px; background: var(--rule); margin: 0 auto 14px; }
.sheet-close {
  position: sticky; top: 10px; float: right;
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: var(--mist); cursor: pointer; font-size: 1.3rem; line-height: 1;
  z-index: 2;
}
.sheet-band { height: 8px; border-radius: 8px; background: var(--c); width: 64px; margin-bottom: 14px; }
.sheet h2 { font-size: clamp(1.7rem, 7vw, 2.2rem); font-weight: 800; letter-spacing: -.02em; padding-right: 48px; }
.sheet .when { margin: 6px 0 14px; color: var(--muted); font-weight: 600; }
.sheet .lead { font-size: 1.08rem; margin: 10px 0 14px; }
.sheet .actions-end { border-top: 1px solid var(--mist); padding-top: 14px; }
.sheet p { margin: 0 0 12px; }
.sheet .tipbox { background: var(--mist); border-radius: 14px; padding: 12px 14px; margin: 0 0 12px; }
.sheet .tipbox strong { display: block; margin-bottom: 2px; }
.sheet .actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 8px; }
.sheet .actions .btn { flex: 1 1 auto; }
.route { margin: 14px 0; padding: 14px; border: 1px solid var(--rule); border-radius: 16px; }
.route[hidden] { display: none; }
.route-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.route-head .big { font-family: var(--display); font-weight: 800; font-size: 1.8rem; line-height: 1; }
.route ol { margin: 0; padding: 0; list-style: none; }
.route ol li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--mist); font-size: .94rem; }
.route ol li:first-child { border-top: 0; }
.route ol li .t { flex: none; width: 52px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* formulario */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field > span { font-weight: 600; font-size: .92rem; }
.field input, .field select, .field textarea {
  font: inherit; color: var(--ink);
  border: 1.5px solid var(--rule); border-radius: 12px;
  padding: 11px 12px; background: #fff; width: 100%;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--ink); }
.row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.row-2 { grid-template-columns: 76px 1fr; }
.results { list-style: none; margin: 0; padding: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--rule); }
.results:empty { display: none; }
.results button { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--mist); background: #fff; padding: 10px 12px; cursor: pointer; }
.results li:first-child button { border-top: 0; }
.results button:hover { background: var(--mist); }
.results small { color: var(--muted); display: block; }
.minimap { height: 220px; border-radius: 14px; overflow: hidden; border: 1px solid var(--rule); }
.hint { font-size: .85rem; color: var(--muted); margin: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 2000;
  left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px);
  transform: translate(-50%, 20px);
  max-width: min(92vw, 460px);
  background: var(--ink); color: #fff;
  padding: 12px 16px; border-radius: 14px;
  font-weight: 600; font-size: .92rem;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Desktop: plan a la izquierda, mapa fijo a la derecha ---------- */
@media (min-width: 960px) {
  :root { --tab-h: 0px; }
  body { padding-bottom: 0; }
  .hero { padding: 36px 32px 100px; }
  .days { grid-template-columns: repeat(4, 160px); justify-content: center; }
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 560px) minmax(0, 1fr);
    gap: 0;
    max-width: none;
  }
  .view-plan, .view-info { grid-column: 1; }
  body .view-map {
    display: block;
    grid-column: 2;
    grid-row: 1;
    position: sticky;
    top: var(--days-h);
    height: calc(100dvh - var(--days-h));
  }
  .map { height: 100%; }
  body.view-map .hero { display: block; }
  body.view-map .view-plan { display: block; }
  .tabbar {
    position: fixed; top: 14px; right: 18px; left: auto; bottom: auto;
    height: auto; width: auto; padding: 4px;
    grid-template-columns: auto auto;
    border-radius: 999px;
    background: rgba(255,255,255,.12);
  }
  .tabbar .tab-map { display: none; }
  .tabbar button { padding: 8px 18px; border-radius: 999px; }
  .tabbar button[aria-current="page"] { background: #fff; color: var(--ink); }
  .tabbar button[aria-current="page"]::before { display: none; }
  .sheet { margin: auto; border-radius: 22px; max-height: 86vh; }
  .toast { bottom: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
