/* ==========================================================================
   rheda — app.css (hoja viva)
   Marca bloqueada: ver brand/BRAND.md y brand/tokens.css. Reglas en DESIGN.md.
   - Botón principal negro, uno por pantalla. Nunca morado.
   - Morado #6528F7 solo para acento, enlaces, radios y la pierna de la R.
   - Inter para la UI, Outfit 700 solo para el logotipo.
   Las pantallas se alternan con el atributo `hidden` (ver DESIGN.md §Pantallas).
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* Marca (copia de brand/tokens.css; no editar aquí sin editar allí) */
  --rheda-black: #000000;
  --rheda-ink: #0F172A;
  --rheda-white: #FFFFFF;
  --rheda-page: #FFFFFF;
  --rheda-control: #EEF0F4;
  --rheda-body: #454F5E;
  --rheda-muted: #69717F;
  --rheda-purple: #6528F7;
  --rheda-purple-dark: #4A1BD1;
  --rheda-purple-soft: #ECE7FD;
  --rheda-purple-focus: #8A63FF;
  --rheda-ok: #1A7F53;
  --rheda-line: rgba(15, 23, 42, 0.12);
  --rheda-line-strong: rgba(15, 23, 42, 0.20);
  --rheda-shadow: rgba(15, 23, 42, 0.18);
  --rheda-font-wordmark: "Outfit", system-ui, sans-serif;
  --rheda-font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Semántica (lo que usan los componentes) */
  --bg: var(--rheda-page);
  --surface: var(--rheda-white);
  --surface-2: var(--rheda-control);
  --text: var(--rheda-ink);
  --text-2: var(--rheda-body);
  --muted: var(--rheda-muted);
  --line: var(--rheda-line);
  --line-strong: var(--rheda-line-strong);
  --accent: var(--rheda-purple);
  --accent-hover: var(--rheda-purple-dark);
  --accent-soft: var(--rheda-purple-soft);
  --focus: var(--rheda-purple-focus);
  --ok: var(--rheda-ok);
  --warn: #A3540B;            /* funcional: solo “ETA aproximado” / errores */
  --primary-bg: var(--rheda-black);
  --primary-fg: var(--rheda-white);
  --primary-hover: #1F2430;
  --mark-fill: var(--rheda-black);
  --scrim: rgba(15, 23, 42, 0.32);

  /* Espaciado 4 pt */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --gutter: 16px;

  /* Radios */
  --r-xs: 8px; --r-sm: 12px; --r-md: 16px; --r-lg: 24px; --r-pill: 999px;

  /* Sombras */
  --sh-1: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 1px rgba(15, 23, 42, .04);
  --sh-2: 0 4px 14px rgba(15, 23, 42, .12);
  --sh-sheet: 0 -8px 28px rgba(15, 23, 42, .14);

  /* Tipo (Inter) — tamaño / interlineado */
  --t-display: 700 2.25rem/1.1 var(--rheda-font-ui);   /* 36 tarifa */
  --t-h1: 700 1.625rem/1.2 var(--rheda-font-ui);       /* 26 */
  --t-h2: 700 1.375rem/1.25 var(--rheda-font-ui);      /* 22 título de hoja */
  --t-h3: 600 1.0625rem/1.35 var(--rheda-font-ui);     /* 17 */
  --t-body: 400 0.9375rem/1.45 var(--rheda-font-ui);   /* 15 */
  --t-small: 400 0.8125rem/1.4 var(--rheda-font-ui);   /* 13 */
  --t-label: 600 0.75rem/1.3 var(--rheda-font-ui);     /* 12 */

  /* Alturas */
  --h-btn: 52px; --h-input: 48px; --h-tool: 44px;
  --sheet-max: 64dvh;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0B0D12;
  --surface: #14171E;
  --surface-2: #1E222B;
  --text: #F4F4F7;
  --text-2: #C3C8D1;
  --muted: #8E95A2;
  --line: rgba(244, 244, 247, 0.12);
  --line-strong: rgba(244, 244, 247, 0.22);
  --accent: #8A63FF;            /* morado legible sobre oscuro */
  --accent-hover: #A88BFF;
  --accent-soft: rgba(101, 40, 247, 0.22);
  --ok: #3DBE86;
  --warn: #E59A4B;
  --primary-bg: var(--rheda-white);   /* en oscuro el principal se invierte */
  --primary-fg: var(--rheda-black);
  --primary-hover: #E6E7EB;
  --mark-fill: var(--rheda-white);
  --scrim: rgba(0, 0, 0, 0.5);
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 4px 14px rgba(0, 0, 0, .45);
  --sh-sheet: 0 -8px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: var(--t-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; font-weight: 500; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.rh-num, .rh-metric dd, [id^="fare-"], #route-distance, #route-duration { font-variant-numeric: tabular-nums; }
kbd {
  font: 600 .7rem/1 var(--rheda-font-ui);
  padding: 2px 5px; border-radius: 5px;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.rh-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 3. Marca ---------- */
.rh-lockup { display: inline-flex; align-items: center; color: var(--mark-fill); }
.rh-mark { width: 28px; height: 28px; flex: none; color: var(--mark-fill); }
.rh-mark use[href="#rh-mark-body"] { fill: currentColor; }
.rh-mark use[href="#rh-mark-leg"] { fill: var(--rheda-purple); }
.rh-wordmark {
  font: 700 1.5rem/1 var(--rheda-font-wordmark);
  letter-spacing: -0.03em;
  color: var(--mark-fill);
}
.rh-lockup--lg { display: flex; flex-direction: column; align-items: center; }
.rh-lockup--lg .rh-wordmark { font-size: 3rem; }
.rh-parent { font: 500 .8125rem/1.3 var(--rheda-font-ui); color: var(--muted); }

/* ---------- 4. Tipo ---------- */
.rh-eyebrow { font: var(--t-label); color: var(--muted); letter-spacing: .02em; }
.rh-title { font: var(--t-h2); letter-spacing: -0.01em; color: var(--text); }
.rh-h1 { font: var(--t-h1); letter-spacing: -0.015em; }
.rh-h3 { font: var(--t-h3); }
.rh-sub { font: var(--t-body); color: var(--text-2); }
.rh-small { font: var(--t-small); color: var(--muted); }
.rh-display { font: var(--t-display); letter-spacing: -0.02em; }

/* ---------- 5. Botones ---------- */
.rh-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--h-btn); padding: 0 var(--s-5);
  border-radius: var(--r-sm); border: 1.5px solid transparent;
  font: 600 1rem/1 var(--rheda-font-ui); letter-spacing: -0.005em;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s, color .15s, border-color .15s, transform .1s;
}
.rh-btn:hover { text-decoration: none; }
.rh-btn:active { transform: scale(.985); }
.rh-btn svg { width: 20px; height: 20px; flex: none; }
.rh-btn--block { display: flex; width: 100%; }
.rh-btn--next { justify-content: space-between; padding-inline: 20px; }
.rh-btn--primary { background: var(--primary-bg); color: var(--primary-fg); }
.rh-btn--primary:hover { background: var(--primary-hover); color: var(--primary-fg); }
.rh-btn--secondary { background: var(--surface); color: var(--text); border-color: var(--text); }
.rh-btn--secondary:hover { background: var(--surface-2); color: var(--text); }
.rh-btn--tertiary { background: transparent; color: var(--accent); min-height: 44px; padding: 0 var(--s-3); }
.rh-btn--tertiary:hover { color: var(--accent-hover); background: var(--accent-soft); }
.rh-btn--quiet { background: var(--surface-2); color: var(--text); }
.rh-btn--quiet:hover { background: var(--line); }
.rh-btn--on-dark { background: transparent; color: #fff; border-color: #fff; }
.rh-btn--sm { min-height: 36px; padding: 0 var(--s-3); font-size: .875rem; border-radius: var(--r-xs); }
.rh-btn:disabled, .rh-btn[aria-disabled="true"] {
  background: var(--surface-2); color: var(--muted); border-color: transparent; cursor: not-allowed; transform: none;
}
.rh-actions { display: grid; gap: var(--s-2); }
.rh-actions--row { grid-auto-flow: column; grid-auto-columns: 1fr; }

/* Botón redondo (cabeceras, acciones de tarjeta) */
.rh-icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text); border: 0;
}
.rh-icon-btn:hover { background: var(--line); }
.rh-icon-btn svg { width: 20px; height: 20px; }
.rh-icon-btn--plain { background: transparent; }
.rh-icon-btn[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-fg); }

