/* ───────── Tokens ───────── */
:root {
  --bg: #F4EBDD;          /* arena */
  --surface: #FBF6EE;
  --surface-2: #EFE3D1;
  --ink: #2A1D17;
  --muted: #6E5A4C;
  --line: #E0CFB8;
  --accent: #B4492A;      /* terracota */
  --accent-ink: #FFF8EF;
  --wine: #6E1D33;        /* vino tinto */
  --route: #B4492A;
  --route-casing: #4A1322;
  --shadow: 0 1px 2px rgb(42 29 23 / .06), 0 6px 20px rgb(42 29 23 / .08);
  --radius: 14px;
  --tiles-filter: sepia(.18) saturate(.9) contrast(.98);
  --map-h: 50svh;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1512;
    --surface: #251B17;
    --surface-2: #2F231E;
    --ink: #F1E6D6;
    --muted: #B3A08D;
    --line: #3D2E27;
    --accent: #E07A52;
    --accent-ink: #1C1512;
    --wine: #D06A82;
    --route: #F08A5D;
    --route-casing: #12090A;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35);
    --tiles-filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) sepia(.25) saturate(.7);
    color-scheme: dark;
  }
}

/* ───────── Base ───────── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.5 "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; font-weight: 700; line-height: 1.1; margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ───────── Layout (mobile-first) ───────── */
.map-pane {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--map-h);
  background: var(--surface-2);
  box-shadow: 0 2px 0 var(--line);
}
#map { position: absolute; inset: 0; background: var(--surface-2); }
/* Móvil: el mapa sigue al scroll (js/app.js); solo se anima al mostrarlo por tocar algo */
@media (max-width: 899px) {
  .map-pane { will-change: transform; }
  .map-pane.is-settling { transition: transform .22s cubic-bezier(.2, .7, .3, 1); }
}
@media (max-width: 899px) and (prefers-reduced-motion: reduce) { .map-pane.is-settling { transition: none; } }

.content {
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  :root { --map-h: 100vh; }
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(400px, 34rem);
    min-height: 100vh;
  }
  .map-pane { box-shadow: 2px 0 0 var(--line); }
  .content {
    max-width: none;
    margin: 0;
    padding: 40px 32px 48px;
    height: 100vh;
    overflow-y: auto;
  }
}

/* ───────── Map buttons (solo ícono) ───────── */
.map-tools {
  position: absolute;
  right: 10px;
  bottom: 28px;
  z-index: 500;
  display: grid;
  gap: 8px;
}
.map-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}
.map-btn svg { width: 22px; height: 22px; }
.map-btn:active { transform: scale(.94); }
.map-btn[aria-pressed="true"] { color: #1A73E8; }
@media (prefers-color-scheme: dark) { .map-btn[aria-pressed="true"] { color: #8AB4F8; } }
.map-btn.is-loading svg { animation: locate-blink 1s ease-in-out infinite; }
@keyframes locate-blink { 50% { opacity: .35; } }

/* Punto azul de "estás aquí" */
.me-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #1A73E8;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  position: relative;
}
.me-dot::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(26, 115, 232, .5);
  animation: me-pulse 2s ease-out infinite;
}
@keyframes me-pulse { to { box-shadow: 0 0 0 16px rgba(26, 115, 232, 0); } }
@media (prefers-reduced-motion: reduce) { .me-dot::after, .map-btn.is-loading svg { animation: none; } }

/* ───────── Hero ───────── */
.hero { margin-bottom: 32px; }
.kicker {
  margin: 0 0 8px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
}
.hero h1 { font-size: clamp(2.25rem, 9vw, 3.25rem); letter-spacing: -.01em; }
.subtitle { margin: 6px 0 0; font-family: "Fraunces", Georgia, serif; font-size: 1.25rem; color: var(--wine); }
.dates { margin: 4px 0 0; color: var(--muted); }
.trip-line { margin: 14px 0 0; font-size: .9375rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin: 20px 0 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
}
.stats div { background: var(--surface); padding: 10px 12px; }
.stats dt { font-size: .75rem; color: var(--muted); }
.stats dd { margin: 0; font-family: "Fraunces", Georgia, serif; font-size: clamp(1.125rem, 5vw, 1.375rem); font-weight: 700; white-space: nowrap; }

/* ───────── Day nav ───────── */
.day-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 -16px 20px;
  padding: 2px 16px 6px;
  scrollbar-width: none;
}
.day-nav::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .day-nav { flex-wrap: wrap; margin: 0 0 24px; padding: 0; overflow: visible; } }
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--day); }
.chip[aria-current="true"] { border-color: var(--day); box-shadow: inset 0 0 0 1px var(--day); }

