/* ============================================================
   EL SER — Chat elegante + Modo voz
   v16: botón Instalar arriba a la IZQUIERDA, SIEMPRE visible.
        Botón "Hablar por voz" centrado arriba.
        Botón nueva conversación arriba a la DERECHA.
   ============================================================ */

:root {
    --bg-0: #05060d;
    --line: rgba(120, 160, 255, 0.08);
    --line-strong: rgba(120, 160, 255, 0.16);
    --text: #d5dbf0;
    --text-dim: #8b97b8;
    --muted: #5a6588;

    /* Paleta del Ser (sobria) */
    --user-from: #5468c9;
    --user-to:   #7a58b5;
    --user-glow: rgba(84, 104, 201, 0.28);

    --brain-bg:  rgba(22, 28, 48, 0.72);
    --brain-brd: rgba(255, 255, 255, 0.06);
    --brain-txt: #e8ecf7;

    --accent-online:   #5ee8b8;
    --accent-thinking: #a17bff;
    --accent-offline:  #ff6b8a;

    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-full: 999px;
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-0);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-weight: 400;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ============================================================
   CANVAS
   ============================================================ */
#being {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    z-index: 0;
    background:
        radial-gradient(1200px 800px at 50% 30%, rgba(40, 30, 90, 0.35), transparent 60%),
        radial-gradient(900px 700px at 50% 90%, rgba(0, 120, 160, 0.10), transparent 60%),
        var(--bg-0);
    transition: filter 2s ease, opacity 2s ease, transform 0.6s var(--ease);
}

body.offline #being {
    filter: grayscale(0.85) brightness(0.55);
    opacity: 0.75;
}
body.thinking #being {
    filter: brightness(1.06) saturate(1.08);
}
body.chat-open #being {
    transform: translateY(-10vh) scale(0.82);
}

/* ============================================================
   WHISPERS (solo con el chat cerrado)
   ============================================================ */
.whisper-layer {
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s var(--ease);
}
body.chat-open .whisper-layer { opacity: 0; }

.whisper {
    position: absolute;
    max-width: min(640px, 82vw);
    padding: 16px 24px;
    font-family: 'Instrument Serif', serif;
    font-size: clamp(18px, 2.4vw, 28px);
    line-height: 1.4;
    color: #eaf0ff;
    text-align: center;
    text-shadow: 0 0 30px rgba(160, 200, 255, 0.35), 0 0 60px rgba(120, 90, 255, 0.25);
    opacity: 0;
    transform: translateY(14px) scale(0.96);
    animation: whisperIn 0.8s var(--ease) forwards;
    pointer-events: none;
    word-wrap: break-word;
}
.whisper.user {
    font-style: italic;
    font-size: clamp(14px, 1.7vw, 18px);
    color: #b9c6e6;
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.2);
    top: 64%;
    max-width: min(560px, 78vw);
}
.whisper.brain { top: 28%; }
.whisper.fade-out { animation: whisperOut 1s var(--ease) forwards; }

@keyframes whisperIn {
    from { opacity: 0; transform: translateY(16px) scale(0.94); filter: blur(10px); }
    to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes whisperOut {
    to { opacity: 0; transform: translateY(-18px) scale(1.03); filter: blur(8px); }
}

/* ============================================================
   PILL FLOTANTE
   ============================================================ */
.chat-pill {
    position: fixed;
    left: 50%;
    bottom: calc(30px + env(safe-area-inset-bottom, 0));
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px 12px 18px;
    border-radius: var(--radius-full);
    background: rgba(16, 22, 44, 0.72);
    border: 1px solid var(--line-strong);
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    color: #c8d3ee;
    font-family: inherit;
    font-size: 14px;
    font-style: italic;
    cursor: pointer;
    box-shadow:
        0 16px 40px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.35s var(--ease);
    opacity: 0.9;
}
.chat-pill:hover,
.chat-pill:focus-visible {
    opacity: 1;
    border-color: rgba(120, 150, 255, 0.4);
    color: #eaf0ff;
    transform: translateX(-50%) translateY(-2px);
}
.chat-pill-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-online);
    box-shadow: 0 0 10px var(--accent-online);
    animation: pillDot 2.4s ease-in-out infinite;
}
@keyframes pillDot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}
body.chat-open .chat-pill {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
}