/* ---------- 6. Campos ---------- */
.rh-field { display: grid; gap: var(--s-2); }
.rh-label { font: var(--t-label); color: var(--muted); letter-spacing: .02em; }
.rh-input {
  width: 100%; height: var(--h-input); padding: 0 var(--s-4);
  border-radius: var(--r-sm); border: 1.5px solid transparent;
  background: var(--surface-2); color: var(--text);
  font: 500 1rem/1 var(--rheda-font-ui);
}
.rh-input::placeholder { color: var(--muted); font-weight: 400; }
.rh-input:focus { outline: none; border-color: var(--text); background: var(--surface); }
.rh-input:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent); }
.rh-phone { display: flex; gap: var(--s-2); }
.rh-phone > .rh-input { flex: 1; min-width: 0; }
.rh-phone-cc {
  flex: none;
  display: inline-flex; align-items: center;
  height: var(--h-input); padding: 0 28px 0 12px;
  border: 0; border-radius: var(--r-sm); background-color: var(--surface-2);
  color: var(--text); font: 600 .9375rem/1 var(--rheda-font-ui);
  white-space: nowrap;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%2369717F' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.rh-phone-cc-wrap {
  position: relative;
  flex: none;
  width: 6.75rem;
}
.rh-phone-cc-wrap .rh-phone-cc {
  width: 100%;
  pointer-events: none;
}
.rh-phone-cc-select {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  font: inherit; border: 0; background: transparent;
}
.rh-phone-cc-wrap:focus-within .rh-phone-cc {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent);
}
select.rh-phone-cc-select option { font-weight: 500; }
.rh-input--code { height: 60px; text-align: center; font: 700 1.75rem/1 var(--rheda-font-ui); letter-spacing: .5em; padding-left: .5em; font-variant-numeric: tabular-nums; }

/* Radios (morados por marca) */
.rh-choices { display: grid; gap: var(--s-2); }
.rh-choice {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 56px; padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm); border: 1.5px solid var(--line);
  background: var(--surface); cursor: pointer;
}
.rh-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.rh-choice input { accent-color: var(--rheda-purple); width: 20px; height: 20px; margin: 0; flex: none; }
.rh-choice-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.rh-choice-title { font: 600 .9375rem/1.3 var(--rheda-font-ui); }
.rh-choice-sub { font: var(--t-small); color: var(--muted); }
.rh-choice-ico { width: 36px; height: 36px; border-radius: var(--r-xs); display: grid; place-items: center; background: var(--surface-2); flex: none; }
.rh-choice-ico svg { width: 20px; height: 20px; }

/* Switch */
.rh-switch { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line-strong); position: relative; margin: 0; flex: none; cursor: pointer; transition: background .15s; }
.rh-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform .15s; }
.rh-switch:checked { background: var(--rheda-purple); }
.rh-switch:checked::after { transform: translateX(18px); }

