/* MentorLab UCE v5 — interfaz conversacional */
:root {
  --tinta: #1B2A4A;
  --texto: #2A3142;
  --suave: #667086;
  --papel: #F7F9FC;
  --superficie: #FFFFFF;
  --linea: #E2E7EF;
  --linea-fuerte: #CBD3E0;
  --hover: #EEF2F8;
  --fisica: #2457C5;
  --quimica: #B86E0B;
  --biologia: #2C7D52;
  --acento: var(--fisica);
  --acento-suave: color-mix(in srgb, var(--acento) 10%, transparent);
  --peligro: #B42318;
  --radio-s: 8px;
  --radio-m: 14px;
  --radio-l: 22px;
  --sombra: 0 1px 2px rgba(27, 42, 74, .06), 0 8px 24px rgba(27, 42, 74, .07);
  --fuente: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
body[data-centro="Química"] { --acento: var(--quimica); }
body[data-centro="Biología"] { --acento: var(--biologia); }

@media (prefers-color-scheme: dark) {
  :root {
    --tinta: #E6ECF7; --texto: #D5DCE8; --suave: #97A1B5;
    --papel: #11161F; --superficie: #171D28; --linea: #262F3D; --linea-fuerte: #364153;
    --hover: #1F2734;
    --fisica: #6E97F2; --quimica: #E3A34A; --biologia: #5DBB86;
    --sombra: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--fuente);
  font-size: 16px;
  line-height: 1.55;
  color: var(--texto);
  background: var(--papel);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.flex { flex: 1; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: 272px 1fr; height: 100dvh; }

/* ---------- barra lateral ---------- */
.sidebar {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 12px; border-right: 1px solid var(--linea);
  background: var(--superficie); min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 6px; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  color: #fff; background: var(--acento); transition: background .25s;
}
.brand-name { font-weight: 700; color: var(--tinta); letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { font-size: 12.5px; color: var(--suave); }
.brand .icon-btn { margin-left: auto; }
.new-chat {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; border: 1px solid var(--linea-fuerte); border-radius: var(--radio-s);
  background: var(--superficie); font-weight: 500; color: var(--tinta);
}
.new-chat:hover { background: var(--hover); }
.conv-list { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.conv-group { font-size: 12.5px; color: var(--suave); padding: 12px 8px 4px; }
.conv-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 7px 8px; border: 0; border-radius: var(--radio-s); background: none;
  font-size: 14.5px; color: var(--texto);
}
.conv-item:hover { background: var(--hover); }
.conv-item[aria-current="true"] { background: var(--acento-suave); color: var(--tinta); font-weight: 500; }
.conv-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; }
.conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-del { opacity: 0; border: 0; background: none; color: var(--suave); padding: 2px; border-radius: 6px; }
.conv-item:hover .conv-del, .conv-del:focus-visible { opacity: 1; }
.conv-del:hover { color: var(--peligro); }
.conv-empty { font-size: 14px; color: var(--suave); padding: 10px 8px; }
.sidebar-foot { font-size: 12.5px; color: var(--suave); line-height: 1.45; padding: 8px 6px 2px; border-top: 1px solid var(--linea); }
.sidebar-foot a { display: block; margin-top: 6px; color: var(--acento); text-decoration: none; }
.sidebar-foot a:hover { text-decoration: underline; }

/* ---------- principal ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; border-bottom: 1px solid var(--linea); background: var(--papel);
}
.session { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: min(100%, 860px); margin: 0 auto; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--hover); }
.seg button {
  border: 0; background: none; padding: 5px 12px; border-radius: 8px;
  font-size: 14.5px; font-weight: 500; color: var(--suave);
}
.seg button[aria-checked="true"] { background: var(--superficie); color: var(--acento); box-shadow: 0 1px 2px rgba(27,42,74,.12); }
.field select, .field input {
  height: 36px; padding: 0 10px; border: 1px solid var(--linea-fuerte); border-radius: var(--radio-s);
  background: var(--superficie); font-size: 14.5px;
}
.field select { padding-right: 28px; }
.field-practica { flex: 1; min-width: 180px; }
.field-practica input { width: 100%; }

.thread { flex: 1; overflow-y: auto; position: relative; scroll-behavior: smooth; }

/* Pantalla inicial: papel milimetrado en el color del Centro */
.empty { position: relative; min-height: 100%; display: grid; place-items: center; padding: 32px 20px; }
.paper {
  position: absolute; inset: 0; pointer-events: none;
  --l: color-mix(in srgb, var(--acento) 9%, transparent);
  --L: color-mix(in srgb, var(--acento) 18%, transparent);
  background-image:
    linear-gradient(var(--L) 1px, transparent 1px),
    linear-gradient(90deg, var(--L) 1px, transparent 1px),
    linear-gradient(var(--l) 1px, transparent 1px),
    linear-gradient(90deg, var(--l) 1px, transparent 1px);
  background-size: 50px 50px, 50px 50px, 10px 10px, 10px 10px;
  background-position: -1px -1px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 45%, #000 20%, transparent 72%);
          mask-image: radial-gradient(ellipse at 50% 45%, #000 20%, transparent 72%);
}
.empty-inner { position: relative; width: min(100%, 680px); }
.empty h1 {
  margin: 0 0 8px; font-size: clamp(28px, 4.2vw, 40px); line-height: 1.12;
  letter-spacing: -.025em; color: var(--tinta); font-weight: 600;
}
.empty-lead { margin: 0 0 24px; color: var(--suave); max-width: 56ch; }
.suggest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.suggest button {
  text-align: left; padding: 12px 14px; border: 1px solid var(--linea-fuerte); border-radius: var(--radio-m);
  background: color-mix(in srgb, var(--superficie) 88%, transparent); backdrop-filter: blur(2px);
  font-size: 14.5px; color: var(--texto); line-height: 1.4;
}
.suggest button strong { display: block; color: var(--tinta); font-weight: 600; margin-bottom: 2px; }
.suggest button:hover { border-color: var(--acento); }

/* Mensajes */
.messages { width: min(100%, 800px); margin: 0 auto; padding: 24px 20px 12px; }
.msg { margin: 0 0 22px; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  max-width: 80%; padding: 10px 15px; border-radius: 18px 18px 4px 18px;
  background: var(--hover); color: var(--tinta); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-bot .who { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13.5px; color: var(--suave); }
.who-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--acento); color: #fff; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px;
  font-size: 12.5px; border: 1px solid var(--linea-fuerte); color: var(--suave);
}
.badge.guia { color: var(--acento); border-color: color-mix(in srgb, var(--acento) 40%, transparent); background: var(--acento-suave); }

.md { color: var(--texto); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md table, .md blockquote, .md pre { margin: 0 0 .85em; }
.md h1, .md h2, .md h3, .md h4 { color: var(--tinta); line-height: 1.25; margin: 1.2em 0 .45em; letter-spacing: -.01em; }
.md h1 { font-size: 1.3em; } .md h2 { font-size: 1.18em; } .md h3, .md h4 { font-size: 1.05em; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: .2em 0; }
.md strong { color: var(--tinta); font-weight: 600; }
.md a { color: var(--acento); }
.md code { font-size: .9em; padding: .1em .35em; border-radius: 5px; background: var(--hover); }
.md pre { padding: 12px 14px; border-radius: var(--radio-s); background: var(--hover); overflow-x: auto; }
.md pre code { padding: 0; background: none; }
.md blockquote { margin-left: 0; padding: 2px 0 2px 14px; border-left: 3px solid var(--acento); color: var(--suave); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: .95em; }
.md th, .md td { border: 1px solid var(--linea-fuerte); padding: 6px 10px; text-align: left; }
.md th { background: var(--hover); font-weight: 600; }
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; margin: .6em 0; }
.md em:last-child:only-child { color: var(--tinta); }

.cursor::after {
  content: ""; display: inline-block; width: 8px; height: 1.05em; margin-left: 2px; vertical-align: -2px;
  background: var(--acento); border-radius: 2px; animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.thinking { display: inline-flex; gap: 5px; padding: 6px 0; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--acento); opacity: .35; animation: pulse 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 40% { opacity: 1; transform: translateY(-2px); } }

.actions { display: flex; gap: 2px; margin-top: 8px; }
.act {
  display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: none; color: var(--suave);
}
.act:hover { background: var(--hover); color: var(--tinta); }
.act[aria-pressed="true"] { color: var(--acento); }
.act.cargando { animation: pulso-btn 1s ease-in-out infinite; }
@keyframes pulso-btn { 50% { opacity: .35; } }
.msg-error { padding: 10px 14px; border-radius: var(--radio-s); border: 1px solid color-mix(in srgb, var(--peligro) 35%, transparent); color: var(--peligro); background: color-mix(in srgb, var(--peligro) 6%, transparent); }

/* ---------- compositor ---------- */
.composer-wrap { padding: 8px 20px calc(12px + env(safe-area-inset-bottom)); }
.composer {
  width: min(100%, 800px); margin: 0 auto; padding: 10px 10px 8px 16px;
  border: 1px solid var(--linea-fuerte); border-radius: var(--radio-l);
  background: var(--superficie); box-shadow: var(--sombra);
}
.composer:focus-within { border-color: color-mix(in srgb, var(--acento) 55%, var(--linea-fuerte)); }
.composer textarea {
  display: block; width: 100%; resize: none; border: 0; outline: none; background: none;
  padding: 4px 4px 6px 0; max-height: 220px; line-height: 1.5;
}
.composer-actions { display: flex; align-items: center; gap: 6px; }
.web-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--suave); }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: none; color: var(--suave);
}
.icon-btn:hover { background: var(--hover); color: var(--tinta); }
#btnMic.rec { color: #fff; background: var(--peligro); animation: none; }
.send {
  display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: var(--acento); color: #fff; transition: opacity .15s;
}
.send:disabled { opacity: .35; cursor: default; }
.send .i-stop { display: none; }
.send.stop .i-send { display: none; } .send.stop .i-stop { display: block; }
.disclaimer { margin: 6px 0 0; text-align: center; font-size: 12.5px; color: var(--suave); }

