/* Chat en vivo MAES: compartido por casa (/) y auto (/auto). Mobile-first. */
:root {
  --navy: #16324f;
  --navy-2: #1f4468;
  --gold: #c4a35a;
  --ink: #243044;
  --paper: #efe9dd;
  --white: #fff;
  --muted: #5c6b7a;
  --line: #e4ddd0;
  --ok: #2d6a4f;
  --warn: #b08900;
  --err: #9b2226;
  --header-bg: #16324f;
  --bubble-bot: #ffffff;
  --bubble-me: #16324f;
  --bubble-me-ink: #ffffff;
  --chip: #faf8f4;
  --chip-line: #d3cbbd;
  --wall-dot: rgba(22, 50, 79, 0.05);
  --wall-top: #f4f0e8;
  --wall-bottom: #ebe4d6;
  --bubble-shadow: 0 1px 2px rgba(22, 50, 79, 0.08), 0 2px 8px rgba(22, 50, 79, 0.05);
  --composer-bg: rgba(255, 255, 255, 0.86);
  --field-bg: #f6f3ee;
  --sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "DM Serif Display", "Iowan Old Style", Palatino, Georgia, serif;
  --spring: cubic-bezier(0.2, 0.8, 0.3, 1.2);
  --app-h: 100dvh;
  font-family: var(--sans);
}
html[data-theme="dark"] {
  --paper: #0f141b;
  --header-bg: #1b2a3d;
  --bubble-bot: #1b2230;
  --bubble-me: #2c4058;
  --bubble-me-ink: #f4efe6;
  --chip: #243044;
  --chip-line: #3a4a5c;
  --wall-dot: rgba(213, 228, 242, 0.04);
  --wall-top: #111821;
  --wall-bottom: #0c1118;
  --bubble-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --composer-bg: rgba(21, 27, 36, 0.9);
  --field-bg: #0f141b;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; max-width: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Estructura: cabecera fija, conversación con scroll, composer abajo ---------- */
.app {
  height: var(--app-h);
  display: flex;
  flex-direction: column;
  max-width: 760px;
  margin: 0 auto;
  background-color: var(--paper);
  background-image:
    radial-gradient(var(--wall-dot) 1px, transparent 1.2px),
    linear-gradient(180deg, var(--wall-top), var(--wall-bottom));
  background-size: 22px 22px, 100% 100%;
  position: relative;
}
@media (min-width: 761px) {
  .app { box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(22, 50, 79, 0.12); }
}

.chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--header-bg) 88%, #fff 12%), var(--header-bg));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 6px 18px rgba(16, 32, 52, 0.18);
  z-index: 3;
}
.avatar {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  box-shadow: 0 0 0 2px rgba(196, 163, 90, 0.85);
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: visible;
}
.avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  padding: 3px;
}
.avatar .avatar-fallback {
  font-family: var(--serif);
  font-weight: 700;
  color: #16324f;
  font-size: 1.1rem;
}
.avatar::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: 1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #3ecf7a;
  border: 2px solid var(--header-bg);
}
.app.offline .avatar::after { background: #9aa8b6; }
.who { min-width: 0; flex: 1 1 auto; line-height: 1.2; }
.who-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who-status {
  margin: 1px 0 0;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 400px) {
  .chat-header { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .who-name { font-size: 0.95rem; }
  .product-switch { padding: 6px 10px; }
}
.who-status.typing { color: var(--gold); font-weight: 600; font-style: italic; }
.header-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.product-switch,
.chat-header .theme-toggle {
  min-height: 36px;
  min-width: 36px;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 12px;
  font: 600 0.75rem var(--sans);
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}
.product-switch:focus-visible { outline: 3px solid rgba(196, 163, 90, 0.7); outline-offset: 2px; }

.thread {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 10px 16px;
  scroll-behavior: smooth;
}
.brand-card {
  margin: 6px auto 4px;
  width: min(72%, 300px);
  padding: 10px 14px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--bubble-bot) 70%, transparent);
  box-shadow: var(--bubble-shadow);
}
.brand-card img { display: block; width: 100%; height: auto; }
.brand-card .logo-dark { display: none; }
html[data-theme="dark"] .brand-card .logo-light { display: none; }
html[data-theme="dark"] .brand-card .logo-dark { display: block; }
.log { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.day-chip,
.system-note {
  align-self: center;
  margin: 6px 0 8px;
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: center;
  color: var(--muted);
  background: color-mix(in srgb, var(--bubble-bot) 88%, transparent);
  box-shadow: var(--bubble-shadow);
  max-width: 88%;
}
.day-chip { font-weight: 650; letter-spacing: 0.02em; padding: 4px 12px; }
.system-note { background: #fdf6e3; color: #6b5a2e; }
html[data-theme="dark"] .system-note { background: #2a2618; color: #e0cf9f; }

/* ---------- Burbujas ---------- */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  margin-top: 8px;
  animation: msg-in 0.22s ease-out both;
}
.msg.cont { margin-top: 2px; }
.msg.bot { align-self: flex-start; align-items: flex-start; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.wide { max-width: 100%; width: 100%; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.bubble {
  position: relative;
  padding: 9px 13px 7px;
  border-radius: 18px;
  line-height: 1.45;
  font-size: 1rem;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  box-shadow: var(--bubble-shadow);
}
.bot .bubble { background: var(--bubble-bot); color: var(--ink); }
.me .bubble {
  background: linear-gradient(160deg, color-mix(in srgb, var(--bubble-me) 82%, #3a6a96 18%), var(--bubble-me));
  color: var(--bubble-me-ink);
}
.bot:not(.cont) .bubble { border-top-left-radius: 6px; }
.me:not(.cont) .bubble { border-top-right-radius: 6px; }
.bot.cont .bubble { border-top-left-radius: 8px; }
.me.cont .bubble { border-top-right-radius: 8px; }
.msg.wide .bubble { width: 100%; }

.bubble p { margin: 0 0 0.55em; }
.bubble p:last-of-type { margin-bottom: 0; }
.bubble ul { margin: 0.3em 0 0.6em; padding-left: 1.15em; }
.bubble li { margin: 0.2em 0; }
.bubble strong { font-weight: 650; }
.bubble a { color: var(--navy-2); font-weight: 650; }
.me .bubble a { color: #fff; }
html[data-theme="dark"] .bot .bubble a { color: var(--gold); }
.bubble blockquote {
  margin: 0.5em 0;
  padding: 6px 10px;
  border-left: 3px solid var(--gold);
  background: #f3eee3;
  color: #3d4a5c;
  border-radius: 0 8px 8px 0;
}
html[data-theme="dark"] .bubble blockquote { background: #243044; color: var(--navy); }

.meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  margin: 2px -2px 0 12px;
  float: right;
  position: relative;
  top: 5px;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  user-select: none;
}
.me .meta { color: rgba(255, 255, 255, 0.72); }
.bubble::after { content: ""; display: block; clear: both; }
.ticks { width: 16px; height: 11px; display: inline-block; }
.ticks path { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ticks .t2 { opacity: 0; transition: opacity 0.2s; }
.msg.delivered .ticks .t2 { opacity: 1; }
.msg.read .ticks { color: #8fd3ff; }
.msg.failed .meta { color: #ffb3b5; }

/* Escribiendo… */
.typing-bubble {
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
}
.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa8b6;
  animation: dots 1.2s infinite ease-in-out;
}
.typing-bubble span:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dots {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Respuestas rápidas ---------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 2px;
  max-width: 100%;
  animation: msg-in 0.25s ease-out both;
}
.actions.chips { flex-wrap: wrap; max-width: 100%; }
.actions.choices,
.actions.confirm,
.actions.ownership { display: grid; width: min(100%, 420px); }
.actions.ownership { grid-template-columns: 1fr 1fr; }
.action-btn {
  flex: 0 0 auto;
  border: 1.5px solid color-mix(in srgb, var(--navy) 28%, var(--chip-line));
  background: var(--chip);
  color: var(--navy);
  border-radius: 999px;
  min-height: 44px;
  padding: 9px 16px;
  font: 600 0.95rem var(--sans);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--bubble-shadow);
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
  touch-action: manipulation;
}
@media (hover: hover) {
  .actions:not(.spent) .action-btn:hover { border-color: var(--gold); }
}
.action-btn:active { transform: scale(0.97); }
.action-btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
html[data-theme="dark"] .action-btn.primary { background: var(--gold); border-color: var(--gold); color: #12171e; }
.action-btn.recommended { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.action-btn:focus-visible,
.chat-composer input:focus-visible,
.send-btn:focus-visible {
  outline: 3px solid rgba(196, 163, 90, 0.55);
  outline-offset: 2px;
}
.action-btn:disabled { cursor: default; }
.actions.spent .action-btn { opacity: 0.4; box-shadow: none; }
.actions.spent .action-btn.picked { opacity: 1; background: var(--header-bg); color: #fff; border-color: var(--header-bg); }
.actions.confirm .action-btn,
.actions.ownership .action-btn { text-align: center; min-height: 46px; }
.choice-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  border-radius: 16px;
  padding: 12px 15px;
}
.choice-title { font-weight: 700; line-height: 1.25; }
.choice-meta { font-size: 0.8rem; font-weight: 500; color: var(--muted); line-height: 1.35; }
.action-btn.primary .choice-meta,
.actions.spent .picked .choice-meta { color: rgba(255, 255, 255, 0.8); }
html[data-theme="dark"] .action-btn.primary .choice-meta { color: rgba(18, 23, 30, 0.75); }

/* ---------- Tablas (catálogo de paquetes, comparativa) ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; margin: 0.4em 0; }
.bubble table,
.quote-compare {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5em 0 0.7em;
  font-size: 0.86rem;
}
.bubble th,
.bubble td,
.quote-compare th,
.quote-compare td {
  border: 1px solid #ddd6c8;
  padding: 7px 9px;
  text-align: left;
}
.bubble th,
.quote-compare th { background: #f3eee3; color: var(--navy); font-weight: 650; }
html[data-theme="dark"] .bubble th,
html[data-theme="dark"] .quote-compare th { background: #243044; }
html[data-theme="dark"] .bubble td,
html[data-theme="dark"] .quote-compare td { border-color: #3a4a5c; }
.bubble td:not(:first-child),
.quote-compare td:not(:first-child) { text-align: right; }
.quote-compare caption { caption-side: top; text-align: left; font-weight: 650; color: var(--navy); margin: 0 0 8px; }
.quote-compare th[scope="row"] { background: #faf8f4; white-space: nowrap; }
html[data-theme="dark"] .quote-compare th[scope="row"] { background: #1b2230; }
.quote-compare td.quote-vehicle { text-align: left; font-size: 0.8rem; line-height: 1.35; white-space: normal; }
.quote-best { color: var(--ok); font-weight: 700; }
.quote-best-tag { display: inline-block; margin-left: 6px; font-size: 0.72rem; font-weight: 650; color: var(--ok); }
.quote-compare-note { margin: 8px 0 0; font-size: 0.84rem; color: var(--muted); }
.quote-compare .quote-card-pdf { margin-top: 0; padding: 6px 10px; font-size: 0.8rem; }

/* ---------- Panel de cotización en vivo ---------- */
.quote-progress { width: 100%; }
.quote-progress-done.quote-has-compare .quote-cards { display: none; }
.progress-title { margin: 0 0 2px; color: var(--navy); }
.quote-summary { margin: 4px 0 0; color: var(--ink); }
.delivery-notice { margin: 0.6rem 0 0; font-size: 0.9rem; line-height: 1.45; color: var(--muted); }
.quote-cards { display: grid; gap: 8px; margin-top: 10px; }
.quote-card {
  background: #faf8f4;
  border-radius: 12px;
  padding: 10px 12px;
  border-left: 4px solid #d3cbbd;
}
html[data-theme="dark"] .quote-card { background: #141a24; }
.quote-card h3 { margin: 0 0 2px; color: var(--navy); font-size: 0.98rem; }
.quote-card-title { display: flex; align-items: center; gap: 8px; }
.quote-card-status { margin: 0; color: var(--muted); font-size: 0.85rem; }
.quote-card-premium { margin: 6px 0 2px; font-size: 1.3rem; font-weight: 700; color: var(--navy); }
.quote-card-premium span { font-size: 0.76rem; font-weight: 500; color: var(--muted); }
.quote-card-meta { margin: 0; font-size: 0.8rem; color: var(--muted); }
.quote-card-ok { border-left-color: var(--ok); background: #f3f8f4; }
html[data-theme="dark"] .quote-card-ok { background: #14231c; }
.quote-card-busy { border-left-color: var(--gold); }
.quote-card-busy .quote-card-status::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  border-right-color: transparent;
  vertical-align: -1px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.quote-card-err { border-left-color: var(--err); }
.quote-check {
  display: inline-flex;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.quote-card-pdf {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
html[data-theme="dark"] .quote-card-pdf { background: var(--gold); color: #12171e; }
.quote-card-just-ready { animation: quote-ready 0.7s ease; }
.quote-card-just-ready .quote-check { animation: check-pop 0.45s ease; }
@keyframes quote-ready {
  0% { transform: scale(0.97); box-shadow: 0 0 0 0 rgba(45, 106, 79, 0.35); }
  45% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(45, 106, 79, 0); }
  100% { transform: scale(1); box-shadow: none; }
}
@keyframes check-pop {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}
.quote-toasts { display: grid; gap: 6px; margin-top: 8px; }
.quote-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--ok);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  animation: toast-in 0.35s ease, toast-out 0.4s ease 3.1s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }
.quote-progress-done .progress-wrap { display: none; }
.progress-wrap { margin: 8px 0 2px; }
.progress-bar { height: 8px; background: #ece6da; border-radius: 999px; overflow: hidden; }
html[data-theme="dark"] .progress-bar { background: #243044; }
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--navy));
  transition: width 0.3s linear;
}
.progress-meta { display: flex; justify-content: flex-end; margin-top: 4px; font-size: 0.8rem; color: var(--muted); }
.status-ok { color: var(--ok); }
.status-warn { color: var(--ok); }
.status-err { color: var(--err); }

/* ---------- Composer ---------- */
.chat-composer {
  flex: 0 0 auto;
  padding: 8px 10px calc(4px + env(safe-area-inset-bottom, 0px));
  background: var(--composer-bg);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
  z-index: 3;
}
html[data-theme="dark"] .chat-composer { border-top-color: #232c38; }
.composer-hint {
  margin: 0 6px 5px;
  font-size: 0.76rem;
  line-height: 1.3;
  color: var(--muted);
  min-height: 1em;
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-composer input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 23px;
  border: 1.5px solid transparent;
  background: var(--field-bg);
  color: var(--ink);
  font: 1rem var(--sans); /* 16px: iOS no hace zoom al enfocar */
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chat-composer input:focus { border-color: color-mix(in srgb, var(--gold) 70%, transparent); background: var(--white); }
html[data-theme="dark"] .chat-composer input { background: var(--field-bg); border-color: #2a3340; color: var(--ink); }
.powered a { color: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }
.powered {
  margin: 6px 0 0;
  text-align: center;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  opacity: 0.85;
}
.send-btn {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(160deg, #24507a, var(--navy));
  color: #fff;
  box-shadow: 0 4px 12px rgba(22, 50, 79, 0.28);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
  touch-action: manipulation;
}
html[data-theme="dark"] .send-btn { background: var(--gold); color: #12171e; }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.5; cursor: default; }
.send-btn svg { width: 21px; height: 21px; margin-left: 2px; }

.jump-down {
  position: absolute;
  right: 14px;
  bottom: 118px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bubble-bot);
  color: var(--navy);
  box-shadow: 0 4px 14px rgba(22, 50, 79, 0.18);
  display: none;
  place-items: center;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 4;
}
.jump-down.show { display: grid; }
.jump-down .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--gold);
  color: #12171e;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
}

.offline-bar {
  display: none;
  padding: 6px 12px;
  font-size: 0.8rem;
  text-align: center;
  background: #9b2226;
  color: #fff;
}
.app.offline .offline-bar { display: block; }

/* ---------- Celular: tablas en tarjetas ---------- */
@media (max-width: 639px) {
  .msg { max-width: 90%; }
  /* Las tarjetas de opción ya traen las sumas: en celular la tabla sobra. */
  .msg.has-actions .table-wrap { display: none; }
  .table-wrap { overflow: visible; }
  .bubble table thead { display: none; }
  .bubble table,
  .bubble tbody,
  .bubble tr,
  .bubble th,
  .bubble td { display: block; width: 100%; }
  .bubble tr {
    border: 1px solid #ddd6c8;
    border-radius: 12px;
    margin: 0 0 8px;
    padding: 6px 10px;
    background: #faf8f4;
  }
  html[data-theme="dark"] .bubble tr { background: #141a24; border-color: #3a4a5c; }
  .bubble th,
  .bubble td,
  .quote-compare th,
  .quote-compare td { border: 0; padding: 3px 0; text-align: left; }
  .bubble td { display: flex; justify-content: space-between; gap: 12px; }
  .bubble td:not(:first-child),
  .quote-compare td:not(:first-child) { text-align: left; }
  .bubble td::before { content: attr(data-label); font-weight: 650; color: var(--navy); flex: 0 0 auto; }
  .bubble tr th[scope="row"] { background: transparent; margin-bottom: 4px; }
}

/* ---------- v2: nivel Caro Fit ---------- */

/* Entrada con un poco de rebote. */
.msg { animation: msg-pop 0.34s var(--spring) both; }
@keyframes msg-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Avatar del asistente junto a sus mensajes (solo en el primero del grupo). */
.msg.bot { flex-direction: row; align-items: flex-end; gap: 7px; }
.msg.bot.wide { flex-direction: column; align-items: stretch; }
.bot-face {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1.5px rgba(196, 163, 90, 0.7), var(--bubble-shadow);
  display: grid;
  place-items: center;
  overflow: hidden;
  align-self: flex-start;
}
.bot-face img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.msg.bot.cont .bot-face { visibility: hidden; height: 0; }

/* Respuestas rápidas abajo, en el área de escribir. */
.reply-tray {
  max-height: min(46vh, 380px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 2px 10px;
  scrollbar-width: thin;
}
.reply-tray[hidden] { display: none; }
.reply-tray .actions { margin: 0; animation: none; width: 100%; }
.reply-tray .actions.chips { justify-content: flex-end; }
.reply-tray .actions.choices,
.reply-tray .actions.confirm,
.reply-tray .actions.ownership { width: 100%; margin-left: auto; max-width: 520px; }
.reply-tray .action-btn {
  animation: chip-in 0.34s var(--spring) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
@keyframes chip-in {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: none; }
}
@media (hover: hover) {
  .reply-tray .action-btn:hover {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
    transform: translateY(-1px);
  }
  .reply-tray .action-btn:hover .choice-meta { color: rgba(255, 255, 255, 0.82); }
  html[data-theme="dark"] .reply-tray .action-btn:hover { background: var(--gold); border-color: var(--gold); color: #12171e; }
}
.app.has-tray .composer-hint { text-align: right; }

/* Paquetes: cuadrícula 2×2 compacta para que se siga viendo la conversación. */
.reply-tray .actions.choices { grid-template-columns: 1fr 1fr; gap: 8px; max-width: 560px; }
.reply-tray .actions.choices .choice-card { padding: 9px 11px; border-radius: 14px; min-height: 0; }
.reply-tray .actions.choices .choice-title { font-size: 0.92rem; }
.reply-tray .actions.choices .choice-meta { font-size: 0.74rem; }
.reply-tray { max-height: min(34vh, 300px); }

/* Resumen antes de confirmar. */
.msg.summary .bubble {
  border: 1.5px solid color-mix(in srgb, var(--gold) 65%, transparent);
  padding-top: 30px;
}
.msg.summary .bubble::before {
  content: "Revisa tus datos";
  position: absolute;
  top: 9px;
  left: 13px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}

/* La mejor opción, al terminar de cotizar. */
.best-offer {
  margin: 12px 0 4px;
  padding: 16px 16px 14px;
  border-radius: 18px;
  background: linear-gradient(160deg, #1f4468, #16324f 60%);
  color: #fff;
  box-shadow: 0 18px 30px -20px rgba(22, 50, 79, 0.9);
  animation: msg-pop 0.45s var(--spring) both;
}
.best-kicker {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.best-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 6px; flex-wrap: wrap; }
.best-name { font-weight: 650; font-size: 1.05rem; }
.best-price { font-family: var(--serif); font-size: 1.9rem; line-height: 1; }
.best-price small { font-family: var(--sans); font-size: 0.72rem; color: rgba(255, 255, 255, 0.72); }
.best-pdf {
  display: inline-flex;
  margin-top: 12px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--gold);
  color: #12171e;
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
}

/* Los botones-enlace dentro de una burbuja no heredan el color de los enlaces. */
.bubble a.quote-card-pdf { color: #fff; }
.bubble a.best-pdf,
html[data-theme="dark"] .bot .bubble a.best-pdf { color: #12171e; }
html[data-theme="dark"] .bot .bubble a.quote-card-pdf { color: #12171e; }

/* Comparación: tarjetas por aseguradora en celular, tabla en computadora. */
.compare-cards { display: grid; gap: 10px; margin: 6px 0 4px; }
.compare-card {
  background: var(--bubble-bot);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 14px 12px;
  box-shadow: var(--bubble-shadow);
}
.compare-card.best { border: 1.5px solid var(--gold); }
.cc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cc-name { font-weight: 700; font-size: 1.02rem; color: var(--navy); }
.cc-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #12171e;
  background: var(--gold);
  border-radius: 999px;
  padding: 3px 9px;
}
.cc-price { margin: 6px 0 8px; font-family: var(--serif); font-size: 1.8rem; line-height: 1.05; color: var(--navy); }
.cc-price small { font-family: var(--sans); font-size: 0.74rem; color: var(--muted); }
.cc-cov { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.cc-cov li { display: flex; justify-content: space-between; gap: 12px; font-size: 0.86rem; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.cc-cov li span { color: var(--muted); }
.cc-cov li b { font-weight: 650; white-space: nowrap; }
.cc-more { margin-top: 6px; font-size: 0.84rem; }
.cc-more summary { cursor: pointer; color: var(--navy-2); font-weight: 650; padding: 4px 0; }
html[data-theme="dark"] .cc-more summary { color: var(--gold); }
.cc-meta { margin: 8px 0 0; font-size: 0.78rem; color: var(--muted); }
.compare-card .quote-card-pdf { margin-top: 10px; }
.compare-pending {
  margin: 2px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: var(--ok);
  font-size: 0.86rem;
  line-height: 1.4;
}
.quote-compare-wrap .compare-cards { display: none; }
@media (max-width: 639px) {
  .quote-compare-wrap .compare-cards { display: grid; }
  .quote-compare-wrap table,
  .quote-compare-wrap .quote-compare,
  .quote-compare-wrap .quote-compare-note { display: none !important; }
}
.quote-compare caption { caption-side: top; text-align: left; }

/* Aseguradora que no salió en automático: en manos de un asesor, no «error». */
.quote-card-manual { border-left-color: var(--ok); background: #f3f8f4; }
html[data-theme="dark"] .quote-card-manual { background: #14231c; }
.quote-card-manual .quote-card-status { color: var(--ok); font-weight: 600; }
.quote-card-manual .quote-card-status::before { content: "✉ "; }

/* Botón Asesor: con texto en pantallas medianas, solo icono en las chicas. */
.advisor-btn { cursor: pointer; }
.advisor-btn svg { flex: 0 0 auto; }
@media (max-width: 400px) {
  .advisor-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* Computadora: panel de marca a la izquierda, chat como tarjeta a la derecha. */
.side { display: none; }
@media (min-width: 960px) {
  body { background: var(--wall-bottom); }
  .page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(420px, 540px);
    gap: 56px;
    max-width: 1180px;
    height: var(--app-h);
    margin: 0 auto;
    padding: 28px 40px;
  }
  .side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    color: var(--ink);
    min-width: 0;
  }
  .side-logo { width: min(320px, 80%); height: auto; margin-bottom: 18px; }
  .side .logo-dark { display: none; }
  html[data-theme="dark"] .side .logo-light { display: none; }
  html[data-theme="dark"] .side .logo-dark { display: block; }
  .side-kicker {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
  }
  .side-title {
    margin: 0;
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(2.6rem, 4.6vw, 4rem);
    line-height: 1.02;
    color: var(--navy);
  }
  .side-lead { margin: 4px 0 6px; max-width: 30rem; font-size: 1.02rem; line-height: 1.55; color: var(--muted); }
  .side-steps { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 10px; }
  .side-steps li { display: flex; align-items: center; gap: 12px; font-size: 0.95rem; }
  .side-steps span {
    flex: 0 0 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--bubble-bot);
    box-shadow: var(--bubble-shadow);
    font-weight: 700;
    color: var(--navy);
  }
  .side-foot { margin: 18px 0 0; font-size: 0.82rem; color: var(--muted); }
  .app {
    height: calc(var(--app-h) - 56px);
    max-width: none;
    margin: 0;
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--line), 0 40px 80px -40px rgba(22, 50, 79, 0.45);
  }
  .brand-card { display: none; }
}

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

.restore-note .restart-chat {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}