/* ---------- 7. Tarjetas, listas, chips ---------- */
.rh-card { background: var(--surface); border-radius: var(--r-md); border: 1px solid var(--line); padding: var(--s-4); }
.rh-card--flat { background: var(--surface-2); border-color: transparent; }
.rh-divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.rh-list { display: grid; }
.rh-row {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 56px; padding: var(--s-3) 0; border-bottom: 1px solid var(--line);
  color: var(--text); text-decoration: none; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer;
}
.rh-row:last-child { border-bottom: 0; }
.rh-row-ico { width: 40px; height: 40px; border-radius: var(--r-pill); background: var(--surface-2); display: grid; place-items: center; flex: none; }
.rh-row-ico svg { width: 20px; height: 20px; }
.rh-row-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.rh-row-title { font: 600 .9375rem/1.3 var(--rheda-font-ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-row-sub { font: var(--t-small); color: var(--muted); }
.rh-row-end { font: 600 .9375rem/1.3 var(--rheda-font-ui); text-align: right; }
.rh-row-chev { width: 18px; height: 18px; color: var(--muted); flex: none; }

.rh-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text); font: 600 .75rem/1 var(--rheda-font-ui);
}
.rh-chip--accent { background: var(--accent-soft); color: var(--accent); }
.rh-chip--ink { background: var(--primary-bg); color: var(--primary-fg); }
.rh-dot {
  display: inline-block; width: 8px; height: 8px; min-width: 8px; min-height: 8px;
  border-radius: 50%; background: currentColor; flex: none; vertical-align: middle;
}
.rh-dot--ok { background: var(--ok); }
.rh-dot--live {
  background: var(--ok);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent);
  animation: rh-live 1.6s ease-out infinite;
}
@keyframes rh-live {
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.rh-kv { display: flex; justify-content: space-between; gap: var(--s-3); font: var(--t-body); padding: 6px 0; }
.rh-kv dt, .rh-kv > :first-child { color: var(--text-2); }
.rh-kv dd, .rh-kv > :last-child { font-weight: 600; }
.rh-kv--total { font-size: 1.0625rem; padding-top: var(--s-3); border-top: 1px solid var(--line); margin-top: var(--s-2); }
.rh-kv--total > * { color: var(--text) !important; font-weight: 700; }

.rh-avatar {
  width: 48px; height: 48px; border-radius: var(--r-pill); flex: none;
  display: grid; place-items: center; background: var(--rheda-ink); color: #fff;
  font: 700 1rem/1 var(--rheda-font-ui);
}
:root[data-theme="dark"] .rh-avatar { background: #2A2F3A; }
.rh-avatar--lg { width: 72px; height: 72px; font-size: 1.5rem; }
.rh-avatar--sm { width: 32px; height: 32px; font-size: .75rem; }

.rh-stars { display: inline-flex; gap: 2px; color: var(--ok); }
.rh-stars svg { width: 14px; height: 14px; }

/* ---------- 8. Paradas (recogida → entrega) ---------- */
.rh-stops { position: relative; display: grid; gap: var(--s-2); }
.rh-stop { position: relative; display: grid; grid-template-columns: 24px 1fr; gap: var(--s-3); align-items: start; }
.rh-stop-node { width: 24px; height: var(--h-input); display: grid; place-items: center; }
.rh-stop-node::before { content: ""; width: 12px; height: 12px; }
.rh-stop--pickup .rh-stop-node::before { border-radius: 50%; background: var(--surface); border: 4px solid var(--text); width: 14px; height: 14px; }
.rh-stop--dropoff .rh-stop-node::before { border-radius: 3px; background: var(--rheda-purple); }
.rh-stops--input .rh-stop-body > .rh-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
/* Conector vertical entre nodos */
.rh-stops::before {
  content: ""; position: absolute; left: 11px; top: calc(var(--h-input) / 2 + 10px);
  height: calc(100% - var(--h-input) - 20px); border-left: 2px dotted var(--line-strong);
}
.rh-stops--static::before { top: 22px; height: calc(100% - 44px); }
.rh-stops--static .rh-stop-node { height: 20px; margin-top: 2px; }
.rh-stop-text { display: grid; gap: 1px; min-width: 0; padding: 2px 0; }
.rh-stop-name { font: 600 .9375rem/1.3 var(--rheda-font-ui); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-stop-addr { font: var(--t-small); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rh-search { position: relative; display: flex; align-items: center; }
.rh-search-ico { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.rh-search input {
  width: 100%; height: var(--h-input); padding: 0 52px 0 42px;
  border-radius: var(--r-sm); border: 1.5px solid transparent;
  background: var(--surface-2); color: var(--text); font: 500 .9375rem/1 var(--rheda-font-ui);
  appearance: none; -webkit-appearance: none;
}
.rh-search input::-webkit-search-cancel-button { display: none; }
.rh-search input::placeholder { color: var(--muted); font-weight: 400; }
.rh-search input:focus { outline: none; border-color: var(--text); background: var(--surface); }
.rh-search .rh-icon-btn { position: absolute; right: 4px; width: 40px; height: 40px; background: transparent; color: var(--text-2); border-radius: var(--r-xs); }
.rh-search .rh-icon-btn:hover { background: var(--line); }
.rh-search .rh-icon-btn[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-fg); }

/* Sugerencias de Nominatim (js/geocode.js pinta li > button, o li[role=status]) */
.rh-results {
  margin-top: var(--s-2); max-height: 232px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--sh-2);
}
.rh-results li { border-bottom: 1px solid var(--line); }
.rh-results li:last-child { border-bottom: 0; }
.rh-results li[role="status"] { padding: var(--s-3) var(--s-4); font: var(--t-small); color: var(--muted); }
.rh-results button {
  display: block; width: 100%; padding: var(--s-3) var(--s-4) var(--s-3) 44px; text-align: left;
  border: 0; background: transparent; color: var(--text); font: 500 .875rem/1.35 var(--rheda-font-ui);
  position: relative;
}
.rh-results button::before {
  content: ""; position: absolute; left: 16px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Cpath d='M12 21s-7-6.1-7-11.5A7 7 0 0 1 19 9.5C19 14.9 12 21 12 21z'/%3E%3Ccircle cx='12' cy='9.5' r='2.5'/%3E%3C/svg%3E") center/contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2'%3E%3Cpath d='M12 21s-7-6.1-7-11.5A7 7 0 0 1 19 9.5C19 14.9 12 21 12 21z'/%3E%3Ccircle cx='12' cy='9.5' r='2.5'/%3E%3C/svg%3E") center/contain no-repeat;
}
.rh-results button:hover, .rh-results button:focus-visible { background: var(--surface-2); outline: none; }

.rh-hint { font: var(--t-small); color: var(--muted); margin-top: var(--s-3); }
.rh-hint-target { display: inline-block; width: 12px; height: 12px; vertical-align: -1px; border-radius: 50%; border: 2px solid currentColor; box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 5px currentColor; }

/* Planificador: acciones en línea */
.rh-planner-tools { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-top: var(--s-3); }
.rh-planner-tools .rh-btn--tertiary { min-height: 36px; padding: 0 var(--s-2); color: var(--text-2); font-size: .875rem; }
.rh-planner-tools .rh-btn--tertiary svg { width: 16px; height: 16px; }

/* ---------- 9. Resumen de ruta / métricas ---------- */
.rh-status {
  display: flex; align-items: center; gap: var(--s-2);
  font: 500 .875rem/1.35 var(--rheda-font-ui); color: var(--text-2);
}
.rh-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.rh-status[data-state="calculando"]::before { background: var(--accent); animation: rh-blink 1s infinite alternate; }
.rh-status[data-state="listo"]::before { background: var(--ok); }
.rh-status[data-state="error"] { color: var(--warn); }
.rh-status[data-state="error"]::before { background: var(--warn); }
@keyframes rh-blink { to { opacity: .25; } }

.rh-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); margin-top: var(--s-3); }
.rh-metric { background: var(--surface-2); border-radius: var(--r-sm); padding: var(--s-3); display: grid; gap: 4px; }
.rh-metric dt { display: flex; align-items: center; gap: 6px; font: var(--t-label); color: var(--muted); }
.rh-metric dt svg { width: 14px; height: 14px; }
.rh-metric dd { font: 700 1.25rem/1.2 var(--rheda-font-ui); letter-spacing: -0.01em; }
.rh-metrics--3 { grid-template-columns: repeat(3, 1fr); }