/* ---------- diálogos ---------- */
.modal {
  width: min(92vw, 480px); padding: 22px 22px 18px; border: 1px solid var(--linea); border-radius: var(--radio-m);
  background: var(--superficie); color: var(--texto); box-shadow: var(--sombra);
}
.modal::backdrop { background: rgba(17, 22, 31, .45); }
.modal h2 { margin: 0 0 10px; font-size: 20px; color: var(--tinta); letter-spacing: -.01em; }
.modal p, .modal li { font-size: 15px; }
.modal ul { padding-left: 1.2em; margin: 8px 0 0; }
.modal textarea { width: 100%; margin-top: 12px; padding: 8px 10px; border: 1px solid var(--linea-fuerte); border-radius: var(--radio-s); background: var(--papel); resize: vertical; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.btn-primary, .btn-ghost { padding: 8px 14px; border-radius: var(--radio-s); font-weight: 500; font-size: 14.5px; }
.btn-primary { border: 0; background: var(--acento); color: #fff; }
.btn-ghost { border: 1px solid var(--linea-fuerte); background: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { padding: 5px 11px; border: 1px solid var(--linea-fuerte); border-radius: 999px; font-size: 14px; cursor: pointer; }
.chips input { position: absolute; opacity: 0; }
.chips label:has(input:checked) { border-color: var(--acento); background: var(--acento-suave); color: var(--acento); }
.chips label:has(input:focus-visible) { outline: 2px solid var(--acento); outline-offset: 2px; }

.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%);
  padding: 8px 14px; border-radius: 10px; background: var(--tinta); color: var(--papel);
  font-size: 14px; box-shadow: var(--sombra); z-index: 50;
}

.only-mobile { display: none; }
.scrim { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); z-index: 40;
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--sombra);
  }
  .sidebar.open { transform: none; }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(17,22,31,.4); }
  .only-mobile { display: grid; }
  .topbar { padding: 8px 12px; align-items: flex-start; }
  .messages { padding: 18px 14px 8px; }
  .composer-wrap { padding: 6px 10px calc(8px + env(safe-area-inset-bottom)); }
  .suggest { grid-template-columns: 1fr; }
  .session { gap: 6px; }
  .session .field { flex: 1 1 140px; min-width: 0; }
  .field select, .field input { width: 100%; }
  .msg-user .bubble { max-width: 90%; }
}
/* Resumen de sesión (solo en pantallas estrechas, p. ej. el panel dentro de Moodle) */
.session-resumen { display: none; }
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; }
  .session-resumen {
    display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; height: 36px;
    padding: 0 10px; border: 1px solid var(--linea); border-radius: 10px; background: var(--superficie);
    font-size: 14.5px; font-weight: 500; color: var(--tinta); text-align: left;
  }
  .resumen-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--acento); }
  .resumen-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .session-resumen svg { flex: none; color: var(--suave); transition: transform .15s; }
  .session-resumen[aria-expanded="true"] svg { transform: rotate(180deg); }
  .session { display: none; width: 100%; padding: 6px 0 2px; }
  .topbar.abierta .session { display: flex; }
  .session .seg { width: 100%; }
  .session .seg button { flex: 1; }
  .session .field { flex: 1 1 100%; }
  /* Pantalla inicial compacta */
  .empty { padding: 18px 14px; place-items: start center; }
  .empty h1 { font-size: 24px; margin-bottom: 4px; }
  .empty-lead { font-size: 14.5px; margin-bottom: 14px; }
  .suggest { grid-template-columns: 1fr 1fr; gap: 8px; }
  .suggest button { padding: 10px 12px; }
  .suggest button span { display: none; }
  .suggest button strong { margin: 0; font-weight: 500; }
  .composer { padding: 8px 8px 6px 12px; border-radius: 18px; }
}
@media (max-width: 520px) {
  .seg button { padding: 5px 9px; font-size: 14px; }
  .disclaimer { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Gráficas en papel milimetrado */
.graf { margin: .6em 0 1em; max-width: 520px; border: 1px solid var(--linea-fuerte); border-radius: var(--radio-s); overflow: hidden; background: #fff; }
.graf img { display: block; width: 100%; height: auto; }
.graf figcaption { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; background: var(--superficie); border-top: 1px solid var(--linea); font-size: 13.5px; color: var(--suave); }
.graf figcaption span { flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.graf-btn { padding: 5px 10px; border: 1px solid var(--linea-fuerte); border-radius: 8px; background: var(--superficie); font-size: 13.5px; font-weight: 500; color: var(--tinta); }
.graf-btn:hover { background: var(--hover); }
.graf-btn.primario { border-color: var(--acento); background: var(--acento); color: #fff; }
.graf-aviso { margin: .6em 0; padding: 10px 12px; border: 1px dashed var(--linea-fuerte); border-radius: var(--radio-s); font-size: 14px; color: var(--suave); }
.cargando-graf { animation: pulso-btn 1.2s ease-in-out infinite; }
.modal-graf { width: min(96vw, 820px); max-height: 94vh; padding: 12px; overflow: auto; }
.modal-graf img { display: block; width: 100%; height: auto; border: 1px solid var(--linea); }
.graf-ayuda { margin: 8px 2px 0; font-size: 13px; color: var(--suave); }

/* ---------- Conversación guiada (inicio de cada conversación) ---------- */
.empty { place-items: start center; padding-top: 28px; }
.guia { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.guia:empty { display: none; }
.guia-bot { display: flex; align-items: flex-start; gap: 10px; animation: aparecer .22s ease-out; }
.guia-bot .who-mark { flex: none; width: 28px; height: 28px; border-radius: 8px; margin-top: 2px; }
.guia-texto {
  max-width: 560px; padding: 10px 14px; border-radius: 4px 16px 16px 16px;
  background: var(--superficie); border: 1px solid var(--linea); color: var(--texto); line-height: 1.5;
}
.guia-texto strong { color: var(--tinta); }
.guia-usuario { display: flex; justify-content: flex-end; animation: aparecer .18s ease-out; }
.guia-usuario .bubble { padding: 8px 14px; border-radius: 16px 16px 4px 16px; background: var(--hover); color: var(--tinta); font-weight: 500; }
.guia-opciones { display: flex; flex-wrap: wrap; gap: 8px; margin-left: 38px; animation: aparecer .22s ease-out; }
.guia-opciones button {
  padding: 8px 14px; border: 1px solid color-mix(in srgb, var(--acento) 45%, var(--linea-fuerte)); border-radius: 999px;
  background: var(--superficie); color: var(--tinta); font-size: 14.5px; text-align: left; line-height: 1.3;
}
.guia-opciones button strong { font-weight: 500; }
.guia-opciones button:hover:not(:disabled) { background: var(--acento-suave); border-color: var(--acento); }
.guia-opciones button.secundaria { border-style: dashed; color: var(--suave); }
.guia-opciones.lista { flex-direction: column; align-items: stretch; max-width: 460px; }
.guia-opciones.lista button { display: flex; flex-direction: column; gap: 2px; padding: 9px 14px; border-radius: 12px; }
.guia-opciones.lista button span { font-size: 13px; color: var(--suave); }
.guia-opciones button:disabled { cursor: default; opacity: .45; }
.guia-opciones button.elegida { opacity: 1; background: var(--acento-suave); border-color: var(--acento); }
.guia-opciones:has(button:disabled) { pointer-events: none; }
.hero { animation: aparecer .25s ease-out; }
@keyframes aparecer { from { opacity: 0; transform: translateY(4px); } }
/* Mientras dura la guía, los controles de sesión se ocultan para no duplicar */
body.guiando .session, body.guiando .session-resumen { display: none !important; }
body.guiando .topbar { min-height: 49px; }
@media (max-width: 600px) {
  .empty { padding-top: 16px; }
  .guia-opciones { margin-left: 0; }
  .guia-texto { max-width: 100%; }
}

/* ---------- Mascota de MentorLab (siempre visible, junto al compositor) ---------- */
.composer-row { display: flex; align-items: flex-end; gap: 10px; width: min(100%, 868px); margin: 0 auto; }
.composer-row .composer { flex: 1; min-width: 0; width: auto; margin: 0; }
.mascota {
  position: relative; flex: none; width: 58px; height: 58px; margin-bottom: 4px; padding: 4px;
  border: 1px solid var(--linea); border-radius: 18px; background: var(--superficie); cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.mascota:hover { border-color: var(--acento); }
.mascota[aria-pressed="true"] { border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
.mascota svg { display: block; width: 100%; height: 100%; overflow: visible; }
.m-vidrio { fill: color-mix(in srgb, var(--acento) 7%, var(--superficie)); stroke: var(--tinta); stroke-width: 2.2; stroke-linejoin: round; }
.m-liquido { fill: var(--acento); opacity: .85; transition: fill .25s; }
.m-boca-tapa { fill: var(--tinta); }
.m-ojos ellipse { fill: var(--tinta); transform-box: fill-box; transform-origin: center; animation: parpadeo 4.6s infinite; }
.m-boca { fill: var(--tinta); transform-box: fill-box; transform-origin: center; }
.m-burbujas circle { fill: var(--acento); opacity: 0; }
/* Indicador de voz automática */
.m-voz { position: absolute; right: -4px; top: -4px; width: 18px; height: 18px; border-radius: 50%; background: var(--superficie); border: 1px solid var(--linea-fuerte); }
.m-voz::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--linea-fuerte); }
.mascota[aria-pressed="true"] .m-voz::after { background: var(--acento); }
/* Estados */
.mascota.pensando .m-burbujas circle { animation: burbuja 1.4s ease-in infinite; }
.mascota.pensando .m-b2 { animation-delay: .35s !important; }
.mascota.pensando .m-b3 { animation-delay: .7s !important; }
.mascota.pensando .m-ojos ellipse { animation: mirar 1.6s ease-in-out infinite; }
.mascota.escuchando { border-color: var(--peligro); box-shadow: 0 0 0 3px color-mix(in srgb, var(--peligro) 18%, transparent); }
.mascota.escuchando .m-ojos ellipse { transform: scale(1.15); animation: none; }
@keyframes parpadeo { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes burbuja { 0% { opacity: 0; transform: translateY(6px); } 30% { opacity: .9; } 100% { opacity: 0; transform: translateY(-6px); } }
@keyframes mirar { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-1.2px); } 70% { transform: translateX(1.2px); } }
@media (max-width: 600px) {
  .composer-row { gap: 6px; }
  .mascota { width: 46px; height: 46px; border-radius: 14px; padding: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .m-ojos ellipse, .mascota.pensando .m-burbujas circle { animation: none !important; }
}

/* Atajo «pregúntame en voz alta» en la guía inicial */
.guia-voz {
  display: flex; width: fit-content; max-width: calc(100% - 38px); align-items: center; gap: 12px; margin: 14px 0 0 38px; padding: 10px 16px 10px 12px;
  border: 1px dashed var(--acento); border-radius: 999px; background: var(--acento-suave); color: var(--acento);
  font: inherit; text-align: left; cursor: pointer; transition: background .2s, transform .1s;
}
.guia-voz:hover { background: color-mix(in srgb, var(--acento) 16%, var(--superficie)); }
.guia-voz:active { transform: scale(.98); }
.guia-voz svg { flex: none; width: 34px; height: 34px; padding: 7px; border-radius: 50%; background: var(--acento); color: #fff; }
.guia-voz strong { display: block; font-size: .95rem; }
.guia-voz small { display: block; color: var(--suave); font-size: .8rem; }
body.dictando .guia-voz { border-style: solid; border-color: var(--peligro); color: var(--peligro); }
body.dictando .guia-voz svg { background: var(--peligro); animation: latido 1.2s ease-in-out infinite; }
@keyframes latido { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--peligro) 45%, transparent); } 50% { box-shadow: 0 0 0 8px transparent; } }
@media (max-width: 600px) { .guia-voz { margin-left: 0; max-width: 100%; } }
@media (prefers-reduced-motion: reduce) { body.dictando .guia-voz svg { animation: none; } }


/* Estado de activación y conversación por voz (v5.1) */
.voice-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 24px;
  margin: 5px 8px 1px;
  color: var(--suave);
  font-size: .76rem;
  line-height: 1.25;
  text-align: center;
}
.voice-status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--linea-fuerte);
}
.voice-status[data-state="wake"] .voice-status-dot { background: #3b82f6; box-shadow: 0 0 0 4px color-mix(in srgb, #3b82f6 14%, transparent); }
.voice-status[data-state="listening"] { color: var(--peligro); }
.voice-status[data-state="listening"] .voice-status-dot { background: var(--peligro); animation: latido 1.2s ease-in-out infinite; }
.voice-status[data-state="processing"] .voice-status-dot { background: var(--acento); }
.voice-status[data-state="speaking"] .voice-status-dot { background: #0f9f6e; }
.voice-status[data-state="manual"] .voice-status-dot { background: #d97706; }
@media (max-width: 600px) { .voice-status { font-size: .7rem; margin-inline: 4px; } }
@media (prefers-reduced-motion: reduce) { .voice-status[data-state="listening"] .voice-status-dot { animation: none; } }

/* ---------- Identidad visual MentorLab UCE ---------- */
.brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
}
.brand { gap: 10px; }
.brand-name { font-size: 16px; }
.brand-sub { font-size: 12px; }
.hero-logo {
  display: block;
  width: clamp(112px, 19vw, 168px);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  margin: 0 auto 18px;
  filter: drop-shadow(0 3px 9px rgba(10, 42, 82, .12));
}
@media (max-width: 600px) {
  .brand-logo { width: 46px; height: 46px; }
  .hero-logo { width: 118px; margin-bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-logo { filter: none; }
}

/* MentorLab v5.3.1: guía permanente de comandos y control de parada */
.mentorlab-voice-guide { width: min(100%, 800px); margin: 6px auto 3px; font-size: 12.5px; color: var(--suave); }
.mentorlab-voice-guide details { border: 1px solid var(--linea-fuerte); border-radius: 10px; background: var(--superficie); }
.mentorlab-voice-guide summary { cursor: pointer; padding: 8px 11px; font-weight: 600; color: var(--acento); }
.mentorlab-voice-guide summary:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
.mentorlab-voice-guide-body { padding: 2px 12px 12px; line-height: 1.45; }
.mentorlab-voice-guide-body p { margin: 8px 0; }
.mentorlab-stop-button { border: 1px solid var(--linea-fuerte); border-radius: 8px; background: var(--hover); color: var(--tinta); padding: 7px 11px; font-weight: 600; }
.mentorlab-stop-button:hover { border-color: var(--acento); }
@media (max-width: 600px) { .mentorlab-voice-guide { font-size: 12px; } }
