/* Estilos del chat de Thorly IA en Blazor.
   Generado desde public/styles (main.bundle.css, live-response.css, model-picker.css) con
   «body» → «.chat-raiz». Los iconos son de Tabler (fuente), no SVG de Lucide: el ajuste va al final. */

/* Generado por scripts/build.mjs a partir de main.css — no editar a mano */

/* ── tokens.css ── */
/* ==========================================================================
   THORLY AI — Design Tokens (CSS Custom Properties)
   Variables, brand colors, themes dark/light
   ========================================================================== */

:root {
    /* Brand Gradient */
    --brand-blue: #3B72FF;
    --brand-purple: #9B3BFF;
    --brand-pink: #FF2E60;

    /* Font */
    --font-main: 'Google Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'Google Sans Mono', 'Roboto Mono', 'Courier New', monospace;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-med: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    /* Sidebar */
    --sidebar-width: 240px;
}

/* ── DARK THEME (default) ───────────────────────────────────────────────── */
[data-theme="dark"] {
    --bg-base: #0F0F0F;
    --bg-surface: #1A1A1A;
    --bg-elevated: #242424;
    --bg-hover: #2A2A2A;
    --bg-active: #303030;
    --bg-input: #1E1E1E;
    --bg-code: #141414;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.16);

    --text-primary: #E3E3E3;
    --text-strong: #FFFFFF;
    --text-secondary: #ABABAB;
    --text-tertiary: #707070;
    --text-on-brand: #0F0F0F;

    --accent-primary: #8AB4F8;
    --accent-primary-dim: rgba(138, 180, 248, 0.12);
    --accent-primary-glow: rgba(138, 180, 248, 0.25);

    --pill-active-bg: rgba(138, 180, 248, 0.15);
    --pill-active-border: rgba(138, 180, 248, 0.40);
    --pill-active-text: #8AB4F8;

    --send-btn-bg: #8AB4F8;
    --send-btn-text: #0F0F0F;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.40);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);

    --scrollbar-thumb: rgba(255, 255, 255, 0.12);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.22);
}

/* ── LIGHT THEME ────────────────────────────────────────────────────────── */
[data-theme="light"] {
    --bg-base: #F8F9FA;
    --bg-surface: #FFFFFF;
    --bg-elevated: #F1F3F4;
    --bg-hover: #EAECEF;
    --bg-active: #E0E3E8;
    --bg-input: #FFFFFF;
    --bg-code: #F1F3F4;

    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-default: rgba(0, 0, 0, 0.09);
    --border-strong: rgba(0, 0, 0, 0.15);

    --text-primary: #1A1A1A;
    --text-strong: #000000;
    --text-secondary: #5F6368;
    --text-tertiary: #9AA0A6;
    --text-on-brand: #FFFFFF;

    --accent-primary: #1A73E8;
    --accent-primary-dim: rgba(26, 115, 232, 0.10);
    --accent-primary-glow: rgba(26, 115, 232, 0.22);

    --pill-active-bg: rgba(26, 115, 232, 0.10);
    --pill-active-border: rgba(26, 115, 232, 0.35);
    --pill-active-text: #1A73E8;

    --send-btn-bg: #1A73E8;
    --send-btn-text: #FFFFFF;

    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.10);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 6px 24px rgba(0, 0, 0, 0.15);

    --scrollbar-thumb: rgba(0, 0, 0, 0.13);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.22);
}


/* ── base.css ── */
/* ==========================================================================
   THORLY AI — Reset & Base Styles
   Reset, .chat-raiz, scrollbars, global utilities
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

.chat-raiz {
    font-family: var(--font-main);
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
    transition: background-color var(--transition-med), color var(--transition-med);
}

/* Custom scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

button {
    font-family: var(--font-main);
}

a {
    text-decoration: none;
    color: var(--accent-primary);
}

a:hover {
    text-decoration: underline;
}

/* Gradient text utility */
.gradient-text {
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-purple), var(--brand-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── layout.css ── */
/* ==========================================================================
   THORLY AI — Layout Shell
   Sidebar shell, main-wrapper, overlay
   ========================================================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform var(--transition-med), width var(--transition-med), background-color var(--transition-med);
    overflow: hidden;
}

#sidebar-toggle-btn-desktop {
    display: none !important;
}

.sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-med);
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.main-wrapper {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    transition: padding-left var(--transition-med),
                padding-top 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                justify-content 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.main-wrapper.chat-empty {
    justify-content: flex-start;
    padding-top: 15vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.main-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: calc(50% + 30px); /* Centered in chat area (W/2 + CollapsedSidebar/2) */
    transform: translateX(-50%);
    width: min(1100px, 95vw);
    height: min(350px, 35vh);
    background: radial-gradient(ellipse at center bottom,
        rgba(255, 255, 255, 0.20) 0%,
        rgba(255, 255, 255, 0.12) 30%,
        rgba(255, 255, 255, 0.05) 60%,
        transparent 85%);
    border-radius: 50% 50% 0 0;
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
                left var(--transition-med);
}

.main-wrapper.sidebar-visible::after {
    left: calc(50% + 130px); /* Centered in chat area (W/2 + ExpandedSidebar/2) */
}

.main-wrapper:not(.chat-empty)::after {
    opacity: 1;
}

[data-theme="light"] .main-wrapper::after {
    background: radial-gradient(ellipse at center bottom,
        rgba(160, 80, 240, 0.18) 0%,
        rgba(160, 80, 240, 0.10) 30%,
        rgba(160, 80, 240, 0.04) 60%,
        transparent 85%);
}

.main-wrapper.chat-empty::after {
    opacity: 0;
}

.main-wrapper.chat-empty .topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.main-wrapper.chat-empty .chat-area {
    flex: 0 0 auto;
    min-height: auto;
    position: relative;
    z-index: 1;
    overflow: visible;
}

.main-wrapper.chat-empty .input-area-wrapper {
    background: transparent;
    position: relative;
    z-index: 1;
}

.main-wrapper.chat-empty .welcome-screen {
    position: relative;
    inset: auto;
    padding-bottom: 24px;
    padding-top: 10vh;
    z-index: 1;
    overflow: visible;
}


/* On desktop, shift main content when sidebar is open */
@media (min-width: 992px) {
    .sidebar-overlay {
        display: none;
    }

    .sidebar {
        transform: translateX(0) !important;
        width: 60px;
        box-shadow: none;
    }

    .sidebar.sidebar-expanded {
        width: var(--sidebar-width);
    }

    #sidebar-toggle-btn {
        display: none !important;
    }

    #sidebar-toggle-btn-desktop {
        display: inline-flex !important;
    }

    .sidebar:not(.sidebar-expanded) #sidebar-toggle-btn-desktop {
        display: none !important;
    }

    .main-wrapper {
        padding-left: 60px;
    }

    .main-wrapper.sidebar-visible {
        padding-left: var(--sidebar-width);
    }

    .main-wrapper.chat-empty .topbar {
        left: 60px;
        transition: left var(--transition-med);
    }

    .main-wrapper.chat-empty.sidebar-visible .topbar {
        left: var(--sidebar-width);
    }

    /* Hide text elements when collapsed */
    .sidebar:not(.sidebar-expanded) .sidebar-brand,
    .sidebar:not(.sidebar-expanded) .new-chat-btn span,
    .sidebar:not(.sidebar-expanded) .sidebar-section-label,
    .sidebar:not(.sidebar-expanded) .sidebar-nav,
    .sidebar:not(.sidebar-expanded) .sidebar-footer-item span,
    .sidebar:not(.sidebar-expanded) .sidebar-empty {
        display: none;
    }

    .sidebar:not(.sidebar-expanded) .sidebar-header {
        justify-content: center !important;
        padding-left: 0;
        padding-right: 0;
    }

    .sidebar:not(.sidebar-expanded) .sidebar-branding-link {
        width: 100%;
        justify-content: center;
    }

    .sidebar:not(.sidebar-expanded) .sidebar-actions {
        padding: 4px 8px 10px;
    }

    .sidebar:not(.sidebar-expanded) .new-chat-btn {
        justify-content: center;
        padding: 8px;
    }

    .sidebar:not(.sidebar-expanded) .sidebar-footer {
        align-items: center;
    }

    .sidebar:not(.sidebar-expanded) .sidebar-footer-item {
        justify-content: center;
        padding: 9px;
    }
}

/* ── components/sidebar.css ── */
/* ==========================================================================
   THORLY AI — Sidebar Component
   Header, nav, items, footer, user-profile
   ========================================================================== */

.sidebar-header {
    padding: calc(16px + env(safe-area-inset-top, 0px)) 14px 12px;
    flex-shrink: 0;
}

.thorly-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-claro,
.logo-oscuro {
    display: none;
}

[data-theme="light"] .logo-oscuro {
    display: block;
}

[data-theme="dark"] .logo-claro {
    display: block;
}

.sidebar-branding-link {
    text-decoration: none !important;
    color: inherit;
    transition: opacity var(--transition-fast);
}

.sidebar-branding-link:hover {
    opacity: 0.8;
}

.sidebar-brand {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-actions {
    padding: 4px 12px 10px;
    flex-shrink: 0;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    margin-bottom: 4px;
    background-color: transparent;
}

/* Dark theme colors */
[data-theme="dark"] .new-chat-btn {
    color: var(--text-secondary);
}

[data-theme="dark"] .new-chat-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Light theme colors */
[data-theme="light"] .new-chat-btn {
    color: var(--text-secondary);
}

[data-theme="light"] .new-chat-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.new-chat-btn i {
    width: 16px;
    height: 16px;
}

.sidebar-section-label {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
    padding: 0 8px;
    margin-top: 10px;
    margin-bottom: 10px;
    flex: 1 0 0;
    min-height: 0;
}

.sidebar-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 400;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-item i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.sidebar-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
    font-weight: 500;
}

.item-actions {
    display: none;
    align-items: center;
    gap: 2px;
}

.sidebar-item:hover .item-actions {
    display: flex;
}

.item-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.item-menu-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.delete-btn {
    color: #ef4444 !important;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #f87171 !important;
}

.item-menu-btn i {
    width: 14px;
    height: 14px;
    color: inherit;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 8px 12px calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.sidebar-footer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 400;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    width: 100%;
    text-align: left;
}

.sidebar-footer-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-footer-item i {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px;
    border-radius: var(--radius-md);
    margin-top: 4px;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-profile:hover {
    background: var(--bg-hover);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.user-name {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Empty State */
.sidebar-empty {
    padding: 16px;
    color: var(--text-tertiary);
    font-size: 13px;
    text-align: center;
}

/* ── components/topbar.css ── */
/* ==========================================================================
   THORLY AI — Top Bar Component
   Top bar, icon-btn, model selector, theme toggle
   ========================================================================== */

.topbar {
    height: calc(60px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: 16px;
    padding-bottom: 0;
    padding-left: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    background-color: var(--bg-base);
    flex-shrink: 0;
    gap: 12px;
    transition: background-color var(--transition-med);
    position: relative;
    z-index: 100;
}

/* Icon Button (universal) */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.icon-btn i {
    width: 18px;
    height: 18px;
}

/* Theme toggle icon visibility */
.icon-sun, .icon-moon {
    display: none !important;
}

[data-theme="dark"] .icon-sun {
    display: block !important;
}

[data-theme="light"] .icon-moon {
    display: block !important;
}



.topbar-profile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.topbar-profile-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.topbar-profile-btn i {
    width: 18px;
    height: 18px;
}

.topbar-profile-btn .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-purple));
}

.topbar-profile-btn .avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* ── components/dropdowns.css ── */
/* ==========================================================================
   THORLY AI — Dropdown Menus
   Model dropdown + mode options (Bootstrap structure, custom visual)
   ========================================================================== */

.dropdown-menu {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 220px;
    animation: dropIn var(--transition-fast) ease;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dropdown-header-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-tertiary);
    padding: 6px 10px 4px;
}

/* Model dropdown */
.model-dropdown-menu {
    min-width: 260px;
}

.dropdown-item {
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13.5px;
    padding: 0;
    width: 100%;
    cursor: pointer;
    display: block;
    transition: background var(--transition-fast);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.model-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
}

.model-item.active {
    background: var(--accent-primary-dim);
}

.model-item-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent-primary);
}

.model-item-icon i {
    width: 16px;
    height: 16px;
}

.model-item-info {
    flex: 1;
    text-align: left;
}

.model-item-name {
    display: block;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
}

.model-item-desc {
    display: block;
    font-size: 11.5px;
    color: var(--text-tertiary);
}

.model-check {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}

/* Mode options menu */
.mode-options-menu {
    min-width: 190px;
}

.mode-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    color: var(--text-primary);
}

.mode-opt i {
    width: 15px;
    height: 15px;
    color: var(--text-tertiary);
}

.mode-opt.active {
    color: var(--accent-primary);
    background: var(--accent-primary-dim);
}

.mode-opt.active i {
    color: var(--accent-primary);
}

/* Profile Dropdown Minimalist */
.profile-dropdown {
    min-width: 180px;
    padding: 6px;
    border: 1px solid var(--border-strong);
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-lg);
}

.profile-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}

.profile-dropdown .dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.profile-dropdown .dropdown-item i {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}

.logout-item {
    color: #ef4444 !important;
}

.logout-item:hover {
    background: rgba(239, 68, 68, 0.1) !important;
}

/* ── components/chat.css ── */
/* ==========================================================================
   THORLY AI — Chat Area
   Chat area, welcome screen, messages, thinking indicator
   ========================================================================== */

.chat-area {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Welcome Screen */
.welcome-screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    padding-top: 8vh;
    overflow-y: auto;
    opacity: 1;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --welcome-glow-gradient: radial-gradient(ellipse at center,
        rgba(255, 255, 255, 0.40) 0%,
        rgba(255, 255, 255, 0.25) 40%,
        rgba(255, 255, 255, 0.12) 70%,
        transparent 85%);
}

.welcome-screen.hiding {
    opacity: 0;
    pointer-events: none;
}

[data-theme="light"] .welcome-screen {
    --welcome-glow-gradient: radial-gradient(ellipse at center,
        rgba(160, 80, 240, 0.35) 0%,
        rgba(160, 80, 240, 0.22) 40%,
        rgba(160, 80, 240, 0.10) 70%,
        transparent 85%);
}

.welcome-screen::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(1000px, 90vw);
    height: min(420px, 42vh);
    background: var(--welcome-glow-gradient);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(90px);
    opacity: 1;
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.6s ease;
}

.welcome-screen.hiding::before {
    transform: translate(-50%, calc(-50% + 20vh));
    opacity: 0;
}

.welcome-screen .col-12 {
    position: relative;
    z-index: 1;
}


.welcome-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.welcome-logo {
    width: 72px;
    height: 72px;
    filter: drop-shadow(0 0 15px rgba(197, 138, 249, 0.25));
}

.welcome-heading {
    font-size: clamp(28px, 5vw, 42px);
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 10px;
}

.welcome-sub {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* Suggestion Cards */
.suggestion-grid {
    margin-top: 32px;
}

.suggestion-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px;
    width: 100%;
    height: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-fast),
        border-color var(--transition-fast),
        color var(--transition-fast),
        transform var(--transition-fast),
        box-shadow var(--transition-fast);
}