/* ============================================================
   BOTÓN INSTALAR — arriba a la IZQUIERDA, SIEMPRE VISIBLE
   ============================================================ */
.install-btn {
    position: fixed;
    top: calc(18px + env(safe-area-inset-top, 0));
    left: 18px;
    z-index: 25;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-full);
    border: 1px solid var(--line-strong);
    background: rgba(16, 22, 44, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #c8d3ee;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    opacity: 1;
    transform: translateY(0);
    transition:
        color 0.3s var(--ease),
        border-color 0.3s var(--ease),
        background 0.3s var(--ease),
        transform 0.25s var(--ease),
        box-shadow 0.3s var(--ease);
    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.install-btn svg {
    flex-shrink: 0;
    color: rgba(161, 123, 255, 0.9);
    transition: color 0.3s var(--ease);
}
.install-btn:hover,
.install-btn:focus-visible {
    color: #eaf0ff;
    border-color: rgba(120, 150, 255, 0.4);
    background: rgba(24, 30, 56, 0.85);
    transform: translateY(-1px);
    box-shadow:
        0 10px 26px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 20px rgba(161, 123, 255, 0.18);
    outline: none;
}
.install-btn:hover svg,
.install-btn:focus-visible svg { color: #c9b8ff; }
.install-btn:active {
    transform: translateY(0) scale(0.96);
}
.install-btn[hidden] { display: none; }
.install-btn-text { font-weight: 500; }

/* ============================================================
   BOTÓN ÚNICO DE VOZ — "Hablar por voz" (centrado arriba)
   ============================================================ */
.voice-top-btn {
    position: fixed;
    top: calc(18px + env(safe-area-inset-top, 0));
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px 10px 18px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(161, 123, 255, 0.35);
    background:
        linear-gradient(180deg, rgba(30, 26, 60, 0.85), rgba(16, 22, 44, 0.78));
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    color: #d5dbf0;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 0 0 rgba(161, 123, 255, 0);
    transition:
        color 0.3s var(--ease),
        border-color 0.3s var(--ease),
        background 0.3s var(--ease),
        box-shadow 0.3s var(--ease),
        opacity 0.35s var(--ease),
        transform 0.25s var(--ease);
}
.voice-top-btn svg {
    flex-shrink: 0;
    color: rgba(161, 123, 255, 0.9);
    transition: color 0.3s var(--ease);
}
.voice-top-btn:hover,
.voice-top-btn:focus-visible {
    color: #f5f7ff;
    border-color: rgba(161, 123, 255, 0.65);
    background:
        linear-gradient(180deg, rgba(40, 34, 78, 0.9), rgba(22, 28, 56, 0.85));
    box-shadow:
        0 12px 34px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 0 28px rgba(161, 123, 255, 0.28);
    transform: translateX(-50%) translateY(-1px);
    outline: none;
}
.voice-top-btn:hover svg,
.voice-top-btn:focus-visible svg { color: #c9b8ff; }
.voice-top-btn:active {
    transform: translateX(-50%) scale(0.97);
}
.voice-top-btn[hidden] { display: none; }

/* Ocultar el botón cuando el chat está abierto o ya estamos en modo voz */
body.chat-open .voice-top-btn,
body.voice-mode-active .voice-top-btn {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-12px);
}

/* ============================================================
   NUEVA CONVERSACIÓN — arriba a la derecha, icono de mensaje
   ============================================================ */
.reset-btn {
    position: fixed;
    top: calc(18px + env(safe-area-inset-top, 0));
    right: 18px;
    z-index: 25;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(120, 150, 255, 0.22);
    background:
        linear-gradient(180deg, rgba(30, 26, 60, 0.85), rgba(16, 22, 44, 0.78));
    backdrop-filter: blur(24px) saturate(140%);
    -webkit-backdrop-filter: blur(24px) saturate(140%);
    color: #c8d3ee;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition:
        color 0.3s var(--ease),
        border-color 0.3s var(--ease),
        background 0.3s var(--ease),
        box-shadow 0.3s var(--ease),
        transform 0.25s var(--ease),
        opacity 0.35s var(--ease);
}
.reset-btn:hover,
.reset-btn:focus-visible {
    color: #f5f7ff;
    border-color: rgba(161, 123, 255, 0.65);
    background:
        linear-gradient(180deg, rgba(40, 34, 78, 0.9), rgba(22, 28, 56, 0.85));
    box-shadow:
        0 12px 34px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 0 22px rgba(161, 123, 255, 0.28);
    transform: translateY(-1px) rotate(-8deg);
    outline: none;
}
.reset-btn:active {
    transform: scale(0.94);
}

/* Ocultar cuando el chat está abierto o en modo voz */
body.chat-open .reset-btn,
body.voice-mode-active .reset-btn {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
}

/* ============================================================
   PANEL DE CHAT
   ============================================================ */
.chat {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: min(72vh, 660px);
    z-index: 30;
    display: flex;
    flex-direction: column;
    background: rgba(8, 11, 22, 0.85);
    border-top: 1px solid var(--line-strong);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    backdrop-filter: blur(30px) saturate(140%);
    -webkit-backdrop-filter: blur(30px) saturate(140%);
    box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.6);
    transform: translateY(100%);
    transition: transform 0.5s var(--ease);
    will-change: transform;
}
.chat.open { transform: translateY(0); }

/* ---------- Header ---------- */
.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 30%, rgba(120, 140, 220, 0.5), transparent 60%),
        conic-gradient(from 200deg, #5468c9, #7a58b5, #5468c9);
    box-shadow: 0 0 16px rgba(84, 104, 201, 0.3);
    position: relative;
    flex-shrink: 0;
}
.chat-avatar::after {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: var(--bg-0);
}