/* ───────── Days ───────── */
.days { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.day {
  --day: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  scroll-margin-top: calc(var(--map-h) + 12px);
}
@media (min-width: 900px) { .day { scroll-margin-top: 16px; } }
.day-heading { font: inherit; }
.day-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 2px 12px;
  width: 100%;
  padding: 14px 16px 12px;
  border: 0;
  text-align: left;
  cursor: pointer;
  border-top: 3px solid var(--day);
  background: transparent;
}
.day-label {
  grid-row: span 2;
  align-self: center;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: .9375rem;
  color: var(--day);
  min-width: 4.2em;
  line-height: 1.15;
}
@media (prefers-color-scheme: dark) { .day-label { color: color-mix(in srgb, var(--day) 55%, white); } }
.day-title { font-family: "Fraunces", Georgia, serif; font-weight: 700; font-size: 1.1875rem; line-height: 1.15; }
.day-head .day-summary { grid-column: 2; }
.day-chevron {
  grid-column: 3; grid-row: 1 / span 2; align-self: center;
  width: 10px; height: 10px; margin: 0 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .2s ease;
}
.day-head[aria-expanded="true"] .day-chevron { transform: rotate(-135deg) translate(-2px, -2px); }
.day-head:hover { background-color: color-mix(in srgb, var(--day) 6%, transparent); }
.day-body { padding-top: 4px; }
@media (prefers-reduced-motion: reduce) { .day-chevron { transition: none; } }
.day-drive { font-size: .8125rem; color: var(--muted); }
.today-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--day);
  color: #fff;
  font: 600 .6875rem/1.6 "Work Sans", sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.stops { list-style: none; margin: 0; padding: 4px 0 6px; }
.stop-btn {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  position: relative;
  scroll-margin-top: calc(var(--map-h) + 12px);
}
@media (min-width: 900px) { .stop-btn { scroll-margin-top: 16px; } }
.stops li + li .stop-btn::before {
  content: "";
  position: absolute;
  left: 32px;
  top: -12px;
  height: 24px;
  border-left: 2px dotted color-mix(in srgb, var(--day) 55%, transparent);
}
.stop-btn:hover { background: color-mix(in srgb, var(--day) 6%, transparent); }
.stop-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--day) 13%, transparent); }
.stop-btn[aria-pressed="true"] .stop-num { box-shadow: 0 0 0 3px color-mix(in srgb, var(--day) 35%, transparent); }

.stop-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--day);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: .9375rem;
  position: relative;
  z-index: 1;
}
.stop-name { display: block; font-weight: 600; line-height: 1.3; }
.stop-meta { display: block; margin-top: 2px; font-size: .875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.stop-notes { display: block; margin-top: 4px; font-size: .9375rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}
.tag.alert { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

.foot { margin-top: 32px; font-size: .75rem; color: var(--muted); text-align: center; }

.error {
  position: fixed;
  left: 16px; right: 16px; bottom: 16px;
  z-index: 2000;
  margin: 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--wine);
  color: #fff;
  box-shadow: var(--shadow);
}

/* ───────── Leaflet overrides ───────── */
.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-tile-pane { filter: var(--tiles-filter); }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--muted); }
.leaflet-control-attribution a { color: var(--muted); }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--surface-2); }

.marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--day);
  color: #fff;
  border: 2px solid #FFF8EF;
  display: grid;
  place-items: center;
  font: 600 13px/1 "Work Sans", sans-serif;
  box-shadow: 0 2px 6px rgb(0 0 0 / .35);
  transition: transform .15s ease;
}
.marker.is-active { transform: scale(1.3); }
/* hover en el itinerario (js/app.js → highlightPlace) */
.marker.is-hover { transform: scale(1.35); box-shadow: 0 0 0 4px color-mix(in srgb, var(--day) 40%, transparent), 0 2px 8px rgb(0 0 0 / .4); }
.marker--added.is-hover { transform: rotate(45deg) scale(1.35); }

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.leaflet-popup-content-wrapper { border-radius: var(--radius); }
.leaflet-popup-content { margin: 14px 16px; min-width: 210px; font-size: .9375rem; line-height: 1.45; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); width: 32px; height: 32px; font-size: 22px; }
.popup-date { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.popup-title { font-family: "Fraunces", Georgia, serif; font-size: 1.125rem; font-weight: 700; margin: 2px 24px 6px 0; line-height: 1.2; }
.popup-row { margin: 0 0 4px; }
.popup-row b { font-weight: 600; }
.gmaps-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 10px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink) !important;
  text-decoration: none;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .marker, .map-btn { transition: none; }
}

.popup { border-left: 4px solid var(--day); padding-left: 10px; }
.popup .popup-date { color: var(--day); }
@media (prefers-color-scheme: dark) { .popup .popup-date { color: color-mix(in srgb, var(--day) 55%, white); } }

/* ═════════ Lugares agregados, detalle y edición ═════════ */

/* Fila: botón principal + botón de detalle */
.stop { display: grid; grid-template-columns: 1fr auto; align-items: stretch; }
.stop-text { display: block; min-width: 0; }
.stop-plan {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 4px;
  font-size: .9375rem;
}
.stop-notes { color: var(--muted); font-size: .875rem; }
.detail-btn {
  width: 40px;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--muted) 70%, transparent);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.detail-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--day) 6%, transparent); }
.stop-num--added { background: var(--surface); border: 3px solid var(--day); }
.stop-num--added span { width: 10px; height: 10px; transform: rotate(45deg); background: var(--day); border-radius: 2px; }

.marker--added {
  width: 24px; height: 24px;
  margin: 3px;
  border-radius: 6px;
  transform: rotate(45deg);
  background: #FFF8EF;
  border: 3px solid var(--day);
}
.marker--added span { width: 8px; height: 8px; border-radius: 2px; background: var(--day); }
.marker--added.is-active { transform: rotate(45deg) scale(1.3); }