.suggestion-card i {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.suggestion-card:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-primary-glow);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* Messages Container */
.messages-container {
    display: none;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 32px 16px 12px;
    scroll-padding-top: 20px;
}

.messages-container.visible {
    display: block;
}

/* Message bubble */
.message {
    margin-bottom: 24px;
    max-width: 768px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    padding-left: 24px;
    padding-right: 24px;
}

.user-message {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-message .message-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl) var(--radius-xl) var(--radius-sm) var(--radius-xl);
    padding: 12px 18px;
    max-width: 80%;
    font-size: 15px;
    color: var(--text-primary);
}

.message-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Mayor separación horizontal */
    margin-top: 8px;
    opacity: 1;
    /* Siempre visibles */
    transition: opacity var(--transition-fast);
}

.artifact-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    background: rgba(138, 180, 248, 0.08);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-pill);
    color: var(--accent-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.artifact-toggle-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(138, 180, 248, 0.15), rgba(124, 167, 255, 0.08));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.artifact-toggle-btn:hover {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: 0 0 16px rgba(138, 180, 248, 0.35);
    transform: translateY(-1px);
}

.artifact-toggle-btn:hover::before {
    opacity: 1;
}

.artifact-toggle-btn.active {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: 0 0 12px rgba(138, 180, 248, 0.3);
}

.artifact-toggle-btn i {
    width: 14px;
    height: 14px;
    position: relative;
    z-index: 1;
}

.artifact-toggle-btn span {
    position: relative;
    z-index: 1;
}

/* Eliminamos la dependencia del hover para mostrar los botones */
.message:hover .message-actions {
    opacity: 1;
}

.msg-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.msg-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.msg-action-btn i {
    width: 15px;
    height: 15px;
}

.msg-action-btn.tts-btn.speaking {
    color: var(--accent-primary);
    background: rgba(138, 180, 248, 0.15);
    border-radius: 50%;
    animation: speakerPulse 1.2s ease-in-out infinite;
}

.msg-action-btn.tts-btn.loading {
    color: var(--accent-primary);
    opacity: 0.6;
}

@keyframes speakerPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.15);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}



/* AI Message */
.ai-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background:
        linear-gradient(var(--bg-elevated), var(--bg-elevated)) padding-box,
        linear-gradient(135deg, var(--brand-blue), var(--brand-purple), var(--brand-pink)) border-box;
    border: 2px solid transparent;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    box-shadow: 0 0 8px rgba(155, 59, 255, 0.2);
}

.message-body {
    flex: 1;
    min-width: 0;
}

/* La imagen flotante se estila en content/markdown.css (aquí había una copia duplicada) */

.ai-message .message-content {
    font-size: 15.5px;
    color: var(--text-primary);
    line-height: 1.8;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ai-message .message-content p {
    margin-bottom: 20px; /* Más espacio entre párrafos para dar aire */
}

.message-content p:first-child {
    margin-top: 0 !important;
}

.message-content p:last-child {
    margin-bottom: 0 !important;
}

.ai-message .message-content ul,
.ai-message .message-content ol {
    padding-left: 24px;
    margin-top: 20px; /* Más aire antes de la lista */
    margin-bottom: 24px; /* Más aire después de la lista */
}

.ai-message .message-content li {
    margin-bottom: 12px; /* Ítems más separados y legibles */
    line-height: 1.8;
}

/* Bullet styling for better visual hierarchy */
.ai-message .message-content ul {
    list-style-type: disc;
}

.ai-message .message-content ul li::marker {
    color: var(--accent-primary);
    font-size: 1.1em;
}

.ai-message .message-content ol li::marker {
    color: var(--text-secondary);
    font-weight: 600;
}

.ai-message .message-content strong {
    color: var(--text-strong, #ffffff); /* Resalta según el tema activo (claro/oscuro) */
    font-weight: 700;
    letter-spacing: 0.2px;
}

.ai-message .message-content em {
    color: inherit;
    font-style: italic; /* Cursiva estándar para markdown */
}

/* Thinking Indicator */
.thinking-message {
    animation: msgIn 0.3s ease both;
}

/* ── AI Avatar Animation (while generating) ─────────────────────────── */
.thinking-message .ai-avatar {
    position: relative;
    border-color: transparent;
    background: var(--bg-elevated);
    box-shadow:
        0 0 12px var(--accent-primary-glow),
        0 0 24px rgba(138, 180, 248, 0.1);
    animation: avatarBreath 2s ease-in-out infinite,
        avatarGlow 2s ease-in-out infinite;
}

/* Rotating gradient ring */
.thinking-message .ai-avatar::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg,
            #4968ff,
            #8640ff,
            #f521f5,
            transparent 60%,
            transparent 80%,
            #395afc);
    animation: avatarRingSpin 1.8s linear infinite;
    z-index: -1;
    opacity: 0.9;
}

/* Inner mask so the ring looks like a spinning border */
.thinking-message .ai-avatar::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 50%;
    background: var(--bg-elevated);
    z-index: -1;
}

/* Subtle breathing scale on the logo image */
.thinking-message .ai-avatar img {
    animation: avatarLogoPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 4px var(--accent-primary-glow));
}

@keyframes avatarRingSpin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes avatarBreath {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.06);
    }
}

@keyframes avatarGlow {

    0%,
    100% {
        box-shadow:
            0 0 8px var(--accent-primary-glow),
            0 0 16px rgba(138, 180, 248, 0.08);
    }

    50% {
        box-shadow:
            0 0 16px var(--accent-primary-glow),
            0 0 32px rgba(138, 180, 248, 0.2);
    }
}

@keyframes avatarLogoPulse {

    0%,
    100% {
        opacity: 0.85;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.08);
    }
}

.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

/* ── Premium Thinking Block (Perplexity / Gemini style) ────────── */
.thinking-block {
    background: rgba(25, 25, 25, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    padding: 12px 16px;
    max-width: 400px;
    position: relative;
    overflow: hidden;
    animation: thinkingFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Organic glow pulse from logo colors (purple, blue, pink) */
.thinking-glow {
    position: absolute;
    top: -60%;
    left: -30%;
    width: 160%;
    height: 160%;
    background: radial-gradient(
        ellipse at center,
        rgba(168, 85, 247, 0.08) 0%,
        rgba(59, 130, 246, 0.05) 35%,
        rgba(236, 72, 153, 0.03) 60%,
        transparent 80%
    );
    animation: glowPulse 5s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

/* Animated conic-gradient border */
.thinking-border-spin {
    position: absolute;
    inset: 0;
    border-radius: 14px;
    padding: 1px;
    background: conic-gradient(
        from 0deg,
        transparent 0%,
        rgba(168, 85, 247, 0.4) 15%,
        rgba(59, 130, 246, 0.4) 30%,
        rgba(236, 72, 153, 0.3) 45%,
        transparent 55%,
        transparent 100%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: borderSpin 4s linear infinite;
    pointer-events: none;
    z-index: 1;
}

/* Inner subtle border for depth */
.thinking-block::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    pointer-events: none;
    z-index: 2;
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: default;
    user-select: none;
    position: relative;
    z-index: 3;
}

/* Quantum gradient spinner ring */
.thinking-spinner {
    width: 18px;
    height: 18px;
    position: relative;
    flex-shrink: 0;
}

.thinking-spinner-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent 0%,
        rgba(168, 85, 247, 0.8) 20%,
        rgba(59, 130, 246, 0.8) 40%,
        rgba(236, 72, 153, 0.6) 60%,
        transparent 70%
    );
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #fff calc(100% - 2px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #fff calc(100% - 2px));
    animation: spinnerRotate 2s linear infinite;
}

.thinking-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    flex: 1;
    letter-spacing: 0.01em;
}

.thinking-chevron {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    opacity: 0.35;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.thinking-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.15s ease;
}

.thinking-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
}

.thinking-toggle:hover .thinking-chevron {
    opacity: 0.6;
}

.thinking-toggle.expanded .thinking-chevron {
    transform: rotate(180deg);
}

.thinking-steps {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    position: relative;
    z-index: 3;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    max-height: 200px;
    opacity: 1;
}

.thinking-steps.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.thinking-step {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-tertiary);
    opacity: 0;
    transform: translateY(6px);
    animation: stepEmerg 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    position: relative;
}

.step-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-tertiary);
    opacity: 0.3;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.thinking-step.active .step-dot {
    background: #3b82f6;
    opacity: 1;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.5);
    animation: dotPulseActive 1.4s ease-in-out infinite;
}

.thinking-step.completed .step-dot {
    background: #22c55e;
    opacity: 0.6;
    box-shadow: none;
    animation: none;
}

/* Shimmer sweep on active step text */
.shimmer-text {
    position: relative;
    display: inline-block;
    background: linear-gradient(
        110deg,
        var(--text-tertiary) 0%,
        var(--text-tertiary) 40%,
        rgba(255, 255, 255, 0.6) 50%,
        var(--text-tertiary) 60%,
        var(--text-tertiary) 100%
    );
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmerSweep 2.5s ease-in-out infinite;
}

.thinking-step.active .shimmer-text {
    animation: shimmerSweep 2.5s ease-in-out infinite;
}

.thinking-step.completed {
    opacity: 0.4;
    transform: translateY(0);
}

.thinking-step.completed .shimmer-text {
    animation: none;
    background: none;
    -webkit-text-fill-color: var(--text-tertiary);
}

/* ── Animations ────────────────────────────────────────────────── */
@keyframes thinkingFadeIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes glowPulse {
    0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.6; }
    33% { transform: scale(1.05) translate(5%, -3%); opacity: 0.9; }
    66% { transform: scale(0.97) translate(-3%, 4%); opacity: 0.7; }
}

