:root {
            --red:        #e8192c;
            --red-deep:   #b8101f;
            --red-glow:   rgba(232,25,44,0.35);
            --red-soft:   rgba(232,25,44,0.08);
            --red-mid:    rgba(232,25,44,0.18);
            --dark:       #0a0a0c;
            --dark-2:     #111114;
            --dark-3:     #18181d;
            --dark-4:     #222228;
            --dark-5:     #2e2e36;
            --light:      #f0f0f5;
            --muted:      #7a7a8c;
            --border:     rgba(255,255,255,0.07);
            --border-red: rgba(232,25,44,0.3);
            --white:      #ffffff;
            --gold:       #f5a623;
            --shadow-red: 0 8px 32px rgba(232,25,44,0.25);
            --shadow-card:0 4px 24px rgba(0,0,0,0.5);
        }

        *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

        html { scroll-behavior: smooth; }

        body {
            font-family: 'Plus Jakarta Sans', sans-serif;
            background: var(--dark);
            color: var(--light);
            min-height: 100vh;
            overflow-x: hidden;
        }

        /* ── NOISE TEXTURE OVERLAY ── */
        body::before {
            content: '';
            position: fixed; inset: 0; pointer-events: none; z-index: 0;
            background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.035'/%3E%3C/svg%3E");
            opacity: 0.4;
        }

        /* ── AMBIENT GLOW BG ── */
        body::after {
            content: '';
            position: fixed;
            top: -20%; left: -10%;
            width: 60%; height: 60%;
            background: radial-gradient(ellipse, rgba(232,25,44,0.12) 0%, transparent 70%);
            pointer-events: none; z-index: 0;
            animation: drift 12s ease-in-out infinite alternate;
        }
        @keyframes drift {
            from { transform: translate(0, 0) scale(1); }
            to   { transform: translate(8%, 5%) scale(1.1); }
        }

        /* ── LAYOUT WRAPPER ── */
        .wrapper {
            position: relative; z-index: 1;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        /* ── TOP NAV ── */
        .topnav {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 16px 28px;
            border-bottom: 1px solid var(--border);
            background: rgba(10,10,12,0.85);
            backdrop-filter: blur(16px);
            position: sticky; top: 0; z-index: 100;
        }

        .brand {
            display: flex; align-items: center; gap: 10px;
        }

        .brand-icon {
            width: 36px; height: 36px;
            background: var(--red);
            border-radius: 10px;
            display: flex; align-items: center; justify-content: center;
            font-size: 18px;
            box-shadow: 0 0 16px var(--red-glow);
            flex-shrink: 0;
        }

        .brand-text {
            display: flex; flex-direction: column;
        }

        .brand-name {
            font-family: 'Bebas Neue', sans-serif;
            font-size: 1.3rem;
            letter-spacing: 0.06em;
            color: var(--white);
            line-height: 1;
        }

        .brand-sub {
            font-size: 0.6rem;
            font-weight: 600;
            letter-spacing: 0.15em;
            text-transform: uppercase;
            color: var(--red);
            line-height: 1;
        }

        .nav-right {
            display: flex; align-items: center; gap: 10px;
        }

        .live-pill {
            display: flex; align-items: center; gap: 6px;
            background: var(--red-soft);
            border: 1px solid var(--border-red);
            padding: 5px 12px;
            border-radius: 999px;
            font-size: 0.68rem;
            font-weight: 700;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--red);
        }

        .live-dot {
            width: 6px; height: 6px;
            border-radius: 50%;
            background: var(--red);
            animation: live-blink 1.2s ease-in-out infinite;
        }
        @keyframes live-blink {
            0%,100% { opacity:1; box-shadow:0 0 0 0 var(--red-glow); }
            50%      { opacity:0.5; box-shadow:0 0 0 4px transparent; }
        }

        /* ── MAIN CONTENT ── */
        .main {
            flex: 1;
            display: grid;
            grid-template-columns: 300px 1fr;
            gap: 0;
            min-height: calc(100vh - 69px);
        }

        /* ── LEFT PANEL ── */
        .left-panel {
            border-right: 1px solid var(--border);
            background: var(--dark-2);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* Avatar section */
        .avatar-section {
            padding: 28px 24px 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 12px;
            border-bottom: 1px solid var(--border);
            background: linear-gradient(180deg, var(--dark-3) 0%, var(--dark-2) 100%);
            position: relative;
            overflow: hidden;
        }

        .avatar-section::before {
            content: '';
            position: absolute;
            bottom: -30px; left: 50%; transform: translateX(-50%);
            width: 180px; height: 60px;
            background: radial-gradient(ellipse, var(--red-glow) 0%, transparent 70%);
            pointer-events: none;
        }

        .avatar-ring-wrap {
            position: relative;
            width: 100px; height: 100px;
        }

        .avatar-ring-svg {
            position: absolute; inset: -10px;
            width: calc(100% + 20px); height: calc(100% + 20px);
            animation: none;
        }

        .avatar-ring-svg.speaking {
            animation: rotate-ring 3s linear infinite;
        }

        @keyframes rotate-ring { to { transform: rotate(360deg); } }

        .avatar-core {
            width: 100px; height: 100px;
            border-radius: 50%;
            background: linear-gradient(135deg, #1a1a22 0%, #2a0a0e 100%);
            border: 2px solid var(--dark-5);
            display: flex; align-items: center; justify-content: center;
            font-size: 44px;
            position: relative;
            z-index: 1;
            transition: box-shadow 0.4s;
        }

        .avatar-core.speaking {
            box-shadow: 0 0 30px var(--red-glow), 0 0 60px rgba(232,25,44,0.15);
        }

        .tutor-identity { text-align: center; }

        .tutor-name {
            font-family: 'Bebas Neue', sans-serif;
            font-size: 1.6rem;
            letter-spacing: 0.08em;
            color: var(--white);
            line-height: 1;
        }

        .tutor-role {
            font-size: 0.68rem;
            font-weight: 600;
            letter-spacing: 0.14em;
            text-transform: uppercase;
            color: var(--red);
            margin-top: 2px;
        }

        /* Stats bar */
        .stats-row {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 1px;
            background: var(--border);
            border-top: 1px solid var(--border);
            border-bottom: 1px solid var(--border);
        }

        .stat-cell {
            background: var(--dark-2);
            padding: 10px 8px;
            text-align: center;
        }

        .stat-num {
            font-family: 'Bebas Neue', sans-serif;
            font-size: 1.4rem;
            color: var(--red);
            line-height: 1;
        }

        .stat-lbl {
            font-size: 0.58rem;
            font-weight: 600;
            letter-spacing: 0.1em;
            text-transform: uppercase;
            color: var(--muted);
            margin-top: 2px;
        }

        /* Model selector */
        .section-head {
            padding: 16px 20px 8px;
            font-size: 0.6rem;
            font-weight: 700;
            letter-spacing: 0.15em;
            text-transform: uppercase;
            color: var(--muted);
        }

        .model-list {
            padding: 0 12px 12px;
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .model-card {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 12px;
            border: 1px solid var(--border);
            background: var(--dark-3);
            cursor: pointer;
            transition: all 0.2s;
            position: relative;
            overflow: hidden;
        }

        .model-card::before {
            content: '';
            position: absolute; left: 0; top: 0; bottom: 0;
            width: 3px;
            background: transparent;
            transition: background 0.2s;
            border-radius: 3px 0 0 3px;
        }

        .model-card:hover {
            border-color: var(--dark-5);
            background: var(--dark-4);
        }

        .model-card.selected {
            border-color: var(--border-red);
            background: var(--red-soft);
        }

        .model-card.selected::before { background: var(--red); }

        .model-emoji-wrap {
            width: 34px; height: 34px;
            border-radius: 9px;
            background: var(--dark-4);
            display: flex; align-items: center; justify-content: center;
            font-size: 1.1rem;
            flex-shrink: 0;
            border: 1px solid var(--border);
        }

        .model-card.selected .model-emoji-wrap {
            background: var(--red-mid);
            border-color: var(--border-red);
        }

        .model-info { flex: 1; min-width: 0; }

        .model-title {
            font-size: 0.78rem;
            font-weight: 700;
            color: var(--light);
            line-height: 1.2;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .model-card.selected .model-title { color: #ff5566; }

        .model-tag {
            font-size: 0.6rem;
            font-weight: 600;
            color: var(--muted);
        }

        .free-tag {
            font-size: 0.56rem;
            font-weight: 700;
            letter-spacing: 0.08em;
            background: rgba(34,197,94,0.15);
            color: #4ade80;
            border: 1px solid rgba(74,222,128,0.25);
            padding: 2px 7px;
            border-radius: 5px;
            text-transform: uppercase;
            flex-shrink: 0;
        }

        /* Tips */
        .tips-section {
            padding: 4px 12px 16px;
            margin-top: auto;
        }

        .tip-row {
            display: flex; align-items: center; gap: 10px;
            padding: 8px 10px;
            border-radius: 10px;
            margin-bottom: 4px;
        }

        .tip-row:hover { background: var(--dark-3); }

        .tip-ic {
            width: 28px; height: 28px;
            border-radius: 8px;
            background: var(--red-soft);
            border: 1px solid var(--border-red);
            display: flex; align-items: center; justify-content: center;
            font-size: 0.8rem;
            flex-shrink: 0;
        }

        .tip-txt {
            font-size: 0.73rem;
            color: var(--muted);
            line-height: 1.35;
        }

        /* ── RIGHT PANEL (CHAT) ── */
        .right-panel {
            display: flex;
            flex-direction: column;
            background: var(--dark);
            min-height: 0;
        }

        /* Chat header */
        .chat-header {
            padding: 16px 24px;
            border-bottom: 1px solid var(--border);
            display: flex;
            align-items: center;
            justify-content: space-between;
            background: var(--dark-2);
            flex-shrink: 0;
        }

        .chat-header-left .ch-title {
            font-family: 'Bebas Neue', sans-serif;
            font-size: 1.1rem;
            letter-spacing: 0.07em;
            color: var(--white);
        }

        .chat-header-left .ch-sub {
            font-size: 0.68rem;
            color: var(--muted);
            margin-top: 1px;
        }

        .active-chip {
            display: flex; align-items: center; gap: 6px;
            background: var(--red-soft);
            border: 1px solid var(--border-red);
            padding: 6px 14px;
            border-radius: 999px;
            font-size: 0.68rem;
            font-weight: 700;
            color: #ff5566;
            letter-spacing: 0.03em;
            transition: all 0.3s;
        }

        .chip-dot {
            width: 6px; height: 6px;
            border-radius: 50%;
            background: var(--red);
            animation: live-blink 1.4s ease-in-out infinite;
        }

        /* Chat messages */
        .chat-box {
            flex: 1;
            overflow-y: auto;
            padding: 24px 28px 12px;
            display: flex;
            flex-direction: column;
            gap: 16px;
            scroll-behavior: smooth;
        }

        .chat-box::-webkit-scrollbar { width: 4px; }
        .chat-box::-webkit-scrollbar-track { background: transparent; }
        .chat-box::-webkit-scrollbar-thumb { background: var(--dark-5); border-radius: 10px; }

        .msg-row {
            display: flex;
            gap: 10px;
            animation: msg-appear 0.25s ease;
        }

        @keyframes msg-appear {
            from { opacity:0; transform:translateY(12px); }
            to   { opacity:1; transform:translateY(0); }
        }

        .msg-row.user-row { flex-direction: row-reverse; }

        .msg-avatar {
            width: 32px; height: 32px;
            border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-size: 0.9rem;
            flex-shrink: 0;
            margin-top: 2px;
        }

        .msg-avatar.ai-av {
            background: linear-gradient(135deg, var(--red-deep), #8b0000);
            border: 1px solid var(--border-red);
            box-shadow: 0 0 10px var(--red-glow);
        }

        .msg-avatar.user-av {
            background: var(--dark-4);
            border: 1px solid var(--border);
        }

        .msg-body { max-width: 72%; display: flex; flex-direction: column; gap: 4px; }
        .user-row .msg-body { align-items: flex-end; }

        .msg-meta {
            font-size: 0.6rem;
            font-weight: 600;
            letter-spacing: 0.06em;
            text-transform: uppercase;
            color: var(--muted);
            padding: 0 4px;
        }

        .msg-meta .meta-model { color: var(--red); }

        .msg-bubble {
            padding: 12px 16px;
            border-radius: 18px;
            font-size: 0.875rem;
            line-height: 1.65;
            white-space: pre-wrap;
        }

        .ai-bubble {
            background: var(--dark-3);
            border: 1px solid var(--dark-5);
            border-bottom-left-radius: 4px;
            color: var(--light);
        }

        .user-bubble {
            background: linear-gradient(135deg, var(--red), var(--red-deep));
            border-bottom-right-radius: 4px;
            color: #fff;
            box-shadow: var(--shadow-red);
        }

        .error-bubble {
            background: rgba(232,25,44,0.08);
            border: 1px solid var(--border-red);
            color: #ff6677;
            border-radius: 14px;
            padding: 10px 14px;
            font-size: 0.8rem;
        }

        /* Typing indicator */
        .typing-row {
            display: flex; gap: 10px;
            animation: msg-appear 0.25s ease;
        }

        .typing-bubble {
            display: flex; gap: 5px; align-items: center;
            background: var(--dark-3);
            border: 1px solid var(--dark-5);
            border-bottom-left-radius: 4px;
            padding: 14px 18px;
            border-radius: 18px;
        }

        .typing-bubble span {
            width: 7px; height: 7px;
            border-radius: 50%;
            background: var(--red);
            animation: bounce-dot 1.1s ease-in-out infinite;
            opacity: 0.7;
        }
        .typing-bubble span:nth-child(2) { animation-delay: 0.18s; }
        .typing-bubble span:nth-child(3) { animation-delay: 0.36s; }
        @keyframes bounce-dot {
            0%,60%,100% { transform:translateY(0); opacity:0.5; }
            30%          { transform:translateY(-7px); opacity:1; }
        }

        /* ── INPUT ZONE ── */
        .input-zone {
            padding: 16px 24px 20px;
            border-top: 1px solid var(--border);
            background: var(--dark-2);
            flex-shrink: 0;
        }

        .recording-banner {
            display: none;
            align-items: center;
            gap: 8px;
            margin-bottom: 10px;
            font-size: 0.7rem;
            font-weight: 700;
            color: var(--red);
            letter-spacing: 0.1em;
            text-transform: uppercase;
        }
        .recording-banner.active { display: flex; animation: fade-pulse 0.9s ease infinite; }
        @keyframes fade-pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
        .rec-dot-anim {
            width: 8px; height: 8px; border-radius: 50%; background: var(--red);
        }

        .input-bar {
            display: flex;
            gap: 10px;
            align-items: center;
            background: var(--dark-3);
            border: 1px solid var(--dark-5);
            border-radius: 18px;
            padding: 6px 6px 6px 18px;
            transition: border-color 0.25s, box-shadow 0.25s;
        }

        .input-bar:focus-within {
            border-color: var(--border-red);
            box-shadow: 0 0 0 3px var(--red-soft);
        }

        .txt-input {
            flex: 1;
            background: transparent;
            border: none;
            outline: none;
            font-family: 'Plus Jakarta Sans', sans-serif;
            font-size: 0.9rem;
            color: var(--light);
            padding: 6px 0;
        }

        .txt-input::placeholder { color: var(--dark-5); }

        .input-actions {
            display: flex; gap: 6px; align-items: center;
        }

        .iact-btn {
            width: 40px; height: 40px;
            border-radius: 12px;
            border: none; cursor: pointer;
            display: flex; align-items: center; justify-content: center;
            font-size: 1rem;
            transition: all 0.15s;
        }
        .iact-btn:active { transform: scale(0.9); }

        .btn-mic-new {
            background: var(--dark-4);
            color: #ff5566;
            border: 1px solid var(--border);
        }
        .btn-mic-new:hover { background: var(--dark-5); }
        .btn-mic-new.on {
            background: var(--red);
            color: #fff;
            border-color: var(--red);
            box-shadow: 0 0 12px var(--red-glow);
            animation: mic-glow 0.8s ease-in-out infinite;
        }
        @keyframes mic-glow {
            0%,100% { box-shadow: 0 0 8px var(--red-glow); }
            50%      { box-shadow: 0 0 20px var(--red-glow); }
        }

        .btn-send-new {
            background: var(--red);
            color: #fff;
            border: none;
            box-shadow: var(--shadow-red);
        }
        .btn-send-new:hover { background: var(--red-deep); }
        .btn-send-new:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

        .input-hint {
            text-align: center;
            font-size: 0.62rem;
            color: var(--dark-5);
            margin-top: 8px;
            letter-spacing: 0.04em;
        }

        /* ── MOBILE BOTTOM NAV ── */
        .mobile-nav {
            display: none;
            position: fixed;
            bottom: 0; left: 0; right: 0;
            background: var(--dark-2);
            border-top: 1px solid var(--border);
            padding: 10px 16px;
            gap: 6px;
            z-index: 200;
            flex-wrap: nowrap;
            overflow-x: auto;
        }

        .mobile-model-btn {
            display: flex; flex-direction: column; align-items: center; gap: 2px;
            padding: 8px 12px;
            border-radius: 12px;
            border: 1px solid var(--border);
            background: var(--dark-3);
            cursor: pointer;
            font-family: 'Plus Jakarta Sans', sans-serif;
            transition: all 0.18s;
            white-space: nowrap;
            flex-shrink: 0;
        }
        .mobile-model-btn.selected {
            border-color: var(--border-red);
            background: var(--red-soft);
        }
        .mobile-model-btn .mm-icon { font-size: 1rem; }
        .mobile-model-btn .mm-name { font-size: 0.62rem; font-weight: 700; color: var(--muted); }
        .mobile-model-btn.selected .mm-name { color: #ff5566; }

        /* ── RESPONSIVE ── */
        @media (max-width: 900px) {
            .main {
                grid-template-columns: 260px 1fr;
            }
        }

        @media (max-width: 680px) {
            .main {
                grid-template-columns: 1fr;
            }

            .left-panel {
                display: none;
            }

            .right-panel {
                min-height: calc(100vh - 69px - 70px);
            }

            .mobile-nav {
                display: flex;
            }

            .chat-box {
                padding: 16px 16px 8px;
            }

            .input-zone {
                padding: 12px 16px 16px;
                margin-bottom: 70px;
            }

            .chat-header {
                padding: 12px 16px;
            }

            .topnav {
                padding: 12px 16px;
            }

            .brand-name { font-size: 1.1rem; }
        }

        /* ── SCROLL reveal for messages ── */
        .msg-row, .typing-row {
            will-change: transform, opacity;
        }

        /* Selection glow on send */
        @keyframes send-flash {
            0% { box-shadow: 0 0 0 0 var(--red-glow); }
            100% { box-shadow: 0 0 0 16px transparent; }
        }
        
        .msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-top: 2px;
    overflow: hidden; /* IMPORTANTE: Recorta la imagen en círculo */
}

/* Estilo para que la imagen ocupe todo el avatar sin deformarse */
.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-avatar.ai-av {
    background: linear-gradient(135deg, var(--red-deep), #8b0000);
    border: 1px solid var(--border-red);
    box-shadow: 0 0 10px var(--red-glow);
}

.msg-avatar.user-av {
    background: var(--dark-4);
    border: 1px solid var(--border);
}

#btn-report:hover {
    background: var(--red-deep) !important;
    color: white !important;
    border-color: var(--red-glow) !important;
    box-shadow: 0 0 10px var(--red-glow);
}