.chat-title h2 {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: 17px;
    color: #eaf0ff;
    line-height: 1.1;
    letter-spacing: 0.2px;
}
.chat-status {
    display: block;
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 1.4px;
    text-transform: uppercase;
    margin-top: 3px;
}
.chat-status.online   { color: rgba(94, 232, 184, 0.75); }
.chat-status.thinking { color: rgba(161, 123, 255, 0.9); }
.chat-status.offline  { color: rgba(255, 107, 138, 0.85); }

.chat-close {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 10px;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
}
.chat-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #eaf0ff;
}

/* ---------- Body (burbujas) ---------- */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px 18px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(140, 180, 255, 0.15) transparent;
    -webkit-overflow-scrolling: touch;
}
.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb {
    background: rgba(140, 180, 255, 0.18);
    border-radius: 3px;
}

.chat-empty {
    text-align: center;
    color: rgba(160, 180, 220, 0.45);
    font-family: 'Instrument Serif', serif;
    font-size: 17px;
    font-style: italic;
    padding: 80px 30px;
    line-height: 1.7;
    letter-spacing: 0.2px;
}

/* ---------- Burbujas ---------- */
.bubble {
    max-width: 72%;
    padding: 12px 17px;
    border-radius: 20px;
    font-size: 15px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    animation: bubbleIn 0.4s var(--ease);
    will-change: transform, opacity;
}

@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--user-from) 0%, var(--user-to) 100%);
    color: #f5f7ff;
    border-bottom-right-radius: 6px;
    box-shadow:
        0 6px 20px var(--user-glow),
        0 1px 3px rgba(0, 0, 0, 0.15);
    font-weight: 400;
    letter-spacing: 0.05px;
}