@keyframes borderSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes spinnerRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes stepEmerg {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmerSweep {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes dotPulseActive {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* ── iOS-style circular spinner loader with gradient colors ────────────────────── */
.ios-spinner {
    position: relative;
    width: 32px;
    height: 32px;
    --spinner-idle-bg: rgba(255, 255, 255, 0.15); /* Gris en modo oscuro */
}

[data-theme="light"] .ios-spinner {
    --spinner-idle-bg: rgba(181, 102, 255, 0.22); /* Morado clarito en modo claro */
}

.ios-spinner .dot {
    position: absolute;
    width: 6.5px;
    height: 6.5px;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    margin-top: -3.25px;
    margin-left: -3.25px;
    background-color: var(--spinner-idle-bg);
    animation: iosSpinnerFadeColor 0.8s linear infinite;
}

.ios-spinner .dot:nth-child(1) { transform: rotate(0deg) translateY(-11px); animation-delay: 0s; --dot-color: #5C8DFF; }
.ios-spinner .dot:nth-child(2) { transform: rotate(45deg) translateY(-11px); animation-delay: -0.7s; --dot-color: #8c88f9; }
.ios-spinner .dot:nth-child(3) { transform: rotate(90deg) translateY(-11px); animation-delay: -0.6s; --dot-color: #B566FF; }
.ios-spinner .dot:nth-child(4) { transform: rotate(135deg) translateY(-11px); animation-delay: -0.5s; --dot-color: #dc66ff; }
.ios-spinner .dot:nth-child(5) { transform: rotate(180deg) translateY(-11px); animation-delay: -0.4s; --dot-color: #ff66d0; }
.ios-spinner .dot:nth-child(6) { transform: rotate(225deg) translateY(-11px); animation-delay: -0.3s; --dot-color: #ff669e; }
.ios-spinner .dot:nth-child(7) { transform: rotate(270deg) translateY(-11px); animation-delay: -0.2s; --dot-color: #FF667D; }
.ios-spinner .dot:nth-child(8) { transform: rotate(315deg) translateY(-11px); animation-delay: -0.1s; --dot-color: #ff8597; }

@keyframes iosSpinnerFadeColor {
    0% {
        background-color: var(--dot-color);
        box-shadow: 0 0 6px var(--dot-color);
        opacity: 1;
    }
    100% {
        background-color: var(--spinner-idle-bg);
        box-shadow: none;
        opacity: 0.35;
    }
}

/* Message File Preview */
.message-file-preview {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    background: var(--bg-code);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    margin-bottom: 6px;
}

.message-file-preview i {
    width: 14px;
    height: 14px;
}

/* Chat Area — Make messages-container fill and scroll properly */
.messages-container.visible {
    display: block;
    min-height: calc(100vh - 200px);
    padding-bottom: 32px;
}

/* Markdown Tables */
.table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
    max-width: 100%;
}

.md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    border-radius: var(--radius-md);
}

.md-table th,
.md-table td {
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    text-align: left;
}

.md-table th {
    background: var(--bg-elevated);
    font-weight: 600;
    color: var(--text-primary);
}

.md-table tr:nth-child(even) {
    background: rgba(128, 128, 128, 0.05);
}

/* Justified Text mode */
.chat-raiz.justify-text .message-content p {
    text-align: justify;
    text-justify: inter-word;
}

/* Responsive adjustment for justified text */
@media (max-width: 768px) {
    .chat-raiz.justify-text .message-content p {
        text-align: left;
        /* Better readability on small screens */
    }
}

/* ── TASK CARDS (Humanizer / Coding / etc) ───────────────────────── */
.task-card-message {
    align-items: stretch !important;
    width: 100%;
}

.task-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    max-width: 520px;
    margin: 8px 0 8px auto;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: taskIn 0.5s cubic-bezier(0.19, 1, 0.22, 1) both;
}

.task-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.humanizer-request-card {
    background: linear-gradient(135deg, rgba(197, 138, 249, 0.08), rgba(242, 139, 130, 0.05));
    border-color: rgba(197, 138, 249, 0.2);
}

.task-card-icon {
    width: 44px;
    height: 44px;
    background: var(--accent-primary-dim);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.humanizer-request-card .task-card-icon {
    background: rgba(197, 138, 249, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.humanizer-request-card .task-card-icon img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}

.task-card-body {
    flex: 1;
    min-width: 0;
}

.task-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.task-card-subtitle {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-style: italic;
    opacity: 0.8;
}

.task-card-preview {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--radius-md);
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.5;
    position: relative;
    max-height: 80px;
    overflow: hidden;
}

.quote-icon {
    width: 14px;
    height: 14px;
    opacity: 0.4;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Animations */
@keyframes taskIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive adjustment */
@media (max-width: 600px) {
    .task-card {
        max-width: 90%;
        padding: 16px;
    }
    .task-card-icon {
        width: 36px;
        height: 36px;
    }
}

/* Compact Mode */
.chat-raiz.compact-mode .message {
    margin-bottom: 12px;
}

.chat-raiz.compact-mode .message-content p {
    margin-bottom: 4px;
}

.chat-raiz.compact-mode .ai-message {
    gap: 8px;
}

.chat-raiz.compact-mode .messages-container {
    padding-top: 12px;
}

/* --- Message Editing Styles --- */
.user .message-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
}

.user .message-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    opacity: 0;
    transition: all 0.2s ease;
    transform: translateY(4px);
}

.user:hover .message-actions {
    opacity: 1;
    transform: translateY(0);
}

.edit-msg-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.edit-msg-btn:hover {
    background: var(--accent-primary-glow);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.edit-msg-btn i {
    width: 14px;
    height: 14px;
}

/* Inline Editor */
.inline-editor {
    width: 100%;
    margin-top: 8px;
}

.inline-editor textarea {
    width: 100%;
    background: var(--bg-deep);
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 12px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    resize: vertical;
    min-height: 80px;
    outline: none;
    box-shadow: 0 0 15px rgba(138, 180, 248, 0.1);
}

.editor-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.editor-btn {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.save-edit-btn {
    background: var(--accent-primary);
    color: #000;
    border: none;
}

.save-edit-btn:hover {
    background: #fff;
    transform: translateY(-2px);
}

.cancel-edit-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.cancel-edit-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ── Structured Layout Border (Invisible Width Limit) ── */
#messages-inner, 
.input-area-wrapper .col-12 {
    max-width: 768px !important;
    margin: 0 auto !important;
    padding-left: 24px !important;
    padding-right: 24px !important;
}


/* ── components/input-area.css ── */
/* ==========================================================================
   THORLY AI — Input Area
   Mode pills, input box, send btn, attachments
   ========================================================================== */

.input-area-wrapper {
    position: relative;
    padding-top: 10px;
    padding-right: 16px;
    padding-left: 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-base);
    flex-shrink: 0;
    transition: background-color var(--transition-med),
                transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

/* ── Luz pulsante estilo olas detrás del input mientras Thorly está pensando ───────── */
:root {
    --thinking-color-rgb: 255, 255, 255; /* Blanco (Modo Oscuro) */
}

[data-theme="light"] {
    --thinking-color-rgb: 124, 58, 237; /* Morado más oscuro/vibrante para que contraste en Modo Claro */
}

.chat-raiz.app-is-thinking .input-box {
    border-color: rgba(var(--thinking-color-rgb), 0.15);
    transition: border-color 0.5s ease;
    animation: input-glow-pulse-dynamic 2.5s ease-in-out infinite;
    z-index: 2;
}

.chat-raiz.app-is-thinking .input-area-wrapper {
    background: linear-gradient(to top, rgba(var(--thinking-color-rgb), 0.05) 0%, transparent 50%);
}

/* Wavy light effect using a pseudo-element */
.chat-raiz.app-is-thinking .input-area-wrapper::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -20%;
    width: 140%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    /* Multiple radial gradients acting as light peaks */
    background: 
        radial-gradient(ellipse at 15% 100%, rgba(var(--thinking-color-rgb), 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 35% 100%, rgba(var(--thinking-color-rgb), 0.18) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 120%, rgba(var(--thinking-color-rgb), 0.12) 0%, transparent 40%),
        radial-gradient(ellipse at 65% 100%, rgba(var(--thinking-color-rgb), 0.20) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 100%, rgba(var(--thinking-color-rgb), 0.15) 0%, transparent 60%);
    background-size: 100% 100%;
    animation: light-waves-pulse 3.5s infinite alternate ease-in-out;
}

@keyframes light-waves-pulse {
    0% {
        opacity: 0.6;
        transform: translateY(5%) scaleY(0.85) translateX(-1%);
    }
    50% {
        opacity: 1;
        transform: translateY(0%) scaleY(1.05) translateX(1%);
    }
    100% {
        opacity: 0.8;
        transform: translateY(2%) scaleY(0.95) translateX(2%);
    }
}

@keyframes input-glow-pulse-dynamic {
    0%,
    100% {
        box-shadow:
            0 0 30px 2px rgba(var(--thinking-color-rgb), 0.08),
            0 5px 40px 0px rgba(var(--thinking-color-rgb), 0.1);
    }
    50% {
        box-shadow:
            0 0 45px 5px rgba(var(--thinking-color-rgb), 0.12),
            0 8px 60px 0px rgba(var(--thinking-color-rgb), 0.15);
    }
}



/* Input Box */
.input-box {
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: 28px;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
    overflow: visible;
    position: relative;
}

.input-box:focus-within {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}


/* Left action plus button dropdown styles (Gemini-style) */
.left-action-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.plus-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50% !important;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.plus-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.plus-dropdown-menu {
    background-color: var(--bg-elevated) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 6px 0 !important;
    min-width: 180px !important;
    margin-bottom: 8px !important;
}

.plus-dropdown-menu .dropdown-item {
    color: var(--text-primary) !important;
    font-size: 13.5px !important;
    padding: 8px 16px !important;
    transition: background var(--transition-fast) !important;
}

.plus-dropdown-menu .dropdown-item:hover {
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
}

.plus-dropdown-menu .dropdown-item i {
    color: var(--text-secondary) !important;
}

.input-box.drag-active {
    border-color: var(--accent-primary) !important;
    background: var(--accent-primary-dim) !important;
    box-shadow: 0 0 0 4px var(--accent-primary-dim) !important;
    border-style: dashed !important;
    transform: scale(1.01);
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 8px 12px 8px 16px;
}

.attach-btn {
    flex-shrink: 0;
    margin-bottom: 0;
    /* Eliminado para centrado */
    color: var(--text-secondary);
    cursor: pointer;
}

.attach-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.chat-input,
#chatInput {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: var(--font-main);
    font-size: 16px;
    color: var(--text-primary);
    line-height: 20px;
    max-height: 200px;
    min-height: 20px;
    padding: 8px 0;
    overflow-y: auto;
}

.chat-input::placeholder,
#chatInput::placeholder {
    color: var(--text-tertiary);
}

.input-right-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-bottom: 0;
}

.input-right-actions .icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.input-right-actions .icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.input-right-actions .icon-btn i {
    width: 18px;
    height: 18px;
}

/* Send Button */
.send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: background var(--transition-fast),
        color var(--transition-fast),
        transform var(--transition-fast),
        opacity var(--transition-fast),
        width var(--transition-fast);
}

.send-btn:enabled {
    color: var(--send-btn-text);
    background: var(--send-btn-bg);
}

.send-btn:enabled:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

.send-btn:disabled {
    opacity: 0;
    width: 0;
    padding: 0;
    overflow: hidden;
    pointer-events: none;
}

.send-btn i {
    width: 18px;
    height: 18px;
}

/* Attached file preview */
.attached-file-preview {
    padding: 8px 14px 0;
}

.attached-file-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 6px 10px;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.attached-file-item i {
    width: 14px;
    height: 14px;
    color: var(--accent-primary);
}

.attached-file-name {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-file-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.remove-file-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.remove-file-btn i {
    width: 12px;
    height: 12px;
}

/* Disclaimer */
.input-disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 8px;
    margin-bottom: 0;
}

.input-disclaimer a {
    color: var(--text-tertiary);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.input-disclaimer a:hover {
    color: var(--accent-primary);
}

/* ===== VOICE BUTTON & RECORDING — Premium Design ===== */

/* Voice Button base */
#voice-btn {
    position: relative;
    transition: background var(--transition-fast),
        color var(--transition-fast),
        transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.25s ease;
    border-radius: 50%;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    z-index: 2;
}

/* Hover hint */
#voice-btn:not(.active-listening):hover {
    color: var(--accent-primary);
    background: var(--accent-primary-dim);
}

/* ── Active (Listening) State ── */
#voice-btn.active-listening {
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-purple)) !important;
    color: #fff !important;
    transform: scale(1.18);
    box-shadow: 0 0 0 0 rgba(138, 180, 248, 0.45);
    animation: voice-btn-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes voice-btn-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(138, 180, 248, 0.45);
    }

    40% {
        box-shadow: 0 0 0 10px rgba(197, 138, 249, 0.0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(197, 138, 249, 0.0);
    }
}

/* ── Recording Indicator Bar ── */
.voice-recording-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    background: var(--accent-primary-dim);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 500;
    color: var(--accent-primary);
    animation: indicator-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: right center;
}

.voice-recording-indicator.visible {
    display: flex;
}

@keyframes indicator-enter {
    from {
        opacity: 0;
        transform: scale(0.85) translateX(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateX(0);
    }
}

/* ── Animated Wave Bars ── */
.voice-wave {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.voice-wave span {
    width: 3px;
    border-radius: var(--radius-pill);
    background: linear-gradient(180deg, var(--brand-blue), var(--brand-purple));
    animation: wave-bar 1s ease-in-out infinite;
    will-change: transform;
}

.voice-wave span:nth-child(1) {
    height: 8px;
    animation-delay: 0s;
}

.voice-wave span:nth-child(2) {
    height: 14px;
    animation-delay: 0.15s;
}

.voice-wave span:nth-child(3) {
    height: 10px;
    animation-delay: 0.3s;
}

.voice-wave span:nth-child(4) {
    height: 16px;
    animation-delay: 0.45s;
}

@keyframes wave-bar {

    0%,
    100% {
        transform: scaleY(0.5);
        opacity: 0.6;
    }

    50% {
        transform: scaleY(1.4);
        opacity: 1;
    }
}

/* ── Timer Text ── */
.voice-timer {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    min-width: 32px;
    text-align: center;
}

/* ── Recording dot (pulsing red dot inside indicator) ── */
.voice-recording-indicator::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #F28B82;
    flex-shrink: 0;
    animation: rec-dot 1.2s ease-in-out infinite;
}

@keyframes rec-dot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* ===== SUGGESTION CARDS ===== */
.suggestion-cards {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    justify-content: center;
}

.suggestion-cards::-webkit-scrollbar {
    display: none;
}

.suggestion-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill, 100px);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font-main);
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.suggestion-chip:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.suggestion-chip i {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Ocultar sugerencias cuando hay un mensaje o el chat no está vacío */
#main-wrapper.chat-empty .suggestion-cards {
    display: flex;
}

#main-wrapper:not(.chat-empty) .suggestion-cards,
.chat-raiz.app-is-thinking .suggestion-cards {
    display: none;
}
/* Input area wrapper (standalone in chat panel) */
.input-area {
    flex-shrink: 0;
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-base);
}


/* ── components/settings.css ── */
/* ==========================================================================
   THORLY AI — Settings Panel
   Complete settings panel styles
   ========================================================================== */

.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1299;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-med);
    will-change: opacity;
}

.settings-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(460px, 100vw);
    background: var(--bg-surface);
    border-left: 1px solid var(--border-subtle);
    z-index: 1300;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--transition-slow), background-color var(--transition-med);
    box-shadow: var(--shadow-lg);
    will-change: transform;
}

.settings-panel.settings-open {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(16px + env(safe-area-inset-top, 0px)) 14px 12px;
    flex-shrink: 0;
    contain: paint;
}

.settings-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.settings-header h2 i {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0 24px;
    will-change: scroll-position;
    contain: content;
    scroll-behavior: auto !important;
}

.settings-section {
    padding: 16px 14px;
    contain: content;
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    padding: 0 6px;
}

.settings-section-title i {
    width: 14px;
    height: 14px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.settings-row > i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-tertiary);
}

.settings-row:hover {
    background: var(--bg-hover);
}

.settings-row+.settings-row {
    margin-top: 2px;
}

.settings-row-info {
    flex: 1;
    min-width: 0;
}

.settings-row-label {
    display: block;
    font-size: 13.5px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 2px;
    transition: color var(--transition-fast);
}

.settings-row-desc {
    display: block;
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-tertiary);
}

.settings-row:hover .settings-row-label {
    color: var(--text-primary);
}

/* Theme Toggle Group */
.theme-toggle-group {
    display: flex;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
    flex-shrink: 0;
}

.theme-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
}

.theme-btn i {
    width: 13px;
    height: 13px;
}

.theme-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.theme-btn.active {
    background: var(--bg-surface);
    color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}



/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-thumb {
    position: absolute;
    inset: 0;
    background: var(--bg-active);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-default);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.toggle-thumb::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.toggle-switch input:checked+.toggle-thumb {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.toggle-switch input:checked+.toggle-thumb::after {
    transform: translateY(-50%) translateX(16px);
    background: #fff;
}

.toggle-switch input:focus-visible+.toggle-thumb {
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

/* Settings Select */
.settings-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font-main);
    padding: 7px 30px 7px 10px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 140px;
    flex-shrink: 0;
    transition: border-color var(--transition-fast);
}

.settings-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-dim);
}

/* Slider */
.slider-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
    flex-shrink: 0;
}

.settings-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: var(--radius-pill);
    background: var(--bg-active);
    outline: none;
    cursor: pointer;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-dim);
    cursor: pointer;
    transition: box-shadow var(--transition-fast);
}

.settings-slider::-webkit-slider-thumb:hover {
    box-shadow: 0 0 0 5px var(--accent-primary-dim);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-tertiary);
}

.slider-value {
    font-weight: 600;
    color: var(--accent-primary);
}

/* Danger Button */
.danger-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    background: rgba(242, 139, 130, 0.12);
    border: 1px solid rgba(242, 139, 130, 0.30);
    border-radius: var(--radius-md);
    color: #F28B82;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
    font-family: var(--font-main);
}

.danger-btn:hover {
    background: rgba(242, 139, 130, 0.22);
    border-color: rgba(242, 139, 130, 0.50);
}

.danger-btn i {
    width: 14px;
    height: 14px;
}

/* Keyboard Shortcuts */
.shortcuts-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-subtle);
}

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-desc {
    font-size: 13.5px;
    color: var(--text-secondary);
}

.shortcut-keys {
    display: flex;
    align-items: center;
    gap: 4px;
}

.shortcut-keys span {
    color: var(--text-tertiary);
    font-size: 12px;
}

kbd {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    box-shadow: 0 1px 0 var(--border-strong);
}

/* Settings Footer */
.settings-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.settings-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-main);
}

.settings-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.settings-btn.secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.settings-btn.primary {
    background: var(--accent-primary);
    border: none;
    color: #fff;
    box-shadow: 0 4px 12px var(--accent-primary-glow);
}

.settings-btn.primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--accent-primary-glow);
}

.settings-btn i {
    width: 16px;
    height: 16px;
}

/* ─── Campos de texto (Personalización / Tus claves de IA) ───────────────── */
.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 10px 0;
}

.settings-field-label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-primary);
}

.settings-field-hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-tertiary);
}

.settings-textarea,
.settings-input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 13px;
    line-height: 1.5;
    padding: 9px 11px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.settings-textarea {
    resize: vertical;
    min-height: 104px;
}

.settings-textarea:focus,
.settings-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-dim);
}

.settings-field-footer {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--text-tertiary);
}

.settings-field-status {
    color: var(--accent-primary);
}

/* ─── Tus claves de IA ───────────────────────────────────────────────────── */
.byok-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 10px 0;
}

/* display:flex anularía el atributo hidden: el interruptor apagado debe ocultarlo */
.byok-panel[hidden],
.byok-field[hidden] {
    display: none !important;
}

.byok-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
}

.byok-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 0;
    padding: 8px 6px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.byok-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.byok-tab[aria-selected="true"] {
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.byok-tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.byok-dot {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--text-tertiary);
}

