/* ===== SISTEMA DE TEMAS ===== */
:root {
    /* CORES PRIMÁRIAS - PALETA BRANCA MINIMALISTA */
    --primary-color: #fbfcf9;
    --primary-dark: #ffffff;
    --primary-light: #ffffff;
    --primary-rgba-1: rgba(255, 255, 255, 0.1);
    --primary-rgba-3: rgba(255, 255, 255, 0.555);
    --primary-rgba-5: rgba(255, 255, 255, 0.5);
    --primary-glow: rgba(255, 255, 255, 0.6);
    /* MODAL SYSTEM - VARIÁVEIS PARA ELIMINAR DUPLICAÇÃO */
    --modal-overlay-bg: rgba(0, 0, 0, 0.8);
    --modal-backdrop-blur: blur(10px);
    --modal-z-index: 2100;  /* alinhado à escala --z-modal (legado, mantido por compat) */
    --modal-border-radius: 20px;
    --modal-transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);

    /* RESPONSIVE SYSTEM - VARIÁVEIS PARA MOBILE */
    --mobile-padding: 15px;
    --mobile-padding-small: 10px;
    --mobile-padding-xs: 5px;
    --mobile-gap: 8px;
    --mobile-gap-small: 4px;
    --mobile-border-radius: 8px;
    --mobile-font-size: 14px;
    --mobile-font-size-small: 12px;

    /* BUTTON SYSTEM - VARIÁVEIS PARA ELIMINAR DUPLICAÇÃO */
    --btn-padding: 12px 24px;
    --btn-padding-sm: 8px 16px;
    --btn-padding-lg: 14px 18px;
    --btn-radius-round: 50%;
    --btn-radius-normal: 10px;
    --btn-bg-alpha: rgba(255, 255, 255, 0.03);
    --btn-bg-alpha-hover: rgba(255, 255, 255, 0.05);
    --btn-transform-hover: translateY(-1px);
    --btn-transition: all 0.2s ease;

    /* RGBA SYSTEM - VALORES MAIS REPETIDOS NO CÓDIGO */
    --rgba-white-05: rgba(255, 255, 255, 0.05);
    --rgba-white-1: rgba(255, 255, 255, 0.1);
    --rgba-white-15: rgba(255, 255, 255, 0.15);
    --rgba-white-2: rgba(255, 255, 255, 0.2);
    --rgba-white-3: rgba(255, 255, 255, 0.3);
    --rgba-black-8: rgba(0, 0, 0, 0.8);
    --rgba-black-5: rgba(0, 0, 0, 0.5);

    /* Variáveis que eram USADAS no CSS/JS mas nunca foram DEFINIDAS (resolviam
       pra vazio). Valores coerentes com o tema dark. */
    --text-tertiary: rgba(255, 255, 255, 0.45);
    --background-secondary: #2e2e2e;
    --primary-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* ESCALA DE Z-INDEX SEMÂNTICA — substitui a escala caótica (9998/10000/
       20000/30000). A ordem (de baixo p/ cima) preserva o empilhamento atual:
       conteúdo < input < dropdowns < UI flutuante < overlay < modal < popover <
       crítico. Use SEMPRE estas variáveis para novos z-index. */
    --z-base: 10;          /* botões/indicadores dentro do conteúdo */
    --z-sticky: 100;       /* área de input fixa */
    --z-floating-ui: 1000; /* botões flutuantes (toggle, seletor, export) */
    --z-dropdown: 1100;    /* dropdowns/menus — abrem DE botões, ficam acima deles */
    --z-overlay: 2000;     /* fundos escuros de modal/sidebar */
    --z-modal: 2100;       /* conteúdo de modal / sidebar */
    --z-popover: 2200;     /* flyouts que saem de dentro de modais */
    --z-critical: 3000;    /* progresso, limite excedido, settings overlay */

    /* TAMANHO DA FONTE REMOVIDO - agora fixo em cada elemento */
}

/* TEMA ESCURO (padrão) */
:root,
[data-theme="dark"] {
    --bg-dark: rgb(31, 31, 31);
    --bg-darker: #2e2e2e;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-light: rgba(255, 255, 255, 0.05);
    --surface-color: rgba(255, 255, 255, 0.1);
    --surface-hover: rgba(255, 255, 255, 0.15);

    /* CODE BLOCKS - TEMA ESCURO */
    --code-bg: #000000;
    --code-header-bg: #000000;
    --code-text: #ececf1;
    --inline-code-bg: #374151;
    --inline-code-text: #fbbf24;

    /* SYNTAX HIGHLIGHTING - TEMA ESCURO (melhorado) */
    --syntax-keyword: #ff79c6;
    /* Rosa vibrante para keywords (def, class, if) */
    --syntax-string: #50fa7b;
    /* Verde neon para strings */
    --syntax-comment: #6272a4;
    /* Azul acinzentado para comentários */
    --syntax-function: #8be9fd;
    /* Ciano claro para funções */
    --syntax-number: #ffb86c;
    /* Laranja suave para números */
    --syntax-tag: #ff5555;
    /* Vermelho para tags HTML */
    --syntax-attr-name: #ff79c6;
    /* Rosa para atributos */
    --syntax-attr-value: #50fa7b;
    /* Verde para valores */
    --syntax-property: #ff5555;
    /* Vermelho para propriedades CSS */
    --syntax-selector: #ff79c6;
    /* Rosa para seletores CSS */
    --syntax-value: #50fa7b;
    /* Verde para valores CSS */
    --syntax-builtin: #f1fa8c;
    /* Amarelo para built-ins (None, True, False) */
    --syntax-class: #bd93f9;
    /* Roxo claro para classes */
    --syntax-operator: #ff79c6;
    /* Rosa para operadores (+, -, *, ==) */
}

/* TEMA CLARO */
[data-theme="light"] {
    --bg-dark: #ffffff;
    --bg-darker: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: rgba(33, 37, 41, 0.7);
    --text-muted: rgba(33, 37, 41, 0.5);
    --border-color: rgba(0, 0, 0, 0.1);
    --border-color-light: rgba(0, 0, 0, 0.05);
    --surface-color: rgba(0, 0, 0, 0.05);
    --surface-hover: rgba(0, 0, 0, 0.1);

    /* CODE BLOCKS - TEMA CLARO */
    --code-bg: #f8fafc;
    --code-header-bg: #f1f5f9;
    --code-text: #374151;
    --inline-code-bg: #f1f5f9;
    --inline-code-text: #e11d48;

    /* SYNTAX HIGHLIGHTING - TEMA CLARO (melhorado) */
    --syntax-keyword: #d946ef;
    /* Magenta forte para keywords */
    --syntax-string: #16a34a;
    /* Verde escuro para strings */
    --syntax-comment: #64748b;
    /* Cinza azulado para comentários */
    --syntax-function: #0ea5e9;
    /* Azul claro para funções */
    --syntax-number: #ea580c;
    /* Laranja escuro para números */
    --syntax-tag: #dc2626;
    /* Vermelho para tags */
    --syntax-attr-name: #d946ef;
    /* Magenta para atributos */
    --syntax-attr-value: #16a34a;
    /* Verde escuro para valores */
    --syntax-property: #dc2626;
    /* Vermelho para propriedades */
    --syntax-selector: #d946ef;
    /* Magenta para seletores */
    --syntax-value: #16a34a;
    /* Verde escuro para valores */
    --syntax-builtin: #ca8a04;
    /* Dourado para built-ins */
    --syntax-class: #7c3aed;
    /* Roxo para classes */
    --syntax-operator: #e11d48;
    /* Rosa escuro para operadores */

    /* Equivalentes claras das variáveis antes indefinidas (ver :root dark) */
    --text-tertiary: rgba(33, 37, 41, 0.45);
    --background-secondary: #f8f9fa;
}

* {
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        opacity 0.2s ease;
}

/* ===== SISTEMA DE MODALS GLOBAL (ANTES: 642 LINHAS → AGORA: 80 LINHAS) ===== */

/* OVERLAY GLOBAL - USADO POR TODOS OS MODALS */
.modal-overlay,
.logout-modal-overlay,
.rename-modal-overlay,
.delete-modal-overlay,
.success-modal-overlay,
.error-modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay-bg);
    -webkit-backdrop-filter: var(--modal-backdrop-blur);
    backdrop-filter: var(--modal-backdrop-blur);
    z-index: var(--modal-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--modal-transition);
}

.modal-overlay.show,
.logout-modal-overlay.show,
.rename-modal-overlay.show,
.delete-modal-overlay.show,
.success-modal-overlay.show,
.error-modal-overlay.show {
    opacity: 1;
}

/* MODAL CONTAINER GLOBAL */
.modal,
.logout-modal,
.rename-modal,
.delete-modal,
.success-modal,
.error-modal {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--modal-border-radius);
    padding: 32px;
    max-width: 460px;
    width: 90%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-color);
    transform: scale(0.9) translateY(20px);
    transition: var(--modal-transition);
}

.modal-overlay.show .modal,
.logout-modal-overlay.show .logout-modal,
.rename-modal-overlay.show .rename-modal,
.delete-modal-overlay.show .delete-modal,
.success-modal-overlay.show .success-modal,
.error-modal-overlay.show .error-modal {
    transform: scale(1) translateY(0);
}

/* HEADER GLOBAL */
.modal-header,
.logout-modal-header,
.rename-modal-header,
.delete-modal-header,
.success-modal-header,
.error-modal-header {
    text-align: center;
    margin-bottom: 24px;
}

/* ÍCONES GLOBAIS */
.modal-icon,
.logout-icon,
.rename-icon,
.delete-icon,
.success-icon,
.error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 16px;
    color: rgb(0, 0, 0);
}

.logout-icon {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.rename-icon,
.success-icon {
    background: linear-gradient(135deg, #10b981, #059669);
}

.delete-icon,
.error-icon {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.modal-header h3,
.logout-modal-header h3,
.rename-modal-header h3,
.delete-modal-header h3,
.success-modal-header h3,
.error-modal-header h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

/* BODY GLOBAL */
.modal-body,
.logout-modal-body,
.rename-modal-body,
.delete-modal-body,
.success-modal-body,
.error-modal-body {
    text-align: center;
    margin-bottom: 32px;
}

.modal-body p,
.logout-modal-body p,
.rename-modal-body p,
.delete-modal-body p,
.success-modal-body p,
.error-modal-body p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 8px 0;
}

.logout-modal-subtitle {
    font-size: 14px !important;
    color: #a0a0a0 !important;
    margin: 0 !important;
}

/* ACTIONS GLOBAL */
.modal-actions,
.logout-modal-actions,
.rename-modal-actions,
.delete-modal-actions,
.success-modal-actions,
.error-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* BOTÕES GLOBAIS */
.modal-btn,
.logout-btn-cancel,
.logout-btn-confirm,
.rename-btn-cancel,
.rename-btn-confirm,
.delete-btn-cancel,
.delete-btn-confirm,
.success-btn-confirm,
.error-btn-confirm {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
    justify-content: center;
}

.logout-btn-cancel {
    background: var(--rgba-white-1);
    color: #e0e0e0;
    border: 1px solid var(--rgba-white-2);
}

.logout-btn-cancel:hover {
    background: var(--rgba-white-15);
    border-color: var(--rgba-white-3);
    transform: translateY(-1px);
}

.logout-btn-confirm {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: 1px solid rgba(239, 68, 68, 0.5);
}

.logout-btn-confirm:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.3);
}