.bubble.brain {
    align-self: flex-start;
    background: var(--brain-bg);
    border: 1px solid var(--brain-brd);
    color: var(--brain-txt);
    font-family: 'Instrument Serif', serif;
    font-size: 17px;
    line-height: 1.5;
    letter-spacing: 0.1px;
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow:
        0 2px 12px rgba(0, 0, 0, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.bubble.error {
    align-self: flex-start;
    background: rgba(255, 107, 138, 0.08);
    border: 1px solid rgba(255, 107, 138, 0.25);
    color: #ffa8b8;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    max-width: 78%;
}

/* ---------- Typing ---------- */
.chat-typing {
    align-self: flex-start;
    padding: 14px 18px;
    background: var(--brain-bg);
    border: 1px solid var(--brain-brd);
    border-radius: 20px 20px 20px 6px;
    display: inline-flex;
    gap: 5px;
    align-items: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    margin-top: 8px;
    animation: bubbleIn 0.35s var(--ease);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22);
}
.chat-typing[hidden] { display: none; }

.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(200, 210, 240, 0.55);
    animation: typingDot 1.4s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.chat-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-3px); opacity: 1; }
}

/* ---------- Composer ---------- */
.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--line);
    flex-shrink: 0;
}

#input {
    flex: 1;
    background: rgba(8, 12, 24, 0.7);
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    outline: none;
    resize: none;
    color: #eaf0ff;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.45;
    padding: 11px 18px;
    min-height: 42px;
    max-height: 140px;
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
#input:focus {
    border-color: rgba(120, 150, 255, 0.5);
    box-shadow: 0 0 0 3px rgba(120, 150, 255, 0.08);
}
#input::placeholder {
    color: var(--muted);
    font-style: italic;
}

#send {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--user-from), var(--user-to));
    color: #f5f7ff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s var(--ease);
    box-shadow: 0 6px 18px var(--user-glow);
}
#send:hover:not(:disabled) {
    transform: scale(1.06);
    box-shadow: 0 10px 26px var(--user-glow);
}
#send:active:not(:disabled) { transform: scale(0.94); }
#send:disabled { opacity: 0.35; cursor: not-allowed; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    z-index: 40;
    padding: 10px 18px;
    border-radius: var(--radius-full);
    background: rgba(16, 22, 44, 0.85);
    border: 1px solid var(--line-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    font-size: 12.5px;
    color: var(--text);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
    max-width: 90vw;
    text-align: center;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.toast.error {
    border-color: rgba(255, 107, 138, 0.4);
    color: #ffa8b8;
}
body.chat-open .toast { bottom: calc(72vh + 20px); }

/* ============================================================
   MODO VOZ — overlay transparente; el Ser es el protagonista
   ============================================================ */
.voice-mode {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;          /* NO bloquea el canvas */
    opacity: 0;
    transition: opacity 0.5s var(--ease);
}
.voice-mode.visible { opacity: 1; }
.voice-mode[hidden] { display: none; }

/* Solo los botones capturan clicks */
.voice-mode button { pointer-events: auto; }

/* Botón cerrar (arriba derecha) */
.voice-exit {
    position: absolute;
    top: calc(20px + env(safe-area-inset-top, 0));
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(120, 150, 255, 0.18);
    background: rgba(16, 22, 44, 0.55);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: rgba(200, 210, 240, 0.75);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.25s var(--ease);
}
.voice-exit:hover {
    background: rgba(217, 74, 107, 0.25);
    border-color: rgba(217, 74, 107, 0.5);
    color: #fff;
}

/* Botón grande de micrófono (abajo, para salir) */
.voice-mic {
    position: absolute;
    bottom: calc(48px + env(safe-area-inset-bottom, 0));
    left: 50%;
    transform: translateX(-50%);
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 1.5px solid rgba(217, 74, 107, 0.5);
    background:
        radial-gradient(circle at 40% 35%, rgba(255, 120, 150, 0.4), transparent 60%),
        linear-gradient(135deg, #d94a6b, #b53a8f);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow:
        0 0 0 0 rgba(217, 74, 107, 0.5),
        0 12px 40px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(217, 74, 107, 0.35);
    animation: voiceMicPulse 1.8s ease-out infinite;
    transition: transform 0.2s var(--ease);
}
.voice-mic:hover { transform: translateX(-50%) scale(1.06); }
.voice-mic:active { transform: translateX(-50%) scale(0.94); }

@keyframes voiceMicPulse {
    0%   { box-shadow:
            0 0 0 0 rgba(217, 74, 107, 0.5),
            0 12px 40px rgba(0, 0, 0, 0.5),
            0 0 60px rgba(217, 74, 107, 0.35); }
    70%  { box-shadow:
            0 0 0 22px rgba(217, 74, 107, 0),
            0 12px 40px rgba(0, 0, 0, 0.5),
            0 0 60px rgba(217, 74, 107, 0.35); }
    100% { box-shadow:
            0 0 0 0 rgba(217, 74, 107, 0),
            0 12px 40px rgba(0, 0, 0, 0.5),
            0 0 60px rgba(217, 74, 107, 0.35); }
}

/* En modo voz: el Ser se agranda ligeramente y se centra */
body.voice-mode-active #being {
    transform: scale(1.08);
    filter: brightness(1.05);
    transition: transform 0.8s var(--ease), filter 0.8s var(--ease);
}

/* Ocultar chat y controles secundarios en modo voz.
   IMPORTANTE: el botón de instalar SE MANTIENE visible porque
   el usuario lo pidió "siempre visible". */
body.voice-mode-active .chat,
body.voice-mode-active .chat-pill,
body.voice-mode-active .reset-btn,
body.voice-mode-active .voice-top-btn,
body.voice-mode-active .whisper-layer,
body.voice-mode-active .toast {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s var(--ease);
}

/* ============================================================
   INSTALL BANNER
   ============================================================ */
.install-banner {
    position: fixed;
    left: 50%;
    bottom: calc(110px + env(safe-area-inset-bottom, 0));
    transform: translateX(-50%) translateY(16px);
    z-index: 45;
    width: min(440px, calc(100vw - 32px));
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}
.install-banner.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}
.install-banner[hidden] { display: none; }