/* Tarifa */
.rh-fare { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.rh-card.rh-fare .rh-fare-amount { font-size: 1.875rem; }
.rh-fare > p { white-space: nowrap; }
.rh-fare-amount { font: var(--t-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.rh-fare-cur { font: 600 1rem/1 var(--rheda-font-ui); color: var(--muted); margin-left: 4px; }
.rh-vehicle { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.rh-vehicle .rh-h3 { white-space: nowrap; }
.rh-vehicle-img { width: 52px; height: 32px; flex: none; color: var(--text); }

/* ---------- 10. Hoja inferior ---------- */
.rh-sheet {
  position: relative; z-index: 3;
  background: var(--surface); color: var(--text);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--sh-sheet);
  padding: var(--s-2) var(--s-5) calc(var(--s-5) + env(safe-area-inset-bottom));
  max-height: var(--sheet-max); overflow-y: auto; overscroll-behavior: contain;
  display: grid; gap: var(--s-4); align-content: start;
}
.rh-grip { width: 36px; height: 5px; border-radius: 99px; background: var(--line-strong); margin: 0 auto var(--s-1); }
.rh-sheet-head { display: grid; gap: var(--s-1); }
.rh-sheet-head--row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.rh-sheet-foot { display: grid; gap: var(--s-3); }
.rh-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font: var(--t-small); color: var(--text-2); }
.rh-legend li { display: inline-flex; align-items: center; gap: 6px; }
.rh-legend img { width: auto; height: 18px; }
.rh-credits { font: 400 .6875rem/1.45 var(--rheda-font-ui); color: var(--muted); }
.rh-credits a { font-weight: 500; }

/* ---------- 11. Cromo del mapa ---------- */
.rh-stage { position: relative; min-height: 0; overflow: hidden; background: #E9E7E1; }
:root[data-theme="dark"] .rh-stage { background: #1A1C22; }
.rh-stage #map { position: absolute; inset: 0; width: 100%; height: 100%; }

.rh-tool {
  display: inline-grid; place-items: center; width: var(--h-tool); height: var(--h-tool);
  border-radius: var(--r-pill); border: 0; background: var(--surface); color: var(--text); box-shadow: var(--sh-2);
}
.rh-tool:hover { background: var(--surface-2); }
.rh-tool svg { width: 20px; height: 20px; }
.rh-tool[aria-pressed="false"] { color: var(--muted); }
.rh-tool:disabled { opacity: .5; cursor: not-allowed; }
.rh-tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.rh-ico-moon { display: none; }
:root[data-theme="dark"] .rh-ico-sun { display: none; }
:root[data-theme="dark"] .rh-ico-moon { display: block; }

.rh-map-tools {
  position: absolute; z-index: 4; right: var(--gutter); top: calc(var(--s-3) + env(safe-area-inset-top));
  display: grid; gap: var(--s-2); justify-items: end;
}

.rh-map-info {
  position: absolute; z-index: 5; left: var(--gutter); top: calc(var(--s-3) + env(safe-area-inset-top));
}
.rh-map-info > summary { list-style: none; cursor: pointer; display: grid; }
.rh-map-info > summary::-webkit-details-marker { display: none; }
.rh-tool--glass {
  width: 32px; height: 32px;
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  box-shadow: var(--sh-2);
  font: italic 700 16px/1 Georgia, "Times New Roman", serif;
  font-style: italic;
  color: var(--text);
}
.rh-map-info[open] .rh-tool--glass { background: var(--surface); }
.rh-map-info-pop {
  position: absolute; top: calc(100% + 8px); left: 0;
  width: min(248px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--sh-2);
  font: 400 .75rem/1.45 var(--rheda-font-ui);
  color: var(--text-2);
}
.rh-map-info-pop a { color: var(--text); font-weight: 600; }

/* Aviso “toca el mapa” (visible cuando un botón “usar el mapa” está pulsado) */
.rh-map-hint {
  position: absolute; z-index: 4; left: 50%; bottom: var(--s-8); transform: translateX(-50%);
  display: none; align-items: center; gap: var(--s-2);
  height: 40px; padding: 0 var(--s-4); border-radius: var(--r-pill);
  background: var(--rheda-black); color: #fff; font: 600 .875rem/1 var(--rheda-font-ui); white-space: nowrap; box-shadow: var(--sh-2);
}
.rh-map-hint svg { width: 16px; height: 16px; }
.rh-map-hint > span { display: none; }
#app-shell:has(#btn-use-map-pickup[aria-pressed="true"]) .rh-map-hint,
#app-shell:has(#btn-use-map-dropoff[aria-pressed="true"]) .rh-map-hint { display: inline-flex; }
#app-shell:has(#btn-use-map-pickup[aria-pressed="true"]) .rh-hint-pickup,
#app-shell:has(#btn-use-map-dropoff[aria-pressed="true"]) .rh-hint-dropoff { display: inline; }
#app-shell:has(#btn-use-map-pickup[aria-pressed="true"]) #map,
#app-shell:has(#btn-use-map-dropoff[aria-pressed="true"]) #map { cursor: crosshair; }

/* MapLibre: atribución, popups, marcadores */
.maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: var(--s-5); }
.maplibregl-ctrl.maplibregl-ctrl-attrib {
  background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--text-2);
  font: 400 .625rem/1.4 var(--rheda-font-ui); border-radius: var(--r-xs) 0 0 var(--r-xs); padding: 2px 8px;
}
.maplibregl-ctrl-attrib a { color: var(--text-2); font-weight: 500; }
.maplibregl-popup-content {
  background: var(--surface); color: var(--text); border-radius: var(--r-sm); box-shadow: var(--sh-2);
  padding: var(--s-3) var(--s-4); font: var(--t-small);
}
.maplibregl-popup-content strong { display: block; font: 600 .875rem/1.3 var(--rheda-font-ui); }
.maplibregl-popup-content div { color: var(--muted); }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; padding: 2px 6px; }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-marker { cursor: grab; }
.maplibregl-marker:active { cursor: grabbing; }

/* Coche del chofer en el mapa (marcador HTML opcional para js) */
.rh-car { width: 36px; height: 36px; border-radius: 50%; background: var(--rheda-black); display: grid; place-items: center; box-shadow: 0 0 0 3px #fff, var(--sh-2); }
.rh-car svg { width: 20px; height: 20px; color: #fff; }

/* ---------- 12. Pantallas ---------- */
/* Disposición en móvil: mapa arriba (1fr), hoja abajo (auto). */
#app-shell {
  position: relative; height: 100dvh; overflow: hidden;
  display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "map" "sheet";
}
#screen-client { display: contents; }
#app-shell .rh-stage { grid-area: map; }
#app-shell .rh-sheet { grid-area: sheet; margin-top: calc(var(--r-lg) * -1); }
/* Hojas sobre el mapa: se muestran en la zona “sheet”; mientras una está visible, se oculta la del planificador. */
#app-shell > .rh-screen--sheet { display: contents; }
#app-shell > .rh-screen--sheet[hidden] { display: none !important; }
#app-shell:has(> .rh-screen--sheet:not([hidden])) .rh-planner { display: none; }
#app-shell:has(> #screen-driver-trip:not([hidden])) .rh-map-tools,
#app-shell:has(> #screen-driver-trip:not([hidden])) .rh-map-info { display: none; }
/* Pantallas completas: cubren todo, mapa incluido. */
#app-shell > .rh-screen--full {
  position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto;
  display: flex; flex-direction: column;
}

/* Contenido de pantalla completa */
.rh-page { width: 100%; max-width: 480px; margin: 0 auto; flex: 1; display: flex; flex-direction: column; padding: 0 var(--gutter) calc(var(--s-6) + env(safe-area-inset-bottom)); }
.rh-page-head { display: flex; align-items: center; gap: var(--s-2); min-height: 56px; padding-top: env(safe-area-inset-top); margin: var(--s-2) 0 var(--s-2); }
.rh-page-head .rh-h3 { flex: 1; text-align: center; margin-right: 40px; }
.rh-page-head:has(.rh-chip) .rh-h3 { margin-right: 0; text-align: left; }
.rh-page-body { flex: 1; display: grid; gap: var(--s-5); align-content: start; }
.rh-page-foot { display: grid; gap: var(--s-3); padding-top: var(--s-5); }

/* Splash */
.rh-screen--splash { background: var(--rheda-page) !important; color: var(--rheda-ink); }
:root[data-theme="dark"] .rh-screen--splash { background: var(--rheda-black) !important; }
.rh-splash { flex: 1; display: grid; place-items: center; align-content: center; gap: var(--s-4); text-align: center; padding: var(--s-6); }
.rh-splash .rh-parent { margin-top: var(--s-2); }
.rh-splash-foot { padding: var(--s-6) var(--gutter) calc(var(--s-8) + env(safe-area-inset-bottom)); text-align: center; }
.rh-loader { width: 40px; height: 4px; border-radius: 99px; background: var(--line); overflow: hidden; margin: var(--s-8) auto 0; position: relative; }
.rh-loader::after { content: ""; position: absolute; inset: 0; width: 40%; background: var(--rheda-purple); border-radius: inherit; animation: rh-load 1.1s ease-in-out infinite; }
@keyframes rh-load { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* Avisos (antes del mapa) */
.rh-notify {
  flex: 1; display: flex; flex-direction: column;
  width: 100%; max-width: 480px; margin: 0 auto;
  padding: env(safe-area-inset-top) var(--gutter) calc(var(--s-6) + env(safe-area-inset-bottom));
}
.rh-notify-art { display: grid; place-items: center; padding: 64px 0 40px; }
.rh-notify-art svg { width: min(228px, 62vw); height: auto; }
.rh-notify-copy { display: grid; gap: var(--s-3); padding: 0 4px var(--s-4); }
.rh-notify-copy h1 { font: var(--t-h1); letter-spacing: -0.015em; }
.rh-notify-copy p { font: var(--t-body); color: var(--text-2); max-width: 38ch; }
.rh-notify .rh-btn--next { margin-top: auto; }

/* Rol (demo) */
.rh-role-card { display: flex; align-items: center; gap: var(--s-4); width: 100%; padding: var(--s-5) var(--s-4); border-radius: var(--r-md); border: 1.5px solid var(--line); background: var(--surface); text-align: left; color: var(--text); }
.rh-role-card:hover { border-color: var(--text); }
.rh-role-card .rh-row-ico { width: 48px; height: 48px; border-radius: var(--r-sm); background: var(--surface-2); }

/* Buscando chofer */
.rh-pulse { position: relative; width: 72px; height: 72px; margin: var(--s-2) auto; display: grid; place-items: center; }
.rh-pulse::before, .rh-pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: rh-ring 2s infinite; }
.rh-pulse::after { animation-delay: 1s; }
.rh-pulse .rh-mark { width: 40px; height: 40px; }
@keyframes rh-ring { 0% { transform: scale(.55); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
.rh-progress { height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.rh-progress > span { display: block; height: 100%; width: 35%; background: var(--text); border-radius: inherit; animation: rh-load 1.4s ease-in-out infinite; }

/* Chofer asignado / viaje */
.rh-driver { display: flex; align-items: center; gap: var(--s-3); }
.rh-driver-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.rh-driver-name { font: 600 1rem/1.3 var(--rheda-font-ui); display: flex; align-items: center; gap: 6px; }
.rh-driver-car { font: var(--t-small); color: var(--muted); }
.rh-plate { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line-strong); font: 700 .875rem/1 var(--rheda-font-ui); letter-spacing: .06em; }
.rh-eta { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.rh-eta-time { font: var(--t-h1); letter-spacing: -0.015em; }
.rh-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.rh-steps span { height: 4px; border-radius: 99px; background: var(--surface-2); }
.rh-steps span.is-done { background: var(--text); }
.rh-steps span.is-now { background: var(--accent); }

/* Estado de viaje: muestra solo los bloques del estado actual.
   <section data-state="accepted|arriving|onboard|completed"> + hijos [data-show="estado estado"] */
[data-state="accepted"]  [data-show]:not([data-show~="accepted"]),
[data-state="arriving"]  [data-show]:not([data-show~="arriving"]),
[data-state="onboard"]   [data-show]:not([data-show~="onboard"]),
[data-state="completed"] [data-show]:not([data-show~="completed"]),
[data-state="phone"]     [data-show]:not([data-show~="phone"]),
[data-state="code"]      [data-show]:not([data-show~="code"]) { display: none !important; }
/* Barra de progreso del viaje (cliente) según estado */
#screen-trip[data-state="arriving"] .rh-steps span:nth-child(-n+2),
#screen-trip[data-state="onboard"] .rh-steps span:nth-child(-n+3),
#screen-trip[data-state="completed"] .rh-steps span { background: var(--text); }

/* Reseña */
.rh-rate { display: flex; justify-content: center; gap: var(--s-2); flex-direction: row-reverse; }
.rh-rate input { position: absolute; opacity: 0; pointer-events: none; }
.rh-rate label { cursor: pointer; color: var(--line-strong); }
.rh-rate label svg { width: 40px; height: 40px; }
.rh-rate input:checked ~ label, .rh-rate label:hover, .rh-rate label:hover ~ label { color: var(--ok); }
.rh-rate input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.rh-tags { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; }
.rh-tag { height: 36px; padding: 0 var(--s-3); border-radius: var(--r-pill); border: 1.5px solid var(--line); background: var(--surface); font: 500 .875rem/1 var(--rheda-font-ui); color: var(--text); }
.rh-tag[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.rh-textarea { width: 100%; min-height: 88px; padding: var(--s-3) var(--s-4); border-radius: var(--r-sm); border: 1.5px solid transparent; background: var(--surface-2); resize: vertical; font: var(--t-body); }
.rh-textarea:focus { outline: none; border-color: var(--text); background: var(--surface); }

/* Chofer */
.rh-online { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.rh-online-state { display: inline-flex; align-items: center; gap: var(--s-2); font: 600 1rem/1.3 var(--rheda-font-ui); }
.rh-online-state .rh-when-off {
  display: inline-flex; align-items: center; gap: 8px;
}
.rh-when-on { display: none; }
#app-shell:has(#btn-go-online[aria-pressed="true"]) .rh-when-on,
.rh-is-online .rh-when-on { display: inline; }
#app-shell:has(#btn-go-online[aria-pressed="true"]) p.rh-when-on,
.rh-is-online p.rh-when-on { display: block; }
#app-shell:has(#btn-go-online[aria-pressed="true"]) .rh-online-state .rh-when-on,
.rh-is-online .rh-online-state .rh-when-on {
  display: inline-flex; align-items: center; gap: 8px;
}
#app-shell:has(#btn-go-online[aria-pressed="true"]) .rh-when-off,
.rh-is-online .rh-when-off { display: none; }
#btn-go-online[aria-pressed="true"] { background: var(--surface); color: var(--text); border-color: var(--text); }

.rh-offer-timer { position: relative; width: 56px; height: 56px; flex: none; }
.rh-offer-timer svg { width: 56px; height: 56px; transform: rotate(-90deg); }
.rh-offer-timer circle { fill: none; stroke-width: 4; }
.rh-offer-timer .rh-t-bg { stroke: var(--surface-2); }
.rh-offer-timer .rh-t-fg { stroke: var(--text); stroke-linecap: round; stroke-dasharray: 151; stroke-dashoffset: 50; }
.rh-offer-timer span { position: absolute; inset: 0; display: grid; place-items: center; font: 700 1rem/1 var(--rheda-font-ui); }

.rh-nav-banner {
  position: absolute; z-index: 4; left: var(--gutter); right: var(--gutter); top: calc(var(--s-3) + env(safe-area-inset-top));
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md); background: var(--rheda-black); color: #fff; box-shadow: var(--sh-2);
}
.rh-nav-banner svg { width: 32px; height: 32px; flex: none; }
.rh-nav-banner b { display: block; font: 700 1.125rem/1.25 var(--rheda-font-ui); }
.rh-nav-banner small { font: var(--t-small); color: rgba(255,255,255,.7); }

/* Ganancias */
.rh-earn-hero { background: var(--rheda-black); color: #fff; border-radius: var(--r-md); padding: var(--s-5); display: grid; gap: var(--s-2); }
.rh-earn-hero .rh-eyebrow { color: rgba(255,255,255,.65); }
.rh-earn-hero .rh-display { color: #fff; }
.rh-earn-hero .rh-small { color: rgba(255,255,255,.7); }
:root[data-theme="dark"] .rh-earn-hero { background: var(--surface-2); }
.rh-bars { display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: var(--s-2); height: 96px; }
.rh-bars i { display: block; border-radius: 6px 6px 2px 2px; background: var(--surface-2); }
.rh-bars i.is-today { background: var(--text); }
.rh-bars-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s-2); text-align: center; font: var(--t-label); color: var(--muted); }
.rh-tabs { display: flex; gap: 4px; padding: 4px; border-radius: var(--r-sm); background: var(--surface-2); }
.rh-tabs button { flex: 1; height: 36px; border: 0; border-radius: var(--r-xs); background: transparent; font: 600 .875rem/1 var(--rheda-font-ui); color: var(--text-2); }
.rh-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }

/* Perfil chofer / vehículo */
.rh-id-card { display: flex; align-items: center; gap: var(--s-4); }
.rh-id-card .rh-driver-body { flex: 1; min-width: 0; }
.rh-verified { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font: 600 .75rem/1.2 var(--rheda-font-ui); color: var(--ok); }
.rh-verified svg { width: 14px; height: 14px; }
.rh-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--r-sm); background: var(--surface-2); }
.rh-seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; border: 0; border-radius: var(--r-xs);
  background: transparent; color: var(--text-2);
  font: 600 .875rem/1 var(--rheda-font-ui);
}
.rh-seg-btn svg { width: 18px; height: 18px; }
.rh-seg-btn[aria-pressed="true"] { background: var(--primary-bg); color: var(--primary-fg); }
.rh-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.rh-card-head .rh-btn { min-height: 36px; }
.rh-vehicle-card { display: flex; align-items: center; gap: var(--s-3); width: 100%; text-align: left; color: inherit; appearance: none; font: inherit; cursor: pointer; }
.rh-vehicle-card .rh-row-title { white-space: normal; }
.rh-docs { display: grid; margin-top: var(--s-2); }
.rh-docs .rh-kv { padding: 12px 0; border-bottom: 1px solid var(--line); }
.rh-docs .rh-kv:last-child { border-bottom: 0; padding-bottom: 0; }
.rh-docs .rh-kv:first-child { padding-top: 0; }
.rh-doc-ok { color: var(--ok); font-weight: 600; }
.rh-docs--upload { gap: var(--s-2); }
.rh-docs--upload .rh-upload { margin-top: 0; }
.rh-upload.is-ready { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.rh-upload.is-ready .rh-upload-cta,
.rh-upload-cta.is-ready { color: var(--ok); }
.rh-type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.rh-type {
  position: relative; display: grid; place-items: center; gap: 8px;
  min-height: 88px; padding: var(--s-3); border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--surface);
  font: 600 .8125rem/1 var(--rheda-font-ui); color: var(--text); cursor: pointer;
}
.rh-type svg { width: 36px; height: 36px; }
.rh-type input { position: absolute; opacity: 0; pointer-events: none; }
.rh-type:has(input:checked) { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }
.rh-fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.rh-seats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); }
.rh-seat {
  position: relative; display: grid; place-items: center;
  min-height: 44px; border-radius: var(--r-sm); border: 1.5px solid var(--line);
  background: var(--surface-2); font: 700 1rem/1 var(--rheda-font-ui); cursor: pointer;
}
.rh-seat input { position: absolute; opacity: 0; pointer-events: none; }
.rh-seat:has(input:checked) { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }
.rh-upload {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 72px; padding: var(--s-3) var(--s-4); margin-top: var(--s-3);
  border-radius: var(--r-sm); border: 1.5px dashed var(--line-strong);
  background: var(--surface-2); cursor: pointer; color: inherit;
}
.rh-upload-cta { font: 600 .8125rem/1 var(--rheda-font-ui); color: var(--accent); flex: none; }
.rh-card .rh-field + .rh-field, .rh-card .rh-fields-2 { margin-top: var(--s-4); }
.rh-card .rh-field:first-of-type { margin-top: var(--s-4); }

