:root {
  --fondo: #f6f6f9;
  --tarjeta: #ffffff;
  --borde: #e4e4ec;
  --texto: #15151f;
  --suave: #6b6b7b;
  --rosa: #e6168f;
  --morado: #6f3bd6;
  --degradado: linear-gradient(135deg, var(--rosa), var(--morado));
  --ok: #1f9d55;
  --error: #d6313b;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--fondo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.barra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--tarjeta);
  border-bottom: 1px solid var(--borde);
}
.marca { display: flex; align-items: center; gap: 12px; min-width: 0; }
.marca-icono { width: 36px; height: 36px; object-fit: contain; }
h1 { margin: 0; font-size: 1.1rem; font-weight: 650; }
h2 { margin: 0 0 12px; font-size: 0.95rem; font-weight: 600; color: var(--suave); }
.barra-derecha { display: flex; align-items: center; gap: 16px; }

.estado { display: inline-flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--suave); }
.estado::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #b5b5c2; }
.estado[data-estado="conectando"]::before { background: #e0a100; }
.estado[data-estado="conectado"]::before { background: var(--ok); }
.estado[data-estado="error"]::before { background: var(--error); }

.boton {
  border: 1px solid var(--borde);
  background: var(--tarjeta);
  color: var(--texto);
  font: inherit;
  font-weight: 550;
  border-radius: 10px;
  padding: 9px 18px;
  cursor: pointer;
  transition: transform 0.05s, box-shadow 0.15s, opacity 0.15s;
}
.boton:hover:not(:disabled) { box-shadow: 0 2px 8px rgb(0 0 0 / 0.1); }
.boton:active:not(:disabled) { transform: translateY(1px); }
.boton:disabled { opacity: 0.45; cursor: not-allowed; }
.boton.primario { border: 0; color: #fff; background: var(--degradado); }
.boton.primario.colgar { background: var(--error); }

.principal {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 20px;
  padding: 24px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
@media (max-width: 760px) {
  .principal { grid-template-columns: minmax(0, 1fr); padding: 12px; gap: 12px; }
  .tarjeta { padding: 16px; }
  .bot { min-height: 0; gap: 14px; padding: 16px; }
  .logo { width: min(140px, 45%); }
  .conversacion { min-height: 280px; }
  .registro { max-height: 50vh; max-height: 50dvh; }
  .burbuja { max-width: 92%; }
}
@media (max-width: 520px) {
  .barra { padding: 10px 12px; gap: 8px; }
  h1 { font-size: 1rem; }
  .barra-derecha { width: 100%; justify-content: space-between; gap: 8px; }
  .controles { padding: 10px 12px; gap: 12px; }
  .selector { width: 100%; flex-direction: column; align-items: stretch; gap: 4px; }
  .selector select { max-width: none; width: 100%; }
  body.ptt .boton.hablar { flex: 1; }
}
@media (max-height: 480px) and (orientation: landscape) {
  .bot { display: none; }
  .principal { grid-template-columns: minmax(0, 1fr); }
  .registro { max-height: none; }
}

.tarjeta {
  background: var(--tarjeta);
  border: 1px solid var(--borde);
  border-radius: 16px;
  padding: 24px;
}

.bot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; min-height: 380px; }
.logo { width: min(220px, 60%); height: auto; }
.bot-estado { margin: 0; color: var(--suave); text-align: center; font-size: 0.95rem; }

.visualizador { display: flex; align-items: center; gap: 6px; height: 56px; }
.visualizador span {
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--degradado);
  transition: height 0.08s linear;
}

.conversacion { display: flex; flex-direction: column; min-height: 380px; }
.registro { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; max-height: 60vh; max-height: 60dvh; }
.vacio { color: var(--suave); font-size: 0.9rem; margin: 0; }
.registro > * { flex: 0 0 auto; }
.burbuja { margin: 0; flex-shrink: 0; max-width: 85%; padding: 9px 14px; border-radius: 14px; font-size: 0.95rem; line-height: 1.4; overflow-wrap: anywhere; }
.burbuja.de-bot { align-self: flex-start; background: #f0eefb; border-bottom-left-radius: 4px; }
.burbuja.de-usuario { align-self: flex-end; background: var(--degradado); color: #fff; border-bottom-right-radius: 4px; }
.burbuja.de-sistema { align-self: center; background: none; color: var(--suave); font-size: 0.8rem; padding: 0; }

.controles {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  padding: 14px 24px;
  background: var(--tarjeta);
  border-top: 1px solid var(--borde);
}

.boton.circular { width: 46px; height: 46px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.boton.circular svg { width: 22px; height: 22px; fill: currentColor; }
.boton.circular .tachado { display: none; stroke: currentColor; stroke-width: 2; fill: none; }
.boton.circular[aria-pressed="true"] { background: var(--error); border-color: var(--error); color: #fff; }
.boton.circular[aria-pressed="true"] .tachado { display: block; stroke: #fff; }

.boton.hablar { display: none; user-select: none; touch-action: none; }
body.ptt .boton.hablar { display: inline-block; }
body.ptt #micro { display: none; }
.boton.hablar.activo { background: var(--degradado); color: #fff; border: 0; box-shadow: 0 0 0 4px rgb(230 22 143 / 0.2); }

.interruptor { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; user-select: none; }
.interruptor input { position: absolute; opacity: 0; }
.pista { width: 38px; height: 22px; border-radius: 11px; background: #cfcfdb; position: relative; transition: background 0.15s; }
.bola { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.interruptor input:checked + .pista { background: var(--morado); }
.interruptor input:checked + .pista .bola { transform: translateX(16px); }
.interruptor input:focus-visible + .pista { outline: 2px solid var(--morado); outline-offset: 2px; }

.selector { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; color: var(--suave); }
.selector select { font: inherit; padding: 7px 10px; border: 1px solid var(--borde); border-radius: 8px; background: var(--tarjeta); color: var(--texto); max-width: 240px; }

/* Acceso: la demo se ve difuminada detrás hasta que se introduce la clave. */
body.bloqueado .principal,
body.bloqueado .controles { filter: blur(4px); opacity: 0.6; }
body.bloqueado .barra-derecha { visibility: hidden; }
.acceso {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(246 246 249 / 0.5);
}
.acceso[hidden] { display: none; }
.barra { position: relative; z-index: 1; }
.acceso-tarjeta { width: min(320px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; box-shadow: 0 8px 30px rgb(0 0 0 / 0.08); }
.acceso-titulo { margin: 0; color: var(--texto); font-size: 1.05rem; font-weight: 650; }
.acceso-sub { margin: 0 0 6px; color: var(--suave); font-size: 0.9rem; }
.acceso-campo { font: inherit; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px; background: var(--tarjeta); color: var(--texto); }
.acceso-campo:focus-visible { outline: 2px solid var(--morado); outline-offset: 1px; }
.acceso-boton { width: 100%; }
.acceso-error { margin: 0; color: var(--error); font-size: 0.85rem; }
