/* Chat Cadipel a pantalla completa — brand del landing (#062858 / #1e6bff / Space Grotesk). */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --border: #dce6f5;
  --text: #062858;
  --muted: #6b7280;
  --accent: #1e6bff;
  --accent-dark: #1558db;
  --accent-soft: #e4f0ff;
  --user-bg: #1e6bff;
  --user-text: #ffffff;
  --danger: #d93a3a;
  --shadow: 0 10px 30px rgba(6, 40, 88, 0.10);
  --shadow-soft: 0 1px 2px rgba(6, 40, 88, 0.06);
  --topbar-h: 64px;
  --sidebar-w: 280px;
  --logo-filter: none;
}

:root[data-theme="dark"] {
  --bg: #0b1424;
  --surface: #111d33;
  --surface-2: #17263f;
  --border: #223454;
  --text: #e8eefb;
  --muted: #93a1bd;
  --accent: #4f8bff;
  --accent-dark: #3b78f0;
  --accent-soft: #172a4d;
  --user-bg: #2a62d9;
  --user-text: #ffffff;
  --danger: #ff6b6b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.35);
  --logo-filter: brightness(0) invert(1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
button, a, .chip, .conv_item, .conv_open { -webkit-tap-highlight-color: transparent; }

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Topbar ---------- */
.topbar {
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; margin-right: 6px; }
/* El wordmark del logo pesa visualmente más que el trazo diagonal que lo corona: centrado por
   bounding box (igual altura que el botón de menú) el texto se ve corrido hacia abajo. Se compensa
   con un pequeño ajuste óptico hacia arriba. */
.brand_logo { height: 30px; width: auto; display: block; filter: var(--logo-filter); transform: translateY(-2px); }
.topbar_spacer { flex: 1; }

.icon_btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.icon_btn:hover { background: var(--surface-2); color: var(--text); }
.icon_btn.is-on { background: var(--accent-soft); color: var(--accent); }
.icon_btn--danger:hover { color: var(--danger); }
.sidebar_toggle { display: none; }

.pill_btn {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.pill_btn--ghost:hover { background: var(--surface-2); }
.pill_btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill_btn--primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* ---------- Layout ---------- */
.layout { flex: 1; min-height: 0; display: flex; position: relative; }

.sidebar {
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.new_chat_btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 11px 14px;
  border: 1px dashed var(--accent);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}
.new_chat_btn:hover { background: var(--surface-2); }
.sidebar_label {
  margin: 8px 8px 0;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.conv_list { flex: 1; list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.conv_item { display: flex; align-items: center; border-radius: 10px; }
.conv_item:hover, .conv_item.is-active { background: var(--surface-2); }
.conv_item.is-active .conv_open { font-weight: 600; color: var(--accent); }
.conv_open {
  flex: 1;
  min-width: 0;
  padding: 10px 10px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv_del {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin-right: 6px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
}
.conv_item:hover .conv_del, .conv_item.is-active .conv_del { opacity: 1; }
.conv_del:hover { color: var(--danger); background: var(--surface); }

.sidebar_footer { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; border-top: 1px solid var(--border); }
.side_link {
  display: block;
  padding: 9px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
}
.side_link:hover { background: var(--surface-2); color: var(--text); }
.show_sm { display: none; }
.sidebar_backdrop { display: none; }

/* Contacto/idioma/tema, movidos acá desde el topbar en mobile (ver media query 820px). */
.sidebar_quick_actions { display: none; flex-direction: column; gap: 8px; padding-bottom: 12px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.sidebar_quick_actions .pill_btn { justify-content: center; width: 100%; }
.sidebar_quick_row { display: flex; gap: 8px; }
.sidebar_quick_row .pill_btn { flex: 1; }
.sidebar_quick_row .icon_btn { flex-shrink: 0; border: 1px solid var(--border); }

/* ---------- Chat ---------- */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.chat_head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}
.chat_head_avatar { width: 40px; height: 40px; flex-shrink: 0; }
.chat_head_text { display: flex; flex-direction: column; line-height: 1.25; }
.chat_head_status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.chat_head_status i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; }

.messages_scroll { flex: 1; min-height: 0; overflow-y: auto; }
.messages {
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.msg--user { align-items: flex-end; }
.msg--bot { align-items: flex-start; }

.bubble {
  max-width: min(680px, 100%);
  padding: 12px 16px;
  border-radius: 18px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.msg--user .bubble { background: var(--user-bg); color: var(--user-text); border-bottom-right-radius: 6px; }
.msg--bot .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; box-shadow: var(--shadow-soft); white-space: normal; }
.bubble--error { border-color: var(--danger) !important; color: var(--danger); }

.md p { margin: 0 0 .6em; }
.md p:last-child, .md ul:last-child, .md ol:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 0 0 .6em; padding-left: 1.3em; }
.md li { margin: .15em 0; }
.md code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); font-size: .9em; }

.msg_actions { display: flex; gap: 2px; margin-left: 4px; }
.act_btn {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: none; border-radius: 8px; background: transparent; color: var(--muted);
}
.act_btn:hover { background: var(--surface-2); color: var(--text); }
.act_btn--speak .ic_stop_sm { display: none; }
.act_btn--speak.is-playing { color: var(--accent); }
.act_btn--speak.is-playing .ic_speak { display: none; }
.act_btn--speak.is-playing .ic_stop_sm { display: block; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 14px;
  transition: background .15s, border-color .15s;
}
.chip:hover { background: var(--accent-soft); border-color: var(--accent); }

.typing { display: inline-flex; gap: 5px; align-items: center; height: 22px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typing 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Welcome ---------- */
.is-empty .chat_head { display: none; }
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
  padding: 6vh 0 0;
}
.welcome_avatar { width: 112px; height: 112px; }
.welcome_title { margin: 6px 0 0; font-size: clamp(22px, 4vw, 30px); line-height: 1.2; }
.welcome_text { margin: 0; max-width: 520px; color: var(--muted); }
.welcome .chips { justify-content: center; max-width: 620px; margin-top: 8px; }

/* ---------- Composer ---------- */
.composer_wrap { flex: 0 0 auto; padding: 8px 24px calc(14px + env(safe-area-inset-bottom)); max-width: 860px; width: 100%; margin: 0 auto; }
.composer {
  display: flex;
  align-items: flex-end; /* el textarea puede crecer a varias líneas: los botones quedan abajo */
  gap: 6px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
/* Mientras se graba/está bloqueado/hay replay, la franja no crece — centrarla en vez de alinearla
   abajo evita que quede unos px más baja que los botones circulares de al lado (mic/orbe). */
.composer.is-holding { align-items: center; }
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 160px;
  padding: 9px 0;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}
.composer textarea::placeholder { color: var(--muted); }
.composer_actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.send_btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: var(--accent); color: #fff;
  transition: background .15s, opacity .15s;
}
.send_btn:hover:not(:disabled) { background: var(--accent-dark); }
.send_btn:disabled { opacity: .35; cursor: default; }
.send_btn .ic_stop { display: none; }
.send_btn.is-stop .ic_send { display: none; }
.send_btn.is-stop .ic_stop { display: block; }

.disclaimer { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* El detalle del dictado (franja de grabación, lock, orbe) vive en el bloque "Modo voz" más abajo. */
.composer.is-transcribing { opacity: .6; pointer-events: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .hide_sm { display: none; }
  .show_sm { display: block; }
  .sidebar_quick_actions.show_sm { display: flex; }
  .sidebar_toggle { display: inline-grid; }
  .pill_btn { padding: 0 12px; font-size: 13px; }

  .sidebar {
    position: absolute;
    z-index: 30;
    top: 0; bottom: 0; left: 0;
    width: min(300px, 84vw);
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .sidebar_open .sidebar { transform: none; box-shadow: var(--shadow); }
  .sidebar_backdrop { position: absolute; inset: 0; z-index: 20; background: rgba(6, 20, 44, .45); }
  .sidebar_open .sidebar_backdrop { display: block; }

  .chat_head { padding: 10px 16px; }
  .messages { padding: 4px 16px 20px; }
  .composer_wrap { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
  .disclaimer { display: none; }
  .bubble { max-width: 92%; }
  .toast { bottom: 84px; }
}

@media (max-width: 420px) {
  #contact_btn { font-size: 12px; padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Evita el destello de textos sin traducir hasta que carga el diccionario */
.app { opacity: 0; transition: opacity .15s; }
.is-ready .app { opacity: 1; }

/* ================= Modo voz: dictado (hold-to-talk) + orbe "mantené para hablar" =================
   Puerto de camiaHoldMic.css / CamiaVoiceHold.tsx (mi-oshka/CamIA vía web/css/assistant.css),
   con los colores mapeados a los tokens de tema de este archivo (funciona en claro y oscuro). */

.chat { position: relative; }

/* ---------- Campo de texto: contiene textarea, franja de grabación y animación de cancelar ---------- */
.text_field { flex: 1 1 auto; min-width: 0; position: relative; display: flex; align-items: center; }

/* Durante el swipe-cancelar se tiñe TODO el composer (misma forma, sin costuras) en vez de un
   rectángulo interno con su propio radio — evita el "escalón" entre la cápsula blanca y el tinte. */
.composer.is-swiping-cancel { background: rgba(217, 58, 58, 0.05); border-color: rgba(217, 58, 58, 0.22); }
.composer.is-cancel { background: rgba(217, 58, 58, 0.09); border-color: rgba(217, 58, 58, 0.36); }

.hold_strip { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; position: relative; height: 40px; }
/* Punto + timer + onda se apagan a medida que aparece "Soltá para cancelar", en vez de superponerse. */
.hold_meter {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  opacity: clamp(0, calc(1 - var(--cancel-progress, 0) * 1.7), 1);
  transition: opacity .05s linear;
}
.hold_trash_anchor {
  /* Siempre a tamaño completo (sin el pop-in ligado al progreso del swipe): a mitad de escala
     quedaba mal recortado/descentrado — el tinte rosa de fondo ya avisa que se está cancelando. */
  position: relative; z-index: 2; width: 22px; height: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.hold_trash { width: 18px; height: 18px; display: block; filter: brightness(0) saturate(100%) invert(24%) sepia(93%) saturate(4200%) hue-rotate(350deg); }
.hold_dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0; animation: dotPulse 1.4s ease-in-out infinite; }
@keyframes dotPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .65; transform: scale(.92); } }
.hold_time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--text); flex-shrink: 0; min-width: 4.4em; }
.hold_wave { flex: 1; min-width: 0; height: 24px; display: flex; align-items: center; justify-content: space-evenly; }
.hold_wave span { display: block; width: 3px; min-height: 3px; background: var(--accent); border-radius: 3px; transition: height .08s ease-out; }
.hold_cancel_hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  font-size: 13px; font-weight: 500; color: var(--danger); white-space: nowrap; pointer-events: none;
  opacity: clamp(0, calc((var(--cancel-progress, 0) - 0.3) * 2.2), 1);
}

/* ---------- Mic con gesto de mantener presionado ---------- */
.mic_slot { position: relative; flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; }
.mic_btn {
  position: relative; z-index: 1; width: 40px; height: 40px; display: grid; place-items: center;
  border: none; border-radius: 50%; background: transparent; color: var(--muted); padding: 0;
  transition: background .15s, box-shadow .15s, color .15s;
}
.mic_btn:hover { background: var(--surface-2); color: var(--text); }
.mic_btn.is-recording { background: var(--accent); color: #fff; box-shadow: 0 0 0 3px rgba(30, 107, 255, .18); animation: micRecPulse .85s ease-in-out infinite; }
.mic_btn.is-cancel-armed { box-shadow: 0 0 0 5px rgba(217, 58, 58, .28); }
@keyframes micRecPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.mic_lock_zone {
  position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 5px 9px 4px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-soft);
  color: var(--muted); pointer-events: none; white-space: nowrap;
  transform: translateX(-50%) translateY(calc(8px * (1 - var(--lock-progress, 0)))) scale(calc(.88 + .12 * var(--lock-progress, 0)));
  opacity: calc(.75 + .25 * var(--lock-progress, 0));
  transition: transform .08s linear, opacity .08s linear, border-color .15s, background .15s;
}
.mic_lock_zone.is-armed { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.mic_lock_icon { width: 13px; height: 13px; display: block; }
.mic_lock_arrow { width: 11px; height: 11px; display: block; opacity: .85; animation: lockBounce 1.1s ease-in-out infinite; }
.mic_lock_label { font-size: 11px; font-weight: 600; letter-spacing: .02em; }
@keyframes lockBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }

.locked_actions { position: relative; flex-shrink: 0; width: 40px; height: 40px; }
.locked_send {
  position: relative; z-index: 1; width: 40px; height: 40px; display: grid; place-items: center;
  border: none; border-radius: 50%; background: var(--accent); color: #fff; padding: 0;
  box-shadow: 0 0 0 3px rgba(30, 107, 255, .14);
  transition: background .15s, transform .12s;
  animation: lockedSendIn .25s cubic-bezier(.22, 1, .36, 1);
}
.locked_send:hover:not(:disabled) { background: var(--accent-dark); }
.locked_send:active:not(:disabled) { transform: scale(.94); }
.locked_send:disabled { opacity: .4; cursor: default; }
@keyframes lockedSendIn { from { transform: scale(.5); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.locked_cancel {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; background: var(--surface); border: 1px solid var(--border); color: var(--muted); padding: 0;
  transition: color .15s, border-color .15s;
}
.locked_cancel:hover { color: var(--danger); border-color: var(--danger); }

.voice_toggle_btn {
  flex-shrink: 0; width: 44px; height: 44px; display: grid; place-items: center;
  border: none; border-radius: 50%; padding: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 28%, rgba(255,255,255,.3), transparent 42%), linear-gradient(180deg, var(--accent-dark) 0%, var(--accent) 100%);
  box-shadow: 0 4px 14px rgba(21, 88, 219, .28);
  transition: transform .15s, box-shadow .15s;
}
.voice_toggle_btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(21, 88, 219, .34); }

/* ---------- Animación de "tacho" al cancelar (swipe) ---------- */
.replay_strip { flex: 1; min-width: 0; display: flex; align-items: center; height: 22px; position: relative; }
.mic_trash_bin { position: relative; width: 26px; height: 22px; isolation: isolate; overflow: visible; }
.mic_trash_svg { position: absolute; left: 0; bottom: 0; display: block; overflow: visible; }
.mic_trash_svg--body { z-index: 2; }
.mic_trash_svg--lid { z-index: 12; pointer-events: none; }
.mic_trash_shape { fill: #d93a3a; }
.mic_trash_lid_grp { transform-origin: 3px 6.2px; transform-box: fill-box; }
.mic_trash_drop_mic { position: absolute; left: 13px; bottom: 18px; width: 16px; height: 16px; margin-left: -8px; z-index: 1; line-height: 0; transform-origin: center center; }
.mic_drop_icon { display: block; filter: brightness(0); }
.mic_trash_bin--replay .mic_trash_drop_mic { animation: micDropFall 1.65s ease-in forwards; }
.mic_trash_bin--replay .mic_trash_lid_grp { animation: micLidCycle 1.65s ease-out forwards; }
.mic_trash_bin--replay .mic_trash_svg--body { animation: micCanCatch 1.65s cubic-bezier(.45, .05, .25, 1) forwards; }
@keyframes micDropFall {
  0% { transform: translateY(-80px) rotate(0deg) scale(1); opacity: 0; }
  3% { opacity: 1; }
  46% { transform: translateY(-2px) rotate(16deg) scale(.68); opacity: 1; }
  51%, 100% { transform: translateY(7px) rotate(20deg) scale(.52); opacity: 0; }
}
@keyframes micLidCycle {
  0%, 4% { transform: rotate(0deg); }
  10% { transform: rotate(-40deg); }
  16% { transform: rotate(-78deg); }
  22%, 48% { transform: rotate(-95deg); }
  62% { transform: rotate(-30deg); }
  76% { transform: rotate(-6deg); }
  88% { transform: rotate(1deg); }
  100% { transform: rotate(0deg); }
}
@keyframes micCanCatch {
  0%, 51% { transform: translateX(0); }
  55% { transform: translateX(0) translateY(.5px) scale(1.012, .992); }
  63%, 100% { transform: translateX(0); }
}

/* ================= Pantalla de modo voz ================= */
.voice_view {
  display: none;
  position: absolute; inset: 0;
  flex-direction: column; align-items: center; justify-content: space-between;
  gap: 24px;
  padding: 56px 24px calc(40px + env(safe-area-inset-bottom));
  text-align: center; overflow: hidden;
  background: var(--bg);
}
.app.voice-mode .chat_head,
.app.voice-mode .messages_scroll,
.app.voice-mode .composer_wrap { display: none; }
.app.voice-mode .voice_view { display: flex; }

.back_text_btn {
  position: absolute; left: 16px; bottom: 16px; z-index: 2;
  width: 38px; height: 38px; display: grid; place-items: center;
  border: none; border-radius: 10px; color: var(--accent); background: transparent;
  transition: background .15s;
}
.back_text_btn:hover { background: var(--surface-2); }
:root[data-theme="dark"] .back_text_btn img { filter: brightness(1.35); }

.voice_hero {
  display: flex; flex-direction: column; align-items: center;
  /* Más separación entre el avatar y la burbuja de texto que la del resto de la UI a propósito. */
  gap: 40px; min-height: 0; overflow: hidden; padding-top: 8px;
}
.voice_avatar_wrap { width: 128px; height: 128px; flex-shrink: 0; }

.voice_caption {
  position: relative; min-width: 180px; max-width: min(92%, 460px);
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow-soft);
  font-size: 15px; line-height: 1.5; max-height: 220px; overflow-y: auto; min-height: 22px;
}
.voice_caption.is-tts { padding-top: 18px; padding-left: 38px; }
.stop_tts_btn {
  position: absolute; top: 8px; left: 8px; z-index: 2; width: 28px; height: 28px;
  display: grid; place-items: center; border: 1px solid var(--border); background: var(--surface);
  color: var(--accent); border-radius: 50%; padding: 0;
  animation: ttsPulse 1.2s ease-in-out infinite;
}
.stop_tts_btn:hover { background: var(--accent-soft); border-color: var(--accent); }
@keyframes ttsPulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.voice_dock { display: flex; flex-direction: column; align-items: center; gap: 16px; flex-shrink: 0; }
.voice_orb_wrap { --cadipel-mic-level: 0; position: relative; width: 76px; height: 76px; flex-shrink: 0; }
.voice_orb_wrap::before, .voice_orb_wrap::after {
  content: ''; position: absolute; left: 50%; top: 50%; border-radius: 50%; pointer-events: none;
  transform: translate(-50%, -50%); border: 1px solid rgba(30, 107, 255, .28);
}
.voice_orb_wrap::before { width: calc(100% + 22px); height: calc(100% + 22px); opacity: .7; animation: orbBreathe 3.4s ease-in-out infinite; }
.voice_orb_wrap::after { width: calc(100% + 38px); height: calc(100% + 38px); opacity: .4; animation: orbBreathe 3.4s ease-in-out infinite .6s; }
.voice_orb_wrap.is-live::before, .voice_orb_wrap.is-live::after {
  animation-duration: 1.7s; border-color: rgba(30, 107, 255, calc(.35 + var(--cadipel-mic-level, 0) * .3));
}
@keyframes orbBreathe { 0%, 100% { opacity: .35; transform: translate(-50%, -50%) scale(.985); } 50% { opacity: .75; transform: translate(-50%, -50%) scale(1.02); } }

.voice_orb {
  position: relative; z-index: 1; width: 76px; height: 76px; border-radius: 50%; border: none; padding: 0;
  cursor: pointer; touch-action: none; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 28%, rgba(255,255,255,.28), transparent 42%), linear-gradient(180deg, var(--accent-dark) 0%, var(--accent) 48%, #74b0ff 100%);
  box-shadow: 0 14px 32px rgba(21, 88, 219, .26), 0 0 0 8px var(--bg), inset 0 2px 3px rgba(255,255,255,.2), inset 0 -8px 14px rgba(6,40,88,.16);
  transition: transform .16s cubic-bezier(.22,1,.36,1), box-shadow .16s ease, filter .16s ease;
}
.voice_orb.is-pressing { transform: scale(.94); filter: brightness(.93); }
.voice_orb.is-live:not(.is-pressing) { transform: scale(1.03); }
.voice_orb.is-live {
  box-shadow: 0 16px 36px rgba(21, 88, 219, calc(.28 + var(--cadipel-mic-level, 0) * .18)),
    0 0 0 calc(8px + var(--cadipel-mic-level, 0) * 3px) var(--bg),
    inset 0 2px 3px rgba(255,255,255,.2), inset 0 -8px 14px rgba(6,40,88,.16);
}

/* Mini onda del botón "modo voz" en el composer (5 barras, forma de cerro simétrica) */
.orb_wave { display: flex; align-items: center; justify-content: center; gap: 2.5px; height: 16px; pointer-events: none; }
.orb_wave i { display: block; width: 2.5px; border-radius: 99px; background: #fff; opacity: .95; }
.orb_wave i:nth-child(1) { height: 5px; } .orb_wave i:nth-child(2) { height: 10px; } .orb_wave i:nth-child(3) { height: 16px; }
.orb_wave i:nth-child(4) { height: 10px; } .orb_wave i:nth-child(5) { height: 5px; }

/* Onda grande del orbe de la pantalla de voz (9 barras) */
.orb_wave--lg { gap: 3px; height: 30px; }
.orb_wave--lg i { width: 3px; }
.orb_wave--lg i:nth-child(1) { height: 7px; } .orb_wave--lg i:nth-child(2) { height: 12px; } .orb_wave--lg i:nth-child(3) { height: 18px; }
.orb_wave--lg i:nth-child(4) { height: 23px; } .orb_wave--lg i:nth-child(5) { height: 28px; }
.orb_wave--lg i:nth-child(6) { height: 23px; } .orb_wave--lg i:nth-child(7) { height: 18px; }
.orb_wave--lg i:nth-child(8) { height: 12px; } .orb_wave--lg i:nth-child(9) { height: 7px; }
.voice_orb_wrap.is-live .orb_wave i:nth-child(1) { height: calc(6px + var(--cadipel-mic-level, 0) * 6px); }
.voice_orb_wrap.is-live .orb_wave i:nth-child(2) { height: calc(10px + var(--cadipel-mic-level, 0) * 7px); }
.voice_orb_wrap.is-live .orb_wave i:nth-child(3) { height: calc(14px + var(--cadipel-mic-level, 0) * 9px); }
.voice_orb_wrap.is-live .orb_wave i:nth-child(4) { height: calc(19px + var(--cadipel-mic-level, 0) * 9px); }
.voice_orb_wrap.is-live .orb_wave i:nth-child(5) { height: calc(24px + var(--cadipel-mic-level, 0) * 11px); }
.voice_orb_wrap.is-live .orb_wave i:nth-child(6) { height: calc(19px + var(--cadipel-mic-level, 0) * 9px); }
.voice_orb_wrap.is-live .orb_wave i:nth-child(7) { height: calc(14px + var(--cadipel-mic-level, 0) * 9px); }
.voice_orb_wrap.is-live .orb_wave i:nth-child(8) { height: calc(10px + var(--cadipel-mic-level, 0) * 7px); }
.voice_orb_wrap.is-live .orb_wave i:nth-child(9) { height: calc(6px + var(--cadipel-mic-level, 0) * 6px); }

.voice_footer { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 30px; }
.voice_timer { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent-dark); letter-spacing: .02em; visibility: hidden; }
.voice_status { margin: 0; font-size: 13px; font-weight: 600; color: var(--accent-dark); text-align: center; }

@media (max-width: 820px) {
  .voice_avatar_wrap { width: 104px; height: 104px; }
  .voice_view { padding: 48px 16px calc(32px + env(safe-area-inset-bottom)); }
  .voice_hero { gap: 28px; }
}