.byok-dot.is-connected { background: #34d399; }
.byok-dot.is-paused { background: #fbbf24; }
.byok-dot.is-invalid { background: #F28B82; }

.byok-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.byok-body > .byok-btn {
    align-self: flex-start;
}

.byok-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.byok-field .settings-select {
    width: 100%;
    min-width: 0;
}

.byok-field > .byok-btn {
    align-self: flex-start;
}

.byok-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.byok-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
}

.byok-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--bg-active);
    color: var(--text-tertiary);
}

.byok-badge.is-connected {
    background: rgba(52, 211, 153, 0.14);
    color: #34d399;
}

.byok-badge.is-paused {
    background: rgba(251, 191, 36, 0.14);
    color: #fbbf24;
}

.byok-badge.is-invalid {
    background: rgba(242, 139, 130, 0.14);
    color: #F28B82;
}

.byok-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.byok-row .settings-input {
    flex: 1 1 180px;
    min-width: 0;
    width: auto;
}

.byok-row .byok-model {
    flex: 1 1 160px;
    min-width: 0;
}

.byok-key {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

.byok-btn {
    flex-shrink: 0;
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    color: #fff;
    font-family: var(--font-main);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--transition-fast), background var(--transition-fast);
}

.byok-btn:hover {
    filter: brightness(1.1);
}

.byok-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.byok-btn:disabled {
    opacity: 0.6;
    cursor: progress;
}

.byok-btn.is-ghost {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}

.byok-btn.is-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    filter: none;
}

.byok-status {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-tertiary);
}

.byok-status:empty {
    display: none;
}

.byok-link {
    align-self: flex-start;
    font-size: 12px;
    color: var(--accent-primary);
    text-decoration: none;
}

.byok-link:hover {
    text-decoration: underline;
}
/* Tu uso de hoy: barra del cupo diario de IA */
.usage-bar {
    display: block;
    height: 4px;
    margin-top: 8px;
    border-radius: var(--radius-pill, 999px);
    background: var(--border-subtle, rgba(127, 127, 127, 0.2));
    overflow: hidden;
}

.usage-bar > span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--accent-primary, #6aa1ff);
    transition: width var(--transition-fast, 160ms);
}

.usage-bar > span[data-level="warn"] { background: #e6a23c; }
.usage-bar > span[data-level="danger"] { background: #e5534b; }


/* ── components/admin.css ── */
/* ==========================================================================
   THORLY AI — Admin Panel Styles
   ========================================================================== */

.admin-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    background: var(--overlay-bg);
    backdrop-filter: var(--overlay-blur);
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
    animation: fadeIn 0.3s ease;
}

.admin-modal.show {
    display: flex;
}

/* Reusing settings panel structure for Thorly consistency */
.admin-modal .settings-panel {
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-view {
    display: none;
}

.admin-view.active {
    display: block;
}

/* User Admin Cards */
.user-admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-admin-card:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.user-admin-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.user-active-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666; /* Gray/Inactive */
}

.status-dot.active {
    background: #10b981; /* Green/Active */
    box-shadow: 0 0 8px #10b981;
}

.user-admin-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-admin-name {
    font-weight: 600;
    color: var(--text-primary);
}

.user-admin-email {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.user-admin-stats {
    display: flex;
    gap: var(--spacing-md);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
}

/* Conversation Items */
.conversation-admin-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.conversation-admin-item:hover {
    background: var(--bg-hover);
}

.cai-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cai-title {
    font-weight: 500;
    color: var(--text-primary);
}

.cai-date {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.cai-delete {
    color: var(--danger);
    background: transparent;
    border: none;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s ease;
}

.cai-delete:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Admin Chat View Corrections */
#adminChatMessages {
    background: var(--bg-chat);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.admin-msg-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    max-width: 85%;
    line-height: 1.5;
}

.admin-msg-user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
}

.admin-msg-bot {
    align-self: flex-start;
    background: var(--bg-surface-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

/* Admin Toolbar (top of users view) */
.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.admin-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
    color: var(--primary);
}

.admin-toolbar-btn i {
    width: 16px;
    height: 16px;
}

/* Humanizer limits form tweaks */
#humanizerLimitsView .settings-row {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

#humanizerLimitsView .settings-row:last-of-type {
    border-bottom: none;
}

#humanizerLimitsView .settings-row-desc {
    color: var(--text-tertiary);
    font-size: 12px;
    margin-top: 2px;
    display: block;
}

#humanizerLimitsView textarea {
    font-family: inherit;
}

#humanizerLimitsView textarea:focus,
#humanizerLimitsView input[type="number"]:focus,
#humanizerLimitsView select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 124, 58, 237), 0.15);
}

#humanizerLimitsView button:hover {
    transform: translateY(-1px);
    transition: all 0.2s ease;
}
/* === Modal de configuraci�n del Humanizador por usuario === */
.user-config-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(124, 58, 237, 0.15);
    color: var(--primary, #7c3aed);
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 4px;
}

.user-config-btn:hover {
    background: rgba(124, 58, 237, 0.25);
    transform: translateY(-1px);
}

.user-config-btn svg,
.user-config-btn [data-lucide] {
    width: 14px;
    height: 14px;
}

.uh-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.uh-modal-overlay.show {
    display: flex;
}

.uh-modal {
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.uh-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.uh-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 600;
    margin: 0;
}

.uh-modal-title svg,
.uh-modal-title [data-lucide] {
    width: 18px;
    height: 18px;
    color: var(--primary, #7c3aed);
}

.uh-modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.uh-modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
}

.uh-modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.uh-modal-subtitle {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0;
    line-height: 1.4;
}

.uh-modal-subtitle strong {
    color: var(--text-primary);
    font-weight: 600;
}

.uh-mode-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.humanizer-mode-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.humanizer-mode-option:hover {
    border-color: var(--primary, #7c3aed);
    background: rgba(124, 58, 237, 0.05);
}

.humanizer-mode-option input[type="radio"] {
    margin-top: 3px;
    accent-color: var(--primary, #7c3aed);
    cursor: pointer;
}

.hmo-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.hmo-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.hmo-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.35;
}

.uh-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.uh-field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.uh-field input[type="number"],
.uh-field input[type="text"],
.uh-field textarea,
.uh-field select {
    padding: 10px 12px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.04));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

.uh-field input:focus,
.uh-field textarea:focus,
.uh-field select:focus {
    outline: none;
    border-color: var(--primary, #7c3aed);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.uh-field textarea {
    resize: vertical;
    min-height: 70px;
    font-family: inherit;
}

.uh-limit-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.uh-usage-info {
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
}

.uh-modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.uh-modal-footer .uh-footer-left,
.uh-modal-footer .uh-footer-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.uh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    font-family: inherit;
}

.uh-btn svg,
.uh-btn [data-lucide] {
    width: 14px;
    height: 14px;
}

.uh-btn-primary {
    background: var(--primary, #7c3aed);
    color: white;
}

.uh-btn-primary:hover {
    background: #6d28d9;
    transform: translateY(-1px);
}

.uh-btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border-color: var(--border-color, rgba(255, 255, 255, 0.1));
}

.uh-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.uh-btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.uh-btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.uh-btn-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.3);
}

.uh-btn-warning:hover {
    background: rgba(245, 158, 11, 0.2);
}


/* ── components/visualizer.css ── */
/* ==========================================================================
   THORLY AI — Artifact Visualizer (Lucent Mode)
   Premium side panel for code preview and diagrams, inspired by modern UIs
   ========================================================================== */