.logout-btn-cancel svg,
.logout-btn-confirm svg {
    width: 16px;
    height: 16px;
}

/* RENAME INPUT - ESPECIFIDADE ÚNICA */
.rename-input {
    width: 100%;
    padding: 16px 20px;
    background: var(--rgba-white-05);
    border: 2px solid var(--rgba-white-1);
    border-radius: 12px;
    color: #ffffff;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
}

.rename-input:focus {
    border-color: #10b981;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.rename-input::placeholder {
    color: #a0a0a0;
}

/* DELETE WARNING - ESPECIFICIDADE ÚNICA */
.delete-warning {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
    text-align: left;
}

.delete-warning-title {
    color: #ef4444;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
}

.delete-warning-text {
    color: #fca5a5;
    font-size: 13px;
    line-height: 1.4;
}

/* ===== RESET E BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.main-input ::placeholder {
    overflow-y: hidden;
    height: 10px;
}

*::-webkit-scrollbar {
    display: none;
}

* {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

body {
    font-family: "Inter", sans-serif !important;
    font-size: 16px;
    background: var(--bg-darker);
    color: var(--text-secondary);
    min-height: 100vh;
    overflow: hidden;
    position: relative;
    margin: 0;
    padding: 0;
    transition: background-color var(--theme-transition), color var(--theme-transition);
}

* {
    font-family: "Inter", sans-serif !important;
}

/* ===== WELCOME CONTAINER ===== */
.welcome-container {
    position: fixed;
    top: -120px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding-top: 10vh;
    box-sizing: border-box;
    opacity: 1;
    visibility: visible;
}

.welcome-container.show {
    opacity: 1;
    visibility: visible;
}

.welcome-container.hidden {
    display: none !important;
}

.welcome-message {
    text-align: center;
    margin-bottom: 40px;
}

.welcome-text {
    font-size: 28px;
    /* Maior */
    font-weight: 600;
    /* Menos bold, mais elegante */
    font-family: "Inter", sans-serif;
    /* Fonte mais bonita */
    line-height: 1.3;
    max-width: 600px;
    color: var(--primary-color);
    letter-spacing: -0.02em;
    /* Tracking sutil */
    transition: color var(--theme-transition) ease-in-out,
        text-shadow var(--theme-transition) ease-in-out !important;
}

@supports (-webkit-background-clip: text) {
    .welcome-text {
        background: linear-gradient(135deg,
                var(--primary-dark) 0%,
                var(--primary-color) 40%,
                var(--primary-light) 60%,
                #ffffff 100%) !important;
        -webkit-background-clip: text !important;
        background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
        transition: background var(--theme-transition) ease-in-out !important;
    }
}

/* ===== INPUT PRINCIPAL ===== */
.main-input-section {
    width: 100%;
    max-width: 700px;
    margin-bottom: 30px;
}

/* Barra estilo Gemini HÍBRIDA via CSS Grid (3 filhos: [+] [texto] [toolbar]):
   - COMPACTO (1 linha): grid "auto 1fr auto" numa linha → + texto ... modelo enviar
     todos centrados verticalmente. Barra baixa, igual à imagem do Gemini.
   - EXPANDIDO (.is-expanded, texto > 1 linha): o texto sobe pra 1ª linha ocupando
     toda a largura (span 3); o + vai pra esquerda da 2ª linha e a toolbar à direita. */
.main-input-container {
    background: rgba(26, 26, 26, 0.8);
    border-radius: 28px;
    padding: 10px 10px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "attach text tools";
    align-items: center;
    column-gap: 4px;
    position: relative;
}

.main-input-container.is-expanded {
    grid-template-areas:
        "text text text"
        "attach . tools";
    align-items: end;
    row-gap: 2px;
}

.main-input-container .bar-attach { grid-area: attach; }
.main-input-container .main-input { grid-area: text; }
.main-input-container .input-toolbar { grid-area: tools; }

/* Grupo da direita: seletor de modelo + enviar */
.input-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-spacer { display: none; }   /* não usado no layout de grid */

/* ===== THINKING MODE INDICATOR ===== */
.thinking-mode-indicator {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: var(--z-base);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.thinking-mode-indicator.active {
    opacity: 1;
    animation: thinkingFadeIn 0.3s ease-out;
}

.thinking-mode-indicator.fade-out {
    animation: thinkingFadeOut 0.3s ease-out forwards;
}

.brain-icon {
    width: 28px;
    height: 28px;
    color: var(--primary-color);
    filter: drop-shadow(0 0 6px var(--primary-rgba-3));
}

@keyframes thinkingFadeIn {
    from {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }

    to {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }
}

@keyframes thinkingFadeOut {
    from {
        opacity: 1;
        transform: translateY(-50%) scale(1);
    }

    to {
        opacity: 0;
        transform: translateY(-50%) scale(0.8);
    }
}

/* Ajustar padding do input quando thinking mode está ativo */
.main-input-container.has-thinking-indicator .main-input {
    padding-left: 60px;
}

.main-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #e0e0e0;
    font-size: 16px;
    padding: 6px 6px;
    font-weight: 400;
    resize: none;
    min-height: 34px;
    /* ~5 linhas (line-height 1.5 * 16px = 24px → 5*24 + paddings ≈ 140px); depois scroll */
    max-height: 140px;
    line-height: 1.5;
    overflow-y: auto;
}

.main-input::placeholder {
    color: #6b7280;
    font-style: italic;
}

/* ===== SISTEMA DE BOTÕES GLOBAL (ANTES: 3 SEÇÕES → AGORA: 1 SISTEMA) ===== */

/* BASE GLOBAL PARA TODOS OS BOTÕES */
.btn,
.settings-btn,
.titan-btn,
.action-btn,
.send-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    transition: var(--btn-transition);
    position: relative;
}

.btn {
    padding: var(--btn-padding);
}

/* HOVER GLOBAL */
.btn:hover,
.settings-btn:hover,
.titan-btn:hover,
.action-btn:hover {
    transform: var(--btn-transform-hover);
}

/* ESTILOS ESPECÍFICOS MANTIDOS */
.settings-btn {
    width: 45px;
    height: 45px;
    background: var(--btn-bg-alpha-hover);
    border: 1px solid var(--primary-rgba-3);
    border-radius: var(--btn-radius-round);
    color: var(--primary-color);
    font-size: 18px;
    font-weight: bold;
    z-index: var(--z-base);
}

.settings-btn:hover {
    background: var(--primary-rgba-1);
    border-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--primary-rgba-3);
}

.settings-btn.active {
    background: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 16px var(--primary-rgba-5);
}

.send-btn {
    width: 36px;
    height: 36px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    flex-shrink: 0;
}

/* Botão stop-mode: fundo branco com SVG preto */
.send-btn.stop-mode {
    background: white !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

.send-btn.stop-mode svg {
    fill: black !important;
}

.send-btn svg {
    width: 24px;
    height: 24px;
    fill: #374151;
    transition: all var(--theme-transition);
}

/* ===== CHAT CONTAINER ===== */
.chat-container {
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-base);
    display: flex;
    flex-direction: column;
}

/* Banner do chat removido - usando apenas botão do header */

.chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* ===== MENSAGENS ===== */
.message {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    animation: fadeIn 0.3s ease-in;
    width: 100%;
    justify-content: flex-start
}

.message.user {
    flex-direction: row;
    justify-content: flex-end;
    margin-left: auto;
    margin-right: 0;
    max-width: 70%;
}

.user-message {
    background-color: #454545;
    color: #e0e0e0;
    padding: 12px 16px;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    word-wrap: break-word;
    font-size: 17px;
    /* Letra maior */
    line-height: 1.5;
}

.assistant-message {
    color: #e0e0e0;
    line-height: 1.6;
    font-size: 17px;
    /* Letra maior */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    /* Mesma fonte do input */
    font-weight: 400;
    /* Mesmo peso do input */
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
}

.message-content {
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-top: 0;
    font-family: "Inter", sans-serif;
    font-size: 17px;  /* UX 2025: 17px ideal para chat AI */
    line-height: 1.6;  /* 1.5-1.6x recomendado para legibilidade */
    font-weight: 400;
    width: 100%;
    box-sizing: border-box;
}

/* ===== LISTAS nas mensagens (bullets de verdade, não "*" cru) ===== */
.message-content .msg-list,
.streaming-content .msg-list {
    margin: 10px 0;
    padding-left: 4px;
    list-style: none;
}

.message-content .msg-list li,
.streaming-content .msg-list li {
    position: relative;
    padding-left: 20px;
    margin: 4px 0;
    line-height: 1.5;
}