.rh-driver-actions { display: flex; gap: var(--s-2); flex: none; }

.rh-chat-bubble {
  position: absolute; z-index: 5;
  left: var(--gutter); bottom: calc(var(--r-lg) + var(--s-3));
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; max-width: min(260px, calc(100% - 72px));
  padding: 6px 14px 6px 6px;
  border: 0; border-radius: var(--r-pill);
  background: var(--surface); color: inherit; text-align: left;
  box-shadow: var(--sh-2); cursor: pointer; font: inherit;
}
.rh-chat-bubble-body { min-width: 0; display: grid; gap: 1px; }
.rh-chat-bubble-name { font: 600 .8125rem/1.2 var(--rheda-font-ui); }
.rh-chat-bubble-text { font: var(--t-small); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-chat-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--accent); color: #fff;
  font: 700 .6875rem/18px var(--rheda-font-ui); text-align: center;
}

.rh-page.rh-chat { padding-bottom: 0; max-height: 100dvh; min-height: 0; height: 100%; }
.rh-chat-head { flex: 1; min-width: 0; }
.rh-chat-head .rh-h3 { text-align: left; margin-right: 0; }
.rh-page.rh-chat .rh-page-head .rh-h3 { margin-right: 0; text-align: left; }
.rh-chat-thread {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: var(--s-2) 0 var(--s-4);
}
.rh-msg {
  max-width: 80%; padding: 10px 14px;
  border-radius: 18px; font: var(--t-body); overflow-wrap: anywhere;
}
.rh-msg--them { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 6px; }
.rh-msg--me { align-self: flex-end; background: var(--rheda-black); color: #fff; border-bottom-right-radius: 6px; }
.rh-chat-dock { display: grid; gap: var(--s-2); padding: var(--s-2) 0 calc(var(--s-3) + env(safe-area-inset-bottom)); }
.rh-chat-quick { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.rh-chat-quick .rh-tag { flex: none; cursor: pointer; }
.rh-chat-compose { display: flex; align-items: center; gap: var(--s-2); }
.rh-chat-compose .rh-input { flex: 1; border-radius: var(--r-pill); }
.rh-chat-send {
  width: 48px; height: 48px; flex: none; border: 0; border-radius: 50%;
  background: var(--primary-bg); color: var(--primary-fg); display: grid; place-items: center; cursor: pointer;
}
.rh-chat-send svg { width: 20px; height: 20px; }

/* Reserva */
.rh-book-widget {
  display: grid; gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--sh-2);
}
.rh-book-widget .rh-field { gap: 6px; }
.rh-stepper {
  display: grid; grid-template-columns: 36px 1fr 36px; align-items: center;
  height: var(--h-input); border-radius: var(--r-sm); background: var(--surface-2);
}
.rh-stepper button {
  height: 100%; border: 0; background: transparent; color: var(--text);
  font: 600 1.125rem/1 var(--rheda-font-ui); cursor: pointer;
}
.rh-stepper input {
  width: 100%; border: 0; background: transparent; text-align: center;
  font: 600 1rem/1 var(--rheda-font-ui); color: var(--text);
}
.rh-book-total {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding-top: var(--s-2);
}
.rh-book-total .rh-btn { min-width: 132px; }
.rh-book-price { font: 600 .875rem/1.3 var(--rheda-font-ui); }
.rh-book-price b { font-size: 1.5rem; letter-spacing: -.03em; }
.rh-book-routes { display: grid; gap: var(--s-3); }
.rh-book-route {
  display: grid; gap: 6px; text-align: left; padding: 0 0 var(--s-3);
  border: 0; background: none; color: inherit; cursor: pointer;
}
.rh-book-route img {
  width: 100%; height: 120px; object-fit: cover; border-radius: var(--r-sm); background: var(--surface-2);
}
.rh-book-route .rh-row-title { white-space: normal; }
.rh-book-route .rh-book-route-price { font: 700 1.125rem/1 var(--rheda-font-ui); }
.rh-book-trust {
  display: grid; gap: var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: var(--rheda-ink); color: #fff;
  font: var(--t-small);
}
.rh-book-trust b { display: block; font: 700 .875rem/1.3 var(--rheda-font-ui); margin-bottom: 2px; }
.rh-book-summary .rh-stops { margin: var(--s-3) 0; }
#screen-book-form[data-state="form"] [data-show-state="done"],
#screen-book-form[data-state="done"] [data-show-state="form"] { display: none !important; }
#screen-book-form[data-state="done"] [data-show-state="done"] { display: grid !important; }
.rh-page--wide { max-width: 720px; }

/* ---------- 13. Escritorio (≥ 960 px): hoja como panel lateral ---------- */
@media (min-width: 960px) {
  #app-shell {
    grid-template-columns: 420px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "sheet map";
  }
  #app-shell .rh-sheet {
    margin: 0; border-radius: 0; max-height: none; height: 100dvh;
    box-shadow: 1px 0 0 var(--line); padding: var(--s-6);
  }
  #app-shell .rh-grip { display: none; }
  #app-shell .rh-map-tools { right: var(--s-4); }
  .maplibregl-ctrl-bottom-right, .maplibregl-ctrl-bottom-left { bottom: 0; }
  #app-shell .rh-tool-label { position: static; width: auto; height: auto; clip: auto; }
  #app-shell .rh-nav-banner { left: calc(420px + var(--s-4)); right: auto; width: 380px; }
}

/* Móvil: la hoja deja más mapa; la leyenda vive en escritorio y en los popups. */
@media (max-width: 959px) {
  .rh-planner .rh-legend { display: none; }
  .rh-planner .rh-metric { padding: 10px var(--s-3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