/* The Side Panel */
.lucent-canva {
    position: fixed;
    top: 60px;
    /* Below topbar */
    right: 0;
    width: 50%;
    height: calc(100vh - 60px);
    background: var(--bg-surface, #ffffff);
    border-left: 1px solid var(--border-subtle, #e5e7eb);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.05);
}

/* Dark mode fallback for Canva */
[data-theme="dark"] .lucent-canva {
    background: var(--bg-elevated, #1e1e24);
    border-left: 1px solid var(--border-subtle, #333);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
}

.lucent-canva.show {
    transform: translateX(0);
}

/* Header Area */
.lucent-header {
    height: 56px;
    padding: 0 16px 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-surface, #ffffff);
    border-bottom: 1px solid var(--border-subtle, #e5e7eb);
    flex-shrink: 0;
}

[data-theme="dark"] .lucent-header {
    background: var(--bg-elevated, #1e1e24);
}

.lucent-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    letter-spacing: -0.01em;
}

.lucent-title i {
    color: var(--accent-primary, #3b82f6);
    width: 18px;
    height: 18px;
}

/* Tabs */
.lucent-tabs {
    display: flex;
    gap: 4px;
    height: 100%;
    align-items: center;
    background: var(--bg-hover, #f3f4f6);
    padding: 4px;
    border-radius: 8px;
    margin-right: 16px;
    height: 38px;
}

[data-theme="dark"] .lucent-tabs {
    background: rgba(255, 255, 255, 0.05);
}

.lucent-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 0 14px;
    height: 100%;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lucent-tab i {
    width: 14px;
    height: 14px;
}

.lucent-tab:hover {
    color: var(--text-primary);
}

.lucent-tab.active {
    color: var(--text-primary);
    background: var(--bg-surface, #ffffff);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .lucent-tab.active {
    background: var(--bg-code, #282a36);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Actions */
.lucent-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.lucent-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.lucent-action-btn:hover {
    background: var(--bg-hover, #f3f4f6);
    color: var(--text-primary);
}

[data-theme="dark"] .lucent-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lucent-action-btn i {
    width: 18px;
    height: 18px;
}

/* Zoom Controls */
.lucent-zoom-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 8px;
    padding: 2px;
    background: var(--bg-hover, #f3f4f6);
    border-radius: 6px;
    height: 34px;
}

[data-theme="dark"] .lucent-zoom-controls {
    background: rgba(255, 255, 255, 0.05);
}

.lucent-zoom-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
}

.lucent-zoom-btn:hover {
    background: var(--bg-surface, #ffffff);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .lucent-zoom-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.lucent-zoom-btn i {
    width: 16px;
    height: 16px;
}

.lucent-zoom-level {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    user-select: none;
}

/* Iframe zoom via scale */
#lucentPreviewTab {
    overflow: auto;
}

#lucentFrame {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
    transform-origin: top left;
    transition: transform 0.15s ease;
}

/* Body / Content Area */
.lucent-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: var(--bg-surface, #ffffff);
}

[data-theme="dark"] .lucent-body {
    background: var(--bg-elevated, #1e1e24);
}

/* Specific tab containers */
.lucent-content-tab {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    animation: fadeInTab 0.3s ease forwards;
}

.lucent-content-tab.active {
    display: flex;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Code Tab Details */
#lucentCodeTab {
    background: var(--bg-code, #1e1e1e);
    overflow: hidden;
    padding: 0;
    flex-direction: column;
}

#lucentCodeDisplay {
    margin: 0;
    font-family: var(--font-mono, 'Menlo', 'Monaco', 'Courier New', monospace);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    tab-size: 4;
}

/* Main Viewport Split-Screen Adjustments */
/* Adds smooth squishing of the main chat area when side panel opens */
@media (min-width: 992px) {
    .main-wrapper {
        transition: padding-right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .main-wrapper.lucent-mode {
        padding-right: 50%;
    }
}

/* Tablet / Mobile Adjustments */
@media (max-width: 991px) {
    .lucent-canva {
        width: 100%;
        top: 0;
        height: 100vh;
        z-index: 2000;
        /* Over everything */
    }

    .main-wrapper.lucent-mode {
        padding-right: 0;
        /* Full cover on mobile */
    }

    .lucent-tab span {
        display: none;
    }
}

/* Scrollbar styling for code block - Inherit from base.css for consistency */
#lucentCodeTab pre::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

#lucentCodeTab pre::-webkit-scrollbar-track {
    background: transparent;
}

#lucentCodeTab pre::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-pill);
}

#lucentCodeTab pre::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}


/* ==========================================================================
   THORLY AI — Artifact Card (Claude Style)
   ========================================================================== */

.artifact-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-surface, #ffffff);
    border: 1px solid var(--border-subtle, #e5e7eb);
    border-radius: 12px;
    padding: 12px 16px;
    margin: 16px 0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    max-width: 420px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    animation: artifactSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="dark"] .artifact-card {
    background: var(--bg-elevated, #1e1e24);
    border-color: var(--border-subtle, #333);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.artifact-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary, #3b82f6);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .artifact-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.artifact-card-icon {
    width: 44px;
    height: 44px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

[data-theme="dark"] .artifact-card-icon {
    background: rgba(59, 130, 246, 0.15);
}

.artifact-card-icon i {
    width: 24px;
    height: 24px;
    color: var(--accent-primary, #3b82f6);
}

.artifact-card-info {
    flex: 1;
    min-width: 0;
}

.artifact-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.artifact-card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.artifact-card-action {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-tertiary);
    transition: all 0.2s ease;
}

.artifact-card:hover .artifact-card-action {
    background: var(--bg-hover, #f3f4f6);
    color: var(--accent-primary, #3b82f6);
}

[data-theme="dark"] .artifact-card:hover .artifact-card-action {
    background: rgba(255, 255, 255, 0.05);
}

/* ── Hiding Logic ── */
/* When a message has an artifact card, we hide the raw code blocks */
.ai-message.has-artifact .code-block,
.ai-message.has-artifact .message-content>pre {
    display: none !important;
}

@keyframes artifactSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Lucent Minimized Code Card (inline artifact) ────────────────── */
.lucent-minimized-code {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated, #1e1e24);
    border: 1px solid var(--border-subtle, #333);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 12px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 380px;
    animation: artifactSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.lucent-minimized-code:hover {
    border-color: var(--accent-primary, #3b82f6);
    background: var(--bg-hover, #2a2a30);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.lucent-min-icon {
    width: 36px;
    height: 36px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--accent-primary, #3b82f6);
}

.lucent-min-icon i {
    width: 18px;
    height: 18px;
}

.lucent-min-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.lucent-min-text strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #e5e7eb);
    line-height: 1.3;
}

.lucent-min-text span {
    font-size: 11.5px;
    color: var(--text-tertiary, #6b7280);
    line-height: 1.3;
}

/* ── components/rename-modal.css ── */
/* ==========================================================================
   THORLY AI — Rename Modal Component
   ========================================================================== */

.rename-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-med);
}

.rename-overlay.show {
    opacity: 1;
    visibility: visible;
}

.rename-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%) scale(0.95);
    width: 90%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 2001;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-med);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.rename-modal.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.rename-header {
    padding: 20px 24px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.rename-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.rename-header h3 i {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.rename-body {
    padding: 0 24px 24px;
}

.rename-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.rename-input-wrapper {
    background: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 4px 12px;
    transition: border-color var(--transition-fast);
}

.rename-input-wrapper:focus-within {
    border-color: var(--accent-primary);
}

#rename-chat-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    padding: 10px 0;
    font-size: 15px;
}

.rename-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-surface);
}

.rename-btn-cancel,
.rename-btn-update {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.rename-btn-cancel {
    background: transparent;
    color: var(--text-secondary);
}

.rename-btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.rename-btn-update {
    background: var(--accent-primary);
    color: var(--text-on-brand);
}

.rename-btn-update:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.rename-btn-update:active {
    transform: translateY(0);
}


/* ── components/delete-modal.css ── */
/* ==========================================================================
   THORLY AI — Delete Modal Component
   ========================================================================== */

.delete-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-med);
}

.delete-overlay.show {
    opacity: 1;
    visibility: visible;
}

.delete-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%) scale(0.95);
    width: 90%;
    max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 2001;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-med);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.delete-modal.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.delete-header {
    padding: 20px 24px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.delete-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.delete-header h3 i {
    width: 20px;
    height: 20px;
    color: #ef4444;
}

.delete-body {
    padding: 0 24px 24px;
}

.delete-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.delete-chat-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-hover);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.delete-chat-info i {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
}

#delete-chat-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.delete-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-surface);
}

.delete-btn-cancel,
.delete-btn-confirm {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
}

.delete-btn-cancel {
    background: transparent;
    color: var(--text-secondary);
}

.delete-btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.delete-btn-confirm {
    background: #ef4444;
    color: #ffffff;
}

.delete-btn-confirm:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.delete-btn-confirm:active {
    transform: translateY(0);
}


/* ── components/pricing-modal.css ── */
/* ==========================================================================
   THORLY AI — Pricing Modal Component
   Ventana modal premium con 3 planes de suscripción
   Paleta: Blanco y Negro (identidad visual Thorly)
   ========================================================================== */

.pricing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(6px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-med);
}

.pricing-overlay.show {
    opacity: 1;
    visibility: visible;
}

.pricing-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%) scale(0.95);
    width: 94%;
    max-width: 920px;
    max-height: 90vh;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 2001;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-med);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pricing-modal.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.pricing-header {
    padding: 28px 28px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.pricing-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pricing-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.pricing-header h2 i {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
}

.pricing-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--text-tertiary);
    padding-left: 34px;
}

/* ── Body / Cards Container ─────────────────────────────────────────────── */
.pricing-body {
    padding: 28px;
    overflow-y: auto;
}

.pricing-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: stretch;
}

/* ── Individual Card ────────────────────────────────────────────────────── */
.pricing-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.pricing-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

/* ── Featured Card (Pro) — Blanco y Negro ───────────────────────────────── */
[data-theme="dark"] .pricing-card-featured {
    background: rgba(255, 255, 255, 0.04);
    border-color: #ffffff;
    box-shadow: 0 0 0 1px #ffffff, var(--shadow-md);
}

[data-theme="dark"] .pricing-card-featured:hover {
    box-shadow: 0 0 0 1px #ffffff, 0 8px 30px rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .pricing-card-featured {
    background: rgba(0, 0, 0, 0.02);
    border-color: #000000;
    box-shadow: 0 0 0 1px #000000, var(--shadow-md);
}

[data-theme="light"] .pricing-card-featured:hover {
    box-shadow: 0 0 0 1px #000000, 0 8px 30px rgba(0, 0, 0, 0.1);
}

/* ── Badge ──────────────────────────────────────────────────────────────── */
[data-theme="dark"] .plan-badge {
    background: #ffffff;
    color: #000000;
}

[data-theme="light"] .plan-badge {
    background: #000000;
    color: #ffffff;
}

.plan-badge {
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 5px 16px;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* ── Card Top ───────────────────────────────────────────────────────────── */
.pricing-card-top {
    text-align: center;
    margin-bottom: 20px;
}

.plan-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
}

.plan-icon i {
    width: 24px;
    height: 24px;
}

.plan-icon-basic {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

[data-theme="dark"] .plan-icon-pro {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

[data-theme="light"] .plan-icon-pro {
    background: rgba(0, 0, 0, 0.08);
    color: #000000;
}

[data-theme="dark"] .plan-icon-enterprise {
    background: rgba(255, 255, 255, 0.06);
    color: #d4d4d4;
}

[data-theme="light"] .plan-icon-enterprise {
    background: rgba(0, 0, 0, 0.05);
    color: #333333;
}

.plan-name {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.plan-desc {
    margin: 0;
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* ── Price ───────────────────────────────────────────────────────────────── */
.plan-price-wrapper {
    text-align: center;
    padding: 16px 0 20px;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 20px;
}

.plan-price {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.plan-period {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-tertiary);
}

/* ── Features List ──────────────────────────────────────────────────────── */
.plan-features {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.plan-features li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    color: var(--text-secondary);
}

.plan-features li i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-primary);
}

.plan-features li.disabled {
    opacity: 0.35;
}

.plan-features li.disabled i {
    color: var(--text-tertiary);
}

/* ── CTA Buttons ────────────────────────────────────────────────────────── */
.plan-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    text-align: center;
    text-decoration: none;
    margin-top: auto;
}

.plan-btn-basic {
    background: var(--bg-hover);
    color: var(--text-secondary);
    cursor: default;
}

.plan-btn-basic:disabled {
    opacity: 0.7;
}

/* Pro Button — B&W */
[data-theme="dark"] .plan-btn-pro {
    background: #ffffff;
    color: #000000;
    font-weight: 700;
}

[data-theme="dark"] .plan-btn-pro:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.15);
}

[data-theme="light"] .plan-btn-pro {
    background: #000000;
    color: #ffffff;
    font-weight: 700;
}

[data-theme="light"] .plan-btn-pro:hover {
    background: #1a1a1a;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.plan-btn-pro:active {
    transform: translateY(0);
}

/* Enterprise Button — B&W Outline */
[data-theme="dark"] .plan-btn-enterprise {
    background: transparent;
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
}

[data-theme="dark"] .plan-btn-enterprise:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.06);
}

[data-theme="light"] .plan-btn-enterprise {
    background: transparent;
    color: #000000;
    border: 1.5px solid rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .plan-btn-enterprise:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.plan-btn-enterprise:active {
    transform: translateY(0);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.pricing-footer {
    padding: 16px 28px 24px;
    text-align: center;
    border-top: 1px solid var(--border-subtle);
}

.pricing-footer p {
    margin: 0;
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
}

.pricing-footer strong {
    color: var(--text-secondary);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .pricing-modal {
        max-width: 100%;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        transform: translate(-50%, -50%) scale(1);
    }

    .pricing-modal.show {
        transform: translate(-50%, -50%) scale(1);
    }

    .pricing-cards {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .pricing-card {
        padding: 22px 20px;
    }

    .pricing-card-featured {
        order: -1;
    }

    .pricing-header {
        padding: 20px 20px 0;
    }

    .pricing-body {
        padding: 20px;
    }

    .pricing-footer {
        padding: 14px 20px 20px;
    }

    .pricing-header h2 {
        font-size: 18px;
    }

    .plan-price {
        font-size: 28px;
    }
}


/* ── components/humanizer-modal.css ── */
/* ==========================================================================
   THORLY AI — Humanizer Modal (Minimalist Focus Style)
   ========================================================================== */

/* ── Overlay ── */
.humanizer-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.5); /* Lighter, no blur for maximum performance */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.humanizer-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ── Modal Panel ── */
.humanizer-modal {
    position: relative;
    width: 100%;
    max-width: 620px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    
    transform: translateY(10px) scale(0.99);
    transition: transform var(--transition-med);
}

.humanizer-overlay.active .humanizer-modal {
    transform: translateY(0) scale(1);
}

/* Solid elevated background for Dark Theme (No laggy backdrop-filter) */
[data-theme="dark"] .humanizer-modal {
    background: var(--bg-elevated);
    border-color: var(--border-subtle);
}

/* ── Header ── */
.humanizer-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: transparent;
}

.humanizer-header-info h3 {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.humanizer-logo-container {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Hide laggy animated ring */
.humanizer-ring {
    display: none;
}

.humanizer-icon-badge {
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.humanizer-icon-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.humanizer-modal-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.humanizer-close-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.humanizer-close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ── Body ── */
.humanizer-modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.humanizer-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.humanizer-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.humanizer-label i {
    width: 14px;
    height: 14px;
    color: var(--text-secondary);
}

.humanizer-textarea-wrapper {
    position: relative;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast);
}

.humanizer-textarea-wrapper:focus-within {
    border-color: var(--accent-primary);
}

.humanizer-textarea {
    width: 100%;
    min-height: 220px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    padding: 16px 16px 40px;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
}

.humanizer-textarea::placeholder {
    color: var(--text-tertiary);
}

.humanizer-char-count {
    position: absolute;
    bottom: 12px;
    right: 16px;
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* ── Hint Box ── */
.humanizer-hint {
    background: var(--bg-hover);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.humanizer-hint i {
    color: var(--text-secondary);
    width: 16px;
    height: 16px;
}

/* ── Footer ── */
.humanizer-modal-footer {
    padding: 16px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}

.humanizer-cancel-btn {
    padding: 7px 14px;
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.humanizer-cancel-btn:hover {
    background: var(--bg-hover);
}

.humanizer-submit-btn {
    padding: 7px 16px;
    background: rgba(197, 138, 249, 0.08);
    color: var(--brand-purple, #c58af9);
    border: 1px solid rgba(197, 138, 249, 0.2);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 0 12px rgba(197, 138, 249, 0.1);
    transition: all var(--transition-fast);
}

[data-theme="dark"] .humanizer-submit-btn {
    background: rgba(197, 138, 249, 0.08);
    color: #e5cdff; /* Lighter purple for dark mode text */
    border-color: rgba(197, 138, 249, 0.25);
}

.humanizer-submit-btn:hover:not(:disabled) {
    background: rgba(197, 138, 249, 0.15);
    border-color: rgba(197, 138, 249, 0.4);
    box-shadow: 0 0 18px rgba(197, 138, 249, 0.25);
    transform: translateY(-1px);
}

.humanizer-submit-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.humanizer-submit-btn.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ── Blocked State (cuando el admin bloqueó al usuario) ── */
.humanizer-blocked-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 16px 8px;
    gap: 14px;
}

.humanizer-blocked-state[hidden] {
    display: none !important;
}

.humanizer-blocked-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: #f59e0b;
}

.humanizer-blocked-icon i {
    width: 26px;
    height: 26px;
}

.humanizer-blocked-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.humanizer-blocked-message {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-secondary);
    max-width: 460px;
}

.humanizer-blocked-message a {
    color: #00aaff;
    text-decoration: underline;
}

.humanizer-blocked-message a:hover {
    opacity: 0.85;
}

/* Cuando el modal está en estado bloqueado, ocultar el footer con Cancelar/Humanizar */
.humanizer-modal.is-blocked .humanizer-modal-footer {
    display: none;
}

/* ── Mobile ── */
@media (max-width: 600px) {
    .humanizer-modal {
        max-width: 100%;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        margin-top: auto;
    }
    .humanizer-overlay {
        align-items: flex-end;
        padding: 0;
    }
}


/* ── components/news-modal.css ── */
/* ==========================================================================
   THORLY AI — News Modal (Install-Prompt Style)
   Consistent with the premium PWA install prompt look
   ========================================================================== */

.news-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: newsFadeIn 0.3s ease;
}

.news-overlay.active {
    display: flex;
}

.news-modal {
    background: var(--bg-surface);
    width: 100%;
    max-width: 400px;
    border-radius: 24px;
    padding: 32px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.news-overlay.active .news-modal {
    transform: translateY(0);
}

.news-logo-container {
    position: relative;
    width: 68px;
    height: 68px;
    margin: 0 auto 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.news-ring {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1.5px solid transparent;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-purple), var(--brand-pink)) border-box;
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: xor;
    animation: newsRingPulse 4s ease-in-out infinite;
}

@keyframes newsRingPulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.06); }
}

.news-icon-badge {
    width: 100%;
    height: 100%;
    background: var(--bg-surface);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.news-icon-badge img {
    width: 70%;
    height: 70%;
    object-fit: contain;
}

.news-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.news-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 24px;
}

.news-highlights {
    text-align: left;
    background: rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 32px;
}

.news-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.news-item:last-child {
    margin-bottom: 0;
}

.news-item-checked {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    flex-shrink: 0;
}

.news-item-checked i {
    width: 14px;
    height: 14px;
}

.news-btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--brand-purple), var(--brand-pink));
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.news-btn-primary:active {
    transform: scale(0.95);
}

@keyframes newsFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}


/* ── components/thorly-code.css ── */
/* Thorly Code Modal Styles heavily inspired by modern design */

#thorly-code-overlay {
    display: none;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

#thorly-code-overlay.active {
    display: flex;
    opacity: 1;
}

.code-modal {
    background-color: var(--_theme---background-primary, var(--bg-surface));
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#thorly-code-overlay.active .code-modal {
    transform: translateY(0);
}

.code-modal-body {
    padding: 60px 40px;
    color: var(--text-primary);
}

.code-hero {
    text-align: center;
    margin-bottom: 56px;
}

.code-hero h1 {
    font-size: 2.75rem;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text-primary), var(--brand-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
}

.code-hero p {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 32px;
    line-height: 1.6;
}

.coming-soon-badge {
    display: inline-block;
    padding: 8px 20px;
    background: rgba(0, 170, 255, 0.1);
    color: var(--brand-blue);
    border: 1px solid rgba(0, 170, 255, 0.2);
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    box-shadow: 0 4px 12px rgba(0, 170, 255, 0.1);
    position: relative;
    top: -20px; /* Move badge up to avoid collision */
}

.code-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
}

.code-feature-card {
    background: var(--bg-hover);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s;
}

.code-feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: var(--brand-blue);
    background: var(--bg-surface);
}

.code-feature-card .feature-icon {
    width: 48px;
    height: 48px;
    background: rgba(0, 170, 255, 0.1); 
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--brand-blue);
}

.code-feature-card h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.code-feature-card p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

#thorly-code-close-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

/* Mascot Walking Animation - Two Layer (Body + Animated Legs) */
.thorly-mascot-container {
    position: absolute;
    top: 2px;
    left: 0;
    right: 0;
    height: 0;
    pointer-events: none;
    z-index: 10;
    /* Horizontal movement: walk from Card 1 to Card 3 */
    animation: mascotMoveSequence 12s ease-in-out forwards 1;
}

/* Original Character.svg body — legs clipped off */
.thorly-mascot-body {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100px;
    height: auto;
    image-rendering: pixelated;
    clip-path: inset(0 0 17% 0); /* Show more body including leg junction contour */
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
}

.thorly-mascot-eyes {
    /* Eyes look right while walking, return to center when stopped */
    animation: eyesLookWalk 12s ease-in-out forwards 1;
}

/* Animated legs sprite — cycles through 4 walk frames */
.thorly-walking-legs {
    position: absolute;
    bottom: 6px; /* Pushed up to overlap with the extended body */
    left: 0;
    width: 100px;
    height: 16px;
    background-image: url('../../image/walk-legs-sprite.svg');
    background-size: 400px 16px; /* 4 frames × 100px each */
    background-repeat: no-repeat;
    background-position: 0 0; /* Frame 1: standing */
    image-rendering: pixelated;
    /* Sprite walk cycle: starts after 1.8s, runs 14 cycles of 0.6s = 8.4s of walking */
    animation: mascotSpriteWalk 0.6s steps(4) 14;
    animation-delay: 1.8s;
    animation-fill-mode: backwards;
}