.install-banner-inner {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(16, 22, 44, 0.9);
    border: 1px solid var(--line-strong);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.install-banner-icon {
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.install-banner-body {
    flex: 1;
    min-width: 0;
}
.install-banner-body h3 {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: 16px;
    color: #eaf0ff;
    margin-bottom: 4px;
}
.install-banner-body p {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
}
.install-banner-ios-steps {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--text-dim);
    line-height: 1.7;
}
.install-banner-ios-steps strong { color: #c8d3ee; }
.install-banner-ios-steps .share-icon {
    display: inline-block;
    vertical-align: -3px;
    width: 14px;
    height: 14px;
    margin: 0 4px;
    stroke: #c8d3ee;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.install-banner-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
.install-banner-btn {
    padding: 8px 14px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s var(--ease);
    white-space: nowrap;
}
.install-banner-btn.primary {
    background: linear-gradient(135deg, var(--user-from), var(--user-to));
    color: #f5f7ff;
    box-shadow: 0 4px 12px var(--user-glow);
}
.install-banner-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--user-glow);
}
.install-banner-btn.ghost {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text-dim);
}
.install-banner-btn.ghost:hover {
    color: #eaf0ff;
    border-color: rgba(120, 150, 255, 0.3);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 720px) {
    .chat { height: min(78vh, 720px); }
    .chat-body { padding: 18px 14px 8px; }
    #input { font-size: 16px; }
    .bubble { max-width: 82%; font-size: 14.5px; padding: 11px 15px; }
    .bubble.brain { font-size: 16px; }
    .chat-pill { bottom: calc(20px + env(safe-area-inset-bottom, 0)); }

    .voice-mic { width: 64px; height: 64px; }

    .voice-top-btn {
        top: calc(14px + env(safe-area-inset-top, 0));
        padding: 9px 18px 9px 14px;
        font-size: 12.5px;
    }

    .reset-btn {
        top: calc(14px + env(safe-area-inset-top, 0));
        right: 14px;
        width: 38px;
        height: 38px;
    }

    .install-btn {
        top: calc(14px + env(safe-area-inset-top, 0));
        left: 14px;
        padding: 7px 10px;
        font-size: 11.5px;
    }
    .install-btn-text { display: none; }   /* solo el icono en móvil */
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
