/* Mesa UDIM Manta — tema oscuro comic-noir, acentos cian/ambar. Mobile-first. */

:root {
  --fondo: #0b1020;
  --fondo-2: #121a30;
  --carta: #182241;
  --carta-2: #1f2b52;
  --borde: #2b3a66;
  --tinta: #e8edf8;
  --tinta-2: #9fb0d4;
  --cian: #35d6f4;
  --cian-osc: #0e7490;
  --ambar: #ffc44d;
  --ambar-osc: #b45309;
  --rojo: #ff6b6b;
  --verde: #4ade80;
  --violeta: #c084fc;
  --radio: 14px;
  --sombra: 0 6px 24px rgba(0, 0, 0, 0.45);
  --transicion: 160ms ease;
  /* altura REAL de la barra superior: los sticky de debajo se anclan a esto
     (un top fijo en px ignoraba el notch y las tarjetas se metían debajo) */
  --alto-barra: calc(56px + env(safe-area-inset-top));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 500px at 80% -10%, #14224d 0%, transparent 60%),
    radial-gradient(900px 400px at -10% 110%, #0e2f3a 0%, transparent 55%),
    var(--fondo);
  color: var(--tinta);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
}

button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.4em; }
h1 { font-size: 1.5rem; letter-spacing: 0.02em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0.4em 0; }
a { color: var(--cian); }

.pantalla-carga { text-align: center; padding: 30vh 1rem 0; color: var(--tinta-2); }
.logo-carga { font-size: 3rem; animation: latido 1.2s infinite; }
@keyframes latido { 50% { transform: scale(1.15); } }

/* ---------- estructura ---------- */

/* padding inferior holgado: la nav fija + el globo del chat flotan encima */
.vista { padding: 0.9rem 0.9rem 9rem; max-width: 860px; margin: 0 auto; }

.barra-sup {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 0.6rem;
  height: var(--alto-barra);
  padding: 0 0.9rem;
  padding-top: env(safe-area-inset-top);
  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--borde);
}
.barra-sup .titulo { font-weight: 800; letter-spacing: 0.03em; font-size: 1.02rem; }
.barra-sup .titulo em { color: var(--cian); font-style: normal; }
.barra-sup .quien { margin-left: auto; color: var(--tinta-2); font-size: 0.85rem; }

.nav-inf {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(13, 19, 38, 0.97);
  border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inf a {
  flex: 1; min-height: 54px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--tinta-2);
  font-size: 0.68rem; transition: color var(--transicion);
}
.nav-inf a .ico { font-size: 1.25rem; }
.nav-inf a.activa { color: var(--ambar); }

/* ---------- componentes ---------- */

