:root {
  --paper: #f6f1e8;
  --card: #fffcf6;
  --ink: #1f1b17;
  --muted: #72695e;
  --line: #e6ddcf;
  --accent: #d2452b;
  --accent-soft: #f7ddd4;
  --indigo: #2c3e6b;
  --ok: #2f7d5b;
  --shadow: 0 1px 2px rgb(60 40 20 / .06), 0 8px 24px -12px rgb(60 40 20 / .18);
  --serif: 'Shippori Mincho B1', 'Hiragino Mincho ProN', Georgia, serif;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 16px;
  --gut: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #151311; --card: #1f1c19; --ink: #f2ece3; --muted: #a59c90; --line: #332e29;
    --accent: #ff6a4d; --accent-soft: #3a1f18; --indigo: #9db1ea; --ok: #5fc497;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px -14px rgb(0 0 0 / .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #151311; --card: #1f1c19; --ink: #f2ece3; --muted: #a59c90; --line: #332e29;
  --accent: #ff6a4d; --accent-soft: #3a1f18; --indigo: #9db1ea; --ok: #5fc497;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 10px 30px -14px rgb(0 0 0 / .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
main { max-width: 680px; margin: 0 auto; padding: 0 var(--gut) calc(32px + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--serif); font-weight: 800; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 1.45rem; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; margin-bottom: 14px; }
h2 small { font: 500 .8rem var(--sans); color: var(--muted); letter-spacing: 0; }
small { color: var(--muted); }
a { color: var(--indigo); }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.lede { color: var(--muted); margin: -6px 0 14px; }
.block { margin-top: 40px; }

/* ---------- header (compacto: la foto tiene que entrar entera sin scroll) */
.top { padding: calc(12px + env(safe-area-inset-top)) 0 12px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kicker { display: flex; align-items: center; gap: 7px; margin: 0; font-size: .7rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.sun { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.clocks { display: flex; gap: 10px; margin: 0; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.clocks b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
h1 { display: flex; align-items: baseline; gap: 8px; line-height: 1; margin-top: 10px; }
h1 .dn { font-size: 2.1rem; }
h1 .of { font: 500 .95rem var(--sans); color: var(--muted); }
.daytitle { font-family: var(--serif); font-weight: 600; font-size: 1.02rem; margin: 4px 0 0; text-wrap: balance; }
.segs { display: grid; grid-template-columns: repeat(23, 1fr); gap: 3px; margin-top: 10px; }
.segs i { height: 4px; border-radius: 2px; background: var(--line); }
.segs i.done { background: var(--accent); opacity: .55; }
.segs i.now { background: var(--accent); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- ahora */
.now:empty { display: none; }
.now {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center;
}
.now .ico { grid-row: span 2; font-size: 1.6rem; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); }
.now .t { font-weight: 600; }
.now .s { color: var(--muted); font-size: .88rem; }
.now .prog { grid-column: 1 / -1; margin-top: 10px; }
.prog-bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.prog-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.prog-ends { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.now .live { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; margin-right: 6px; animation: pulse 1.6s infinite; vertical-align: middle; }

/* ---------- fotos del dia: entera (contain) y con el epigrafe en la primera pantalla */
.hero { margin: 4px calc(-1 * var(--gut)) 0; --photo-max: calc(100svh - 205px); }
#ayer { margin-top: 32px; }
.now { margin-top: 18px; }
.hero-label { margin: 0 var(--gut) 8px; font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.car-wrap { position: relative; }
.car { display: flex; align-items: flex-start; overflow-x: auto; overflow-y: hidden; transition: height .25s ease; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.car::-webkit-scrollbar { display: none; }
.slide { flex: 0 0 100%; scroll-snap-align: center; margin: 0; }
.ph { display: block; width: 100%; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.slide .ph img { display: block; width: 100%; height: auto; max-height: max(260px, var(--photo-max)); object-fit: contain; margin: 0 auto; }
.slide figcaption { padding: 8px var(--gut) 0; display: flex; flex-direction: column; gap: 1px; font-size: .8rem; color: var(--muted); }
.slide figcaption .cap { color: var(--ink); font-family: var(--serif); font-weight: 600; font-size: 1.08rem; line-height: 1.3; }
.car-count { position: absolute; top: 10px; right: 10px; background: rgb(0 0 0 / .55); color: #fff; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 99px; pointer-events: none; font-variant-numeric: tabular-nums; }
.car-nav { display: none; }
@media (hover: hover) and (pointer: fine) {
  .car-nav { display: grid; place-items: center; position: absolute; top: calc(50% - 40px); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgb(0 0 0 / .5); color: #fff; font-size: 1.7rem; line-height: 1; padding-bottom: 3px; cursor: pointer; opacity: .75; transition: opacity .15s, background .15s; }
  .car-nav:hover { opacity: 1; background: rgb(0 0 0 / .7); }
  .car-nav.prev { left: 10px; } .car-nav.next { right: 10px; }
  .car-nav[hidden] { display: none; }
}
.hero.empty { margin: 8px 0 0; }
.hero-empty { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 22px 20px; text-align: center; color: var(--muted); }
.hero-empty .big { font-size: 1.6rem; display: block; margin-bottom: 4px; }
.hero-empty p { margin: 0; }
@media (min-width: 720px) {
  .hero { margin: 8px 0 0; }
  .hero-label { margin-left: 2px; }
  .slide .ph img { border-radius: var(--r); width: auto; max-width: 100%; }
  .slide figcaption { padding: 8px 2px 0; align-items: center; text-align: center; }
}

/* ---------- vuelos */
.flights { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.flight { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.fl-top { display: flex; align-items: baseline; gap: 8px; }
.fl-top .code { font-size: 1.02rem; }
.fl-top .op { font-size: .78rem; }
.chip { margin-left: auto; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 3px 8px; border-radius: 99px; background: var(--line); color: var(--muted); white-space: nowrap; }
.chip.air { background: var(--accent); color: #fff; }
.chip.soon { background: var(--accent-soft); color: var(--accent); }
.chip.done { background: transparent; color: var(--ok); padding-right: 0; }
.fl-route { display: grid; grid-template-columns: 1fr minmax(60px, 1.2fr) 1fr; gap: 8px; align-items: center; margin: 12px 0 8px; }
.ap { display: flex; flex-direction: column; min-width: 0; }
.ap.to { text-align: right; }
.ap b { font: 800 1.5rem var(--serif); line-height: 1.1; }
.ap span { font-size: .8rem; color: var(--muted); line-height: 1.25; }
.ap time { font-size: .76rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.ap time b { display: block; font: 600 1.05rem var(--sans); color: var(--ink); font-variant-numeric: tabular-nums; }
.fl-line { position: relative; height: 20px; }
.fl-line .bar { position: absolute; left: 0; right: 0; top: 9px; height: 2px; background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 10px); }
.fl-line .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); }
.fl-line .plane { position: absolute; top: -1px; left: 0; transform: translateX(-50%); color: var(--muted); font-size: 1rem; line-height: 20px; transition: left .6s; }
.flight.air .plane { color: var(--accent); }
.flight.done .fill { width: 100%; background: var(--ok); opacity: .6; }
.flight.done .plane { left: 100% !important; color: var(--ok); }
.fa { font-size: .8rem; text-decoration: none; }

/* ---------- mapa */
.map { height: 340px; border-radius: var(--r); overflow: hidden; background: var(--line); border: 1px solid var(--line); isolation: isolate; }
@media (max-width: 480px) { .map { height: 300px; margin: 0 calc(-1 * var(--gut)); border-radius: 0; border-left: 0; border-right: 0; } }
.stops { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.stops li { display: grid; grid-template-columns: 26px auto 1fr; gap: 10px; align-items: baseline; }
.stops small { font-size: .82rem; }
.stops .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 600; background: var(--line); color: var(--muted); align-self: center; }
.stops li.here .n { background: var(--accent); color: #fff; }
.stops li.done .n { background: var(--ink); color: var(--paper); opacity: .5; }
.pin { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 600 12px var(--sans); background: var(--card); color: var(--ink); border: 2px solid var(--ink); box-shadow: var(--shadow); }
.pin.here { background: var(--accent); border-color: #fff; color: #fff; }
.me { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 0 var(--accent); animation: ring 2s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgb(210 69 43 / .5); } 100% { box-shadow: 0 0 0 18px rgb(210 69 43 / 0); } }
.leaflet-container { font: 13px var(--sans); background: var(--line); }
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.85) saturate(.6); }
.leaflet-tile-pane { filter: saturate(.75); }
.leaflet-control-attribution { font-size: 10px; }

.plane-ico { font-size: 22px; line-height: 1; filter: drop-shadow(0 1px 2px rgb(0 0 0 / .4)); }
.ap-pin { width: 12px; height: 12px; border-radius: 50%; background: var(--card); border: 2.5px solid var(--ink); }
.ap-pin.here { background: var(--accent); border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.stops[hidden] { display: none; }
.leaflet-tooltip.ap-lbl { background: none; border: 0; box-shadow: none; font: 700 11px var(--sans); color: var(--ink); text-shadow: 0 0 3px var(--paper), 0 0 3px var(--paper); padding: 0; }
.leaflet-tooltip.ap-lbl::before { display: none; }

footer { margin-top: 48px; text-align: center; font-size: .78rem; color: var(--muted); }

/* ---------- lightbox */
.lb { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: rgb(8 7 6 / .96); color: #fff; }
.lb[open] { display: grid; grid-template-columns: 1fr; place-items: center; }
.lb::backdrop { background: rgb(0 0 0 / .8); }
.lb figure { margin: 0; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 56px 0 calc(16px + env(safe-area-inset-bottom)); touch-action: pan-y; }
.lb img { max-width: 100%; max-height: calc(100dvh - 140px); object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lb figcaption { padding: 12px 20px 0; text-align: center; font-size: .9rem; color: #d9d2c8; max-width: 640px; }
.lb figcaption b { font-family: var(--serif); font-size: 1.05rem; color: #fff; display: block; }
.lb-x { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 10px; background: rgb(255 255 255 / .12); border: 0; color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; z-index: 2; }
.lb-nav { position: fixed; top: 50%; transform: translateY(-50%); background: rgb(255 255 255 / .1); border: 0; color: #fff; width: 44px; height: 64px; font-size: 2rem; cursor: pointer; z-index: 2; border-radius: 12px; }
.lb-nav.prev { left: 8px; } .lb-nav.next { right: 8px; }
.lb-nav[hidden] { display: none; }
@media (hover: none) { .lb-nav { background: transparent; opacity: .6; } }

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