@keyframes mascotMoveSequence {
    0%   { transform: translateX(20px) scaleX(1); }
    15%  { transform: translateX(20px) scaleX(1); }
    85%  { transform: translateX(calc(100% - 110px)) scaleX(1); }
    100% { transform: translateX(calc(100% - 110px)) scaleX(1); }
}

@keyframes mascotSpriteWalk {
    from { background-position: 0 0; }
    to   { background-position: -400px 0; }
}

@keyframes eyesLookWalk {
    0%, 14%  { transform: translateX(0); }       /* Idle: eyes forward */
    16%, 84% { transform: translateX(10px); }    /* Walking: eyes look right (10 SVG units = ~3.8 physical px) */
    86%, 100% { transform: translateX(0); }      /* Stopped: eyes back to center */
}






@media (max-width: 768px) {
    .code-modal-body {
        padding: 40px 24px;
    }
    
    .code-hero h1 {
        font-size: 2rem;
    }
}


/* ── components/toasts.css ── */
/* ==========================================================================
   THORLY AI — Toast Notifications
   ========================================================================== */

.thorly-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    padding: 10px 20px;
    font-size: 13.5px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
}

.thorly-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.thorly-toast-success {
    border-color: rgba(52, 211, 153, 0.4);
}

.thorly-toast-success i {
    color: #34d399;
}

.thorly-toast-error {
    border-color: rgba(248, 113, 113, 0.4);
}

.thorly-toast-error i {
    color: #f87171;
}

.thorly-toast-warning {
    border-color: rgba(251, 191, 36, 0.4);
}

.thorly-toast-warning i {
    color: #fbbf24;
}

.thorly-toast-info {
    border-color: var(--accent-primary-glow);
}

.thorly-toast-info i {
    color: var(--accent-primary);
}

/* ── components/tooltips.css ── */
/* Custom Tooltips (Bootstrap based) */
.tooltip {
    --bs-tooltip-bg: var(--bg-surface);
    --bs-tooltip-color: var(--text-primary);
    --bs-tooltip-padding-x: 12px;
    --bs-tooltip-padding-y: 6px;
    --bs-tooltip-font-size: 12.5px;
    --bs-tooltip-border-radius: var(--radius-sm);
    z-index: 2000;
}

.tooltip-inner {
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-md);
    font-weight: 500;
}

[data-theme="light"] .tooltip-inner {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ── components/login.css ── */
/* ==========================================================================
   THORLY AI — Login Page Styles
   Extiende el design system de css/styles.css
   Reutiliza: --bg-*, --text-*, --accent-*, --border-*, --shadow-*,
              --radius-*, --transition-*, --brand-*, --font-main
   ========================================================================== */


/* --------------------------------------------------------------------------
   BODY OVERRIDE (login page necesita scroll y no overflow hidden)
   -------------------------------------------------------------------------- */
.chat-raiz.login-body,
body:has(.login-page) {
    overflow: hidden;
}


/* --------------------------------------------------------------------------
   1–2. LAYOUT: ilustración a la izquierda, entrada a la derecha
   -------------------------------------------------------------------------- */
.login-page {
    position: relative;
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    background: var(--bg-base);
}


/* --------------------------------------------------------------------------
   3. ILUSTRACIÓN (Izquierda) — siempre de noche, sin importar el tema
   -------------------------------------------------------------------------- */
.login-hero {
    flex: 0 0 49%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #000;
}

/* La imagen es más ancha que el panel: se recorta por la derecha y el
   personaje (a ~29 % del ancho) queda cerca del centro. */
.login-hero-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 16% 100%;
    animation: loginCieloIn 1.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes loginCieloIn {
    from {
        opacity: 0;
        transform: scale(1.06);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}


/* --------------------------------------------------------------------------
   4. ENTRADA (Derecha)
   -------------------------------------------------------------------------- */
.login-form-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 32px;
    overflow-y: auto;
}

.login-panel-inner {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: slideUp 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    text-align: center;
}

.login-welcome {
    margin: 0;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
    color: var(--text-primary);
    text-wrap: balance;
}

.login-page .login-card {
    position: relative;
    width: 100%;
    padding: 44px 40px 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-theme-btn {
    position: absolute;
    top: 12px;
    right: 12px;
}

.login-card-lead {
    max-width: 300px;
    margin: 0 auto 28px;
    font-size: 14.5px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.login-page .login-social-row {
    justify-content: center;
    min-height: 44px;
}

.login-legal {
    margin: 28px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-tertiary);
}

.login-legal a {
    color: var(--text-secondary);
    font-weight: 500;
}

.login-legal a:hover {
    color: var(--accent-primary);
    text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
    .login-hero-img,
    .login-panel-inner {
        animation: none;
    }
}


/* --------------------------------------------------------------------------
   5. FORMULARIO
   -------------------------------------------------------------------------- */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-input-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.login-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.login-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
    transition: color var(--transition-fast);
}

.login-input-group.focused .login-label {
    color: var(--accent-primary);
}

.login-forgot-link {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-primary);
}

.login-forgot-link:hover {
    opacity: 0.8;
    text-decoration: none;
}

/* Wrapper del input */
.login-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    pointer-events: none;
    transition: color var(--transition-fast);
    z-index: 2;
}

.login-input-group.focused .login-input-icon {
    color: var(--accent-primary);
}

.login-input {
    width: 100%;
    padding: 13px 14px 13px 44px;
    background: var(--bg-input);
    border: 1.5px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    transition: all var(--transition-med);
    outline: none;
}

.login-input::placeholder {
    color: var(--text-tertiary);
}

.login-input:focus {
    border-color: var(--accent-primary);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px var(--accent-primary-dim), var(--shadow-sm);
}

/* Toggle contraseña */
.login-toggle-pwd {
    position: absolute;
    right: 10px;
    z-index: 2;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.login-toggle-pwd:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.login-toggle-pwd i {
    width: 16px;
    height: 16px;
}

.login-toggle-pwd .icon-eye {
    display: block;
}

.login-toggle-pwd .icon-eye-off {
    display: none;
}

.login-toggle-pwd.active .icon-eye {
    display: none;
}

.login-toggle-pwd.active .icon-eye-off {
    display: block;
}

/* Checkbox personalizado */
.login-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}

.login-checkbox {
    display: none;
}

.login-checkmark {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border-strong);
    border-radius: 5px;
    background: var(--bg-input);
    flex-shrink: 0;
    position: relative;
    transition: all var(--transition-fast);
}

.login-checkmark::after {
    content: '';
    position: absolute;
    inset: 3px;
    background: var(--accent-primary);
    border-radius: 3px;
    transform: scale(0);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-checkbox:checked+.login-checkmark {
    border-color: var(--accent-primary);
    background: var(--accent-primary-dim);
}

.login-checkbox:checked+.login-checkmark::after {
    transform: scale(1);
}


/* --------------------------------------------------------------------------
   6. BOTÓN SUBMIT
   -------------------------------------------------------------------------- */
.login-submit-btn {
    position: relative;
    width: 100%;
    padding: 14px 20px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--accent-primary), var(--brand-purple));
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-on-brand);
    font-family: var(--font-main);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    transition: all var(--transition-med);
}

/* Efecto shimmer al hover */
.login-submit-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 40%, rgba(255, 255, 255, 0.15) 50%, transparent 60%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.login-submit-btn:hover::before {
    transform: translateX(100%);
}

.login-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px var(--accent-primary-glow);
}

.login-submit-btn:active {
    transform: translateY(0);
}

.login-submit-arrow {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-fast);
}

.login-submit-btn:hover .login-submit-arrow {
    transform: translateX(3px);
}

/* Estado de carga */
.login-spinner-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
}

.login-submit-btn.loading .login-submit-text,
.login-submit-btn.loading .login-submit-arrow {
    opacity: 0;
}

.login-submit-btn.loading .login-spinner-wrap {
    opacity: 1;
    visibility: visible;
}

.login-spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: loginSpin 0.7s linear infinite;
}

@keyframes loginSpin {
    to {
        transform: rotate(360deg);
    }
}


/* --------------------------------------------------------------------------
   7. SEPARADOR
   -------------------------------------------------------------------------- */
.login-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

.login-divider span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}


/* --------------------------------------------------------------------------
   8. BOTONES SOCIALES
   -------------------------------------------------------------------------- */
.login-social-row {
    display: flex;
    gap: 12px;
}

.login-social-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-med);
}

.login-social-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary-glow);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.login-social-btn svg {
    flex-shrink: 0;
}


/* --------------------------------------------------------------------------
   9. TEXTOS COMPLEMENTARIOS
   -------------------------------------------------------------------------- */
.login-signup-text {
    text-align: center;
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-top: 24px;
}

.login-signup-link {
    font-weight: 600;
    color: var(--accent-primary);
}

.login-signup-link:hover {
    text-decoration: underline;
}

.login-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
}

.login-footer p {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-tertiary);
    line-height: 1.6;
}

.login-footer a {
    color: var(--text-secondary);
    font-weight: 500;
}

.login-footer a:hover {
    color: var(--accent-primary);
    text-decoration: none;
}


/* --------------------------------------------------------------------------
   10. RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
    .login-hero {
        flex-basis: 42%;
    }
}

/* En teléfono la ilustración pasa a ser una franja arriba. */
@media (max-width: 768px) {
    body:has(.login-page) {
        overflow: auto;
    }

    .login-page {
        flex-direction: column;
    }

    .login-hero {
        flex: none;
        height: 30vh;
        min-height: 180px;
    }

    .login-hero-img {
        object-position: 22% 100%;
    }

    .login-form-panel {
        align-items: flex-start;
        padding: 28px 16px 32px;
        overflow: visible;
    }

    .login-brand {
        margin-bottom: 24px;
    }

    .login-welcome {
        font-size: 23px;
    }

    .login-page .login-card {
        padding: 52px 20px 28px;
    }
}


/* --------------------------------------------------------------------------
   11. ESTILOS DEL OVERLAY ORIGINAL (conservados para thorly-ia.html)
   -------------------------------------------------------------------------- */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #0d1117;
    background-color: var(--bg-base, #0d1117);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    opacity: 1;
    visibility: visible;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(1.05);
}

.login-overlay .login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    padding: 60px 40px;
    border-radius: 32px;
    text-align: center;
    max-width: 480px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 32px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 15px var(--accent-primary-glow));
}

/* Hide the old auth placeholder in settings since it's now global */
#authLoggedOut .auth-placeholder {
    display: none;
}

#authLoggedOut::after {
    content: 'Por favor, inicie sesión en la pantalla principal.';
    display: block;
    text-align: center;
    padding: 20px;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ── components/network.css ── */
/* ==========================================================================
   THORLY AI — Network Notification Banner
   ========================================================================== */

.network-notification {
    position: fixed;
    top: -60px; /* Initially hidden */
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-lg);
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    white-space: nowrap;
}

.network-notification.show {
    top: 24px;
}

.network-notification .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.network-notification .icon i {
    width: 18px;
    height: 18px;
}

.network-notification .text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Offline state (Warning/Error) */
.network-notification.offline {
    border-color: rgba(248, 113, 113, 0.4);
}

.network-notification.offline .icon i {
    color: #f87171;
}

/* Online state (Success) */
.network-notification.online {
    border-color: rgba(52, 211, 153, 0.4);
}

.network-notification.online .icon i {
    color: #34d399;
}


/* ── content/markdown.css ── */
/* ==========================================================================
   THORLY AI — Markdown Rendered Content
   Markdown, tables, math
   ========================================================================== */

.markdown-body,
.ai-message .message-content {
    line-height: 1.55;
}

.md-h1 {
    font-size: 1.5em;
    font-weight: 700;
    margin: 16px 0 8px;
    color: var(--text-primary);
}

.md-h2 {
    font-size: 1.25em;
    font-weight: 600;
    margin: 14px 0 7px;
    color: var(--text-primary);
}

.md-h3 {
    font-size: 1.05em;
    font-weight: 600;
    margin: 12px 0 6px;
    color: var(--text-primary);
}

.md-hr {
    border: none;
    border-top: 1px solid var(--border-default);
    margin: 16px 0;
}

.md-blockquote {
    border-left: 3px solid var(--accent-primary);
    padding: 8px 16px;
    margin: 12px 0;
    background: var(--accent-primary-dim);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.md-ul {
    padding-left: 18px;
    margin: 10px 0;
}

.md-ul li {
    margin-bottom: 4px;
    color: var(--text-primary);
}

.md-link {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--transition-fast);
    /* Anti-break para URLs largas */
    word-break: break-all;
    overflow-wrap: break-word;
}

.md-link:hover {
    border-bottom-color: var(--accent-primary);
    text-decoration: none;
}

.inline-code {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--brand-pink);
}

/* Math */
.math-block {
    overflow-x: auto;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    margin: 12px 0;
    border: 1px solid var(--border-subtle);
    text-align: center;
}

.math-inline {
    display: inline-block;
    vertical-align: middle;
}

/* ── Person Profile Card ──────────────────────────────────────────────
   La tarjeta se renderizaba sin ninguna regla CSS: la foto salía al tamaño
   natural del archivo (a menudo una miniatura ilegible) y sin encuadre. */
.person-profile-card {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin: 20px 0;
    padding: 18px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
}

.person-profile-photo-col {
    flex: 0 0 auto;
    width: 180px;
    max-width: 38%;
}

.person-profile-photo {
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    object-fit: cover;      /* encuadra en vez de deformar */
    object-position: top center;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    display: block;
}

.person-profile-body {
    flex: 1 1 auto;
    min-width: 0;           /* permite que el texto envuelva dentro del flex */
}

.person-profile-name {
    margin: 0 0 8px;
    font-size: 1.25em;
    font-weight: 700;
    color: var(--text-primary);
}

.person-profile-bio {
    color: var(--text-primary);
    line-height: 1.55;
}

.person-profile-bio > *:first-child { margin-top: 0; }
.person-profile-bio > *:last-child { margin-bottom: 0; }

@media (max-width: 600px) {
    .person-profile-card {
        flex-direction: column;
        gap: 14px;
    }
    .person-profile-photo-col {
        width: 140px;
        max-width: 100%;
    }
}

/* Table Styling (Premium GFM) */
.table-wrapper {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    background: var(--bg-surface);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Custom scrollbar for tables */
.table-wrapper::-webkit-scrollbar {
    height: 5px;
}
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-default);
}

/* width:max-content deja que la tabla crezca y sea el wrapper el que haga
   scroll. Con width:100% las columnas se comprimían dentro del ancho del chat
   y partían las palabras a la mitad ("Manchest er United", "2003-2 009"). */
.md-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.md-table th,
.md-table td {
    padding: 12px 16px;
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    text-align: left;
    min-width: 110px;
    max-width: 320px;      /* una celda larga envuelve en vez de estirar la tabla */
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: none;         /* nunca cortar palabras por la mitad */
}

.md-table th {
    background: var(--bg-elevated);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-bottom: 2px solid var(--primary);
}

.md-table tr:nth-child(even) {
    background: rgba(128, 128, 128, 0.03);
}