/* Marcador • discreto, alinhado */
.message-content .msg-list li::before,
.streaming-content .msg-list li::before {
    content: "•";
    position: absolute;
    left: 4px;
    top: -0.5px;
    color: var(--text-secondary, #8b8b8b);
    font-weight: 700;
}

/* ===== FÓRMULAS MATEMÁTICAS (MathJax — renderer SVG) ===== */
/* Wrapper de fórmula em bloco ($$...$$). É o ÚNICO responsável pelo respiro
   vertical (margin) e pela centralização. O formatMessage envolve cada $$ num
   .math-block e engole os <br> em volta -> espaçamento uniforme, sem buracos.
   IMPORTANTE: só overflow-x (scroll horizontal p/ fórmula larga). NÃO usar
   overflow-y:hidden — cortava expoentes/raiz que passam um pouco da caixa. */
.math-block {
    margin: 14px 0;
    text-align: center;
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
    /* Respiro lateral pro scrollbar não encostar na fórmula. */
    padding: 2px 0;
}

/* O SVG interno (mjx-container) NÃO adiciona margem (senão soma com a do
   .math-block). É inline-block por padrão; deixamos o .math-block centralizar.
   font-size leve p/ a fórmula respirar — o SVG escala sem perder nitidez. */
.math-block mjx-container[display="true"] {
    margin: 0 !important;
    padding: 0;
    font-size: 1.1em;
    max-width: 100%;
}

/* SVG: garante que o desenho não seja clipado e alinhe pela base. */
.math-block mjx-container svg {
    overflow: visible;
    vertical-align: middle;
}

/* Fórmula inline: alinha bem com o texto ao redor, sem esticar a linha */
mjx-container:not([display="true"]) {
    font-size: 1.02em;
    margin: 0 1px;
}

.response-time {
    font-size: 11px;
    color: #6b7280;
    margin-top: 8px;
    text-align: right;
    font-style: italic;
}

/* 🧠 THINKING MODE - MOVIDO PARA reasoning.css */

/* ===== CHAT INPUT ===== */
.chat-input-area {
    position: relative;
    bottom: 0;
    padding: 16px 24px 0px 24px;
    /* Remover padding bottom para dar espaço ao aviso */
    z-index: var(--z-sticky);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chat-input-container {
    max-width: 800px;
    margin: 0 auto;
    background: rgba(26, 26, 26, 0.9);
    border-radius: 28px;
    padding: 10px 10px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "attach text tools";
    align-items: center;
    column-gap: 4px;
}

.chat-input-container.is-expanded {
    grid-template-areas:
        "text text text"
        "attach . tools";
    align-items: end;
    row-gap: 2px;
}

.chat-input-container .bar-attach { grid-area: attach; }
.chat-input-container #chatInput { grid-area: text; }
.chat-input-container .input-toolbar { grid-area: tools; }

#chatInput {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #e0e0e0;
    font-size: 16px;
    padding: 6px 6px;
    font-weight: 400;
    resize: none;
    min-height: 34px;
    max-height: 140px;   /* ~5 linhas, depois scroll */
    line-height: 1.5;
    overflow-y: auto;
}

#chatInput::placeholder {
    color: #6b7280;
    font-style: italic;
}

#chatSendBtn {
    width: 36px;
    height: 36px;
}

#chatSendBtn svg {
    width: 24px;
    height: 24px;
    fill: black;
    transition: all var(--theme-transition);
}

/* ===== DROPDOWN DE CONFIGURAÇÕES ===== */
.config-dropdown {
    position: relative;
    display: inline-block;
}

.config-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 9px;
}

.config-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.dropdown-item .clip-icon {
    margin-right: 8px;
}

/* ===== ATTACHED FILES SECTION (ESTILO CHATGPT) ===== */
.attached-files-section {
    background: rgba(26, 26, 26, 0.8);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    /* border: 3px solid var(--primary-rgba-3); */
    /* border-bottom: none; */
    border-radius: 25px 25px 0 0;
    padding: 12px 16px 8px 16px;
    margin-bottom: 0;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

/* ===== FEEDBACK DE PROCESSAMENTO DE ARQUIVOS ===== */
.file-processing-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    /* Mesma margem/fonte do bloco de pensamento (.thinking-simple margin:12px 0,
       header font-size:16px) pra todos os indicadores ficarem ALINHADOS no fluxo:
       Analisando imagem… → Pensando… → dots, tudo na mesma posição horizontal. */
    margin: 12px 0;
    padding: 0;
    color: var(--text-secondary);
    font-size: 16px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.file-processing-text {
    font-style: italic;
    animation: file-processing-pulse 2s ease-in-out infinite;
}

@keyframes file-processing-pulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* Container expandido - sem borda superior para criar continuidade visual */
.main-input-section:has(.attached-files-section[style*="block"]) .main-input-container {
    border-radius: 0 0 25px 25px;
    border-top: none;
    padding-top: 8px;
}

.chat-input-area:has(.attached-files-section[style*="block"]) .chat-input-container {
    border-radius: 0 0 25px 25px;
    border-top: none;
    padding-top: 8px;
}

/* Fallback para navegadores que não suportam :has() */
.main-input-container.expanded-container {
    border-radius: 0 0 25px 25px;
    border-top: none;
    padding-top: 8px;
}

.chat-input-container.expanded-container {
    border-radius: 0 0 25px 25px;
    border-top: none;
    padding-top: 8px;
}

.attached-files-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attached-file-item {
    display: inline-flex;
    align-items: center;
    background: var(--rgba-white-1);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 19px;
    color: var(--text-primary);
    max-width: 200px;
}

.attached-file-icon {
    width: 14px;
    height: 14px;
    margin-right: 6px;
    opacity: 0.7;
}

.attached-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attached-file-remove {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    margin-left: 21px;
    padding: 0;
    width: 16px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.attached-file-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* ===== LOADING STATE PARA ARQUIVOS ===== */
.attached-file-item.loading {
    background: var(--rgba-white-05);
    border: 1px solid var(--rgba-white-1);
    opacity: 0.8;
}

.file-loading-spinner {
    width: 14px;
    height: 14px;
    margin-right: 6px;
}

.spinner {
    animation: spin 1s linear infinite;
}

/* @keyframes spin: duplicata exata removida; definicao mantida ao final do arquivo */

.file-processing-text {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    margin-left: 4px;
}

.attached-file-item.loading .attached-file-name {
    opacity: 0.7;
}

/* ===== THUMBNAIL DE IMAGEM ANEXADA (com loading por cima, estilo ChatGPT) ===== */
.attached-image-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--rgba-white-1);
    background: var(--rgba-white-05);
}

.attached-image-thumb .thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Overlay escuro + spinner por cima da foto enquanto carrega */
.attached-image-thumb .thumb-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(1px);
    backdrop-filter: blur(1px);
}

/* Spinner circular (anel girando) */
.thumb-spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

.thumb-spinner-dark {
    width: 14px;
    height: 14px;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.25);
    border-top-color: rgba(255, 255, 255, 0.8);
    margin-right: 6px;
}

/* Quando o upload termina, o overlay some (a thumb fica limpa) */
.attached-image-thumb:not(.loading) .thumb-loading-overlay {
    display: none;
}

/* Botão de remover (X) no canto da thumbnail final */
.thumb-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.attached-image-thumb:hover .thumb-remove {
    opacity: 1;
}

.thumb-remove:hover {
    background: rgba(0, 0, 0, 0.85);
}

/* No mobile (sem hover), o X fica sempre visível */
@media (hover: none) {
    .thumb-remove { opacity: 1; }
}

.file-type-badge {
    background: var(--rgba-white-1);
    border: 1px solid var(--rgba-white-2);
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 10px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.8);
    margin-left: 4px;
    text-transform: uppercase;
}

/* ===== ARQUIVOS NAS MENSAGENS ===== */
.message-attached-files {
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.message-file-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--rgba-white-1);
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
}

.message-file-icon {
    opacity: 0.7;
    flex-shrink: 0;
}

/* Miniatura de imagem dentro da bolha da mensagem do usuário (estilo ChatGPT) */
.message-image-thumb {
    width: 120px;
    max-width: 60vw;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--rgba-white-1);
}

.message-image-thumb img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 240px;
    object-fit: cover;
}

