/* ============================================================
   Agente de voz para roleplays — UI tema claro moderno
   Inspiración: Linear, Vercel, Stripe. Tipografía Inter sistema-fallback.
   ============================================================ */

:root {
  /* Paleta */
  --bg:           #fafafb;
  --surface:      #ffffff;
  --surface-2:    #f4f5f8;
  --border:       #e6e8ee;
  --border-2:     #d8dbe3;
  --text:         #0f172a;     /* slate-900 */
  --text-2:       #475569;     /* slate-600 */
  --text-3:       #94a3b8;     /* slate-400 */
  --accent:       #4f46e5;     /* indigo-600 */
  --accent-hover: #4338ca;     /* indigo-700 */
  --accent-soft:  #eef2ff;     /* indigo-50 */
  --danger:       #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft:  #fee2e2;
  --ok:           #16a34a;
  --warn:         #f59e0b;
  --bad:          #ef4444;

  /* Sombras y radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
  --shadow-md: 0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 20px 40px -16px rgba(15,23,42,.18), 0 4px 12px rgba(15,23,42,.06);

  /* Tipografía */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { font-size: 15px; line-height: 1.5; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   Layout — Landing / Report (centered card)
   ============================================================ */
.container {
  max-width: 560px;
  margin: 6rem auto;
  padding: 2.25rem 2.5rem 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.container.wide { max-width: 760px; }
h1 {
  margin: 0 0 .25rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.015em;
}
.subtitle {
  margin: 0 0 2rem;
  color: var(--text-2);
  font-size: .95rem;
}

/* ============================================================
   Form
   ============================================================ */
label {
  display: block;
  margin: 1.1rem 0 .35rem;
  font-size: .825rem;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: .005em;
}
input, select, button, textarea {
  font: inherit;
  width: 100%;
  padding: .65rem .85rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--text);
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
input::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
button {
  cursor: pointer;
  font-weight: 500;
  border: 1px solid transparent;
}
button.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
button.primary:hover { background: var(--accent-hover); }
button.primary:active { transform: translateY(1px); }
button.danger {
  background: var(--danger);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
button.danger:hover { background: var(--danger-hover); }
button.ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-2);
}
button.ghost:hover { background: var(--surface-2); }

.form-actions { margin-top: 1.75rem; }

/* Checkbox con descripción debajo (toggle del avatar HeyGen en la landing) */
.chk-row {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  margin: 1.25rem 0 0;
  cursor: pointer;
  user-select: none;
}
.chk-row input { width: auto; margin: .2rem 0 0; flex-shrink: 0; }
.chk-row span { display: block; font-size: .9rem; color: var(--text); font-weight: 500; }
.chk-row small {
  display: block;
  font-weight: 400;
  font-size: .8rem;
  color: var(--text-3);
  margin-top: .15rem;
  line-height: 1.4;
}

/* ============================================================
   Layout — Session (split simétrico 50/50)
   ============================================================ */
.session {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  background: var(--bg);
}
.pane {
  padding: 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow: auto;
}
.pane.left { background: var(--bg); }
.pane.right {
  background: var(--surface);
  border-left: 1px solid var(--border);
  gap: 1rem;
}

/* ----- Cámara + VU + controles ----- */
.cam-wrap {
  position: relative;
  background: #0b0d12;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  aspect-ratio: 16 / 9;
  width: 100%;
}
/* Overlay con el CTA inicial */
.cam-start {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11,13,18,.45);
  backdrop-filter: blur(2px);
  transition: opacity .25s ease;
}
.cam-overlay { z-index: 4; }
.cam-start.hidden { opacity: 0; pointer-events: none; }
.cam-start .btn-start {
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  padding: .85rem 1.6rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(79,70,229,.35);
  display: inline-flex; align-items: center; gap: .5rem;
  width: auto;
  transition: transform .12s ease, background .12s ease;
}
.cam-start .btn-start:hover { background: var(--accent-hover); transform: translateY(-1px); }
.cam-start .btn-start:disabled { opacity: .65; cursor: wait; }
/* Avatar principal (vídeo HeyGen, canvas chroma-key o imagen estática): ocupa
   todo el wrap. Excluimos .cam-pip por si reaparece como hijo del wrap. */
.cam-wrap > video:not(.cam-pip), .cam-wrap > img, .cam-wrap > canvas {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  position: absolute; inset: 0;
}
.cam-wrap > [hidden] { display: none !important; }

/* Backdrop de estudio (gradiente índigo→oscuro) detrás del avatar.
   Sector-agnóstico: encaja con cualquier personaje, sin imagen por escenario. */
.bg-layer {
  position: absolute; inset: 0;
  background: radial-gradient(125% 95% at 50% 0%,
    #312e81 0%,   /* indigo-900 */
    #1e1b4b 40%,  /* indigo-950 */
    #0f172a 100%  /* slate-900 */
  );
  z-index: 0;
}
/* El <video> con el stream HeyGen NO se ve directamente: lo usamos como
   source para el chroma-key. Mantenemos posición y dimensiones normales
   dentro del wrap pero con opacity:0 — así el decoder NO se throttlea
   (Chrome reduce calidad/fps de elementos con visibility:hidden) y
   `requestVideoFrameCallback` se dispara con cada frame nuevo, lo que
   mantiene el lip-sync alineado con el audio. */
.avatar-video-decoder {
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}
/* Canvas con el avatar recortado encima del fondo. */
#avatar-canvas { z-index: 2; background: transparent; }
/* Imagen estática como carátula encima del fondo (todavía dentro del wrap). */
#avatar-image { z-index: 2; background: transparent; }

/* Fila horizontal debajo del avatar: Nivel de conflicto (ancho) + Tiempo (estrecho). */
.under-avatar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .85rem;
  margin-top: .5rem;
}
.under-avatar .tile { padding: .85rem 1rem; }
.under-avatar .tile h3 { margin-bottom: .5rem; }
.under-avatar .tile-time {
  min-width: 9rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}
