:root {
  --fondo: #1C1C1C;
  --superficie: #262626;
  --superficie-2: #303030;
  --linea: #3a3a3a;
  --texto: #F6FBF6;
  --texto-2: #b9c2bb;
  --acento: #00FF88;
  --acento-texto: #0b1a12;
  --bosque: #1C3B2B;
  --peligro: #ff6b6b;
  --radio: 18px;
  --fuente: 'Source Sans 3', 'Source Sans Pro', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente);
  font-size: 17px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--acento); }

/* ── Cabecera ─────────────────────────────── */
.cabeza {
  position: sticky; top: 0; z-index: 5;
  background: rgba(28, 28, 28, .94);
  backdrop-filter: blur(8px);
  padding: 10px 16px 8px;
  border-bottom: 1px solid var(--linea);
}
.marca { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .2px; }
.isotipo { width: 26px; height: 26px; }
.avance { height: 4px; background: var(--superficie-2); border-radius: 4px; margin-top: 8px; overflow: hidden; }
#barra { height: 100%; width: 0; background: var(--acento); transition: width .4s ease; }
.progreso { margin: 4px 0 0; font-size: 13px; color: var(--texto-2); min-height: 1em; }

/* ── Conversación ─────────────────────────── */
.log {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: var(--radio);
  overflow-wrap: anywhere;
  animation: entra .18s ease-out;
}
.msg.bot { background: var(--superficie); align-self: flex-start; border-bottom-left-radius: 6px; }
.msg.yo { background: var(--bosque); align-self: flex-end; border-bottom-right-radius: 6px; }
.msg p { margin: 0 0 8px; }
.msg p:last-child { margin-bottom: 0; }
.msg ol { margin: 6px 0; padding-left: 20px; }
.msg li { margin: 2px 0; }
.msg .pista { display: block; margin-top: 6px; font-size: 14px; color: var(--texto-2); }
.msg.sep {
  align-self: center; max-width: 100%;
  background: none; padding: 10px 0 2px;
  font-size: 13px; color: var(--texto-2); text-transform: uppercase; letter-spacing: .8px; font-weight: 600;
}
.msg.error { background: #3a1f1f; color: #ffd7d7; }
.msg details { margin-top: 8px; }
.msg summary { cursor: pointer; color: var(--acento); font-weight: 600; }
.escribiendo { display: inline-flex; gap: 4px; padding: 14px 16px; }
.escribiendo span { width: 7px; height: 7px; border-radius: 50%; background: var(--texto-2); animation: punto 1s infinite; }
.escribiendo span:nth-child(2) { animation-delay: .15s; }
.escribiendo span:nth-child(3) { animation-delay: .3s; }
.audio-burbuja audio { display: block; width: 220px; max-width: 100%; height: 36px; margin-bottom: 6px; }
.trans { display: block; font-size: 15px; }
.trans em { color: var(--texto-2); font-style: normal; }
.corregir { background: none; border: 0; padding: 0; margin-top: 4px; color: var(--acento); font-weight: 600; cursor: pointer; text-decoration: underline; }
.editor textarea { width: 100%; min-height: 90px; border-radius: 10px; border: 1px solid var(--linea); background: var(--fondo); padding: 8px; }
.editor .fila { display: flex; gap: 8px; margin-top: 6px; }
.swatch-mini { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 3px; border: 1px solid rgba(255,255,255,.25); }

/* ── Pie: zona de controles y composer ────── */
.pie {
  position: sticky; bottom: 0; z-index: 5;
  background: var(--fondo);
  border-top: 1px solid var(--linea);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.zona, .voz, .composer { max-width: 640px; margin: 0 auto; }
.zona:empty { display: none; }
.zona { padding: 4px 0 8px; max-height: 58vh; overflow-y: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 8px 14px;
  border-radius: 22px;
  border: 1.5px solid var(--acento);
  background: transparent; color: var(--texto);
  cursor: pointer; text-align: left;
}
.chip[aria-pressed="true"] { background: var(--acento); color: var(--acento-texto); font-weight: 600; }
.chip.secundario { border-color: var(--linea); color: var(--texto-2); }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.boton {
  min-height: 46px; padding: 10px 20px; border-radius: 24px; border: 0;
  background: var(--acento); color: var(--acento-texto); font-weight: 700; cursor: pointer;
}
.boton:disabled { opacity: .4; cursor: not-allowed; }
.boton.fantasma { background: transparent; color: var(--texto-2); border: 1px solid var(--linea); font-weight: 600; }
.enlace-chico { background: none; border: 0; color: var(--texto-2); text-decoration: underline; cursor: pointer; padding: 6px 2px; font-size: 14px; }

.composer { display: flex; gap: 8px; align-items: center; }
.composer[hidden] { display: none; }
.entrada {
  flex: 1; min-width: 0; min-height: 46px;
  padding: 10px 16px; border-radius: 24px;
  border: 1px solid var(--linea); background: var(--superficie);
  outline: none;
}
.entrada:focus { border-color: var(--acento); }
.boton-icono {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--superficie-2);
}
.boton-icono svg { width: 22px; height: 22px; fill: var(--texto); }
.boton-icono.enviar { background: var(--acento); }
.boton-icono.enviar svg { fill: var(--acento-texto); }
.boton-icono[hidden] { display: none; }

.voz { display: flex; align-items: center; gap: 10px; padding: 6px 0 8px; }
.voz[hidden] { display: none; }
.grabando { display: flex; align-items: center; gap: 8px; flex: 1; font-weight: 600; }
.grabando .punto { width: 10px; height: 10px; border-radius: 50%; background: var(--peligro); animation: late 1s infinite; }
.voz audio { flex: 1; min-width: 0; height: 40px; }

/* ── Controles especiales ─────────────────── */
.productos { display: grid; gap: 8px; }
.productos .fila { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.campo { min-height: 44px; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--linea); background: var(--superficie); width: 100%; }
.campo:focus { outline: none; border-color: var(--acento); }

.meses { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mes { min-height: 44px; border-radius: 12px; border: 1px solid var(--linea); background: var(--superficie); cursor: pointer; }
.mes[data-e="alto"] { background: var(--acento); color: var(--acento-texto); font-weight: 700; border-color: var(--acento); }
.mes[data-e="bajo"] { background: #555; color: #ddd; text-decoration: line-through; }
.leyenda { font-size: 14px; color: var(--texto-2); margin: 0 0 8px; }
.leyenda b { color: var(--texto); }

.fichas { display: grid; gap: 6px; }
.ficha-fila { display: grid; grid-template-columns: 1fr auto 28px auto; gap: 8px; align-items: center; background: var(--superficie); border-radius: 12px; padding: 6px 8px 6px 12px; }
.ficha-fila button { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--linea); background: var(--superficie-2); font-size: 20px; cursor: pointer; }
.ficha-fila output { text-align: center; font-weight: 700; font-size: 18px; }
.quedan { font-weight: 700; }

.escalas { display: grid; gap: 14px; }
.escala label { display: flex; justify-content: space-between; font-size: 15px; color: var(--texto-2); }
.escala input { width: 100%; accent-color: var(--acento); height: 32px; }

.tarjetas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tarjeta { border: 2px solid var(--linea); border-radius: 14px; padding: 6px; background: var(--superficie); cursor: pointer; text-align: left; }
.tarjeta[aria-pressed="true"] { border-color: var(--acento); box-shadow: 0 0 0 2px var(--acento) inset; }
.tarjeta span { display: block; font-size: 14px; font-weight: 600; padding: 6px 2px 2px; }
.mini-feed { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.mini-feed i { display: grid; place-items: center; font-style: normal; font-size: 13px; font-weight: 700; overflow: hidden; }

.colores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.color { aspect-ratio: 1; border-radius: 14px; border: 2px solid rgba(255,255,255,.18); cursor: pointer; position: relative; }
.color[aria-pressed="true"]::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 900; color: #fff; text-shadow: 0 0 4px #000; }

.noscript { padding: 16px; }

@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes punto { 0%, 60%, 100% { opacity: .3; } 30% { opacity: 1; } }
@keyframes late { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) {
  .msg, .escribiendo span, .grabando .punto { animation: none; }
  #barra { transition: none; }
}
@media (min-width: 700px) {
  .tarjetas { grid-template-columns: repeat(4, 1fr); }
  .colores { grid-template-columns: repeat(6, 1fr); }
  .meses { grid-template-columns: repeat(6, 1fr); }
}