.message-file-name {
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-file-type {
    background: var(--rgba-white-15);
    border-radius: 8px;
    padding: 1px 4px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    opacity: 0.8;
}

.dropdown-content {
    position: absolute;
    bottom: 50px;
    right: 0;
    background: rgba(26, 26, 26, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
        border: 1px solid rgb(255 255 255 / 12%);
    border-radius: 12px;
    min-width: 200px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    z-index: var(--z-dropdown);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
}

.dropdown-content.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-section {
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-section:last-child {
    border-bottom: none;
}

/* .dropdown-item: definição consolidada mais abaixo (incluía border-radius). */

.dropdown-item:hover {
    background: var(--rgba-white-05);
}

.dropdown-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* ===== MENU DE ANEXO (bater foto / carregar arquivo) ===== */
.attach-menu {
    padding: 6px;
    min-width: 240px;
}

.attach-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.attach-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.attach-menu-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #f0f0f0);
}

.attach-menu-texts {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.attach-menu-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #f0f0f0);
}

.attach-menu-sub {
    font-size: 12px;
    color: var(--text-secondary, #8b8b8b);
    line-height: 1.2;
}

.dropdown-text {
    flex: 1;
    color: #e0e0e0;
    font-size: 15px;
    font-weight: 500;
}

.dropdown-toggle {
    width: 40px;
    height: 20px;
    background: #374151;
    border-radius: 10px;
    position: relative;
    transition: background-color 0.2s;
    cursor: pointer;
}

.dropdown-toggle.active {
    background: var(--primary-color);
}

.toggle-switch {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.dropdown-toggle.active .toggle-switch {
    transform: translateX(20px);
}

.config-icon svg {
    width: 16px;
    height: 16px;
    color: inherit;
}

/* ===== THINKING TOGGLE SÓBRIO ===== */
.thinking-control {
    display: flex;
    gap: 8px;
    width: 100%;
}

.thinking-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.status-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--primary-color);
    /* Cor sempre consistente */
}

/* Indicador visual mais sóbrio */
.dropdown-toggle {
    position: relative;
}

/* ===== THINKING TOGGLE ===== */
.thinking-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: all var(--theme-transition);
}

.thinking-setting:hover {
    background: var(--rgba-white-05);
    border-color: var(--primary-rgba-3);
}

.thinking-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.thinking-icon-wrapper {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.thinking-details {
    flex: 1;
}

.thinking-details h4 {
    margin: 0;
    color: #ffffff;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
}

.section-title {
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    opacity: 0.8;
}

/* SEÇÃO CONSOLIDADA - TITAN BUTTONS USANDO SISTEMA GLOBAL */
.titan-btn {
    width: 100%;
    padding: var(--btn-padding-lg);
    background: var(--btn-bg-alpha);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--btn-radius-normal);
    color: #e0e0e0;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 10px;
    gap: 10px;
}

.titan-btn:hover {
    background: var(--primary-rgba-1);
    border-color: var(--primary-rgba-3);
    color: #ffffff;
    transform: var(--btn-transform-hover);
}

.titan-btn:last-child {
    margin-bottom: 0;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: rgba(26, 26, 26, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 2px solid var(--primary-rgba-3);
    border-radius: 16px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 18px;
}

.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.shortcut-item kbd {
    background: var(--primary-rgba-1);
    border: 1px solid var(--primary-rgba-3);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--primary-color);
    font-family: monospace;
}

.shortcut-item span {
    color: #e0e0e0;
    font-size: 13px;
}

/* ===== ANIMAÇÕES ===== */

.typing-message .cursor-typing {
    display: inline-block;
    animation: blink 1s infinite;
    color: var(--primary-color);
    font-weight: bold;
    margin-left: 2px;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

.typing-content {
    min-height: 16px;
    line-height: 1.6;
}

/* ===== MODAL DE INFORMAÇÕES DO TITAN ===== */
.titan-info-modal {
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.titan-info-content {
    max-width: 500px;
    width: 90%;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 2px solid var(--primary-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    animation: slideIn 0.3s ease;
}

.titan-info-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.titan-info-logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.titan-info-title h2 {
    margin: 0;
    color: white;
    font-size: 20px;
    font-weight: 700;
}

.titan-info-title p {
    margin: 4px 0 0 0;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
}

.titan-info-body {
    padding: 24px;
}

.info-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.info-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--rgba-white-1);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
}

.info-card:hover {
    background: var(--rgba-white-05);
    border-color: var(--primary-rgba-3);
    transform: translateY(-2px);
}

.info-icon {
    font-size: 24px;
    width: 32px;
    text-align: center;
}

.info-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-details strong {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
}

.info-details span {
    color: #999;
    font-size: 13px;
}

.titan-features {
    margin-bottom: 24px;
}

.titan-features h4 {
    color: #ffffff;
    font-size: 16px;
    margin: 0 0 16px 0;
    font-weight: 600;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    font-size: 13px;
    color: #d1d1d1;
}

.feature-icon {
    font-size: 16px;
}

.titan-description {
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    border-left: 4px solid var(--primary-color);
}

.titan-description p {
    margin: 0;
    color: #d1d1d1;
    font-size: 14px;
    line-height: 1.5;
}

.titan-info-footer {
    text-align: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* .dropdown-item { position: relative } consolidado na definição principal. */

/* ===== BOTÕES DE AÇÃO DAS MENSAGENS ===== */
/* Container fixo para evitar quebras de layout */
.message-actions-container {
    position: relative;
    height: 40px;
    /* Altura fixa reservada para os botões */
    margin-top: 8px;
    width: 100%;
}

.message-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.5;  /* Sempre discreto */
    margin-top: 5px;
}

/* Hover removido - manter discreto sempre */

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #6b7280;  /* Mais discreto */
    cursor: pointer;
    user-select: none;
    font-family: inherit;
    position: relative;
    padding: 0;
}

/* Hover removido - sem efeitos visuais */
.action-btn:hover {
    color: #9ca3af;  /* Apenas leve mudança de cor */
}

.action-btn.active {
    color: var(--primary-color);
    background: var(--primary-rgba-1);
}

.action-btn.liked {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.action-btn.disliked {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.action-btn.copied {
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.action-btn-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    transition: all 0.2s ease;
}

.action-btn-text {
    display: none;
}

/* Animações */
/* @keyframes spin: duplicata exata removida; definicao mantida ao final do arquivo */

@keyframes actionFeedback {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

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

.action-btn.animate {
    animation: actionFeedback 0.3s ease;
}

/* Tooltips */
.action-btn {
    position: relative;
}

/* ===== RESPONSIVO MOBILE MODERNO ===== */

/* Safe Area Support */
html {
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

/* SEÇÃO DUPLICADA REMOVIDA - JÁ CONSOLIDADA NO SISTEMA RESPONSIVO GLOBAL */

/* ===== THINKING CONTAINER ===== */
.thinking-container {
    margin-bottom: 10px;
}

.thinking-scroll {
    font-size: 12px;
    max-height: 200px;
}

/* ===== MESSAGE ACTIONS ===== */
.message-actions-container {
    height: 36px;
    /* Altura reduzida para mobile */
    margin-top: 6px;
}

.message-actions {
    gap: 8px;
}

/* SEÇÃO DUPLICADA REMOVIDA - AÇÕES DE MENSAGEM JÁ ESTÃO NO SISTEMA GLOBAL */

.action-btn {
    width: 44px;
    height: 44px;
}

.action-btn-icon svg {
    width: 20px;
    height: 20px;
}

/* ===== DROPDOWN MOBILE ===== */
.dropdown-content {
    bottom: 45px;
    right: -2;
    min-width: 188px;
}

/* ===== SIDEBAR DE HISTÓRICO ===== */

/* Botão toggle da sidebar - Estilo Claude/GPT */
/* Botão de abrir a sidebar — clean estilo Apple: sem caixa/borda,
   só o ícone discreto que ganha um leve fundo arredondado no hover. */
.sidebar-toggle {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 38px;
    height: 38px;
    background: transparent;
    border: none !important;
    border-radius: 10px;
    color: var(--text-secondary, #b5b5b5) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease, opacity 0.2s ease;
    z-index: var(--z-floating-ui);
    box-shadow: none;
    opacity: 1;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary, #ffffff) !important;
}

.sidebar-toggle:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.10);
}

.sidebar-toggle.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

.sidebar-toggle svg {
    width: 22px;
    height: 22px;
    transition: transform 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Container da sidebar */
.history-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100vh;          /* fallback navegadores antigos */
    height: 100dvh;         /* Safari iOS: não corta na barra inferior */
    background: #181818;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;

    /* Animação suave igual Claude/GPT */
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    transition:
        transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
        opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
        visibility 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
}

.history-sidebar.visible {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    z-index: var(--z-overlay);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.3s cubic-bezier(0.4, 0.0, 0.2, 1),
        visibility 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Header da sidebar */
.sidebar-header {
    padding: 18px 16px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.2px;
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-secondary, #9ca3af);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* "Nova Conversa" — estilo Gemini: linha com ícone à esquerda, não botão cheio */
.sidebar-controls {
    padding: 2px 8px;
    flex-shrink: 0;
}

.sidebar-btn {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: flex-start;   /* alinhado à esquerda, igual Gemini */
    gap: 12px;
    border: none;
    background: transparent;
    color: var(--text-primary, #f0f0f0);
}

.sidebar-btn svg {
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-btn.primary {
    background: transparent;
    color: var(--text-primary, #f0f0f0);
}

.sidebar-btn:hover,
.sidebar-btn.primary:hover {
    background: rgba(255, 255, 255, 0.06);
    filter: none;
    transform: none;
}

/* Busca */
.sidebar-search {
    padding: 4px 12px 8px;
    flex-shrink: 0;
}

.search-input {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 14px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.search-input::placeholder { color: var(--text-secondary, #8b8b8b); }

.search-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Cabeçalho de seção "Recentes" (estilo Gemini) */
.sidebar-section-label {
    padding: 14px 16px 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #8b8b8b);
    letter-spacing: 0.2px;
    flex-shrink: 0;
}

/* Esconde o label "Recentes" quando a lista está vazia (sem conversas/busca) */
.history-sidebar:has(#historyList .empty-history) .sidebar-section-label,
.history-sidebar:has(#historyList:empty) .sidebar-section-label {
    display: none;
}

/* ===================== SIDEBAR DE HISTÓRICO — MODERNO MINIMALISTA ===================== */
/* Conteúdo da sidebar (lista de chats) */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;   /* momentum scroll no iOS */
    overscroll-behavior: contain;
    padding: 8px 8px 12px;
    /* Scrollbar discreta (Firefox) */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}
.sidebar-content::-webkit-scrollbar { width: 8px; }
.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.sidebar-content::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); background-clip: padding-box; }

/* Estado vazio — ícone + texto */
.empty-history {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary, #8b8b8b);
    gap: 6px;
}
.empty-history::before {
    content: "";
    width: 44px;
    height: 44px;
    margin-bottom: 6px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    /* balão de conversa em SVG (currentColor herda a cor do texto) */
    -webkit-mask: center / 22px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/%3E%3C/svg%3E");
    mask: center / 22px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z'/%3E%3C/svg%3E");
    background-color: var(--text-secondary, #8b8b8b);
    background-repeat: no-repeat;
    opacity: 0.6;
}
.empty-history p { margin: 0; font-size: 14px; line-height: 1.5; }
.empty-history p:first-of-type { color: var(--text-primary, #f0f0f0); font-weight: 500; }

/* Item de conversa — sem "caixa", arejado, 2 linhas (título + preview) */
.chat-history-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 9px 10px;
    border-radius: 10px;
    margin-bottom: 2px;
    cursor: pointer;
    position: relative;
    background: transparent;
    border: none;
    box-shadow: none;
    transition: background 0.15s ease;
}

.chat-history-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.chat-history-item.active {
    background: rgba(255, 255, 255, 0.10);
}
/* faixinha sutil na cor primária no item ativo */
.chat-history-item.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    border-radius: 0 3px 3px 0;
    background: var(--primary-color);
}

/* ===== LOADING GLOW EFFECT ===== */
.chat-history-item.loading {
    overflow: hidden;
    background: var(--primary-rgba-1);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

.chat-history-item.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--primary-glow), transparent);
    animation: shimmer 1.2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: inset 0 0 0 1px var(--primary-rgba-3); }
    50% { box-shadow: inset 0 0 0 1px var(--primary-glow); }
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Wrapper do conteúdo clicável (título + preview empilhados) */
.chat-content-wrapper {
    flex: 1;
    min-width: 0;          /* permite o ellipsis funcionar */
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item-header {
    display: flex;
    align-items: center;
    min-width: 0;
}

.chat-title {
    font-weight: 500;
    color: var(--text-primary, #f0f0f0);
    font-size: 14px;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

/* Preview da conversa (2ª linha) */
.chat-preview-enhanced { min-width: 0; }
.chat-preview-enhanced .preview-main {
    font-size: 12px;
    line-height: 1.3;
    color: var(--text-secondary, #8b8b8b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* (Regras antigas .chat-preview-enhanced{display:none}, .preview-main, .preview-context,
   .chat-meta-enhanced removidas — escondiam o preview e conflitavam com o layout
   minimalista de 2 linhas definido acima.) */

/* Menu de contexto estilo ChatGPT */
.chat-menu {
    display: flex;
    align-items: center;
    opacity: 0;
    /* Oculto por padrão - aparece no hover (desktop) */
    position: relative;
    transition: opacity 0.15s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.chat-history-item:hover .chat-menu,
.chat-history-item.active .chat-menu {
    opacity: 1;
}

/* Em telas touch (sem hover), o menu fica sempre visível */
@media (hover: none) {
    .chat-menu { opacity: 1; }
}

/* Quando dropdown está aberto, manter item destacado e menu visível */
.chat-history-item.dropdown-open {
    background: rgba(255, 255, 255, 0.10);
}

.chat-history-item.dropdown-open .chat-menu {
    opacity: 1 !important;
}

.menu-toggle {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* Menu sempre visível - não precisa mais hover */
/* .chat-history-item:hover .chat-menu {
    opacity: 1;
} */

/* ===== DROPDOWN STYLE MELHORADO ===== */
.chat-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: rgba(26, 26, 26, 0.98);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    min-width: 180px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.6),
        0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: var(--z-dropdown);
    margin-top: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 8px 0;
    overflow: hidden;
}

.chat-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;   /* herdado da definição antiga (consolidado aqui) */
    font-size: 14px;
    font-weight: 500;
    color: #e5e7eb;
    cursor: pointer;
    transition: all 0.15s ease-out;
    user-select: none;
    position: relative;
}

.dropdown-item:hover {
    background: var(--rgba-white-05);
    color: #f3f4f6;
}

.dropdown-item.delete-item:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.dropdown-item svg {
    opacity: 0.9;
    flex-shrink: 0;
    transition: opacity 0.15s ease-out;
}

.dropdown-item:hover svg {
    opacity: 1;
}

/* Responsividade mobile para dropdown */
@media (max-width: 768px) {
    .chat-dropdown {
        min-width: 200px;
        margin-top: 8px;
        border-radius: 16px;
        -webkit-backdrop-filter: blur(20px);
        backdrop-filter: blur(20px);
    }

    .dropdown-item {
        padding: 16px 20px;
        font-size: 16px;
        gap: 16px;
    }
}

/* (Duplicatas de .chat-history-item e .chat-content-wrapper removidas —
   já definidas na seção principal acima.) */

.overlay-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--rgba-white-1);
    border: 1px solid var(--rgba-white-2);
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
    justify-content: center;
}

.overlay-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.overlay-action-btn.delete-btn {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
}

.overlay-action-btn.delete-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.6);
    color: #ff6b6b;
}

/* Footer da sidebar - Seção do usuário - MODERNA */
.sidebar-footer {
    padding: 8px;
    /* Safari iOS: respeitar a barra inferior / notch */
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    background: transparent;
}

.user-section {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 12px;
    /* sem hover no card inteiro — o hover fica só no botão de 3 pontinhos */
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #000;
    text-transform: uppercase;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

/* Row para nome + botão editar na sidebar */
.user-name-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Botão de editar nome da sidebar removido */

.user-plan {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.user-plan.pro {
    color: #10b981;
    font-weight: 600;
}

.user-plan.free {
    color: #6b7280;
}

/* Model Selector - Design Limpo */
/* Seletor de modelo — mesma pegada clean do botão de anexar (.config-btn):
   sem caixa, leve fundo arredondado no hover. Alinhado ao botão ☰ (top:16px). */
.model-selector {
    position: fixed;
    top: 16px;
    left: 60px;
    height: 38px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-primary, #ffffff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
    font-size: 16px;
    font-weight: 600;
    z-index: var(--z-floating-ui);
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

/* Nome do modelo no seletor: forte. Nível de reasoning ao lado: mais clarinho
   e leve, pra não competir com o nome (ex: "Aether · Estendido"). */
.model-selector .model-name-strong {
    font-weight: 700;
}
.model-selector .model-level {
    font-weight: 400;
    color: var(--text-tertiary, rgba(255, 255, 255, 0.45));
}

/* Wrapper do seletor dentro da barra (estilo Gemini): âncora relative à direita.
   Solto no topo (fora da barra) ele é só um container transparente. */
.model-selector-wrap {
    display: inline-flex;
    align-items: center;
}

.model-selector-wrap.in-bar {
    position: relative;
    flex-shrink: 0;
    text-align: left;        /* o dropdown NÃO herda center do button */
}

/* O botão, quando na barra: inline, compacto */
.model-selector-wrap.in-bar .model-selector {
    position: static;
    top: auto;
    left: auto;
    height: 34px;
    padding: 0 10px;
    font-size: 14px;
    z-index: auto;
}

/* O dropdown abre PRA CIMA, ancorado no wrapper (a barra fica embaixo). */
.model-selector-wrap.in-bar .model-dropdown {
    position: absolute;
    top: auto;
    left: auto;
    bottom: calc(100% + 10px);
    right: 0;
    text-align: left;
    font-size: 14px;
    font-weight: 400;
}

.model-selector:hover {
    background: rgba(255, 255, 255, 0.07);
}

.model-selector:active {
    background: rgba(255, 255, 255, 0.10);
}

/* a setinha do dropdown mais discreta */
.model-selector svg {
    opacity: 0.6;
    transition: transform 0.2s ease;
}
.model-selector:hover svg { opacity: 0.9; }

/* ===== UPGRADE HEADER BUTTON ===== */
.upgrade-header-btn {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    /* Centraliza horizontalmente */
    height: 40px;
    background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 20px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    font-size: 15px;
    font-weight: 600;
    min-width: 100px;
    z-index: var(--z-floating-ui);
}

.upgrade-header-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #9333ea 100%);
}

.upgrade-header-btn .upgrade-icon {
    flex-shrink: 0;
}

.upgrade-header-btn span {
    font-weight: 600;
    letter-spacing: 0.025em;
}

/* SEÇÃO REMOVIDA - UPGRADE BUTTON JÁ TRATADO NO SISTEMA GLOBAL */

/* Model Dropdown */
/* Dropdown de seleção de modelo — clean, badges discretas */
.model-dropdown {
    position: fixed;
    top: 60px;
    left: 60px;
    background: #202020;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    z-index: var(--z-dropdown);
    min-width: 270px;
    /* overflow visible: o flyout lateral do "Nível de raciocínio" sai pra fora.
       Os cantos dos itens já são arredondados individualmente. */
    overflow: visible;
    padding: 6px;
    animation: fadeInScale 0.15s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(-6px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.model-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
    border: none;
}

.model-option:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* Check (✓) estilo Gemini: à esquerda, visível só na opção selecionada.
   A .model-info expande pra empurrar a badge pra direita. */
.model-check {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary, #f0f0f0);
    opacity: 0;
    transition: opacity 0.12s ease;
}

.model-option.selected > .model-check,
.reasoning-submenu.selected-level .reasoning-submenu-trigger > .model-check,
.reasoning-flyout-item.selected > .model-check {
    opacity: 1;
}

.model-option > .model-info,
.reasoning-submenu-trigger > .model-info,
.reasoning-flyout-item > .model-info {
    flex: 1;
}

.model-option.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.model-option.disabled:hover {
    background: transparent;
}

.model-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.model-name {
    color: var(--text-primary, #f0f0f0);
    font-weight: 600;
    font-size: 14px;
}

.model-desc {
    color: var(--text-secondary, #8b8b8b);
    font-size: 12px;
    line-height: 1.3;
}

/* Badges discretas (sem rosa berrante): fundo translúcido + texto colorido */
.model-badge {
    flex-shrink: 0;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary, #b5b5b5);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* "Pro" recebe um toque da cor primária; "Local" fica neutro */
.model-badge.badge-pro,
.model-option[data-model="pro"] .model-badge {
    background: var(--primary-rgba-1, rgba(255,255,255,0.12));
    color: var(--primary-color, #fff);
    border-color: var(--primary-rgba-3, rgba(255,255,255,0.2));
}

/* ===== NÍVEL DE RACIOCÍNIO: SUBMENU LATERAL (estilo Gemini, só LPM Local) ===== */
.reasoning-submenu {
    position: relative;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* A linha "Nível de raciocínio › Estendido" dentro do dropdown de modelo */
.reasoning-submenu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.reasoning-submenu-trigger:hover {
    background: rgba(255, 255, 255, 0.06);
}

.reasoning-submenu-arrow {
    flex-shrink: 0;
    color: var(--text-secondary, #8b8b8b);
    opacity: 0.7;
}

/* O flyout que abre ao lado (à direita do dropdown de modelo) */
.reasoning-flyout {
    position: absolute;
    top: -6px;
    left: calc(100% + 8px);
    min-width: 250px;
}

/* Quando o dropdown está na barra (abre à direita da tela), o flyout vai pra
   ESQUERDA pra não sair da viewport. */
.model-selector-wrap.in-bar .reasoning-flyout {
    left: auto;
    right: calc(100% + 8px);
    transform: translateX(6px);
}
.model-selector-wrap.in-bar .reasoning-submenu:hover .reasoning-flyout,
.model-selector-wrap.in-bar .reasoning-submenu.flyout-open .reasoning-flyout {
    transform: translateX(0);
}

.reasoning-flyout {
    background: #202020;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    padding: 6px;
    z-index: var(--z-popover);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

/* Abre por HOVER no submenu (desktop) OU por classe .flyout-open (clique/mobile) */
.reasoning-submenu:hover .reasoning-flyout,
.reasoning-submenu.flyout-open .reasoning-flyout {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.reasoning-flyout-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.reasoning-flyout-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* ===== MODEL UPGRADE OPTION ===== */
.model-upgrade-option {
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
}

.model-upgrade-option:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(168, 85, 247, 0.2) 100%);
}

.model-upgrade-option .upgrade-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-upgrade-option .upgrade-icon {
    color: #8b5cf6;
    flex-shrink: 0;
}

.model-upgrade-option .upgrade-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-upgrade-option .upgrade-title {
    color: #8b5cf6;
    font-weight: 600;
    font-size: 14px;
}

.model-upgrade-option .upgrade-desc {
    color: rgba(139, 92, 246, 0.8);
    font-size: 12px;
    line-height: 1.3;
}

.user-menu-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary, #9ca3af);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-menu-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.user-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    background: #1f1f1f;
    border: 1px solid var(--rgba-white-1);
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: var(--z-dropdown);
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.2s ease;
}

.user-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu-item {
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: #e5e7eb;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
}

.user-menu-item:hover {
    background: var(--rgba-white-1);
    color: #f3f4f6;
}

.user-menu-item.logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Admin button styles moved to billing.css */

/* Esconder botões específicos por padrão - JavaScript controla visibilidade */
#manageSubscriptionBtn,
#upgradeBtn {
    display: none;
}

.user-menu-item:first-child {
    border-radius: 8px 8px 0 0;
}

.user-menu-item:last-child {
    border-radius: 0 0 8px 8px;
}

/* Regras genéricas de estatísticas (usadas no painel de configurações e na
   moderação). Mantidas aqui — as classes .stat-* são VIVAS. */
.stat-item,
.date-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.stat-label,
.date-label {
    color: #9ca3af;
}

.stat-value,
.date-value {
    color: #e0e0e0;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--rgba-white-1);
    color: white;
    border: 1px solid var(--rgba-white-2);
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Responsividade da Sidebar */

.modal-close {
    background: none;
    border: none;
    color: #999;
    font-size: 28px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.2s ease;
    margin-left: auto;
}

.modal-close:hover {
    color: #fff;
    background: var(--rgba-white-1);
}

.simple-close {
    background: none;
    border: none;
    color: #999;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.simple-close:hover {
    color: #fff;
}

.simple-modal-body {
    padding: 8px 24px 20px 24px;
}

.modal-message {
    color: #e0e0e0;
    font-size: 15px;
    line-height: 1.5;
    margin: 0 0 12px 0;
}

.modal-subtitle {
    color: #999;
    font-size: 13px;
    margin: 8px 0 0 0;
    opacity: 0.8;
}

.modal-label {
    display: block;
    color: #fff;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.modal-input {
    width: 100%;
    background: var(--rgba-white-05);
    border: 2px solid var(--primary-rgba-3);
    color: #fff;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px var(--primary-rgba-1);
}

.modal-input::placeholder {
    color: #666;
    font-style: italic;
}

.simple-field {
    margin-bottom: 20px;
}

.simple-field label {
    display: block;
    color: #fff;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.simple-field input,
.simple-field textarea {
    width: 100%;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #fff;
    padding: 12px;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.simple-field input:focus,
.simple-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.simple-field textarea {
    resize: vertical;
    min-height: 120px;
}

.simple-field small {
    color: #999;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.simple-modal-footer {
    padding: 16px 24px 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.simple-btn {
    padding: 12px 24px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.simple-btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
    border-color: rgba(255, 255, 255, 0.1);
}

.simple-btn-secondary:hover {
    background: var(--rgba-white-15);
    color: #ffffff;
    transform: translateY(-1px);
}

.simple-btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px var(--primary-rgba-3);
}

.simple-btn-primary:hover {
    box-shadow: 0 6px 20px var(--primary-rgba-5);
    transform: translateY(-1px);
}

.simple-btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.simple-btn-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
    transform: translateY(-1px);
}

.simple-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== AVISO IMPORTANTE DO CHAT ===== */
.chat-disclaimer {
    padding: 12px 20px;
    text-align: center;
    background: transparent;
}

.chat-disclaimer p {
    margin: 0;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 400;
    opacity: 0.7;
    line-height: 1.3;
}

/* ===== INDICADOR DE DIGITAÇÃO MODERNO ===== */
/* Indicador de "gerando resposta": 3 pontinhos pulsando (typing indicator).
   Mostra que o modelo recebeu o pedido e está respondendo; some ao finalizar. */
.streaming-cursor {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 12px 0;   /* alinhado com .thinking-simple e .file-processing-feedback */
    height: 16px;
}
.streaming-cursor span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary, #b5b5b5);
    animation: typingDot 1.3s infinite ease-in-out;
}
.streaming-cursor span:nth-child(2) { animation-delay: 0.18s; }
.streaming-cursor span:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingDot {
    0%, 70%, 100% { opacity: 0.3; transform: translateY(0); }
    35% { opacity: 1; transform: translateY(-3px); }
}

.simple-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.8) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    backdrop-filter: blur(10px) !important;
    z-index: var(--z-modal) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0 !important;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1) !important;
}

.simple-modal.modal-show {
    opacity: 1;
}

.simple-modal.modal-closing {
    opacity: 0;
}

.simple-modal-content {
    background: var(--bg-dark);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.simple-modal.modal-show .simple-modal-content {
    transform: scale(1) translateY(0);
}

.simple-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.simple-modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.simple-modal-header h3::before {
    content: "💬";
    font-size: 24px;
}

.simple-close {
    background: var(--rgba-white-1);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 20px;
    transition: all 0.2s ease;
}

.simple-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.simple-modal-body {
    padding: 32px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.simple-field {
    margin-bottom: 20px;
}

.simple-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 8px;
}

.simple-field input,
.simple-field textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--rgba-white-05);
    border: 1px solid var(--rgba-white-1);
    border-radius: 10px;
    color: #ffffff;
    font-size: 14px;
    transition: all 0.2s ease;
    resize: none;
    font-family: inherit;
}

.simple-field input:focus,
.simple-field textarea:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    background: rgba(255, 255, 255, 0.08);
}

.simple-field input::placeholder,
.simple-field textarea::placeholder {
    color: #888;
}

.simple-field textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}

.simple-field small {
    display: block;
    text-align: right;
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.simple-modal-footer {
    display: flex;
    gap: 12px;
    padding: 24px 32px;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.simple-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    border: none;
}

.simple-btn-cancel {
    background: var(--rgba-white-05);
    color: #e0e0e0;
    border: 1px solid var(--rgba-white-2);
}

.simple-btn-cancel:hover {
    background: var(--rgba-white-1);
    border-color: var(--rgba-white-3);
    color: #ffffff;
}

.simple-btn-primary {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.simple-btn-primary:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.simple-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ===== MODAL DE FEEDBACK - IMPLEMENTAÇÃO LIMPA ===== */
.feedback-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--rgba-black-8);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: var(--z-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.feedback-modal-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.feedback-modal {
    background: var(--bg-dark);
    border: 1px solid var(--rgba-white-1);
    border-radius: 20px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.feedback-modal-overlay.show .feedback-modal {
    transform: scale(1) translateY(0);
}

.feedback-modal-header {
    text-align: center;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 16px;
}

.feedback-modal-header h3 {
    font-size: 24px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.feedback-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 50%;
    color: white;
    font-size: 20px;
}

.feedback-modal-body {
    margin-bottom: 32px;
}

.feedback-modal-body p {
    font-size: 16px;
    color: #e0e0e0;
    line-height: 1.5;
    margin: 0 0 8px 0;
    text-align: center;
}

.feedback-modal-subtitle {
    font-size: 14px;
    color: #a0a0a0;
    margin: 0 0 24px 0;
    text-align: center;
}

.feedback-field {
    margin-bottom: 20px;
}

.feedback-field label {
    display: block;
    color: #fff;
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 500;
}

.feedback-field input,
.feedback-field textarea {
    width: 100%;
    background: var(--rgba-white-05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    transition: all 0.2s ease;
    resize: vertical;
}

.feedback-field input:focus,
.feedback-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.feedback-field input::placeholder,
.feedback-field textarea::placeholder {
    color: #666;
    font-style: italic;
}

.feedback-field small {
    color: #999;
    font-size: 12px;
    margin-top: 4px;
    display: block;
    text-align: right;
}

.feedback-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.feedback-btn-cancel,
.feedback-btn-confirm {
    padding: 12px 24px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 120px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.feedback-btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: #d1d5db;
    border-color: rgba(255, 255, 255, 0.1);
}

.feedback-btn-cancel:hover {
    background: var(--rgba-white-15);
    color: #ffffff;
    transform: translateY(-1px);
}

.feedback-btn-confirm {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #ffffff;
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.feedback-btn-confirm:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
    transform: translateY(-1px);
}

.feedback-btn-confirm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* =================== CODE BLOCKS - ULTRA SIMPLIFICADO =================== */

.code-block {
    position: relative;
    background: #1e1e1e;
    border-radius: 8px;
    margin: 1.5rem 0;
    padding: 3rem 1.25rem 1.25rem;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #ececf1;
    border: 1px solid #2d2d2d;
}

/* Label da linguagem usando ::before */
.code-block::before {
    content: attr(data-lang);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 0.6rem 0.75rem;
    background: #1e1e1e;
    border-bottom: 1px solid #2d2d2d;
    /* font-size: 0.75rem; */
    /* font-weight: 500; */
    text-transform: uppercase;
    /* letter-spacing: 0.05em; */
    /* color: #9ca3af; */
    /* text-align: left; */
}

.code-block code {
    display: block;
    white-space: pre;
    color: inherit;
    background: transparent;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
}

.code-block .copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: #2d2d2d;
    border: 1px solid #404040;
    color: #ececf1;
    cursor: pointer;
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    z-index: var(--z-base);
}

.code-block .copy-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Scrollbar */
.code-block::-webkit-scrollbar {
    height: 8px;
}

.code-block::-webkit-scrollbar-track {
    background: #0a0a0a;
    border-radius: 4px;
}

.code-block::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 4px;
}

.code-block::-webkit-scrollbar-thumb:hover {
    background: #525252;
}

/* Streaming indicator */
.streaming-indicator {
    position: absolute;
    top: 0.6rem;
    right: 0.75rem;
    color: #9ca3af;
    font-size: 0.75rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.inline-code {
    background: var(--inline-code-bg, #f1f5f9);
    color: var(--inline-code-text, #e11d48);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', 'Monaco', 'Cascadia Code', 'Roboto Mono', monospace;
    font-size: 0.9em;
    border: 1px solid var(--border-color, #e5e7eb);
}

/* =================== SYNTAX HIGHLIGHTING UNIVERSAL =================== */
/* IMPORTANTE: Cores diretas com !important para garantir aplicação */

/* Keywords - Roxo suave */
.code-block code .token.keyword,
.token.keyword {
    color: #C678DD !important;
    font-weight: 600;
}

/* Strings - Verde claro */
.code-block code .token.string,
.token.string {
    color: #98C379 !important;
}

/* Comentários - Cinza escuro itálico */
.code-block code .token.comment,
.token.comment {
    color: #5C6370 !important;
    font-style: italic;
    opacity: 0.8;
}

/* Funções built-in - Ciano */
.code-block code .token.function,
.token.function {
    color: #56B6C2 !important;
}

/* Números - Amarelo */
.code-block code .token.number,
.token.number {
    color: #E5C07B !important;
}

/* Constantes (True, False, None) - Azul claro */
.code-block code .token.builtin,
.token.builtin {
    color: #61AFEF !important;
    font-weight: 600;
}

/* Operadores - Cinza claro */
.code-block code .token.operator,
.token.operator {
    color: #ABB2BF !important;
}

/* Métodos mágicos (__init__, __main__) - Laranja queimado */
.code-block code .token.magic,
.token.magic {
    color: #D19A66 !important;
    font-weight: 600;
}

/* self - Vermelho suave */
.code-block code .token.self,
.token.self {
    color: #E06C75 !important;
    font-weight: 600;
}

/* HTML/CSS específicos */
.code-block code .token.tag,
.token.tag {
    color: #ff5555 !important;
}

.code-block code .token.attr-name,
.token.attr-name {
    color: #ff79c6 !important;
}

.code-block code .token.attr-value,
.token.attr-value {
    color: #50fa7b !important;
}

.code-block code .token.property,
.token.property {
    color: #ff5555 !important;
}

.code-block code .token.selector,
.token.selector {
    color: #ff79c6 !important;
}

.code-block code .token.class-name,
.token.class-name {
    color: #bd93f9 !important;
    font-weight: 600;
}

.token.value {
    color: var(--syntax-value, #059669);
}

/* =================== MARKDOWN TABLES =================== */
.markdown-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 16px 0;
    border-radius: 8px;
    background: #1e1e1e;
    border: 1px solid #333;
}

.markdown-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #e6e6e6;
}

.markdown-table thead {
    background: #2a2a2a;
    border-bottom: 2px solid #444;
}

.markdown-table th {
    padding: 12px 16px;
    font-weight: 600;
    text-align: left;
    color: #ffffff;
    border-right: 1px solid #333;
}

.markdown-table th:last-child {
    border-right: none;
}

.markdown-table tbody tr {
    border-bottom: 1px solid #333;
    transition: background 0.2s ease;
}

.markdown-table tbody tr:hover {
    background: #252525;
}

.markdown-table tbody tr:last-child {
    border-bottom: none;
}

.markdown-table td {
    padding: 10px 16px;
    text-align: left;
    border-right: 1px solid #333;
}

.markdown-table td:last-child {
    border-right: none;
}

/* Zebra striping para melhor legibilidade */
.markdown-table tbody tr:nth-child(even) {
    background: #1a1a1a;
}

.markdown-table tbody tr:nth-child(even):hover {
    background: #252525;
}

/* Scrollbar horizontal para tabelas grandes */
.markdown-table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.markdown-table-wrapper::-webkit-scrollbar-track {
    background: #0a0a0a;
    border-radius: 4px;
}

.markdown-table-wrapper::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 4px;
}

.markdown-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #525252;
}

/* Responsivo mobile */
@media (max-width: 768px) {
    .markdown-table {
        font-size: 12px;
    }

    .markdown-table th,
    .markdown-table td {
        padding: 8px 12px;
    }
}

/* Tabela em modo streaming - feedback visual */
.markdown-table-wrapper.streaming-table {
    position: relative;
}

.markdown-table-wrapper.streaming-table::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #4ade80, transparent);
    animation: tableStreamingPulse 1.5s ease-in-out infinite;
}

@keyframes tableStreamingPulse {
    0%, 100% {
        opacity: 0.3;
        transform: translateX(-100%);
    }
    50% {
        opacity: 1;
        transform: translateX(100%);
    }
}

/* =================== MODAL DE LIMITE ESGOTADO =================== */
.limit-exceeded-modal {
    position: fixed;
    bottom: 124px;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    max-width: 1000px;
    z-index: var(--z-critical);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease-out;
}

.limit-exceeded-modal.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) scale(1);
}

.limit-modal-content {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
}

/* .limit-controls / -left / -right: 1as definições removidas (eram sobrescritas
   pelas definições mais abaixo no arquivo; a 1a tinha gap:231px, claramente lixo).
   As definições válidas seguem mais adiante neste arquivo. */

.limit-close-btn {
    background: none;
    border: none;
    color: #6b7280;
    font-size: 24px;
    font-weight: bold;
    cursor: not-allowed;
    padding: 0;
    margin: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    opacity: 0.5;
}

.limit-close-btn:hover {
    color: #ef4444;
    opacity: 0.7;
}

.limit-upgrade-btn {
    background: linear-gradient(135deg, var(--primary-dark) 100%);
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-weight: 600;
    transition: all 0.2s ease;
    text-align: center;
    min-width: 70px;
    height: 36px;
}

.limit-upgrade-btn:hover {
    background: var(--primary-color);
    transform: scale(1.05);
}

.upgrade-text {
    color: white;
    font-weight: 600;
    font-size: 12px;
}

@keyframes glowPulse {
    0% {
        background-position: 0% 50%;
        box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
    }

    50% {
        background-position: 100% 50%;
        box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
    }

    100% {
        background-position: 0% 50%;
        box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
    }
}

.limit-modal-body {
    max-width: 800px;
    width: 800px;
    margin: 0 auto;
    padding: 8px;
    background: rgba(26, 26, 26, 0.9);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 3px solid var(--primary-rgba-3);
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.limit-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
}

.limit-controls-left {
    flex: 1;
}

.limit-controls-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.limit-message {
    color: #e0e0e0;
    font-size: 14px;
    margin: 0;
    font-weight: 500;
}

.limit-message strong {
    color: #fef3c7;
    font-weight: 700;
}

/* .limit-reset-time: as duas definições conflitantes consolidadas numa só.
   A 2a vencia em cor/tamanho/align; o margin vinha da 1a (preservado aqui). */
.limit-reset-time {
    color: #d1d5db;
    font-size: 16px;
    text-align: left;
    margin: 2px 0 0 0;
}

@keyframes modalShake {

    0%,
    100% {
        transform: translateX(-50%) scale(1);
    }

    25% {
        transform: translateX(-50%) scale(1) translateX(5px);
    }

    75% {
        transform: translateX(-50%) scale(1) translateX(-5px);
    }
}

.limit-exceeded-modal.shake {
    animation: modalShake 0.3s ease-in-out;
}

/* Modal de Configurações - ANIMADO E VIVO */
.titan-settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--rgba-black-8);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    z-index: var(--z-critical);
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.titan-settings-overlay.active {
    display: flex;
    opacity: 1;
}

.titan-settings-modal {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 900px;
    height: 80vh;
    max-height: 700px;
    overflow: hidden;
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.08);
    transform: scale(1) translateY(0);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    position: relative;
}

/* Sidebar com navegação */
.titan-settings-sidebar {
    width: 240px;
    background: var(--bg-darker);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.titan-settings-nav {
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.titan-settings-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    border-radius: 0;
    position: relative;
    margin: 0 8px;
    border-radius: 8px;
}

.titan-settings-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary, #fff);
}

.titan-settings-nav-item.active {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
}

.titan-settings-nav-item.active svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.titan-settings-nav-item svg {
    flex-shrink: 0;
    transition: all 0.3s ease;
}

/* Container principal com layout lateral */
.titan-settings-container {
    display: flex;
    height: calc(80vh - 64px);
    min-height: 400px;
    max-height: calc(700px - 64px);
    flex: 1;
}

/* Área de conteúdo */
.titan-settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    position: relative;
    -webkit-overflow-scrolling: touch;
    height: 100%;
}

/* Seções do conteúdo */
.titan-settings-section {
    display: none !important;
    padding: 28px 32px;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease-out;
}

.titan-settings-section.active {
    display: block !important;
    opacity: 1;
    transform: translateY(0);
    animation: sectionFadeIn 0.4s ease-out;
}

@keyframes sectionFadeIn {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Header das seções */
.titan-settings-section-header {
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.titan-settings-section-header h3 {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.titan-settings-section-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0;
    line-height: 1.5;
}

/* Header do Modal */
.titan-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-dark);
    position: relative;
}

.titan-settings-header h2 {
    font-family: "Inter", sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.titan-settings-close {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    position: relative;
    overflow: hidden;
}

/* hover removido */

.titan-settings-close:active {
    transform: scale(0.95);
}

/* Animações Keyframes */

/* ===== PROGRESS OVERLAY ===== */
.titan-progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-critical);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.titan-progress-overlay.show {
    opacity: 1;
    visibility: visible;
}

.titan-progress-content {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    min-width: 400px;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.titan-progress-content h3 {
    color: var(--text-primary);
    margin: 20px 0 30px 0;
    font-size: 24px;
    font-weight: 600;
}

.titan-progress-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.titan-progress-steps {
    margin-top: 30px;
    text-align: left;
}

.titan-progress-step {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
    opacity: 0.5;
}

.titan-progress-step:last-child {
    border-bottom: none;
}

.titan-progress-step.active {
    opacity: 1;
    background: rgba(16, 185, 129, 0.05);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 0 -16px;
}

.titan-progress-step.completed {
    opacity: 0.8;
    background: rgba(16, 185, 129, 0.1);
}

.step-number {
    width: 30px;
    height: 30px;
    background: var(--border-color);
    color: var(--text-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.titan-progress-step.active .step-number {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.titan-progress-step.completed .step-number {
    background: #10b981;
    color: white;
}

.step-text {
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
}

.step-status {
    font-size: 16px;
    opacity: 0.7;
}

.titan-progress-step.active .step-status {
    opacity: 1;
    animation: pulse 1.5s infinite;
}

.titan-progress-step.completed .step-status {
    color: #10b981;
    opacity: 1;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===== CONTROLES REDESIGNADOS ===== */

/* Items de configuração melhorados */
.titan-settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 0;
    border-bottom: 1px solid var(--border-color);
    gap: 20px;
    position: relative;
}

.titan-settings-item:last-child { border-bottom: none; }

.titan-settings-item-danger {
    border-color: rgba(239, 68, 68, 0.2);
}

/* Info do item: título (bloco) + descrição (linha de baixo) — antes faltava CSS,
   por isso label e descrição apareciam grudados na mesma linha. */
.titan-settings-item-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}

.titan-settings-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary, #f0f0f0);
}

.titan-settings-description {
    display: block;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary, #8b8b8b);
}

.titan-settings-control {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

/* Formulário de alterar senha (seção Conta) */
.titan-password-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.titan-password-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.titan-password-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.titan-password-save-btn {
    align-self: flex-start;
    padding: 10px 18px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.titan-password-save-btn:hover {
    opacity: 0.9;
}

/* Grupos de botões de tema */
.titan-settings-theme-group {
    display: flex;
    gap: 8px;
    background: var(--bg-darker);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.titan-settings-theme-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 90px;
    justify-content: center;
}

.titan-settings-theme-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(240, 148, 10, 0.3);
    transform: scale(1.05);
}

/* REMOVIDO: Controle de tamanho de fonte - fonte agora é fixa em 17px desktop / 18px mobile */

/* Grupos de velocidade */
.titan-settings-speed-group {
    display: flex;
    gap: 6px;
    background: var(--bg-darker);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.titan-settings-speed-btn {
    padding: 10px 16px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 70px;
}

.titan-settings-speed-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(240, 148, 10, 0.3);
}

/* Botões de ação */
.titan-settings-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
    min-width: 110px;
    justify-content: center;
    white-space: nowrap;
}

/* Primário: cor sólida do tema, sem glow */
.titan-settings-btn-primary {
    background: var(--primary-color);
    color: #000;
}
.titan-settings-btn-primary:hover { filter: brightness(1.05); }

.titan-settings-btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary, #f0f0f0);
    border-color: rgba(255, 255, 255, 0.1);
}
.titan-settings-btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }

/* Perigo: discreto (texto/contorno vermelho); preenche no hover */
.titan-settings-btn-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}
.titan-settings-btn-danger:hover {
    background: rgba(239, 68, 68, 0.9);
    color: #fff;
    border-color: transparent;
}

/* Toggle switches melhorados */
.titan-settings-toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.titan-settings-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.titan-settings-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-darker);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
    border-radius: 28px;
}

.titan-settings-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background: var(--text-secondary);
    transition: all 0.3s ease;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.titan-settings-toggle input:checked+.titan-settings-slider {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(240, 148, 10, 0.2);
}

.titan-settings-toggle input:checked+.titan-settings-slider:before {
    transform: translateX(24px);
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ===== SEÇÃO CONTA ===== */

/* Card do usuário */
.titan-account-card {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.titan-account-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
}

.titan-account-avatar {
    position: relative;
}

.avatar-circle {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 700;
    position: relative;
}

.avatar-circle::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    padding: 2px;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: xor;
    -webkit-mask-composite: xor;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.titan-account-card:hover .avatar-circle::after {
    opacity: 1;
}

/* Nome do usuário com botão de edição */
.titan-account-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.titan-account-info h4 {
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.titan-edit-name-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0.7;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.titan-edit-name-btn:hover {
    opacity: 1;
    background: var(--background-secondary);
    color: var(--primary-color);
    transform: scale(1.1);
}

/* Animação de loading */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

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

.titan-account-info p {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 0 0 12px 0;
}

.titan-account-badge {
    background: rgba(167, 167, 167, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(218, 218, 218, 0.3);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

/* Estatísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
}

.stat-item {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 16px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(240, 148, 10, 0.1);
    transform: translateY(-2px);
}

.stat-number {
    display: block;
    color: var(--primary-color);
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Resumo das configurações */
.titan-account-settings-summary h5 {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px 0;
}

.settings-list {
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.setting-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.setting-summary-item:last-child {
    border-bottom: none;
}

.setting-summary-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.setting-name {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
}

.setting-value {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    padding: 2px 8px;
    background: rgb(219 219 219 / 10%);
    border-radius: 6px;
}

/* ===== TOOL EXECUTION INDICATORS ===== */
.tool-indicator {
    margin: 8px 0;
    padding: 0;
}

.tool-execution {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    font-weight: 500;
}

.tool-execution svg {
    flex-shrink: 0;
    stroke: var(--primary-color);
    transition: all 0.3s ease;
}

.tool-text {
    font-weight: 500;
    flex: 1;
}

.tool-line {
    color: rgba(255, 255, 255, 0.3);
    font-family: monospace;
    font-size: 12px;
    margin-left: auto;
    opacity: 0.7;
}

/* Animações de estado */
.tool-executing .tool-execution {
    background: rgba(240, 148, 10, 0.1);
    border-color: rgba(240, 148, 10, 0.3);
    animation: toolPulse 1.5s infinite;
}

.tool-executing svg {
    animation: toolSpin 2s linear infinite;
}

.tool-completed .tool-execution {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.3);
    color: var(--text-primary);
}

.tool-completed svg {
    stroke: #22c55e;
}

/* ===== PDF FILE CARD (estilo Claude artifact, refinado) ===== */
.pdf-file-card {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 14px 0 18px;
    padding: 13px 15px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    width: fit-content;
    min-width: min(320px, 100%);
    max-width: min(420px, 100%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-sizing: border-box;
    overflow-wrap: normal;
    word-wrap: normal;
    word-break: normal;
    white-space: normal;
}

.pdf-card-wrapper {
    display: block;
    margin: 14px 0 18px;
    width: fit-content;
    min-width: min(320px, 100%);
    max-width: min(420px, 100%);
    box-sizing: border-box;
    overflow-wrap: normal;
    word-wrap: normal;
    word-break: normal;
    white-space: normal;
}

.pdf-card-wrapper .pdf-file-card {
    margin: 0;
    width: 100%;
    max-width: none;
    min-width: auto;
}

.pdf-file-card--creating {
    background: var(--surface-color);
    border-color: var(--border-color);
}

.pdf-file-card--creating .pdf-file-card__icon {
    background: var(--surface-hover);
}

.pdf-file-card--creating .pdf-file-card__icon svg {
    stroke: var(--text-secondary);
    animation: toolSpin 1.4s linear infinite;
}

.pdf-file-card--creating .pdf-file-card__name {
    color: var(--text-primary);
}

.pdf-file-card--creating .pdf-file-card__meta {
    color: var(--text-secondary);
}

.pdf-file-card--ready {
    background: var(--surface-color);
    border-color: var(--border-color);
}

.pdf-file-card--ready .pdf-file-card__icon {
    background: var(--surface-hover);
}

.pdf-file-card--ready .pdf-file-card__icon svg {
    stroke: var(--text-secondary);
}

.pdf-file-card--error {
    background: var(--surface-color);
    border-color: var(--border-color);
}

.pdf-file-card--error .pdf-file-card__icon {
    background: var(--surface-hover);
}

.pdf-file-card--error .pdf-file-card__icon svg {
    stroke: var(--text-secondary);
}

.pdf-file-card--error .pdf-file-card__meta {
    color: var(--text-secondary);
    white-space: normal;
    overflow: visible;
}

.pdf-file-card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    background: var(--surface-hover);
    border-radius: 12px;
}

.pdf-file-card__icon svg {
    stroke: var(--text-secondary);
}

.pdf-file-card__info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.pdf-file-card__name {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal !important;
    word-wrap: normal !important;
    word-break: normal !important;
}

.pdf-file-card__meta {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow-wrap: normal !important;
    word-wrap: normal !important;
    word-break: normal !important;
}

.pdf-file-card__download {
    flex-shrink: 0;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pdf-file-card__download:hover {
    background: var(--surface-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.pdf-file-card__spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-top-color: var(--text-secondary);
    border-radius: 50%;
    animation: toolSpin 1s linear infinite;
    flex-shrink: 0;
}

/* Tema claro: ajustes */
[data-theme="light"] .pdf-file-card {
    background: var(--surface-color);
    border-color: var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 10px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .pdf-file-card--creating {
    border-color: var(--border-color);
}

[data-theme="light"] .pdf-file-card__icon {
    background: var(--surface-hover);
}

[data-theme="light"] .pdf-file-card__icon svg {
    stroke: var(--text-secondary);
}

[data-theme="light"] .pdf-file-card--creating .pdf-file-card__icon svg,
[data-theme="light"] .pdf-file-card--ready .pdf-file-card__icon svg,
[data-theme="light"] .pdf-file-card--error .pdf-file-card__icon svg {
    stroke: var(--text-secondary);
}

[data-theme="light"] .pdf-file-card__download:hover {
    background: var(--surface-hover);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* ===== LEGADO: inline PDF button (mantido para compatibilidade) ===== */
.pdf-creating-box {
    margin: 10px 0 14px;
    padding: 12px 14px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: all 0.4s ease;
}

.pdf-creating-box.pdf-creating-live {
    animation: pdfCreatingPulse 1.8s ease-in-out infinite;
}

.pdf-creating-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pdf-creating-spinner svg,
.pdf-creating-icon svg {
    flex-shrink: 0;
    stroke: var(--text-secondary);
}

.pdf-creating-live .pdf-creating-spinner {
    animation: toolSpin 1.4s linear infinite;
}

.pdf-creating-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.pdf-creating-text strong {
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
}

.pdf-creating-text span {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pdf-creating-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-left: auto;
}

.pdf-creating-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: pdfDotPulse 1.2s ease-in-out infinite;
    opacity: 0.4;
}

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

.pdf-creating-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.pdf-creating-done {
    background: rgba(34, 197, 94, 0.1);
    border-color: rgba(34, 197, 94, 0.35);
}

.pdf-creating-done .pdf-creating-icon svg {
    stroke: #22c55e;
}

.pdf-creating-done .pdf-creating-text strong {
    color: #22c55e;
}

.pdf-creating-done .pdf-creating-text span {
    color: rgba(255, 255, 255, 0.65);
}

.pdf-creating-download {
    margin-left: auto;
    padding: 8px 14px;
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.45);
    border-radius: 6px;
    color: #86efac;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pdf-creating-download:hover {
    background: rgba(34, 197, 94, 0.28);
    border-color: rgba(34, 197, 94, 0.65);
    color: #bbf7d0;
}

@keyframes pdfCreatingPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 var(--border-color);
    }

    50% {
        box-shadow: 0 0 0 8px transparent;
    }
}

@keyframes pdfDotPulse {

    0%,
    100% {
        transform: scale(0.8);
        opacity: 0.35;
    }

    50% {
        transform: scale(1.3);
        opacity: 1;
    }
}

@keyframes toolPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

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

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

/* File Upload Notifications */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

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

.file-notification {
    font-family: var(--primary-font), sans-serif;
}

/* =================== MESSAGE ACTIONS BUTTONS =================== */
.message-actions-container {
    margin-top: 8px;
    width: 100%;
}

.message-actions {
    position: relative;
    display: flex;
    gap: 4px;
    align-items: center;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.message-actions:hover {
    opacity: 1;
}

/* ===== CHAT INDEX STYLES ===== */
/* Elementos inicialmente ocultos */
.model-dropdown,
.model-upgrade-option,
.history-sidebar .upgrade-section,
.name-personalization-banner,
.attached-files-section,
.thinking-mode-indicator,
.chat-container,
.chat-input-area,
.thinking,
.titan-settings-overlay {
    display: none;
}

/* =================== MODAL DE LIMITE (limitModal) =================== */
.limit-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: var(--z-overlay);
    justify-content: center;
    align-items: center;
}

.limit-modal-overlay.show {
    display: flex;
}

.limit-modal {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    border-radius: 16px;
    padding: 24px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid #4b5563;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.limit-modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.limit-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.limit-modal-header h3 {
    color: #f3f4f6;
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

.limit-modal-content {
    color: #d1d5db;
    text-align: center;
}

.limit-modal-content p {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.limit-timer {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 16px 0;
}

.limit-timer span {
    color: #60a5fa;
    font-weight: 600;
    font-size: 18px;
}

.limit-suggestions {
    margin-top: 16px;
}

.limit-modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
}

.limit-modal-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.limit-modal-btn-primary {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: white;
}

.limit-modal-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4);
}

.limit-modal-btn-secondary {
    background: rgba(75, 85, 99, 0.5);
    color: #d1d5db;
}

.limit-modal-btn-secondary:hover {
    background: rgba(75, 85, 99, 0.7);
}

/* Input de arquivo oculto */
#fileInput,
#fileInputChat,
#cameraInput,
#cameraInputChat {
    display: none;
}

/* Lista de dados de privacidade */
.privacy-data-list {
    margin: 10px 0;
    padding-left: 20px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* =================== EXPORTAR / COPIAR CONVERSA =================== */
/* Botão fixo no canto superior direito, espelhando o ☰ da esquerda.
   Só visível no modo chat (display controlado por export.js). */
.export-conversation-wrap {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: var(--z-floating-ui);
    display: inline-flex;
}

.export-conversation-btn {
    width: 38px;
    height: 38px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-secondary, #b5b5b5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.export-conversation-btn:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.12));
    color: var(--text-primary, #ffffff);
}

.export-conversation-btn:active {
    transform: scale(0.94);
}

.export-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #1f1f1f;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    min-width: 180px;
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.export-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.export-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary, #ffffff);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.export-menu-item:hover {
    background: var(--surface-hover, rgba(255, 255, 255, 0.1));
}

.export-menu-item svg {
    flex-shrink: 0;
    opacity: 0.85;
}