.under-avatar .tile-time .time { font-size: 1.4rem; }

/* Tarjeta de notas para la demo (abajo derecha). Tono didáctico, no operativo. */
.demo-card {
  background: linear-gradient(180deg, #fefce8 0%, #fef9c3 100%);
  border-color: #fde68a;
}
.demo-card h3 { color: #92400e; }
.demo-intro,
.demo-foot {
  font-size: .85rem;
  color: #78350f;
  line-height: 1.55;
  margin: 0 0 .65rem;
}
.demo-list {
  margin: .25rem 0 .85rem;
  padding-left: 1.1rem;
  font-size: .85rem;
  color: #78350f;
  line-height: 1.55;
}
.demo-list li { margin-bottom: .55rem; }
.demo-list strong { color: #78350f; }
.demo-list em { color: #92400e; font-style: italic; }
.demo-list code {
  background: rgba(146,64,14,.12);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .8em;
}

/* Cámara del alumno como tarjeta en la columna derecha (ya NO va sobre el avatar). */
.user-cam-card { padding-bottom: 1rem; }
.user-cam {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b0d12;
  border-radius: var(--r-md);
  object-fit: cover;
  display: block;
  border: 1px solid var(--border);
}
.user-cam-hint {
  font-size: .8rem;
  color: var(--text-3);
  margin: .5rem 0 0;
}
.cam-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: .75rem 1rem;
  background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,0));
  display: flex; align-items: center; gap: .75rem;
  color: #fff; font-size: .8rem;
}
.rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(220,38,38,.6);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(220,38,38,.55); }
  70%  { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}

.vu {
  height: 6px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.vu > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #60a5fa, #4f46e5);
  transition: width 80ms linear;
}