.md-table tr:hover td {
    background: var(--bg-hover);
    color: var(--primary);
    transition: all 0.2s ease;
}

/* Responsive iPhone fix for very wide tables */
@media (max-width: 600px) {
    .md-table {
        font-size: 12.5px;
    }
    .md-table th, .md-table td {
        padding: 8px 10px;
        min-width: 80px;
    }
}

/* Premium Next-Gen Citation Pills (Inline domain badges) */
.citation-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(128, 128, 128, 0.12);
    color: var(--text-secondary);
    border: 1px solid rgba(128, 128, 128, 0.18);
    border-radius: 12px;
    padding: 1px 8px;
    font-size: 0.76em;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none !important;
    margin: 0 4px;
    vertical-align: middle;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.citation-pill:hover {
    background: rgba(128, 128, 128, 0.22);
    color: var(--text-primary);
    border-color: rgba(128, 128, 128, 0.3);
    text-decoration: none !important;
    transform: translateY(-0.5px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Premium Collapsible Sources Bottom Pill */
.sources-footer-container {
    margin-top: 16px;
    border-top: 1px solid rgba(128, 128, 128, 0.15);
    padding-top: 12px;
    width: 100%;
    display: flex;
    justify-content: flex-start;
}

.sources-header-pill {
    display: inline-flex;
    align-items: center;
    background: rgba(128, 128, 128, 0.08);
    border: 1px solid rgba(128, 128, 128, 0.15);
    border-radius: 20px;
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.sources-header-pill:hover {
    background: rgba(128, 128, 128, 0.14);
    border-color: rgba(128, 128, 128, 0.25);
    transform: translateY(-0.5px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.stacked-favicons {
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
}

.source-favicon-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--bg-surface, #1e1e1e);
    margin-left: -5px;
    background: #fff;
    object-fit: contain;
}

.source-favicon-circle:first-child {
    margin-left: 0;
}

.sources-count-label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ==========================================================================
   SOURCES DRAWER (PERPLEXITY STYLE)
   ========================================================================== */

/* Drawer Overlay */
.sources-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sources-drawer-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Drawer Container */
.sources-drawer {
    position: fixed;
    top: 0;
    right: -400px; /* Initially offscreen */
    width: 380px;
    height: 100vh;
    background: var(--bg-surface, #151515);
    border-left: 1px solid rgba(128, 128, 128, 0.15);
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.3);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.sources-drawer.open {
    right: 0;
}

/* Header */
.sources-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sources-drawer-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
}

.sources-drawer-close {
    background: none;
    border: none;
    color: var(--text-secondary, #a0a0a0);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.sources-drawer-close:hover {
    background: rgba(128, 128, 128, 0.12);
    color: var(--text-primary);
}

.sources-drawer-close svg,
.sources-drawer-close i {
    width: 18px;
    height: 18px;
}

/* Subtitle */
.sources-drawer-subtitle {
    font-size: 13.5px;
    color: var(--text-secondary, #9c9c9c);
    margin-bottom: 24px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Body / List Container */
.sources-drawer-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

/* Custom Scrollbar for Drawer */
.sources-drawer-body::-webkit-scrollbar {
    width: 5px;
}

.sources-drawer-body::-webkit-scrollbar-track {
    background: transparent;
}

.sources-drawer-body::-webkit-scrollbar-thumb {
    background: rgba(128, 128, 128, 0.2);
    border-radius: 10px;
}

.sources-drawer-body::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 128, 128, 0.35);
}

/* Drawer Source Item Card */
.drawer-source-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(128, 128, 128, 0.04);
    border: 1px solid rgba(128, 128, 128, 0.12);
    border-radius: 12px;
    padding: 14px;
    text-decoration: none !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.drawer-source-item:hover {
    background: rgba(128, 128, 128, 0.08);
    border-color: rgba(128, 128, 128, 0.22);
    transform: translateY(-1.5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.drawer-source-item.highlighted {
    background: rgba(128, 128, 128, 0.16) !important;
    border-color: var(--accent-primary, #6366f1) !important;
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.2);
    transform: scale(1.02);
}

.drawer-source-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-source-favicon {
    width: 14px;
    height: 14px;
    object-fit: contain;
    border-radius: 2px;
}

.drawer-source-hostname {
    font-size: 11.5px;
    color: var(--text-secondary, #8e8e8e);
    font-weight: 500;
}

.drawer-source-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.drawer-source-snippet {
    font-size: 12px;
    color: var(--text-secondary, #a8a8a8);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Prevent document body from scrolling when drawer is open */
.chat-raiz.drawer-open {
    overflow: hidden;
}

/* Responsive Mobile Layout */
@media (max-width: 600px) {
    .sources-drawer {
        width: 100%;
        right: -100%;
    }
}

/* ─── Imagen flotante dentro del texto ────────────────────────────────────── */
/* Solo se inserta una imagen ya validada (ThorlyFloatImage en markdown.js).
   Marco con tope de alto y object-fit: fotos verticales u horizontales ocupan
   un hueco razonable y el texto no salta. */
.search-float-image {
    float: left;
    width: 200px;
    max-width: 38%;
    height: auto;
    max-height: 260px;
    object-fit: cover;
    object-position: top center;
    margin: 4px 18px 12px 0;
    border-radius: 8px;
    border: 1px solid rgba(128, 128, 128, 0.12);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    background: var(--bg-elevated);
}

/* ─── Estructura del texto de respuesta ──────────────────────────────────────
   Los títulos no tenían estilo propio: marked genera <h2> sin clase y se aplicaba
   el de Bootstrap (casi 2rem). Y nada despejaba la imagen flotante, así que un
   título enorme acababa encajado en el hueco estrecho a su derecha. Títulos,
   separadores, código y tablas empiezan siempre debajo de la imagen; las listas
   crean su propio contexto para que las viñetas no se monten sobre ella. */
.ai-message .message-content h1,
.ai-message .message-content h2,
.ai-message .message-content h3,
.ai-message .message-content h4 {
    clear: both;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: -0.01em;
    margin: 1.6em 0 0.55em;
}

.ai-message .message-content h1 { font-size: 1.45em; font-weight: 700; }
.ai-message .message-content h2 { font-size: 1.25em; font-weight: 650; }
.ai-message .message-content h3 { font-size: 1.08em; font-weight: 600; }
.ai-message .message-content h4 { font-size: 1em; font-weight: 600; }

.ai-message .message-content > h1:first-child,
.ai-message .message-content > h2:first-child,
.ai-message .message-content > h3:first-child {
    margin-top: 0;
}

.ai-message .message-content hr,
.ai-message .message-content pre,
.ai-message .message-content .table-wrapper,
.ai-message .message-content .code-block-container,
.ai-message .message-content .sources-footer-container {
    clear: both;
}

.ai-message .message-content ul,
.ai-message .message-content ol {
    display: flow-root;
}

@media (max-width: 600px) {
    .search-float-image {
        float: none;
        display: block;
        width: 100%;
        max-width: 100%;
        max-height: 240px;
        margin: 0 0 14px;
    }
}

/* ── content/code-blocks.css ── */
/* ==========================================================================
   THORLY AI — Code Blocks (VS Code Style)
   Code blocks, syntax highlighting
   ========================================================================== */

.code-block {
    background: #000000;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    margin: 14px 0;
    font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: #252526;
    border-bottom: 1px solid #333;
    font-size: 12px;
    color: #ccc;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

.code-block-header::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff5f57;
    margin-right: 8px;
    box-shadow: 12px 0 0 #fdbc36, 24px 0 0 #2acb4f;
}

[data-theme="light"] .code-block-header {
    background: #f3f3f3;
    border-bottom-color: #e0e0e0;
    color: #333;
}

[data-theme="light"] .code-block-header::before {
    background: #ff5f57;
    box-shadow: 12px 0 0 #fdbc36, 24px 0 0 #2acb4f;
}

.copy-code-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #999;
    font-size: 12px;
    cursor: pointer;
    padding: 3px 8px;
    transition: all 0.15s ease;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

[data-theme="light"] .copy-code-btn {
    color: #666;
}

[data-theme="light"] .copy-code-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #333;
}

.copy-code-btn i {
    width: 13px;
    height: 13px;
}

.code-block pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    color: #d4d4d4;
    background: #000000;
    scrollbar-width: thin;
    scrollbar-color: #424242 #000000;
}

.code-block pre::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.code-block pre::-webkit-scrollbar-track {
    background: #000000;
}

.code-block pre::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 4px;
}

.code-block pre::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.code-block code {
    font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 13px;
}

/* VS Code Dark+ Syntax Highlighting */
.hljs {
    background: #000000;
    color: #d4d4d4;
}

.hljs-keyword, .hljs-selector-tag, .hljs-type {
    color: #569cd6;
}

.hljs-title, .hljs-title.function_, .hljs-function, .hljs-attr {
    color: #dcdcaa;
}

.hljs-string, .hljs-bullet, .hljs-symbol {
    color: #ce9178;
}

.hljs-number, .hljs-literal {
    color: #b5cea8;
}

.hljs-comment, .hljs-quote {
    color: #6a9955;
    font-style: italic;
}

.hljs-tag, .hljs-name {
    color: #569cd6;
}

.hljs-attribute {
    color: #9cdcfe;
}

.hljs-variable, .hljs-template-variable {
    color: #9cdcfe;
}

.hljs-built_in {
    color: #4ec9b0;
}

.hljs-meta {
    color: #d4d4d4;
}

.hljs-doctag {
    color: #c586c0;
}

.hljs-selector-id, .hljs-selector-class {
    color: #d7ba7d;
}

.hljs-params {
    color: #9cdcfe;
}

.hljs-property {
    color: #9cdcfe;
}

.hljs-punctuation {
    color: #d4d4d4;
}

/* Light Theme Overrides */
[data-theme="light"] .code-block {
    background: #ffffff;
    border-color: #e0e0e0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .code-block pre {
    background: #ffffff;
    color: #24292e;
}

[data-theme="light"] .hljs {
    background: #ffffff;
    color: #24292e;
}

[data-theme="light"] .hljs-keyword, 
[data-theme="light"] .hljs-selector-tag,
[data-theme="light"] .hljs-type {
    color: #d73a49;
}

[data-theme="light"] .hljs-title, 
[data-theme="light"] .hljs-title.function_,
[data-theme="light"] .hljs-attr {
    color: #6f42c1;
}

[data-theme="light"] .hljs-string {
    color: #032f62;
}

[data-theme="light"] .hljs-number,
[data-theme="light"] .hljs-literal {
    color: #005cc5;
}

[data-theme="light"] .hljs-comment {
    color: #6a737d;
}

[data-theme="light"] .hljs-tag,
[data-theme="light"] .hljs-name {
    color: #22863a;
}

[data-theme="light"] .hljs-attribute {
    color: #6f42c1;
}

[data-theme="light"] .hljs-variable {
    color: #e36209;
}

[data-theme="light"] .hljs-built_in {
    color: #e36209;
}

[data-theme="light"] .hljs-selector-id,
[data-theme="light"] .hljs-selector-class {
    color: #6f42c1;
}

[data-theme="light"] .hljs-property {
    color: #005cc5;
}

[data-theme="light"] .hljs-params {
    color: #24292e;
}

/* ── Markdown.js Code Block Container ────────────────────────────── */
.code-block-container {
    background: #000000;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
    margin: 14px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: #0d0d0d;
    border-bottom: 1px solid #333;
    font-size: 12px;
    color: #ccc;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

.code-header::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff5f57;
    margin-right: 8px;
    box-shadow: 12px 0 0 #fdbc36, 24px 0 0 #2acb4f;
}

.code-lang {
    font-size: 12px;
    color: #999;
    text-transform: lowercase;
}

[data-theme="light"] .code-block-container {
    background: #ffffff;
    border-color: #e0e0e0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .code-header {
    background: #f3f3f3;
    border-bottom-color: #e0e0e0;
    color: #333;
}

[data-theme="light"] .code-header::before {
    background: #ff5f57;
    box-shadow: 12px 0 0 #fdbc36, 24px 0 0 #2acb4f;
}

[data-theme="light"] .code-lang {
    color: #666;
}

.code-block-container pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    overflow-y: hidden;
    font-size: 13px;
    line-height: 1.6;
    color: #d4d4d4;
    background: #000000;
    border-radius: inherit;
    scrollbar-width: thin;
    scrollbar-color: #424242 #000000;
}

.code-block-container pre::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.code-block-container pre::-webkit-scrollbar-track {
    background: #000000;
}

.code-block-container pre::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 4px;
}

.code-block-container pre::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.code-block-container code {
    font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 13px;
}

[data-theme="light"] .code-block-container pre {
    background: #ffffff;
    color: #24292e;
}

/* ── Lucent Dual View ────────────────────────────────────────────── */
.lucent-dual-view {
    display: flex;
    flex-direction: column;
    margin: 14px 0;
    border-radius: 8px;
    overflow: hidden;
    background: #000000;
    border: 1px solid #333;
}

.lucent-dual-view .code-block-container {
    margin: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.lucent-dual-view .lucent-minimized-code {
    margin: 0;
    border-radius: 0;
    border: none;
    border-top: 1px solid #333;
    max-width: none;
    animation: none;
    position: relative;
    z-index: 2;
}

[data-theme="light"] .lucent-dual-view {
    background: #ffffff;
    border-color: #e0e0e0;
}

[data-theme="light"] .lucent-dual-view .lucent-minimized-code {
    border-top-color: #e0e0e0;
}


/* ── content/mermaid.css ── */
/* ==========================================================================
   THORLY AI — Mermaid Diagrams
   ========================================================================== */

.mermaid-wrapper {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin: 16px 0;
}

.mermaid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 12px;
    color: var(--text-tertiary);
}

.mermaid-header span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mermaid-diagram {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
    min-height: 100px;
}

.mermaid-diagram svg {
    max-width: 100%;
    height: auto;
}

.mermaid-error {
    padding: 12px 16px;
    color: #f28b82;
    font-size: 13px;
    font-family: var(--font-mono);
}

.mermaid-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100px;
    color: var(--text-tertiary);
}

/* ── content/images.css ── */
/* ==========================================================================
   THORLY AI — Generated Images
   Generated images, skeletons
   ========================================================================== */

/* Global anti-layout-shift rules for all images */
img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Generated images */
.generated-image-container img.generated-img {
    max-width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: block;
}

.image-loading-skeleton {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-tertiary);
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.skeleton-shimmer {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.04) 50%, transparent 100%);
    animation: shimmer 1.8s ease-in-out infinite;
    background-size: 200% 100%;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.image-disclaimer {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 16px;
    text-align: center;
    font-style: italic;
}

/* ── animations.css ── */
/* ==========================================================================
   THORLY AI — Reusable Animations
   fadeUp, msgIn, spin, theme transitions, sidebar accents
   ========================================================================== */

/* Shimmer glow on logo */
.welcome-logo {
    animation: logoFloat 3s ease-in-out infinite;
}

/* Staggered entrance for suggestion cards */
.suggestion-card:nth-child(1) {
    animation: fadeUp 0.4s ease 0.1s both;
}

.suggestion-card:nth-child(2) {
    animation: fadeUp 0.4s ease 0.2s both;
}

.suggestion-card:nth-child(3) {
    animation: fadeUp 0.4s ease 0.3s both;
}

.suggestion-card:nth-child(4) {
    animation: fadeUp 0.4s ease 0.4s both;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Message entrance animation */
.message {
    animation: msgIn 0.3s ease both;
}

@keyframes msgIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar item hover accent line */
.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 3px;
    border-radius: var(--radius-pill);
    background: var(--accent-primary);
}

/* Smooth theme transition on all key elements */
.sidebar,
.topbar,
.chat-area,
.input-area-wrapper,
.settings-panel,
.input-box,
.suggestion-card,
.mode-pill {
    transition-property: background-color, border-color, color;
    transition-duration: var(--transition-med);
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Spin animation (used by loaders) */
.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Fallbacks for removed FontAwesome */
.fa-spin {
    animation: spin 1s linear infinite;
}

@keyframes fa-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-25%); }
}

.fa-bounce {
    animation: fa-bounce 1s infinite cubic-bezier(0.28, 0.84, 0.42, 1);
}

/* ── responsive.css ── */
/* ==========================================================================
   THORLY AI — Responsive Media Queries
   Consolidated responsive breakpoints
   ========================================================================== */

@media (max-width: 575.98px) {
    .welcome-heading {
        font-size: 26px;
    }

    .welcome-logo {
        width: 56px;
        height: 56px;
    }

    .suggestion-card {
        padding: 12px;
        font-size: 12px;
    }

    .mode-pills-scroll {
        gap: 5px;
    }

    .mode-pill {
        padding: 5px 10px;
        font-size: 12px;
    }

    .theme-toggle-group {
        flex-direction: column;
    }

    .theme-btn {
        padding: 5px 8px;
    }

    .settings-panel {
        width: 100vw;
    }

    .slider-wrapper {
        min-width: 120px;
    }
}

@media (max-width: 767.98px) {
    .model-name {
        font-size: 13px;
    }

    .settings-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .settings-select {
        width: 100%;
    }

    .slider-wrapper {
        width: 100%;
    }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .settings-panel {
        width: min(400px, 100vw);
    }
}

@media (min-width: 992px) {
    .topbar {
        padding: 0 24px;
    }

    .input-area-wrapper {
        padding: 10px 24px 24px;
    }

    .messages-container {
        padding: 32px 24px 16px;
    }
}

/* ── main.css (reglas propias) ── */
/* ==========================================================================
   THORLY AI — Main CSS Entry Point
   @imports centralizados — incluir solo este archivo en thorly-ia.html
   ========================================================================== */

/* 1. Design Tokens (variables, temas) */


/* 2. Reset & Base */


/* 3. Layout Shell */


/* 4. Components */




















/* 5. Content Rendering */





/* 6. Animations */


/* 7. Responsive */


/* ── Code block macOS dots (inline to bypass @import cache) ── */
.code-header::before,
.code-block-header::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff5f57;
    margin-right: 8px;
    box-shadow: 12px 0 0 #fdbc36, 24px 0 0 #2acb4f;
}