.popup-plan { margin-top: 6px; }
.popup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.popup-actions .gmaps-btn { margin-top: 0; }
.popup-btn {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.banner {
  margin: 0 0 20px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px dashed var(--line);
  font-size: .875rem;
  color: var(--muted);
}

/* Botón flotante */
.fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 1rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / .25);
  cursor: pointer;
}
.fab span { font-size: 1.5rem; line-height: 1; }
.fab:active { transform: scale(.97); }
@media (min-width: 900px) { .fab { right: 32px; bottom: 28px; } }
.content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* Botones y campos */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: .9375rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: #B3261E; border-color: color-mix(in srgb, #B3261E 40%, transparent); }
@media (prefers-color-scheme: dark) { .btn-danger { color: #F2B8B5; border-color: #8C1D18; } }

input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 1rem; /* evita zoom en iOS */
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-weight: 600; font-size: .9375rem; }
.field small { font-weight: 400; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
.field-group { border: 0; padding: 0; margin: 0 0 16px; }
.field-group legend { font-weight: 600; font-size: .9375rem; padding: 0; margin-bottom: 6px; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.hint { margin: 6px 0 10px; font-size: .8125rem; color: var(--muted); }
.loc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pick-map { height: 230px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.results { list-style: none; margin: 0 0 10px; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.results li + li { border-top: 1px solid var(--line); }
.results li.muted { padding: 12px; }
.results button {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}
.results button:hover { background: var(--surface-2); }
.results span { font-size: .8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-hint {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 4px solid var(--day);
  background: color-mix(in srgb, var(--day) 10%, var(--surface));
  font-size: .9375rem;
}
.day-hint .warn { color: var(--accent); font-weight: 600; }
.form-error { margin: 4px 0 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, #B3261E 12%, transparent); color: inherit; font-size: .9375rem; }

/* Hojas (dialog): bottom sheet en móvil, modal en desktop */
html:has(dialog[open]) { overflow: hidden; }
dialog.sheet {
  --day: var(--accent);
  width: 100%;
  max-width: 100%;
  max-height: 94svh;
  margin: auto 0 0;
  padding: 0;
  border: 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 -8px 40px rgb(0 0 0 / .3);
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
dialog.sheet::backdrop { background: rgb(20 10 8 / .55); }
@media (min-width: 700px) {
  dialog.sheet { max-width: 640px; max-height: 90vh; margin: auto; border-radius: 20px; }
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px 12px 20px;
  border-top: 6px solid var(--day);
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 1.5rem; }
.sheet-kicker { margin: 0 0 4px; font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--day); }
@media (prefers-color-scheme: dark) { .sheet-kicker { color: color-mix(in srgb, var(--day) 55%, white); } }
.icon-btn {
  flex: none;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 20px; overscroll-behavior: contain; }
.sheet-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.sheet-foot .btn-primary { margin-left: auto; min-width: 140px; }

/* Detalle */
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.detail-plan h3, .media-block h3 { font-family: "Fraunces", Georgia, serif; font-size: 1.125rem; margin: 0 0 6px; }
.detail-plan p { margin: 0; white-space: pre-wrap; font-size: 1.0625rem; }
.detail-info { display: grid; gap: 8px; margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.detail-info dt { font-size: .75rem; color: var(--muted); }
.detail-info dd { margin: 0; }
.media-block { margin-top: 22px; }
.media-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.link-out { font-size: .875rem; font-weight: 600; color: var(--accent); text-decoration: none; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.media-add .search-row { margin-top: 4px; }

.tt-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.tt-card { position: relative; flex: none; width: 220px; scroll-snap-align: start; }
.tt-poster, .tt-frame {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 9 / 16;
  border: 0;
  border-radius: 12px;
  background: #111 center / cover no-repeat;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
}
.tt-play { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: rgb(0 0 0 / .55); font-size: 1.4rem; padding-left: 4px; }
.tt-meta { display: grid; gap: 2px; margin-top: 6px; font-size: .8125rem; }
.tt-meta span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.tt-meta a { color: var(--accent); font-weight: 600; text-decoration: none; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.photo { position: relative; margin: 0; }
.photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.photo figcaption { margin-top: 3px; font-size: .6875rem; color: var(--muted); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo.broken img { visibility: hidden; }
.photo.broken::after { content: "No se pudo cargar"; position: absolute; inset: 0 0 auto; aspect-ratio: 4/3; display: grid; place-items: center; font-size: .75rem; color: var(--muted); }
.photo-save {
  position: absolute;
  right: 6px; top: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgb(0 0 0 / .62);
  color: #fff;
  font-size: .8125rem;
  font-weight: 600;
  cursor: pointer;
}
.photo-save:disabled { background: color-mix(in srgb, var(--accent) 85%, black); cursor: default; }
.media-del {
  position: absolute;
  right: 6px; top: 6px;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / .62);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.link-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.link-list li { position: relative; padding: 10px 44px 10px 12px; border-radius: 10px; background: var(--surface-2); }
.link-list a { color: var(--accent); font-weight: 600; text-decoration: none; }
.link-list .media-del { top: 50%; transform: translateY(-50%); }

.toast {
  position: fixed;
  inset: auto auto calc(84px + env(safe-area-inset-bottom)) 50%;
  margin: 0;
  border: 0;
  transform: translateX(-50%);
  z-index: 3000;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: .9375rem;
  box-shadow: var(--shadow);
}

@media (min-width: 480px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.legend { margin: 10px 0 0; font-size: .8125rem; color: var(--muted); }

/* ═════════ Timeline por día ═════════ */
.day-summary { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8125rem; color: var(--muted); }
.day-summary span { display: inline-flex; align-items: center; gap: 5px; }
.day-summary i { display: inline-flex; width: 16px; height: 16px; color: var(--day); }
@media (prefers-color-scheme: dark) { .day-summary i { color: color-mix(in srgb, var(--day) 55%, white); } }
.day-summary svg { width: 100%; height: 100%; }
.day-notes { margin: 0 16px 4px; padding-left: 12px; border-left: 2px solid color-mix(in srgb, var(--day) 35%, transparent); font-size: .875rem; color: var(--muted); }
.day-notes p { margin: 0 0 4px; }
.day-notes b { color: var(--ink); font-weight: 600; }

.timeline { list-style: none; margin: 0; padding: 6px 0 8px; }
.tl { display: grid; grid-template-columns: 1fr auto; position: relative; }
.tl-main {
  display: grid;
  grid-template-columns: 46px 34px 1fr;
  gap: 10px;
  width: 100%;
  padding: 10px 6px 10px 12px;
  border: 0;
  background: transparent;
  text-align: left;
  position: relative;
  scroll-margin-top: calc(var(--map-h) + 12px);
}
@media (min-width: 900px) { .tl-main { scroll-margin-top: 16px; } }
button.tl-main { cursor: pointer; }
button.tl-main:hover { background: color-mix(in srgb, var(--day) 6%, transparent); }
.tl-main[aria-pressed="true"] { background: color-mix(in srgb, var(--day) 13%, transparent); }
.tl-main[aria-pressed="true"] .stop-num { box-shadow: 0 0 0 3px color-mix(in srgb, var(--day) 35%, transparent); }
/* línea vertical que une el día */
.tl-main::before {
  content: "";
  position: absolute;
  left: calc(12px + 46px + 10px + 16px);
  top: 0; bottom: 0;
  border-left: 2px solid color-mix(in srgb, var(--day) 30%, transparent);
}
.tl:first-child .tl-main::before { top: 22px; }
.tl:last-child .tl-main::before { bottom: calc(100% - 22px); }

.tl-time { display: grid; align-content: start; padding-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tl-time b { font-size: .875rem; font-weight: 600; }
.tl-time small { font-size: .75rem; color: var(--muted); }
.tl-icon { display: grid; justify-items: center; align-content: start; position: relative; z-index: 1; }
.tl-body { display: block; min-width: 0; padding-top: 4px; }
.tl-text { display: block; font-size: .9375rem; }
.tl--stop .tl-text { margin-top: 2px; }
.tl-text.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tl .stop-num { width: 34px; height: 34px; }

.tl-dot { width: 12px; height: 12px; margin-top: 8px; border-radius: 50%; background: var(--surface); border: 3px solid var(--day); }
.tl-dot--icon { width: 28px; height: 28px; margin-top: 2px; border: 0; border-radius: 50%; padding: 5px; background: var(--surface-2); color: var(--day); }
.tl-car, .tl-bed { display: grid; place-items: center; width: 28px; height: 28px; padding: 5px; border-radius: 8px; }
.tl-car svg, .tl-bed svg, .tl-dot--icon svg { width: 100%; height: 100%; }

.tl--drive .tl-car { background: var(--surface-2); color: var(--muted); }
.tl--drive .tl-main { padding-top: 6px; padding-bottom: 6px; }
.tl--drive .tl-text { color: var(--muted); font-size: .8125rem; margin-top: 1px; }
.drive-meta { display: block; padding-top: 3px; font-size: .875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.drive-meta b { font-weight: 600; color: var(--ink); }
.tl--drive .tl-time b { font-weight: 500; color: var(--muted); }

.tl--sleep { margin-top: 4px; }
.tl--sleep .tl-main { background: color-mix(in srgb, var(--day) 8%, transparent); }
.tl--sleep .tl-bed { background: var(--day); color: #fff; border-radius: 50%; width: 34px; height: 34px; padding: 7px; }
.tl--sleep .tl-body { padding-top: 7px; }
.tl--activity .tl-text { font-size: .9375rem; }

/* Marcadores extra */
.marker { position: relative; }
.bed-badge {
  position: absolute;
  right: -8px; top: -8px;
  display: grid; place-items: center;
  width: 18px; height: 18px;
  padding: 3px;
  border-radius: 50%;
  background: #FFF8EF;
  color: var(--day);
  box-shadow: 0 1px 3px rgb(0 0 0 / .35);
}
.bed-badge svg { width: 100%; height: 100%; }
.marker--via { width: 14px; height: 14px; border-width: 2px; background: #FFF8EF; box-shadow: 0 0 0 2px var(--day), 0 1px 4px rgb(0 0 0 / .3); border-color: var(--day); }
.marker--sleep { background: #FFF8EF; color: var(--day); border: 3px solid var(--day); padding: 4px; }
.marker--sleep svg { width: 100%; height: 100%; }

.leg-label {
  display: none;
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--day);
  font: 600 12px/1.4 "Work Sans", sans-serif;
  box-shadow: 0 1px 4px rgb(0 0 0 / .25);
  pointer-events: none;
}
.leg-label svg { width: 13px; height: 13px; color: var(--day); }
.show-legs-long .leg-label.long, .show-legs-all .leg-label { display: inline-flex; }

/* Popups y detalle */
.popup-visits { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 6px; font-size: .875rem; }
.popup-visits b { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; }
.popup-night { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.popup-night svg { width: 16px; height: 16px; color: var(--day); }
.visit-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.visit-list li { padding: 8px 12px; border-left: 3px solid var(--day); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.visit-when { display: flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.visit-when svg { width: 14px; height: 14px; }

/* ═════════ Plan v3: zonas horarias ═════════ */
.day-label .tz {
  display: block;
  margin-top: 4px;
  font: 600 .625rem/1.2 "Work Sans", sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.tl-time--pending b, .tl-time--pending small { color: var(--accent); }

.tag-todo { background: color-mix(in srgb, #C8962E 22%, transparent); color: var(--ink); }
.tag-done { background: color-mix(in srgb, #5E7A45 22%, transparent); color: var(--ink); }
.popup-warn { font-size: .8125rem; color: var(--accent); }

/* ───────── Navegación entre páginas ───────── */
.site-nav {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 20px;
  padding: 4px;
  overflow-x: auto;
  border-radius: 999px;
  background: var(--surface-2);
  scrollbar-width: none;
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ───────── Páginas sin mapa ───────── */
.page-main { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(104px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .page-main { padding-top: 32px; } }
.block { margin-top: 32px; }
.block h2, .city h2 { font-size: 1.5rem; margin-bottom: 12px; }
.block h2 .count { font: 600 .875rem/1 "Work Sans", sans-serif; color: var(--muted); vertical-align: middle; margin-left: 6px; }
.block > .legend { margin: -4px 0 12px; }
a.chip { color: inherit; text-decoration: none; }
.tag-ok { background: color-mix(in srgb, #5E7A45 22%, transparent); color: var(--ink); }

/* ───────── Gastos ───────── */
.people { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.person {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 40px;
  padding: 0 4px 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
}
.person:not(:has(button)) { padding-right: 14px; }
.person-del {
  width: 32px; height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.person-del:hover { background: var(--surface-2); color: var(--ink); }
.person-form { max-width: 420px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ledger { width: 100%; border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { padding: 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ledger th:first-child { text-align: left; white-space: normal; padding-left: 14px; }
.ledger td:last-child { padding-right: 14px; }
.ledger-person { display: grid; justify-items: start; gap: 4px; }
.ledger td { vertical-align: top; padding-top: 12px; }
.ledger thead th { font-size: .75rem; font-weight: 600; color: var(--muted); }
.ledger tbody th { font-weight: 600; font-size: .9375rem; }
.ledger small { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); }
.ledger tfoot th, .ledger tfoot td { border-bottom: 0; font-weight: 600; background: var(--surface-2); }
.bal { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .8125rem; font-weight: 600; }
.bal.pos { background: color-mix(in srgb, #5E7A45 24%, transparent); }
.bal.neg { background: color-mix(in srgb, #B3261E 14%, transparent); color: #8C1D18; }
.bal.zero { background: var(--surface-2); color: var(--muted); }
@media (prefers-color-scheme: dark) { .bal.neg { background: color-mix(in srgb, #F2B8B5 16%, transparent); color: #F2B8B5; } }

.transfers, .cats, .moves { list-style: none; margin: 0; padding: 0; }
.transfers { display: grid; gap: 8px; }
.transfers li:not(.muted) {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
}
.transfer-amt { font-family: "Fraunces", Georgia, serif; font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.transfers .btn { grid-column: 1 / -1; justify-self: start; min-height: 36px; font-size: .875rem; }

.cats { display: grid; gap: 12px; }
.cats li:not(.muted) { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .9375rem; }
.cat-name { font-weight: 600; }
.cat-amt { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

.move-day + .move-day { margin-top: 18px; }
.move-day h3 {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 2px 6px;
  font: 600 .75rem/1.3 "Work Sans", sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--wine);
}
@media (prefers-color-scheme: dark) { .move-day h3 { color: var(--accent); } }
.moves { display: grid; gap: 6px; }
.move {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: left;
}
button.move { cursor: pointer; }
button.move:hover { background: var(--surface-2); }
.move-text { display: grid; min-width: 0; }
.move-cat { font-size: .6875rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.move-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-text small, .move-amt small { font-size: .8125rem; color: var(--muted); }
.move-amt { display: grid; justify-items: end; font-variant-numeric: tabular-nums; }
.move-amt b { font-weight: 600; }
.is-pay .move { border-style: dashed; background: transparent; }
.is-pay .move-cat { color: var(--muted); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 16px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
.seg label { position: relative; }
.seg input, .check input { position: absolute; inset: 0; width: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 8px;
  border-radius: 9px;
  font-size: .9375rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg input:focus-visible + span, .check input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.amount-row { grid-template-columns: 1fr 108px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { position: relative; }
.check span {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .9375rem;
  font-weight: 600;
}
.check input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.link-btn {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: .8125rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.split-preview { min-height: 1.5em; margin: 0; font-weight: 600; color: var(--wine); }
@media (prefers-color-scheme: dark) { .split-preview { color: var(--accent); } }

/* ───────── Renta de autos ───────── */
.script-box {
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}
.script-box h2 { font-size: 1.25rem; margin-bottom: 6px; }
.script-box p { margin: 0 0 12px; }
.tips { display: grid; gap: 6px; margin: 16px 0 0; padding-left: 1.2em; font-size: .9375rem; color: var(--muted); }
.call-progress { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 20px; }
.city { margin-top: 28px; scroll-margin-top: 12px; }
.city h2 small { display: block; margin-top: 4px; font: 500 .875rem/1.3 "Work Sans", sans-serif; color: var(--muted); }
.offices { display: grid; gap: 12px; }
.office {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.office[data-status="si"] { border-left-color: #5E7A45; }
.office[data-status="cotizacion"] { border-left-color: #C8962E; }
.office[data-status="sin-respuesta"], .office[data-status="no"] { border-left-color: var(--muted); }
.office[data-status="no"] > :not(.call-form) { opacity: .65; }
.office-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.office h3 { font-size: 1.125rem; }
.office-branch { margin: 2px 0 0; font-size: .9375rem; font-weight: 600; }
.office-meta, .office-note { margin: 6px 0 0; font-size: .875rem; color: var(--muted); }
.office-note { color: var(--ink); }
.office-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.office-actions .link-out { margin-left: auto; }
.call-form { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.call-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.call-row select { grid-column: 1 / -1; }
@media (min-width: 560px) {
  .call-row { grid-template-columns: 170px 1fr auto; }
  .call-row select { grid-column: auto; }
}
.call-meta { margin: 6px 0 0; font-size: .75rem; color: var(--muted); }
.call-meta:empty { display: none; }

/* ═════════ Línea de detalles bajo cada fila: «1 h 15 · Importante · Pendiente: …» ═════════ */
.tl-meta { display: block; margin-top: 4px; font-size: .8125rem; line-height: 1.5; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-meta > * + *::before { content: "·"; margin: 0 .45em; color: var(--muted); font-weight: 400; }
.flag { color: var(--accent); font-weight: 600; }
.stay { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); font-weight: 600; vertical-align: top; }
.stay i { display: inline-flex; width: 13px; height: 13px; margin-top: 4px; color: var(--muted); }
.stay svg { width: 100%; height: 100%; }
.stay.is-now { padding: 0 8px 0 6px; border-radius: 6px; background: var(--day); color: #fff; }
.stay.is-now i { color: inherit; }
.tl.is-now > .tl-main { background: color-mix(in srgb, var(--day) 10%, transparent); }

/* ═════════ Gastos: contraseña ═════════ */
.login {
  margin-top: 24px; padding: 20px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.login h2 { font-size: 1.375rem; }
.login .legend { margin: 6px 0 14px; }
.login .form-error { margin-top: 10px; }
.logout-row { margin-top: 32px; text-align: center; }

/* ═════════ Tamaño del mapa en móvil (js/app.js → setMapMode) ═════════ */
.map-mode { display: none; }
@media (max-width: 899px) {
  .map-mode {
    position: fixed;
    left: 50%;
    bottom: calc(14px + env(safe-area-inset-bottom));
    z-index: 1000;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  .map-mode button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
  }
  .map-mode svg { width: 19px; height: 19px; }
  .map-mode button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

  [data-map="hidden"] { --map-h: 0px; }
  [data-map="hidden"] .map-pane { display: none; }
  [data-map="full"] .map-pane { height: 100vh; height: 100dvh; }
  [data-map="full"] .content { display: none; }
}

/* ═════════ Título «Itinerario» + expandir todos ═════════ */
.days-tools { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; }
.section-title { font-size: 1.5rem; }
.days-tools .link-btn { margin: 0; }

/* ═════════ Pendientes y reglas (pendientes.html) ═════════ */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.checklist, .rule-list { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.checklist li:first-child { padding-top: 0; }
.checklist small { display: block; margin-top: 3px; font-size: .8125rem; color: var(--muted); }
.check-mark {
  display: grid; place-items: center;
  width: 22px; height: 22px; margin-top: 1px;
  border: 2px solid var(--accent);
  border-radius: 50%;
}
.check-mark svg { width: 14px; height: 14px; }
.is-done .check-mark { border-color: #5E7A45; background: #5E7A45; color: #FFF8EF; }
.is-done > span:last-child { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--ink) 35%, transparent); }

.rule-list { counter-reset: rule; }
.rule-list li {
  counter-increment: rule;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 2px 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.rule-list li::before {
  content: counter(rule);
  grid-row: span 2;
  font: 700 1.125rem/1.3 "Fraunces", Georgia, serif;
  color: var(--accent);
}
.rule-list strong { font-family: "Fraunces", Georgia, serif; font-size: 1.0625rem; }
.rule-list span { color: var(--muted); }
.block .legend { margin: -6px 0 8px; }