.controls {
  display: flex;
  gap: .75rem;
  align-items: center;
  flex-wrap: wrap;
}
.controls .grow { flex: 1; }
.chk {
  display: flex; align-items: center; gap: .5rem;
  font-size: .85rem;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
.chk input { width: auto; margin: 0; }

.transcript {
  font-size: .85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: .85rem 1rem;
  max-height: 9rem;
  overflow: auto;
  line-height: 1.55;
}
.transcript .u { color: var(--accent); font-weight: 500; }
.transcript .m { color: #b45309; font-weight: 500; }
.transcript > div { margin-bottom: .35rem; }

/* ----- Panel derecho: métricas ----- */
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.metric h3 {
  margin: 0 0 .65rem;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
}
.gauge {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.gauge > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #22c55e 0%, #f59e0b 55%, #ef4444 100%);
  transition: width 350ms cubic-bezier(.22,.61,.36,1);
}
.gauge-label {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  margin-top: .55rem;
  color: var(--text-2);
}
.gauge-label .value { color: var(--text); font-weight: 600; }

/* Etiquetas de los extremos del gauge (Resuelto / Reclamación) */
.gauge-extremes {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  margin-bottom: .35rem;
}
.gauge-end-left  { color: #16a34a; }
.gauge-end-right { color: #dc2626; }

/* Tarjetas <details> colapsables (Cliente / Situación / Señales) */
.details-card { padding: 0; }
.details-card > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1rem 1.1rem;
  user-select: none;
}
.details-card > summary::-webkit-details-marker { display: none; }
.details-card > summary h3 { margin: 0; flex: 1; }
.details-card > summary .hint {
  font-size: .7rem;
  color: var(--text-3);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.details-card > summary .chev {
  font-size: .9rem;
  color: var(--text-3);
  transition: transform .2s ease;
}
.details-card[open] > summary .chev { transform: rotate(180deg); }
.details-card .details-body {
  padding: 0 1.1rem 1rem;
  font-size: .9rem;
  color: var(--text-2);
  line-height: 1.55;
}
.details-body .row { margin: 0 0 .35rem; }
.details-body .row strong { color: var(--text); font-weight: 600; }
.signals-help {
  font-size: .8rem;
  color: var(--text-3);
  margin: 0 0 .75rem;
  font-style: italic;
}
.details-card .signals-live {
  padding: 0 1.1rem 1rem;
}
.details-card[open] .signals-live { display: none; }
.signals-all li.universal { background: rgba(79,70,229,.04); padding-left: .5rem; border-radius: 4px; }

.signals { list-style: none; padding: 0; margin: 0; }
.signals li {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem 0;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.signals li:last-child { border-bottom: none; }
.signals .ico {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sig-done    .ico { background: var(--ok); }
.sig-partial .ico { background: var(--warn); }
.sig-missing .ico { background: var(--text-3); }
.sig-done    { color: var(--text); }
.sig-partial { color: var(--text); }
.sig-missing { color: var(--text-2); }

.time {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}
.time .sep { color: var(--text-3); margin: 0 .35rem; font-weight: 400; }

/* ----- Banner (errores fatales) ----- */
.banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  padding: .9rem 1.25rem;
  background: var(--danger-soft);
  color: var(--danger-hover);
  border-bottom: 1px solid #fecaca;
  text-align: center;
  font-size: .9rem;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Report
   ============================================================ */
.score-hero {
  display: flex; align-items: center; gap: 1.5rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, var(--accent-soft) 0%, #ede9fe 100%);
  border-radius: var(--r-lg);
  margin: 1.5rem 0 2rem;
  border: 1px solid #e0e7ff;
}
.score-hero .num {
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--accent-hover);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.score-hero .num small { font-size: 1.1rem; color: var(--text-2); font-weight: 500; }
.score-hero .label {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-2);
  margin-bottom: .25rem;
}
.score-hero .summary { color: var(--text); font-size: .95rem; }

.report-section { margin-top: 2rem; }
.report-section h2 {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  margin: 0 0 .75rem;
}

.criterion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1rem 1.1rem;
  margin-bottom: .65rem;
  box-shadow: var(--shadow-sm);
}
.criterion .head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: .35rem;
}
.criterion .head .name { font-weight: 600; font-size: .95rem; }
.criterion .head .score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: .85rem;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
}
.criterion .head .score.high { background: #dcfce7; color: #166534; }
.criterion .head .score.mid  { background: #fef3c7; color: #92400e; }
.criterion .head .score.low  { background: #fee2e2; color: #991b1b; }
.criterion .comment {
  color: var(--text-2);
  font-size: .9rem;
  line-height: 1.55;
}

.list-tags {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: .4rem;
}
.list-tags li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  padding: .55rem .8rem;
  font-size: .9rem;
  color: var(--text);
}
.list-tags.improvements li { border-left-color: var(--warn); }

.report-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.report-footer a { font-size: .9rem; }

/* ============================================================
   Responsive — móvil reduce el split a vertical
   ============================================================ */
@media (max-width: 900px) {
  .session {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .pane.right { border-left: none; border-top: 1px solid var(--border); }
  .container { margin: 2rem 1rem; padding: 1.5rem; }
}

/* ============================================================
   Catálogo de escenarios
   ============================================================ */
.catalog { margin-top: 4rem; }
.catalog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.catalog-head .subtitle { margin: 0; }
/* Enlace con apariencia de botón (las CTA del catálogo son <a>) */
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1rem;
  border-radius: var(--r-md);
  font-size: .9rem;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background .12s ease, transform .12s ease, box-shadow .12s ease;
}
.btn-link:hover { text-decoration: none; }
.btn-link.primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-link.primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.scenario-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .85rem;
}
.scenario-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: .7rem;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.scenario-card:hover { border-color: var(--border-2); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.scenario-card .title {
  font-weight: 600;
  font-size: .98rem;
  letter-spacing: -.01em;
  line-height: 1.35;
  padding-right: 1.5rem; /* espacio para el botón borrar */
}
.scenario-meta { display: flex; flex-wrap: wrap; gap: .4rem; }
.badge {
  display: inline-flex;
  align-items: center;
  font-size: .72rem;
  font-weight: 500;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.badge.type { background: var(--accent-soft); color: var(--accent-hover); border-color: #e0e7ff; }
.scenario-card .del {
  position: absolute;
  top: .65rem;
  right: .65rem;
  width: auto;
  padding: .25rem .5rem;
  font-size: .75rem;
  line-height: 1;
  color: var(--text-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  opacity: 0;
  transition: opacity .12s ease, color .12s ease, background .12s ease;
}
.scenario-card:hover .del,
.scenario-card .del:focus-visible { opacity: 1; }
.scenario-card .del:hover { color: var(--danger); background: var(--danger-soft); }

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--border-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text-2);
}
.empty-state p { margin: 0 0 1rem; }

.catalog-status {
  padding: .7rem 1rem;
  border-radius: var(--r-md);
  background: var(--danger-soft);
  color: var(--danger-hover);
  font-size: .88rem;
  margin-bottom: 1rem;
}

.catalog-foot {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: .9rem;
}

/* ============================================================
   Constructor de escenarios (chat)
   ============================================================ */
.builder { margin-top: 4rem; }
.builder-head { margin-bottom: 1.25rem; }
.builder-head .subtitle { margin-bottom: 0; }

.chat {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  min-height: 240px;
  max-height: 52vh;
  overflow-y: auto;
  padding: 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.bubble {
  max-width: 82%;
  padding: .6rem .85rem;
  border-radius: var(--r-lg);
  font-size: .92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  animation: bubble-in .18s ease both;
}
@keyframes bubble-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.bubble.assistant {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: var(--r-sm);
}
.bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: var(--r-sm);
}
/* Indicador "escribiendo…" */
.bubble.typing { display: inline-flex; gap: .25rem; align-items: center; }
.bubble.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  animation: typing 1.2s infinite ease-in-out;
}
.bubble.typing span:nth-child(2) { animation-delay: .15s; }
.bubble.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-form {
  display: flex;
  gap: .6rem;
  margin-top: 1rem;
}
.chat-input { flex: 1 1 auto; width: auto; }
.chat-send { width: auto; flex: 0 0 auto; padding-inline: 1.25rem; }
.chat-send:disabled { opacity: .6; cursor: wait; }

.missing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  margin-top: .85rem;
  font-size: .8rem;
  color: var(--text-3);
}
.missing .chip {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: .15rem .55rem;
  font-weight: 500;
}

.preview {
  margin-top: 1.5rem;
  padding: 1.25rem 1.35rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  animation: bubble-in .2s ease both;
}
.preview-head h2 { margin: 0 0 .25rem; font-size: 1.1rem; font-weight: 600; letter-spacing: -.01em; }
.preview-head p { margin: 0 0 1rem; color: var(--text-2); font-size: .9rem; }
.preview-json {
  margin: 0 0 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 1rem;
  max-height: 40vh;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
.preview #save { width: auto; }