.carta {
  background: linear-gradient(180deg, var(--carta), var(--fondo-2));
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 0.9rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--sombra);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 46px; padding: 0.5rem 1.1rem;
  border-radius: 12px; border: 1px solid var(--borde);
  background: var(--carta-2); color: var(--tinta);
  font-weight: 700; cursor: pointer;
  transition: transform var(--transicion), background var(--transicion), opacity var(--transicion);
}
.btn:active { transform: scale(0.97); }
.btn-primario { background: linear-gradient(135deg, var(--cian-osc), #164e63); border-color: var(--cian); }
.btn-ambar { background: linear-gradient(135deg, var(--ambar-osc), #7c3aed00), var(--carta-2); border-color: var(--ambar); color: var(--ambar); }
.btn-peligro { border-color: var(--rojo); color: var(--rojo); background: transparent; }
.btn-fantasma { background: transparent; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-bloque { width: 100%; }
.btn-icono {
  min-width: 44px; min-height: 44px; border-radius: 12px;
  border: 1px solid var(--borde); background: var(--carta-2); cursor: pointer;
}

input[type="text"], input[type="number"], textarea, select {
  width: 100%; min-height: 48px;
  background: #0d1428; border: 1px solid var(--borde); border-radius: 12px;
  padding: 0.6rem 0.8rem; color: var(--tinta); outline: none;
  transition: border-color var(--transicion);
}
input:focus, textarea:focus { border-color: var(--cian); }
textarea { min-height: 110px; resize: vertical; }
label.campo { display: block; margin-bottom: 0.8rem; font-size: 0.9rem; color: var(--tinta-2); }
label.campo > span { display: block; margin-bottom: 0.3rem; font-weight: 700; color: var(--tinta); }

.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  border: 1px solid var(--borde); border-radius: 999px;
  padding: 0.15rem 0.6rem; font-size: 0.78rem; color: var(--tinta-2);
  background: rgba(255, 255, 255, 0.03);
}
.chip.cian { color: var(--cian); border-color: var(--cian-osc); }
.chip.ambar { color: var(--ambar); border-color: var(--ambar-osc); }
.chip.violeta { color: var(--violeta); border-color: #6d28d9; }
.chip.rojo { color: var(--rojo); border-color: #7f1d1d; }

.aviso, .motivo {
  border-radius: 10px; padding: 0.5rem 0.7rem; margin: 0.4rem 0; font-size: 0.87rem;
}
.aviso { background: rgba(255, 196, 77, 0.1); border: 1px solid var(--ambar-osc); color: var(--ambar); }
.motivo { background: rgba(255, 107, 107, 0.1); border: 1px solid #7f1d1d; color: var(--rojo); }
/* OJO: el cuerpo del tip debe ir en UN solo elemento (.tip-cuerpo) — con flex,
   texto suelto + <b> se parten en items separados y el texto se descoloca */
.tip {
  display: flex; gap: 0.5rem; align-items: flex-start;
  background: rgba(53, 214, 244, 0.07); border: 1px dashed var(--cian-osc);
  border-radius: 10px; padding: 0.55rem 0.7rem; margin: 0.6rem 0;
  font-size: 0.85rem; color: var(--tinta-2);
}
.tip::before { content: "💡"; flex: 0 0 auto; }
.tip .tip-cuerpo { flex: 1; min-width: 0; }
.tip .tip-x {
  flex: 0 0 auto; align-self: flex-start;
  background: none; border: none; color: var(--tinta-2);
  font-size: 1rem; line-height: 1; padding: 0.15rem 0.25rem; margin: -0.05rem -0.2rem 0 0;
  cursor: pointer; opacity: 0.8;
}
.tip .tip-x:active { opacity: 1; color: var(--tinta); }

.vacio { text-align: center; color: var(--tinta-2); padding: 1.6rem 1rem; font-size: 0.95rem; }
.vacio .grande { font-size: 2.2rem; display: block; margin-bottom: 0.4rem; }

/* ---------- medidores de presupuesto ---------- */

.medidores {
  position: sticky; top: var(--alto-barra); z-index: 25;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem;
  padding: 0.5rem 0; margin-bottom: 0.4rem;
  background: linear-gradient(180deg, rgba(11, 16, 32, 0.96) 80%, transparent);
}
.medidor {
  background: var(--carta); border: 1px solid var(--borde); border-radius: 10px;
  padding: 0.35rem 0.5rem;
}
.medidor .etiqueta { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--tinta-2); }
.medidor .cifra { font-size: 0.92rem; font-weight: 800; }
.medidor .cifra small { color: var(--tinta-2); font-weight: 400; }
.medidor .pista { height: 6px; border-radius: 4px; background: #0d1428; margin-top: 4px; overflow: hidden; }
.medidor .pista > div { height: 100%; border-radius: 4px; background: var(--cian); transition: width var(--transicion), background var(--transicion); }
.medidor.justo .pista > div { background: var(--ambar); }
.medidor.pasado .pista > div { background: var(--rojo); }
.medidor.pasado .cifra { color: var(--rojo); }

/* ---------- wizard ---------- */

.progreso { display: flex; gap: 0.3rem; margin: 0.6rem 0 1rem; }
.progreso .paso {
  flex: 1; height: 6px; border-radius: 4px; background: #22305a;
  transition: background var(--transicion);
}
.progreso .paso.hecho { background: var(--cian); }
.progreso .paso.actual { background: var(--ambar); }
.paso-titulo { display: flex; align-items: baseline; gap: 0.6rem; }
.paso-titulo .num { color: var(--ambar); font-weight: 900; }
.wizard-pie {
  display: flex; gap: 0.6rem; margin-top: 1rem;
}
.wizard-pie .btn { flex: 1; }

/* filas de habilidades */
.grupo-hab { margin-bottom: 1rem; }
.grupo-hab > h3 {
  color: var(--cian); text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.1em;
  margin: 0.8rem 0 0.4rem;
}
.fila-hab {
  display: flex; align-items: center; gap: 0.5rem;
  min-height: 52px; padding: 0.25rem 0.2rem;
  border-bottom: 1px solid rgba(43, 58, 102, 0.5);
}
.fila-hab .nombre-hab {
  flex: 1; display: flex; align-items: center; gap: 0.4rem;
  background: none; border: none; text-align: left; padding: 0.55rem 0.2rem;
  cursor: pointer; min-height: 44px; color: var(--tinta);
}
.fila-hab .nombre-hab .flecha { color: var(--tinta-2); font-size: 0.7rem; transition: transform var(--transicion); }
.fila-hab.abierta .nombre-hab .flecha { transform: rotate(90deg); }
.fila-hab .gratis { font-size: 0.68rem; color: var(--verde); }
.stepper { display: flex; align-items: center; gap: 0.15rem; }
.stepper button {
  min-width: 44px; min-height: 44px; border-radius: 10px;
  border: 1px solid var(--borde); background: var(--carta-2);
  font-size: 1.2rem; font-weight: 800; cursor: pointer;
  transition: background var(--transicion);
}
.stepper button:active { background: var(--cian-osc); }
.stepper .valor { min-width: 34px; text-align: center; font-weight: 800; font-size: 1.05rem; }
.stepper .valor.cero { color: #55668f; font-weight: 400; }
.desc-hab {
  font-size: 0.85rem; color: var(--tinta-2);
  padding: 0 0.2rem 0.6rem; margin: 0;
}
.desc-hab .pagina { color: var(--cian); font-size: 0.75rem; }

/* ---------- mapa de Quade ---------- */

.mapa-envoltura { position: relative; margin: 0 -0.9rem; }
.mapa-quade {
  width: 100%; height: min(64dvh, 560px); display: block;
  background:
    linear-gradient(rgba(53, 214, 244, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(53, 214, 244, 0.04) 1px, transparent 1px),
    #0a0f1e;
  background-size: 40px 40px;
  touch-action: none; cursor: grab; user-select: none;
}
.mapa-quade:active { cursor: grabbing; }
.mapa-leyenda {
  display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem;
  padding: 0.5rem 4.5rem 0.5rem 0.9rem; /* hueco a la derecha: ahí flota el chat */
  font-size: 0.72rem; color: var(--tinta-2);
}
.mapa-leyenda .muestra { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 4px; }
.mapa-controles {
  position: absolute; right: 0.7rem; top: 0.7rem; display: flex; flex-direction: column; gap: 0.4rem;
}
.mapa-controles .btn-icono { background: rgba(24, 34, 65, 0.9); }

.nodo-rect { rx: 9px; transition: filter var(--transicion); }
.nodo { cursor: pointer; }
.nodo text { pointer-events: none; fill: var(--tinta); font-size: 11px; }
.nodo .coste-badge { fill: var(--ambar); font-weight: 800; font-size: 11px; }
.nodo.general .nodo-rect { fill: #1c2a52; stroke: #3d548f; }
.nodo.investigacion .nodo-rect { fill: #123a46; stroke: var(--cian-osc); }
.nodo.defecto .nodo-rect { fill: #2d1b47; stroke: #6d28d9; }
.nodo.defecto text { fill: #d8c6f4; }
.nodo.adquirido .nodo-rect { fill: #7c5210; stroke: var(--ambar); filter: drop-shadow(0 0 6px rgba(255, 196, 77, 0.8)); }
.nodo.adquirido text { fill: #fff4dd; }
.nodo.gratis .nodo-rect { stroke: var(--cian); stroke-width: 2.5; filter: drop-shadow(0 0 5px rgba(53, 214, 244, 0.7)); }
.nodo.defecto-mio .nodo-rect { fill: #4c1d95; stroke: var(--violeta); filter: drop-shadow(0 0 6px rgba(192, 132, 252, 0.7)); }
.nodo.seleccionado .nodo-rect { stroke: #ffffff; stroke-width: 2.5; }
.arista { stroke: #3a4a7a; stroke-width: 1.6; }
.arista.correlacionado { stroke-dasharray: 6 5; }
.arista.iluminada { stroke: var(--ambar); stroke-width: 2.6; }

/* ---------- hoja inferior ---------- */

/* fondo tocable: cerrar la hoja tocando fuera (antes solo cerraba el tirador
   y la hoja tapaba la nav → quedabas atrapado) */
.hoja-fondo {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(4, 7, 16, 0.45);
  opacity: 0; transition: opacity 190ms ease;
}
.hoja-fondo.visible { opacity: 1; }

.hoja-cerrar {
  position: absolute; top: 0.45rem; right: 0.6rem;
  background: rgba(13, 20, 40, 0.9); color: var(--tinta-2);
  font-size: 1rem; line-height: 1;
}

.hoja {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--carta); border-top: 1px solid var(--borde);
  border-radius: 18px 18px 0 0;
  max-height: 72dvh; overflow: auto;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.6);
  transform: translateY(105%); transition: transform 190ms ease;
  padding-bottom: calc(0.8rem + env(safe-area-inset-bottom));
}
.hoja.visible { transform: translateY(0); }
.hoja-tirador { display: flex; justify-content: center; padding: 0.55rem; cursor: pointer; }
.hoja-tirador span { width: 44px; height: 5px; border-radius: 3px; background: var(--borde); }
.hoja-contenido { padding: 0 1rem 0.6rem; }
.hoja-contenido h3 { padding-right: 2.8rem; } /* que el título no pise la ✕ */
.hoja-contenido .acciones { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.hoja-contenido .acciones .btn { flex: 1; }
/* descripciones con fases (defectos): lista en vez de parrafón */
.fases { margin: 0.3em 0 0; padding-left: 1.15em; }
.fases li { margin: 0.4em 0; }
.fases li::marker { color: var(--cian); }
b.fase { color: var(--ambar); }

.coste-desglose {
  background: #0d1428; border: 1px solid var(--borde); border-radius: 10px;
  padding: 0.5rem 0.7rem; margin: 0.5rem 0; font-size: 0.9rem;
}
.coste-desglose .total { color: var(--ambar); font-weight: 900; font-size: 1.05rem; }

/* ---------- modo partida ---------- */

.termometro { margin: 0.6rem 0 1rem; }
.termometro .cabecera-termo { display: flex; justify-content: space-between; align-items: baseline; }
.termometro .valor-actual { font-size: 1.5rem; font-weight: 900; }
.termo-pista {
  position: relative; height: 26px; border-radius: 13px; background: #0d1428;
  border: 1px solid var(--borde); overflow: hidden; margin-top: 0.3rem;
}
.termo-relleno {
  position: absolute; top: 0; bottom: 0; left: 0;
  background: linear-gradient(90deg, var(--rojo), var(--ambar) 45%, var(--verde) 75%);
  transition: width 190ms ease;
}
.termo-marca { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, 0.45); }
.termo-marca span {
  position: absolute; top: 100%; left: -20px; width: 44px;
  font-size: 0.6rem; text-align: center; color: var(--tinta-2);
}
.termometro .zona { margin-top: 1.1rem; font-size: 0.8rem; color: var(--tinta-2); }
.zona .estado-actual { font-weight: 800; }
.zona .estado-actual.ok { color: var(--verde); }
.zona .estado-actual.danado { color: var(--ambar); }
.zona .estado-actual.grave { color: var(--rojo); }
.zona .estado-actual.muerto { color: var(--rojo); text-decoration: underline wavy; }
.botones-dano { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.botones-dano .btn { flex: 1; min-height: 44px; }

.pool {
  display: flex; align-items: center; gap: 0.45rem;
  min-height: 54px; padding: 0.3rem 0.1rem;
  border-bottom: 1px solid rgba(43, 58, 102, 0.5);
}
.pool .pool-info { flex: 1; min-width: 0; }
.pool .pool-nombre { font-weight: 700; font-size: 0.92rem; }
.pool .pool-puntos { font-size: 0.75rem; color: var(--tinta-2); }
.pool .fichitas { display: flex; flex-wrap: wrap; gap: 3px; max-width: 40vw; justify-content: flex-end; }
.pool .fichita {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--cian); box-shadow: 0 0 4px rgba(53, 214, 244, 0.6);
}
.pool .fichita.gastada { background: #2b3a66; box-shadow: none; }
.pool button.gastar {
  min-width: 46px; min-height: 46px; border-radius: 12px; border: 1px solid var(--cian-osc);
  background: rgba(53, 214, 244, 0.1); color: var(--cian); font-weight: 800; cursor: pointer;
}
.pool button.deshacer {
  min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--borde);
  background: transparent; color: var(--tinta-2); cursor: pointer;
}
.pool button[disabled] { opacity: 0.35; }

.guardado {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 40;
  font-size: 0.78rem; padding: 0.3rem 0.9rem; border-radius: 999px;
  background: rgba(13, 19, 38, 0.95); border: 1px solid var(--borde); color: var(--tinta-2);
  transition: opacity 300ms ease; pointer-events: none;
}
.guardado.ok { color: var(--verde); border-color: #14532d; }
.guardado.error { color: var(--ambar); border-color: var(--ambar-osc); }
.guardado.oculto { opacity: 0; }

/* ---------- chat ---------- */

.chat-fab {
  position: fixed; right: 0.9rem; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 50;
  width: 56px; height: 56px; border-radius: 50%;
  border: 1px solid var(--cian); background: linear-gradient(135deg, #164e63, #0b3a4a);
  font-size: 1.5rem; cursor: pointer; box-shadow: 0 4px 18px rgba(53, 214, 244, 0.35);
  transition: transform var(--transicion);
}
.chat-fab:active { transform: scale(0.92); }
.chat-fab.oculto { display: none; }

.chat-panel {
  position: fixed; inset: 0; z-index: 70;
  display: flex; flex-direction: column;
  background: var(--fondo);
  transform: translateY(100%); transition: transform 190ms ease;
}
.chat-panel.visible { transform: translateY(0); }
.chat-cabecera {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 0.9rem; padding-top: calc(0.7rem + env(safe-area-inset-top));
  border-bottom: 1px solid var(--borde); background: var(--fondo-2);
}
.chat-sub { display: block; font-size: 0.72rem; color: var(--tinta-2); }
.chat-mensajes { flex: 1; overflow-y: auto; padding: 0.9rem; display: flex; flex-direction: column; gap: 0.55rem; }
.burbuja {
  max-width: 86%; padding: 0.55rem 0.8rem; border-radius: 14px;
  font-size: 0.93rem; white-space: pre-wrap; overflow-wrap: break-word;
}
.burbuja.mia { align-self: flex-end; background: #164e63; border: 1px solid var(--cian-osc); border-bottom-right-radius: 4px; }
.burbuja.suya { align-self: flex-start; background: var(--carta); border: 1px solid var(--borde); border-bottom-left-radius: 4px; }
/* burbujas del ayudante con markdown renderizado, compacto para el chat */
.burbuja.md { white-space: normal; font-size: 0.93rem; }
.burbuja.md h1, .burbuja.md h2, .burbuja.md h3, .burbuja.md h4 { font-size: 0.98rem; margin: 0.8em 0 0.3em; }
.burbuja.md > :first-child { margin-top: 0; }
.burbuja.md > :last-child { margin-bottom: 0; }
.burbuja.md p { margin: 0.45em 0; }
.burbuja.md ul, .burbuja.md ol { margin: 0.3em 0; padding-left: 1.25em; }
.burbuja.md li { margin: 0.2em 0; }
.burbuja.md hr { margin: 0.7em 0; }
.burbuja.error-msg { align-self: center; background: rgba(255, 196, 77, 0.1); border: 1px solid var(--ambar-osc); color: var(--ambar); font-size: 0.83rem; }
.chat-escribiendo { padding: 0 0.9rem 0.5rem; color: var(--tinta-2); font-size: 0.85rem; }
.chat-escribiendo .punto {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--cian);
  animation: parpadeo 1s infinite; margin-right: 2px;
}
.chat-escribiendo .punto:nth-child(2) { animation-delay: 0.2s; }
.chat-escribiendo .punto:nth-child(3) { animation-delay: 0.4s; }
@keyframes parpadeo { 50% { opacity: 0.2; } }
.chat-form {
  display: flex; gap: 0.5rem; padding: 0.6rem 0.9rem;
  padding-bottom: calc(0.6rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--borde); background: var(--fondo-2);
}
.chat-form input { flex: 1; }
.chat-form .btn { min-width: 54px; }

/* ---------- entrada ---------- */

.entrada { max-width: 420px; margin: 0 auto; padding: 12vh 1.2rem 2rem; text-align: center; }
.entrada .placa {
  font-size: 3.4rem; margin-bottom: 0.4rem;
  filter: drop-shadow(0 0 14px rgba(53, 214, 244, 0.5));
}
.entrada h1 { font-size: 1.7rem; }
.entrada h1 em { color: var(--cian); font-style: normal; }
.entrada .lema { color: var(--tinta-2); margin-bottom: 1.6rem; }
.entrada form { text-align: left; }
.entrada input { text-align: center; font-size: 1.15rem; letter-spacing: 0.06em; }

/* ---------- mesa / director ---------- */

.ficha-resumen .poderes-lista { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.4rem 0; }
.stats-mini { display: flex; gap: 0.9rem; font-size: 0.85rem; color: var(--tinta-2); }
.stats-mini b { color: var(--tinta); }

.md { font-size: 0.94rem; }
.md h1, .md h2, .md h3, .md h4 { color: var(--ambar); margin-top: 1.2em; }
.md h1 { font-size: 1.3rem; } .md h2 { font-size: 1.15rem; } .md h3 { font-size: 1rem; }
.md blockquote { border-left: 3px solid var(--cian-osc); margin: 0.6em 0; padding: 0.1em 0.8em; color: var(--tinta-2); }
.md code { background: #0d1428; border-radius: 5px; padding: 0.1em 0.35em; font-size: 0.85em; }
.md pre { background: #0d1428; border: 1px solid var(--borde); border-radius: 10px; padding: 0.7em; overflow-x: auto; }
.md { overflow-wrap: break-word; }
.md table { border-collapse: collapse; width: 100%; margin: 0.6em 0; font-size: 0.85rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--borde); padding: 0.3em 0.5em; text-align: left; }
.md th { background: var(--carta-2); }
.md hr { border: none; border-top: 1px solid var(--borde); margin: 1.2em 0; }
.md ul, .md ol { padding-left: 1.3em; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(var(--alto-barra) + 8px); z-index: 90;
  background: var(--carta-2); border: 1px solid var(--borde); border-radius: 12px;
  padding: 0.6rem 1rem; box-shadow: var(--sombra); font-size: 0.9rem; max-width: 90vw;
}

.resumen-final .linea { display: flex; justify-content: space-between; padding: 0.25rem 0; border-bottom: 1px dashed rgba(43, 58, 102, 0.6); font-size: 0.92rem; }
.resumen-final .linea b { color: var(--cian); }

@media (min-width: 700px) {
  .vista { padding-top: 1.2rem; }
  .mapa-quade { height: 600px; }
  .chat-panel { left: auto; width: 420px; border-left: 1px solid var(--borde); }
}

/* teléfonos estrechos (≤360px): que nada se apriete ni se monte */
@media (max-width: 360px) {
  html, body { font-size: 15px; }
  .medidores { gap: 0.3rem; }
  .medidor { padding: 0.3rem 0.4rem; }
  .medidor .cifra { font-size: 0.85rem; }
  .stepper button { min-width: 40px; }
  .stepper .valor { min-width: 28px; }
  .chat-fab { width: 50px; height: 50px; font-size: 1.3rem; }
}