[data-theme="light"] .code-header::before,
[data-theme="light"] .code-block-header::before {
    background: #ff5f57;
    box-shadow: 12px 0 0 #fdbc36, 24px 0 0 #2acb4f;
}
/* ── Respuesta en vivo: preguntas sugeridas, cursor de streaming y memoria ── */

.followup-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.followup-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 7px 14px 7px 11px;
    font: inherit;
    font-size: 13px;
    line-height: 1.35;
    text-align: left;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition:
        color var(--transition-fast),
        background var(--transition-fast),
        border-color var(--transition-fast),
        transform var(--transition-fast);
    animation: followup-in 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.followup-chip::before {
    content: '↳';
    color: var(--accent-primary);
    opacity: 0.75;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.followup-chip:nth-child(2) { animation-delay: 70ms; }
.followup-chip:nth-child(3) { animation-delay: 140ms; }

.followup-chip:hover {
    color: var(--text-primary);
    background: var(--accent-primary-dim);
    border-color: var(--pill-active-border);
}

.followup-chip:hover::before {
    opacity: 1;
    transform: translateX(2px);
}

.followup-chip:active {
    transform: scale(0.98);
}

.followup-chip:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

@keyframes followup-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* Cursor al final del texto mientras llegan tokens */
.streaming-message .message-content > :last-child::after {
    content: '';
    display: inline-block;
    width: 0.45em;
    height: 1em;
    margin-left: 3px;
    vertical-align: -0.14em;
    background: var(--accent-primary);
    border-radius: 2px;
    animation: stream-caret 1s steps(1) infinite;
}

@keyframes stream-caret {
    50% { opacity: 0; }
}

/* ── Ajustes: memoria ── */

.memory-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 2px 0 10px;
}

.memory-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 8px 8px 12px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
}

.memory-item span {
    flex: 1;
    overflow-wrap: anywhere;
}

.memory-remove {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    color: var(--text-tertiary);
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.memory-remove:hover {
    color: var(--brand-pink);
    background: var(--bg-hover);
}

.memory-remove:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 1px;
}

.memory-empty {
    margin: 0;
    padding: 2px 2px 4px;
    font-size: 12px;
    color: var(--text-tertiary);
}

@media (prefers-reduced-motion: reduce) {
    .followup-chip,
    .streaming-message .message-content > :last-child::after {
        animation: none;
    }
}

/* ==========================================================================
   Selector de modelo en la barra del mensaje (ui/helpers/model-picker.js)
   ========================================================================== */

.model-picker {
    position: relative;
    flex-shrink: 1;
    min-width: 0;
}

.model-picker[hidden] {
    display: none !important;
}

.model-picker-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    max-width: 190px;
    padding: 0 8px 0 10px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--text-secondary);
    font: 500 13px/1 var(--font-main);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.model-picker-trigger:hover,
.model-picker-trigger[aria-expanded="true"] {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.model-picker-trigger:focus-visible,
.model-picker-option:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Con una clave propia en uso, el color de acento indica que no responde Thorly */
.model-picker-trigger.is-custom {
    border-color: var(--pill-active-border);
    background: var(--pill-active-bg);
    color: var(--pill-active-text);
}

.model-picker-trigger i,
.model-picker-trigger svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.model-picker-trigger .model-picker-chevron {
    width: 14px;
    height: 14px;
    opacity: 0.7;
    transition: transform var(--transition-fast);
}

.model-picker-trigger[aria-expanded="true"] .model-picker-chevron {
    transform: rotate(180deg);
}

.model-picker-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* El input está abajo: el menú se abre hacia arriba */
.model-picker-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 10px);
    z-index: 1060;
    width: min(300px, calc(100vw - 32px));
    max-height: 420px; /* JS (place) lo ajusta al espacio disponible */
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    animation: model-picker-in var(--transition-med);
}

.model-picker-menu.opens-below {
    top: calc(100% + 10px);
    bottom: auto;
}

.model-picker-menu[hidden] {
    display: none;
}

@keyframes model-picker-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.model-picker-group {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--border-subtle);
}

.model-picker-group-title {
    padding: 8px 10px 4px;
    color: var(--text-tertiary);
    font: 600 11px/1 var(--font-main);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.model-picker-option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font: 400 14px/1.3 var(--font-main);
    text-align: left;
    cursor: pointer;
}

.model-picker-option:hover {
    background: var(--bg-hover);
}

.model-picker-option[aria-selected="true"] {
    background: var(--accent-primary-dim);
    color: var(--text-strong);
    font-weight: 500;
}

.model-picker-option-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-picker-option-meta {
    color: var(--text-tertiary);
    font-size: 12px;
}

.model-picker-badge {
    flex-shrink: 0;
    padding: 3px 7px;
    border-radius: var(--radius-pill);
    background: rgba(52, 168, 83, 0.14);
    color: #34A853;
    font: 600 11px/1 var(--font-main);
}

/* Sobre fondo blanco el verde claro no llega al contraste mínimo */
[data-theme="light"] .model-picker-badge {
    background: rgba(19, 115, 51, 0.10);
    color: #137333;
}

/* Móvil: solo el icono (como el del micrófono) para no quitarle ancho al mensaje.
   El modelo elegido se ve al abrir el menú y va en el aria-label. */
@media (max-width: 576px) {
    .model-picker-trigger {
        width: 32px;
        padding: 0;
        justify-content: center;
        border-color: transparent;
    }

    .model-picker-trigger .model-picker-label,
    .model-picker-trigger .model-picker-chevron {
        display: none;
    }

    .model-picker-trigger i,
    .model-picker-trigger svg {
        width: 18px;
        height: 18px;
    }

    /* Recupera el ancho del botón para que "Escribe un mensaje..." no se parta */
    .input-row:has(.model-picker:not([hidden])) {
        gap: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .model-picker-menu {
        animation: none;
    }
}

/* ── Iconos de Tabler (fuente) en lugar de Lucide (SVG) ───────────────────── */
.chat-raiz { height: 100vh; height: 100dvh; }
.chat-raiz i.ti { font-size: 18px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; width: auto; height: auto; }
.chat-raiz .msg-action-btn i.ti, .chat-raiz .copy-code-btn i.ti { font-size: 15px; }
.chat-raiz .send-btn i.ti, .chat-raiz .icon-btn i.ti { font-size: 20px; }
.chat-raiz .new-chat-btn i.ti, .chat-raiz .sidebar-footer-item i.ti { font-size: 18px; }
.chat-raiz .settings-row > i.ti, .chat-raiz .settings-header h2 i.ti { font-size: 18px; }
.chat-raiz .suggestion-chip i.ti { font-size: 16px; }
.chat-raiz .model-picker-trigger i.ti { font-size: 15px; }
.chat-raiz .icon-sun, .chat-raiz .icon-moon { display: none; }
.chat-raiz[data-theme="dark"] .icon-sun, .chat-raiz[data-theme="light"] .icon-moon { display: inline-flex; }
.chat-raiz .dropdown-menu.show { display: block; }
.chat-raiz .ti-spin { animation: chat-giro 1s linear infinite; }
@keyframes chat-giro { to { transform: rotate(360deg); } }
/* Cerrados no asoman su sombra por el borde */
.chat-raiz .sources-drawer:not(.open), .chat-raiz .settings-panel:not(.settings-open) { box-shadow: none; }

/* ── Compartir y exportar (menú de la barra) ── */
.chat-raiz .topbar-menu { position: relative; }
.chat-raiz .topbar-menu__fondo { position: fixed; inset: 0; z-index: 40; }
.chat-raiz .topbar-menu__lista {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 41; min-width: 250px; padding: 6px;
    display: flex; flex-direction: column; border-radius: 14px;
    background: var(--bg-elevated); border: 1px solid var(--border-default); box-shadow: var(--shadow-lg);
}
.chat-raiz .topbar-menu__lista > button, .chat-raiz .topbar-menu__lista > a {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 10px;
    background: none; color: var(--text-primary); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer;
}
.chat-raiz .topbar-menu__lista > button:hover, .chat-raiz .topbar-menu__lista > a:hover { background: var(--bg-hover); }
.chat-raiz .topbar-menu__lista i { font-size: 18px; color: var(--text-secondary); }

/* ── Plan de Thorly IA (ajustes) ── */
.chat-raiz .plan-pro { padding: 14px; border-radius: 14px; border: 1px solid var(--border-default); background: linear-gradient(135deg, rgba(217,70,239,.08), rgba(59,130,246,.06)); }
.chat-raiz .plan-pro--activo { border-color: rgba(217,70,239,.45); }
.chat-raiz .plan-pro__cabeza { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; color: var(--text-strong); }
.chat-raiz .plan-pro__cabeza i { color: #d946ef; font-size: 18px; }
.chat-raiz .plan-pro__cabeza span { margin-left: auto; font-size: 13px; color: var(--text-secondary); }
.chat-raiz .plan-pro p { margin: 0 0 10px; font-size: 13px; color: var(--text-secondary); }
.chat-raiz .plan-pro ul { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chat-raiz .plan-pro li { display: flex; gap: 8px; font-size: 13px; color: var(--text-primary); }
.chat-raiz .plan-pro li i { color: #d946ef; margin-top: 2px; }
.chat-raiz .plan-pro__comprar {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px;
    background: #a21caf; color: #fff; font-size: 13px; font-weight: 600; text-decoration: none;
}
.chat-raiz .plan-pro__comprar:hover { filter: brightness(1.1); }
.chat-raiz .plan-pro__codigo { display: flex; gap: 8px; margin-top: 10px; }
.chat-raiz .plan-pro__codigo input {
    flex: 1; min-width: 0; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-default);
    background: var(--bg-input); color: var(--text-primary); font: inherit; font-size: 14px; text-transform: uppercase;
}
.chat-raiz .plan-pro__codigo button { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: none; color: var(--text-primary); font: inherit; font-size: 13px; cursor: pointer; }
.chat-raiz .plan-pro__codigo button:disabled { opacity: .5; cursor: default; }
.chat-raiz .plan-pro__estado { margin: 8px 0 0; font-size: 13px; color: var(--text-secondary); }

/* ── Conversación compartida (/compartido) ── */
.chat-raiz.compartido { min-height: 100vh; background: var(--bg-base); color: var(--text-primary); font-family: var(--font-main); overflow-y: auto; }
.compartido__barra {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px max(16px, calc((100% - 860px) / 2)); background: color-mix(in srgb, var(--bg-base) 88%, transparent);
    backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-subtle);
}
.compartido__marca { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text-strong); text-decoration: none; }
.compartido__cta {
    display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px;
    background: var(--send-btn-bg); color: var(--send-btn-text); font-size: 14px; font-weight: 600; text-decoration: none;
}
.compartido__cuerpo { max-width: 860px; margin: 0 auto; padding: 32px 16px 80px; }
.compartido__cabeza { margin-bottom: 28px; }
.compartido__etiqueta { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-tertiary); }
.compartido__cabeza h1 { margin: 10px 0 6px; font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; color: var(--text-strong); }
.compartido__cabeza time { font-size: 13px; color: var(--text-secondary); }
.compartido__mensaje { margin-bottom: 22px; }
.compartido__mensaje--usuario { display: flex; justify-content: flex-end; }
.compartido__burbuja { max-width: 80%; padding: 12px 16px; border-radius: 18px; background: var(--bg-elevated); white-space: pre-wrap; line-height: 1.55; }
.compartido__respuesta { line-height: 1.7; }
.compartido__estado { color: var(--text-secondary); }
.compartido__vacio { text-align: center; padding: 60px 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.compartido__vacio i { font-size: 40px; color: var(--text-tertiary); }
.compartido__vacio p { color: var(--text-secondary); margin: 0 0 8px; }
.compartido__cierre {
    margin-top: 40px; padding: 22px; border-radius: 18px; text-align: center; border: 1px solid var(--border-default);
    background: linear-gradient(135deg, rgba(217,70,239,.08), rgba(59,130,246,.06));
}
.compartido__cierre p { margin: 0 0 14px; color: var(--text-secondary); }
