        :root {
            --bg: #212121;
            /* fondo oscuro */
            --panel: #303030;
            /* tarjetas */
            --txt: #e6e7ea;
            /* texto */
            --muted: #97a0ac;
            /* subtítulos */
            --blue: #4fc6ff;
            /* láser azul */
            --pink: #ff4bd1;
            /* láser magenta */
            --logo: #c8ced6;
            /* gris claro final del logo */
            --radius: 14px;
            --input-h: 160px;
            --hero-gap: clamp(140px, 32vh, 200px);
            --dock-gap: env(safe-area-inset-bottom, 0px);

            --font-logo: "Audiowide", system-ui, sans-serif;
            --font-ui: "Exo 2", Inter, system-ui, sans-serif;
        }

        * {
            box-sizing: border-box
        }

        html,
        body {
            height: 100%
        }

        body {
            margin: 0;
            color: var(--txt);
            font-family: var(--font-ui);
            background: var(--bg);

            overflow-y: auto;
        }

        .wrap {
            position: relative;
            width: 100%;
            min-height: 100vh;
            /* ⬅️ ocupa al menos la altura de la ventana */
            display: grid;
            place-items: center;
            padding: 24px;
        }


        /* ---------- LOGO ---------- */
        .brand {
            position: absolute;
            inset: 0;
            display: grid;
            place-items: center;
            pointer-events: none;
            transition: transform .7s cubic-bezier(.22, .61, .36, 1)
        }

        body.dock .brand {
            opacity: 0;
            transform: translateY(-60vh) scale(.4);
            transition: transform .6s cubic-bezier(.22, .61, .36, 1), opacity .45s ease;
            pointer-events: none;
        }

        /* En modo chat (dock), el grid ya no centra verticalmente, estira el contenido */
        body.dock .wrap {
            align-items: stretch;
            justify-items: center;
        }

        .brand.shrink {
            transform: translateY(-30vh) scale(.55)
        }

        #logo {
            width: min(72vw, 980px);
            height: auto;
            overflow: visible
        }

        .base {
            fill: none;
            stroke: rgba(255, 255, 255, .08);
            stroke-width: 3.6
        }

        .reveal-blue {
            fill: none;
            stroke: var(--blue);
            stroke-width: 3.6;
            filter: drop-shadow(0 0 14px rgba(79, 198, 255, .9)) drop-shadow(0 0 36px rgba(79, 198, 255, .55));
        }

        .reveal-pink {
            fill: none;
            stroke: var(--pink);
            stroke-width: 3.6;
            filter: drop-shadow(0 0 14px rgba(255, 75, 209, .95)) drop-shadow(0 0 36px rgba(255, 75, 209, .55));
        }

        .fill-final {
            fill: transparent;
            transition: fill .35s ease .05s
        }

        .finalized .fill-final {
            fill: var(--logo)
        }

        /* Máscara: tira vertical con bordes suaves que barre de izquierda→derecha */
        #sweepRect {
            width: 180px;
            height: 360px;
            transform: translateX(-260px)
        }

        .play #sweepRect {
            animation: sweep 1.1s linear forwards
        }

        @keyframes sweep {
            from {
                transform: translateX(-260px)
            }

            to {
                transform: translateX(1260px)
            }
        }

        /* ---------- UI ---------- */
        .app {
            width: min(100%, 680px);
            opacity: 0;
            transform: translateY(12px);
            transition: opacity .5s ease, transform .5s ease;
            display: grid;
            gap: 14px;
        }

        .show-ui .app {
            opacity: 1;
            transform: translateY(0);
            margin-top: var(--hero-gap);
        }


        .card {
            background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .02));
            border: 1px solid rgba(255, 255, 255, .06);
            border-radius: var(--radius);
            box-shadow: 0 16px 48px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .04);
            padding: 0px;
        }

        .input-wrap {
            position: relative;
            background: var(--panel);
            border-radius: 12px;
            display: flex;
            flex-direction: column;
            align-items: stretch;
            padding: 12px 10px 10px 10px;
        }

        textarea {
            flex: 1;
            background: transparent;
            border: 0;
            outline: none;
            resize: none;
            overflow: auto;
            min-height: 80px;
            color: var(--txt);
            font: 500 13px/1.5 Inter, system-ui;
            padding-top: 8px;
            padding-right: 48px;
            /* ancho botón enviar + margen */
            padding-left: 48px;
            /* ancho botón adjuntar + margen */
            padding-bottom: 46px;
            /* altura botón (40px) + margen (6px aprox) */
        }


        .send {
            position: absolute;
            right: 8px;
            bottom: 8px;
            height: 40px;
            min-width: 40px;
            border-radius: 10px;
            border: 1px solid #3a3a3a;
            background: #303030;
            /* tu color */
            color: #e6e7ea;
            display: inline-grid;
            place-items: center;
            padding: 0;
            /* ⬅️ importante para icon-only */
            cursor: pointer;
            transition: transform .06s ease, filter .15s ease, background .2s ease, box-shadow .2s ease;
        }

        .send:hover {
            filter: brightness(1.12);
        }

        .send:active {
            transform: translateY(1px);
        }


        .attach-input {
            position: absolute;
            width: 1px;
            height: 1px;
            opacity: 0;
            pointer-events: none;
        }

        /* botón clip (espejo del botón de enviar) */
        .attach {
            position: absolute;
            left: 8px;
            bottom: 8px;
            height: 40px;
            min-width: 40px;
            display: inline-grid;
            place-items: center;
            border-radius: 10px;
            border: 1px solid #3a3a3a;
            background: #303030;
            /* mismo color que tu send */
            color: #e6e7ea;
            cursor: pointer;
            transition: transform .06s ease, filter .15s ease, background .2s ease, box-shadow .2s ease;
        }

        .attach:hover {
            filter: brightness(1.12);
        }

        .attach:active {
            transform: translateY(1px);
        }

        .icon-send,
        .icon-clip {
            width: 18px;
            height: 18px;
            display: block;
        }

        .icon-send {
            width: 18px;
            height: 18px;
            /* tamaño del icono */
            display: block;
        }


        .hint {
            color: var(--muted);
            font-size: 13px;
            text-align: center
        }



        /* Detalles sutiles */
        .glow {
            position: absolute;
            pointer-events: none;
            width: 36vmax;
            height: 36vmax;
            filter: blur(28px) saturate(115%);
            mix-blend-mode: screen;
            opacity: .8
        }

        .tagline {
            margin: 18px auto 2px auto;
            text-align: center;
            font-family: var(--font-logo);
            font-size: clamp(18px, 2.4vw, 24px);
            letter-spacing: .8px;
            line-height: 1.4;
            opacity: 0;
            transform: translateY(8px);
            background-image: linear-gradient(90deg, rgba(230, 231, 234, .65), rgba(79, 198, 255, .95), rgba(255, 75, 209, .9), rgba(230, 231, 234, .65));
            background-size: 300% 100%;
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            text-shadow: 0 0 10px rgba(79, 198, 255, .08), 0 0 18px rgba(255, 75, 209, .06);
            transition: opacity .6s ease, transform .6s ease;
        }

        .show-ui .tagline {
            opacity: 1;
            transform: translateY(0);
            animation: shimmer 8s linear .2s infinite;
        }

        @keyframes shimmer {
            0% {
                background-position: 0% 50%;
            }

            100% {
                background-position: 200% 50%;
            }
        }

        @media (max-width:640px) {
            .brand.shrink {
                transform: translateY(-26vh) scale(.62)
            }

            textarea {
                min-height: 110px
            }
        }

        .tagline.hide {
            opacity: 0;
            transform: translateY(-6px);
            filter: blur(1px);
            pointer-events: none;
        }

        .chat {
            display: flex;
            flex-direction: column;
            gap: 12px;
            /* Dejamos hueco abajo para que no lo tape la card fija */
            margin: 10px 0 calc(var(--input-h) + 40px) 0;
            overflow-x: hidden;
            /* por si acaso */
            padding: 0 4px;
        }







        /* Burbujas */
        .msg {
            display: flex;
            width: 100%;
            /* la fila ocupa todo el ancho del chat */
        }

        .msg .bubble {
            max-width: 100%;
            padding: 12px 14px;
            border-radius: 12px;
            font: 500 13px/1.5 var(--font-ui, Inter, system-ui, sans-serif);
            word-wrap: break-word;
            white-space: pre-wrap;
        }

        @media (max-width: 640px) {
            .msg .bubble {
                max-width: 100%;
            }
        }

        .msg.user {
            justify-content: end;
        }

        .msg.user .bubble {
            background: #303030;
            /* match tu caja */
            border: 1px solid #3a3a3a;
        }

        .msg.system {
            justify-content: center;
            /* opcional: centramos la fila */
        }

        .msg.system .bubble {
            max-width: 100%;
            width: 100%;
            /* fuerza a ocupar el ancho disponible */
        }

        .msg.system .bubble {
            max-width: 100%;
            width: 100%;
            background: #202020;
            border: 1px solid #444;
            border-radius: 10px;
            font-size: 12px;
            opacity: .95;
        }

        .msg.bot .bubble {
            background: #262626;
            /* sutil contraste */
            border: 1px solid #333333;
        }

        /* Cursor del typewriter */
        .cursor {
            display: inline-block;
            width: 8px;
            height: 1em;
            vertical-align: -0.2em;
            margin-left: 2px;
            background: #e6e7ea;
            border-radius: 1px;
            animation: blink 1s step-end infinite;
        }

        @keyframes blink {
            50% {
                opacity: 0;
            }
        }

        body.dock .app {
            transform: none !important;
            margin-top: 80px;
            /* espacio debajo de la top-bar; ajusta a gusto */
        }


        body.dock .card {
            position: fixed;
            left: 50%;
            transform: translateX(-50%);
            /* solo horizontal */
            bottom: var(--dock-gap);
            margin-bottom: 20px;
            width: min(100%, 680px);
            z-index: 3;
        }

        /* deja hueco en el scroll del chat para que la caja no lo tape */




        .file-preview {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin: 0 0 8px 0;
            /* separación respecto al textarea */
            align-items: center;
        }

        .file-chip {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            padding: 6px 10px;
            border-radius: 10px;
            border: 1px solid #3a3a3a;
            background: #2a2a2a;
            font: 500 12px/1.2 var(--font-ui, Inter, system-ui, sans-serif);
            color: var(--txt);
            max-width: 100%;
        }

        .file-chip .icon {
            width: 16px;
            height: 16px;
            display: inline-block;
            flex: 0 0 16px;
        }

        .file-chip .name {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 240px;
            /* ajusta si quieres más largo */
            opacity: .95;
        }

        @media (max-width:640px) {
            .file-chip .name {
                max-width: 180px;
            }
        }




        .login-card {
            padding: 18px 18px 20px 18px;
            width: 580px;
            margin: 18px auto 0 auto;
            background: linear-gradient(180deg, rgba(255, 255, 255, .03), rgba(255, 255, 255, .01));
        }

        .login-form {
            display: grid;
            gap: 14px;
        }

        .field {
            display: grid;
            gap: 6px;
        }

        .field-label {
            font-size: 12px;
            text-transform: uppercase;
            letter-spacing: .08em;
            color: var(--muted);
        }

        .field-inner {
            position: relative;
            display: flex;
            align-items: center;
            gap: 8px;
            background: #262626;
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, .08);
            padding: 8px 10px 8px 36px;
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
        }

        .field-icon {
            position: absolute;
            left: 10px;
            width: 16px;
            height: 16px;
            opacity: .82;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .field-icon svg {
            width: 100%;
            height: 100%;
        }

        .field-inner input {
            flex: 1;
            border: 0;
            outline: none;
            background: transparent;
            color: var(--txt);
            font: 500 13px/1.5 var(--font-ui, Inter, system-ui, sans-serif);
        }

        .field-inner input::placeholder {
            color: rgba(151, 160, 172, .7);
        }

        /* Botón principal login */
        .login-btn {
            margin-top: 6px;
            width: 100%;
            border: 0;
            border-radius: 12px;
            padding: 10px 14px;
            background: radial-gradient(circle at 0% 0%, rgba(79, 198, 255, .35), transparent 55%),
                radial-gradient(circle at 100% 100%, rgba(255, 75, 209, .35), transparent 55%),
                #303030;
            color: var(--txt);
            font: 600 13px/1.2 var(--font-ui, Inter, system-ui, sans-serif);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            cursor: pointer;
            box-shadow: 0 12px 32px rgba(0, 0, 0, .55),
                0 0 0 1px rgba(255, 255, 255, .04);
            transition: transform .08s ease, filter .15s ease, box-shadow .18s ease;
        }

        .login-btn:hover {
            filter: brightness(1.08);
            box-shadow: 0 16px 40px rgba(0, 0, 0, .7),
                0 0 0 1px rgba(255, 255, 255, .07);
        }

        .login-btn:active {
            transform: translateY(1px) scale(.99);
        }

        .login-arrow {
            width: 16px;
            height: 16px;
        }

        .login-hint {
            margin: 8px 2px 0 2px;
            font-size: 11px;
            color: var(--muted);
            text-align: center;
            opacity: .85;
        }



        /* ---------- ESTADO ÉXITO LOGIN ---------- */
        .login-card.success {
            position: relative;
            overflow: hidden;
            box-shadow: 0 0 0 1px rgba(79, 198, 255, .65),
                0 0 40px rgba(79, 198, 255, .55),
                0 0 68px rgba(255, 75, 209, .45);
            animation: loginSuccessPulse .9s ease-out;
        }

        /* Halo IA detrás de la tarjeta */
        .login-card.success::before {
            content: "";
            position: absolute;
            inset: -40%;
            background:
                radial-gradient(circle at 10% 0%, rgba(79, 198, 255, .28) 0, transparent 55%),
                radial-gradient(circle at 90% 100%, rgba(255, 75, 209, .32) 0, transparent 55%);
            opacity: 0;
            animation: loginSuccessHalo .9s ease-out forwards;
            pointer-events: none;
            z-index: -1;
        }

        @keyframes loginSuccessPulse {
            0% {
                transform: scale(1);
                filter: brightness(1);
            }

            35% {
                transform: scale(1.02);
                filter: brightness(1.07);
            }

            70% {
                transform: scale(0.995);
                filter: brightness(1.02);
            }

            100% {
                transform: scale(1);
                filter: brightness(1);
            }
        }

        @keyframes loginSuccessHalo {
            0% {
                opacity: 0;
                transform: scale(0.9);
            }

            40% {
                opacity: 1;
                transform: scale(1);
            }

            100% {
                opacity: 0.35;
                transform: scale(1.05);
            }
        }

        /* Botón en modo éxito */
        .login-btn.success {
            background:
                radial-gradient(circle at 0% 0%, rgba(79, 255, 168, .5), transparent 55%),
                radial-gradient(circle at 100% 100%, rgba(79, 198, 255, .5), transparent 55%),
                #2f3b30;
            box-shadow: 0 14px 38px rgba(0, 0, 0, .75),
                0 0 0 1px rgba(79, 255, 168, .6);
        }

        /* ---------- ESTADO ERROR LOGIN ---------- */
        .login-card.error {
            animation: loginErrorShake .35s cubic-bezier(.36, .07, .19, .97);
            box-shadow: 0 0 0 1px rgba(255, 75, 109, .6),
                0 0 30px rgba(255, 75, 109, .4);
        }

        /* Fino subrayado "glitch" inferior rojizo */
        .login-card.error::after {
            content: "";
            position: absolute;
            left: 4%;
            right: 4%;
            bottom: 0;
            height: 2px;
            background: linear-gradient(90deg,
                    rgba(255, 75, 109, 0),
                    rgba(255, 75, 109, .8),
                    rgba(255, 75, 109, 0));
            opacity: 0;
            animation: loginErrorGlitch .35s ease-out forwards;
        }

        @keyframes loginErrorShake {
            0% {
                transform: translateX(0);
            }

            20% {
                transform: translateX(-6px);
            }

            40% {
                transform: translateX(4px);
            }

            60% {
                transform: translateX(-3px);
            }

            80% {
                transform: translateX(2px);
            }

            100% {
                transform: translateX(0);
            }
        }

        @keyframes loginErrorGlitch {
            0% {
                opacity: 0;
                transform: translateX(-4px);
            }

            30% {
                opacity: 1;
                transform: translateX(2px);
            }

            100% {
                opacity: 0;
                transform: translateX(0);
            }
        }

        /* Texto de ayuda en error (se pone rojizo) */
        .login-hint.error {
            color: #ff4b6d;
        }

        /* Pequeño “glitch” en el texto del botón al error */
        .login-btn.error {
            animation: loginBtnGlitch .25s linear;
            box-shadow: 0 12px 32px rgba(0, 0, 0, .7),
                0 0 0 1px rgba(255, 75, 109, .7);
        }

        @keyframes loginBtnGlitch {
            0% {
                transform: translate(0, 0);
            }

            25% {
                transform: translate(-1px, 0.5px);
            }

            50% {
                transform: translate(1.5px, -0.5px);
            }

            75% {
                transform: translate(-0.8px, 1px);
            }

            100% {
                transform: translate(0, 0);
            }
        }



        /* ---------- BARRA SUPERIOR (JAX9 + USUARIO) ---------- */

        .top-bar {
            position: fixed;
            top: 14px;
            left: 18px;
            right: 18px;
            z-index: 20;
            display: flex;
            align-items: center;
            justify-content: space-between;
            pointer-events: none;
            /* para que no bloquee clics en el centro */
            opacity: 0;
            transform: translateY(-6px);
            transition: opacity .5s ease, transform .5s ease;
        }

        /* Aparece cuando se muestra la UI (cuando añades .show-ui al body) */
        .show-ui .top-bar {
            opacity: 1;
            transform: translateY(0);
        }

        .top-brand {
            font-family: var(--font-logo);
            font-size: 17px;
            letter-spacing: .18em;
            text-transform: uppercase;
            text-align: left;
            background-image: linear-gradient(90deg,
                    rgba(230, 231, 234, .75),
                    rgba(79, 198, 255, .95),
                    rgba(255, 75, 209, .9));
            background-size: 260% 100%;
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            text-shadow: 0 0 10px rgba(79, 198, 255, .12),
                0 0 18px rgba(255, 75, 209, .08);
        }

        /* Botón tipo pill con usuario (lado derecho) */
        .user-pill {
            pointer-events: auto;
            /* reactivamos eventos solo en el botón */
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, .14);
            background: rgba(24, 24, 24, .9);
            box-shadow: 0 10px 24px rgba(0, 0, 0, .6),
                0 0 0 1px rgba(0, 0, 0, .75);
            cursor: pointer;
            font: 500 12px/1 var(--font-ui, Inter, system-ui, sans-serif);
            color: var(--txt);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            transition: transform .08s ease,
                box-shadow .16s ease,
                background .18s ease,
                filter .18s ease;
        }

        .user-pill:hover {
            background: rgba(34, 34, 34, .98);
            filter: brightness(1.05);
            box-shadow: 0 12px 30px rgba(0, 0, 0, .75),
                0 0 0 1px rgba(255, 255, 255, .12);
        }

        .user-pill:active {
            transform: translateY(1px) scale(.99);
        }

        /* Icono dentro del botón */
        .user-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 19px;
            height: 19px;
            opacity: .9;
        }

        .user-icon svg {
            width: 100%;
            height: 100%;
        }

        /* Nombre de usuario con el mismo rollo de la tagline */
        .user-name {
            font-family: var(--font-logo);
            font-size: 12px;
            letter-spacing: .12em;
            text-transform: uppercase;
            background-image: linear-gradient(90deg,
                    rgba(230, 231, 234, .85),
                    rgba(79, 198, 255, .95),
                    rgba(255, 75, 209, .9));
            background-size: 260% 100%;
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }



        .user-menu-wrapper {
            position: relative;
            pointer-events: auto;
            /* importantísimo porque .top-bar tiene pointer-events:none */
        }

        /* Caja del menú */
        .user-menu {
            position: absolute;
            right: 0;
            top: calc(100% + 8px);
            min-width: 180px;
            padding: 8px;
            border-radius: 12px;
            background: rgba(20, 20, 20, .96);
            box-shadow: 0 18px 40px rgba(0, 0, 0, .85),
                0 0 0 1px rgba(255, 255, 255, .06);
            display: none;
            z-index: 40;
        }

        /* estado visible */
        .user-menu.open {
            display: block;
        }

        /* items del menú */
        .user-menu-item {
            width: 100%;
            text-align: left;
            border: 0;
            background: transparent;
            color: var(--txt);
            font: 500 12px/1.4 var(--font-ui, Inter, system-ui, sans-serif);
            padding: 7px 10px;
            border-radius: 8px;
            cursor: pointer;
            transition: background .16s ease, filter .16s ease, transform .06s ease;
        }

        .user-menu-item:hover {
            background: rgba(255, 255, 255, .06);
            filter: brightness(1.05);
        }

        .user-menu-item:active {
            transform: translateY(1px);
        }

        .user-menu-danger {
            color: #ff6b81;
        }



        /* ---------- MODAL CAMBIO DE CLAVE ---------- */

        .pwd-modal-backdrop {
            position: fixed;
            inset: 0;
            background: rgba(0, 0, 0, .65);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 50;
            opacity: 0;
            pointer-events: none;
            transition: opacity .22s ease;
        }

        .pwd-modal-backdrop.open {
            opacity: 1;
            pointer-events: auto;
        }

        .pwd-modal-card {
            width: min(100%, 420px);
            padding: 20px 20px 18px 20px;
            border-radius: 16px;
            background: radial-gradient(circle at 0% 0%, rgba(79, 198, 255, .16), transparent 60%),
                radial-gradient(circle at 100% 100%, rgba(255, 75, 209, .18), transparent 60%),
                #262626;
            box-shadow: 0 22px 60px rgba(0, 0, 0, .9),
                0 0 0 1px rgba(255, 255, 255, .06);
            transform: translateY(12px) scale(.96);
            opacity: 0;
            transition: opacity .22s ease, transform .22s ease;
        }

        .pwd-modal-backdrop.open .pwd-modal-card {
            opacity: 1;
            transform: translateY(0) scale(1);
        }

        .pwd-modal-title {
            margin: 0 0 10px 0;
            font-size: 15px;
            letter-spacing: .12em;
            text-transform: uppercase;
            font-family: var(--font-logo);
        }

        .pwd-form {
            display: grid;
            gap: 10px;
        }

        .pwd-field {
            display: grid;
            gap: 4px;
        }

        .pwd-field label {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: .08em;
            color: var(--muted);
        }

        .pwd-field input {
            border-radius: 10px;
            border: 1px solid rgba(255, 255, 255, .12);
            background: #1f1f1f;
            color: var(--txt);
            padding: 7px 10px;
            font: 500 13px/1.4 var(--font-ui, Inter, system-ui, sans-serif);
            outline: none;
        }

        .pwd-field input:focus {
            border-color: rgba(79, 198, 255, .8);
            box-shadow: 0 0 0 1px rgba(79, 198, 255, .4);
        }

        .pwd-hint {
            min-height: 16px;
            margin: 2px 1px 4px 1px;
            font-size: 11px;
            color: var(--muted);
        }

        .pwd-hint.error {
            color: #ff6b81;
        }

        .pwd-hint.success {
            color: #7bffb0;
        }

        .pwd-actions {
            margin-top: 4px;
            display: flex;
            justify-content: flex-end;
            gap: 8px;
        }

        .pwd-btn {
            border-radius: 999px;
            border: 0;
            padding: 7px 14px;
            font: 600 12px/1 var(--font-ui, Inter, system-ui, sans-serif);
            cursor: pointer;
            transition: transform .06s ease,
                filter .15s ease,
                box-shadow .18s ease,
                background .18s ease;
        }

        .pwd-btn.ghost {
            background: #2b2b2b;
            color: var(--muted);
        }

        .pwd-btn.ghost:hover {
            filter: brightness(1.05);
        }

        .pwd-btn.primary {
            background:
                radial-gradient(circle at 0% 0%, rgba(79, 198, 255, .4), transparent 55%),
                radial-gradient(circle at 100% 100%, rgba(255, 75, 209, .35), transparent 55%),
                #303030;
            color: var(--txt);
            box-shadow: 0 10px 26px rgba(0, 0, 0, .7),
                0 0 0 1px rgba(255, 255, 255, .08);
        }

        .pwd-btn.primary:hover {
            filter: brightness(1.07);
        }

        .pwd-btn:active {
            transform: translateY(1px) scale(.99);
        }


        .mono-block {
            margin: 4px 0;
            padding: 8px 10px;
            border-radius: 10px;
            background: #181818;
            border: 1px solid #3a3a3a;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
            font-size: 12px;
            line-height: 1.4;
            white-space: pre;
            overflow-x: auto;
        }

        .mono-block strong {
            font-weight: 700;
        }



        .json-block {
            display: block;
            box-sizing: border-box;
            width: 100%;
            max-width: 100%;
            margin: 4px 0;
            padding: 8px 10px;
            border-radius: 10px;
            background: #181818;
            border: 1px solid #3a3a3a;
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
            font-size: 12px;
            line-height: 1.4;
            white-space: pre;
            overflow-x: auto;
        }

        /* Colores de claves y valores */
        .json-key {
            color: #B02962;
            font-weight: 600;
        }

        .json-val {
            color: #00A67D;
        }


        .msg .bubble {
            position: relative;
            max-width: 78%;
            padding: 12px 14px;
            border-radius: 12px;
            font: 500 13px/1.5 var(--font-ui, Inter, system-ui, sans-serif);
            word-wrap: break-word;
            white-space: pre-wrap;
        }

        .msg.bot .bubble {
            max-width: 100%;
            width: 100%;
        }


        /* Para móvil puedes permitir más ancho */
        @media (max-width: 640px) {
            .msg .bubble {
                max-width: 100%;
            }
        }

        /* El contenido real del mensaje */
        .bubble-content {
            white-space: inherit;
        }

        /* Botón copiar */
        .copy-btn {
            position: absolute;
            top: 6px;
            right: 6px;
            width: 22px;
            height: 22px;
            border-radius: 999px;
            border: 1px solid rgba(255, 255, 255, .14);
            background: rgba(24, 24, 24, .9);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            cursor: pointer;
            opacity: 0;
            pointer-events: none;
            transition: opacity .16s ease, transform .06s ease, filter .15s ease;
            color: var(--muted);
        }

        .copy-btn svg {
            width: 14px;
            height: 14px;
        }

        /* Mostrar el botón al pasar el ratón por la burbuja */
        .msg.bot .bubble:hover .copy-btn {
            opacity: 1;
            pointer-events: auto;
        }

        .copy-btn:hover {
            filter: brightness(1.1);
        }

        .copy-btn:active {
            transform: translateY(1px) scale(.97);
        }

        /* Estado "copiado" opcional */
        .copy-btn.copied {
            border-color: #00A67D;
            color: #00A67D;
        }



        .top-left {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            pointer-events: auto;
            /* porque .top-bar tiene pointer-events:none */
        }

        .beta-tag {
            font-size: 11px;
            color: var(--muted);
            opacity: .9;
        }




        .top-left {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
            pointer-events: auto;
            /* porque .top-bar tiene pointer-events:none */
        }

        /* Línea superior: JAX9 (βeta) + flecha */
        .top-left-main {
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .beta-tag {
            font-size: 11px;
            color: var(--muted);
            opacity: .9;
        }

        /* Flecha y menú (como ya tenías) */
        .mode-wrapper {
            position: relative;
        }

        .mode-toggle {
            background: none;
            border: 0;
            padding: 0;
            margin-left: 2px;
            cursor: pointer;
            color: var(--muted);
            line-height: 1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: transform .12s ease, color .12s ease, opacity .12s ease;
            opacity: .8;
        }

        .mode-icon {
            width: 14px;
            height: 14px;
            display: block;
        }

        .mode-toggle:hover {
            color: var(--txt);
            opacity: 1;
        }

        .mode-toggle[aria-expanded="true"] {
            transform: rotate(180deg);
        }

        /* Menú flotante de modos (lo mismo de antes) */
        .mode-menu {
            position: absolute;
            left: 0;
            top: calc(100% + 6px);
            min-width: 180px;
            padding: 6px;
            border-radius: 10px;
            background: rgba(20, 20, 20, .96);
            box-shadow: 0 14px 32px rgba(0, 0, 0, .85),
                0 0 0 1px rgba(255, 255, 255, .05);
            display: none;
            z-index: 30;
        }

        .mode-menu.open {
            display: block;
        }

        .mode-menu-item {
            width: 100%;
            text-align: left;
            border: 0;
            background: transparent;
            color: var(--txt);
            font: 500 12px/1.4 var(--font-ui, Inter, system-ui, sans-serif);
            padding: 6px 8px;
            border-radius: 8px;
            cursor: pointer;
            transition: background .14s ease, filter .14s ease, transform .06s ease;
        }

        .mode-menu-item:hover {
            background: rgba(255, 255, 255, .06);
            filter: brightness(1.05);
        }

        .mode-menu-item:active {
            transform: translateY(1px);
        }

        /* Segunda línea: nombre del modo */
        .mode-label {
            font-size: 11px;
            color: var(--muted);
            opacity: .9;
            padding-left: 2px;
            /* un pelín alineado con JAX9 */
        }


        /* ===============================
   Markdown "pro" para mensajes bot
   =============================== */

        .bot-prose {
            width: 100%;
            max-width: 100%;
            line-height: 1.6;
            font-size: 13px;
            color: var(--txt);
        }

        /* Títulos */
        .bot-prose h1,
        .bot-prose h2,
        .bot-prose h3 {
            margin: 12px 0 8px 0;
            line-height: 1.25;
            font-family: var(--font-ui, Inter, system-ui, sans-serif);
            letter-spacing: 0.02em;
        }

        .bot-prose h1 {
            font-size: 18px;
            font-weight: 800;
        }

        .bot-prose h2 {
            font-size: 16px;
            font-weight: 750;
        }

        .bot-prose h3 {
            font-size: 14px;
            font-weight: 700;
        }

        .bot-prose p {
            margin: 8px 0;
        }

        .bot-prose hr {
            border: 0;
            height: 1px;
            margin: 12px 0;
            background: rgba(255, 255, 255, .10);
        }

        /* Énfasis */
        .bot-prose strong {
            font-weight: 750;
        }

        .bot-prose em {
            font-style: italic;
        }

        /* Listas */
        .bot-prose ul,
        .bot-prose ol {
            margin: 8px 0 8px 18px;
            padding: 0;
        }

        .bot-prose li {
            margin: 4px 0;
        }

        /* Blockquote */
        .bot-prose blockquote {
            margin: 10px 0;
            padding: 8px 10px;
            border-left: 3px solid rgba(79, 198, 255, .65);
            background: rgba(255, 255, 255, .03);
            border-radius: 10px;
            color: rgba(230, 231, 234, .92);
        }

        /* Código inline */
        .bot-prose code {
            font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
            font-size: 12px;
            padding: 1px 6px;
            border-radius: 8px;
            background: rgba(0, 0, 0, .28);
            border: 1px solid rgba(255, 255, 255, .10);
        }

        /* Bloques de código */
        .bot-prose pre {
            margin: 10px 0;
            padding: 10px 12px;
            border-radius: 12px;
            background: #181818;
            border: 1px solid #3a3a3a;
            overflow-x: auto;
        }

        .bot-prose pre code {
            padding: 0;
            border: 0;
            background: transparent;
            font-size: 12px;
            white-space: pre;
        }

        /* Tablas: wrapper para scroll horizontal en móvil */
        .bot-prose table {
            width: 100%;
            border-collapse: collapse;
            margin: 10px 0;
            border-radius: 12px;
            overflow: hidden;
            background: rgba(0, 0, 0, .18);
            border: 1px solid rgba(255, 255, 255, .10);
        }

        .bot-prose thead th {
            text-align: left;
            font-size: 12px;
            font-weight: 750;
            padding: 10px 10px;
            background: rgba(255, 255, 255, .06);
            border-bottom: 1px solid rgba(255, 255, 255, .10);
        }

        .bot-prose tbody td {
            padding: 9px 10px;
            border-bottom: 1px solid rgba(255, 255, 255, .08);
            vertical-align: top;
        }

        .bot-prose tbody tr:nth-child(even) td {
            background: rgba(255, 255, 255, .03);
        }

        .bot-prose tbody tr:last-child td {
            border-bottom: 0;
        }

        /* Enlaces */
        .bot-prose a {
            color: rgba(79, 198, 255, .95);
            text-decoration: none;
            border-bottom: 1px solid rgba(79, 198, 255, .35);
        }

        .bot-prose a:hover {
            filter: brightness(1.1);
            border-bottom-color: rgba(79, 198, 255, .75);
        }










        /* ===== Login moderno + responsive (solo bloque) ===== */
        .login-shell {
            width: min(100%, 680px);
            margin-inline: auto;
            padding-inline: 14px;
        }

        .login-tagline {
            margin: 10px auto 6px auto;
        }

        .login-card.modern {
            width: 100%;
            max-width: 560px;
            margin: 12px auto 0 auto;
            padding: clamp(16px, 3.6vw, 22px);
            border-radius: 18px;
            position: relative;
            overflow: hidden;

            /* glass */
            background:
                radial-gradient(circle at 15% 0%, rgba(79, 198, 255, .10), transparent 55%),
                radial-gradient(circle at 85% 100%, rgba(255, 75, 209, .12), transparent 55%),
                rgba(32, 32, 32, .72);
            border: 1px solid rgba(255, 255, 255, .08);
            box-shadow: 0 22px 70px rgba(0, 0, 0, .55);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
        }

        /* Borde degradado sutil */
        .login-card.modern::before {
            content: "";
            position: absolute;
            inset: 0;
            padding: 1px;
            border-radius: 18px;
            background: linear-gradient(135deg,
                    rgba(79, 198, 255, .55),
                    rgba(255, 75, 209, .45),
                    rgba(255, 255, 255, .08));
            -webkit-mask:
                linear-gradient(#000 0 0) content-box,
                linear-gradient(#000 0 0);
            -webkit-mask-composite: xor;
            mask-composite: exclude;
            pointer-events: none;
            opacity: .55;
        }

        .login-form {
            display: grid;
            gap: 12px;
        }

        .login-head {
            display: grid;
            gap: 4px;
            margin-bottom: 4px;
        }

        .login-title {
            margin: 0;
            font-family: var(--font-logo);
            font-size: clamp(16px, 3.8vw, 18px);
            letter-spacing: .14em;
            text-transform: uppercase;
        }

        .login-subtitle {
            margin: 0;
            color: var(--muted);
            font-size: 12px;
            line-height: 1.4;
        }

        .field {
            display: grid;
            gap: 6px;
        }

        .field-label {
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: .08em;
            color: var(--muted);
        }

        .field-inner {
            position: relative;
            display: flex;
            align-items: center;
            gap: 10px;

            border-radius: 14px;
            padding: 11px 12px 11px 40px;
            background: rgba(18, 18, 18, .55);
            border: 1px solid rgba(255, 255, 255, .10);
            box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .38);
            transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
        }

        .field-icon {
            position: absolute;
            left: 12px;
            width: 16px;
            height: 16px;
            opacity: .86;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: rgba(230, 231, 234, .85);
        }

        .field-inner input {
            flex: 1;
            border: 0;
            outline: none;
            background: transparent;
            color: var(--txt);
            font: 600 13px/1.4 var(--font-ui, Inter, system-ui, sans-serif);
            min-width: 0;
            /* evita overflow en móviles */
        }

        .field-inner input::placeholder {
            color: rgba(151, 160, 172, .70);
        }

        /* focus moderno */
        .field-inner:focus-within {
            border-color: rgba(79, 198, 255, .55);
            box-shadow:
                0 0 0 1px rgba(79, 198, 255, .35),
                0 10px 26px rgba(0, 0, 0, .45);
            background: rgba(22, 22, 22, .62);
        }

        /* Botón */
        .login-btn.modern {
            margin-top: 6px;
            width: 100%;
            border: 0;
            border-radius: 999px;
            padding: 11px 14px;

            background:
                radial-gradient(circle at 0% 0%, rgba(79, 198, 255, .38), transparent 55%),
                radial-gradient(circle at 100% 100%, rgba(255, 75, 209, .30), transparent 60%),
                #2f2f2f;

            color: var(--txt);
            font: 700 13px/1 var(--font-ui, Inter, system-ui, sans-serif);
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;

            box-shadow: 0 16px 44px rgba(0, 0, 0, .62),
                0 0 0 1px rgba(255, 255, 255, .06);
            cursor: pointer;
            transition: transform .08s ease, filter .16s ease, box-shadow .18s ease;
        }

        .login-btn.modern:hover {
            filter: brightness(1.08);
            box-shadow: 0 18px 52px rgba(0, 0, 0, .72),
                0 0 0 1px rgba(255, 255, 255, .09);
        }

        .login-btn.modern:active {
            transform: translateY(1px) scale(.99);
        }

        .login-btn.modern:focus-visible {
            outline: none;
            box-shadow:
                0 0 0 2px rgba(79, 198, 255, .35),
                0 18px 52px rgba(0, 0, 0, .72),
                0 0 0 1px rgba(255, 255, 255, .08);
        }

        /* puntito "status" */
        .login-btn-dot {
            width: 8px;
            height: 8px;
            border-radius: 999px;
            background: rgba(79, 198, 255, .85);
            box-shadow: 0 0 12px rgba(79, 198, 255, .55);
            opacity: .9;
        }

        /* hint */
        .login-hint {
            margin: 6px 2px 0 2px;
            font-size: 11px;
            color: var(--muted);
            text-align: center;
            opacity: .88;
        }

        /* Responsive: en móviles ajusta padding y radios */
        @media (max-width: 420px) {
            .login-card.modern {
                border-radius: 16px;
            }

            .field-inner {
                border-radius: 12px;
                padding: 10px 11px 10px 38px;
            }
        }

        /* Respeta usuarios con menos animación */
        @media (prefers-reduced-motion: reduce) {

            .login-btn.modern,
            .field-inner {
                transition: none;
            }
        }






        /* Estado "procesando" del botón enviar */
        .send.processing {
            border-color: rgba(79, 198, 255, .45);
            box-shadow: 0 0 0 1px rgba(79, 198, 255, .25), 0 14px 34px rgba(0, 0, 0, .55);
        }

        /* Animación suave del icono cuando va rotando */
        .send .icon-send {
            transition: opacity .18s ease, transform .18s ease, filter .18s ease;
            will-change: transform, opacity;
        }

        .send.processing .icon-send {
            filter: drop-shadow(0 0 10px rgba(79, 198, 255, .30));
        }

        .send .icon-send.fade-out {
            opacity: 0;
            transform: translateY(2px) scale(.96);
        }

        .send .icon-send.fade-in {
            opacity: 1;
            transform: translateY(0) scale(1);
        }

        /* Respeta reduce motion */
        @media (prefers-reduced-motion: reduce) {
            .send .icon-send {
                transition: none;
            }
        }


        .send[disabled],
        .send.processing {
            pointer-events: none;
            /* bloquea clicks */
            cursor: not-allowed;
            opacity: .92;
            /* opcional */
        }





        /* Adjuntos dentro del chat */
        .msg.user .attachments {
            display: flex;
            justify-content: flex-end;
            width: 100%;
        }

        .attachments-bubble {
            max-width: 78%;
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            padding: 10px 10px;
            border-radius: 12px;
            background: #303030;
            border: 1px solid #3a3a3a;
        }

        .attachments-bubble .file-chip {
            background: #2a2a2a;
        }






        .msg.bot.thinking .bubble {
            opacity: .92;
        }

        .thinking-text {
            margin-right: 8px;
            opacity: .85;
        }

        .thinking-dots span {
            display: inline-block;
            width: 5px;
            height: 5px;
            margin: 0 2px;
            background: rgba(79, 198, 255, .9);
            border-radius: 50%;
            animation: thinkingBlink 1.4s infinite both;
        }

        .thinking-dots span:nth-child(2) {
            animation-delay: .2s;
        }

        .thinking-dots span:nth-child(3) {
            animation-delay: .4s;
        }

        @keyframes thinkingBlink {
            0% {
                opacity: .25;
                transform: translateY(0);
            }

            25% {
                opacity: 1;
                transform: translateY(-1px);
            }

            100% {
                opacity: .25;
                transform: translateY(0);
            }
        }


        /* Indicador "Pensando" NO es un mensaje */
        .thinking-row {
            width: 100%;
            display: flex;
            justify-content: flex-start;
            /* o center si lo prefieres */
            padding: 2px 6px;
            margin: 6px 0 2px 0;
            opacity: .85;
            pointer-events: none;
        }

        .thinking-inline {
            display: inline-flex;
            align-items: center;
            /* MISMA LINEA */
            gap: 8px;
            /* espacio entre icono y texto */
            font-size: 12px;
            color: var(--muted);
            letter-spacing: .02em;
        }

        /* Spinner moderno */
        .thinking-spinner {
            width: 14px;
            height: 14px;
            border-radius: 999px;
            border: 2px solid rgba(255, 255, 255, .16);
            border-top-color: rgba(79, 198, 255, .95);
            /* azul */
            animation: thinkingSpin 1.1s linear infinite;
        }

        @keyframes thinkingSpin {
            from {
                transform: rotate(0deg);
            }

            to {
                transform: rotate(360deg);
            }
        }


        .thinking-row {
            display: flex;
            justify-content: flex-start;
            margin: 10px 0 14px;
            padding-left: 14px;
            /* mismo offset que burbujas bot */
        }


        /* contenedor de ondas */
        .thinking-wave {
            display: flex;
            gap: 5px;
        }

        /* barras */
        .thinking-wave i {
            width: 3px;
            height: 14px;
            background: linear-gradient(180deg, #7dd3fc, #38bdf8);
            border-radius: 3px;
            animation: wave 1.2s ease-in-out infinite;
            opacity: .85;
        }

        .thinking-wave i:nth-child(2) {
            animation-delay: .1s
        }

        .thinking-wave i:nth-child(3) {
            animation-delay: .2s
        }

        .thinking-wave i:nth-child(4) {
            animation-delay: .3s
        }

        .thinking-wave i:nth-child(5) {
            animation-delay: .4s
        }

        @keyframes wave {

            0%,
            100% {
                transform: scaleY(.4)
            }

            50% {
                transform: scaleY(1)
            }
        }