/* Um único stylesheet para o app inteiro (sem outro <link> concorrente), então empilhar tudo em
   camadas aqui dentro não muda nenhuma disputa de cascata existente — cada seletor continua
   vencendo exatamente como antes. O que a camada compra é estrutura: um token nunca é
   acidentalmente sobrescrito por um componente carregado depois, porque tokens e base sempre
   perdem para components por definição de ordem de camada, não por especificidade de seletor. */
@layer tokens, base, components;

@layer tokens {
    :root {
        color-scheme: light;

        /* ---------- superfícies ---------- */
        --canvas: #f3f1eb;
        --surface: #fffefa;
        --surface-strong: #ffffff;
        --surface-hover: #f9faf8;

        /* ---------- texto ---------- */
        --ink: #17201b;
        --ink-muted: #667068;
        --placeholder: #666d68;

        /* ---------- bordas ---------- */
        /* --line é decorativa (divisórias, bordas de painel estático) e pode ficar discreta.
           Qualquer borda que delimita um controle de fato precisa do mínimo não textual da
           WCAG 1.4.11 (3:1) — é isso que --line-control garante. */
        --line: #d9dcd5;
        --line-hover: #9fa8a1;
        --line-control: #828983;
        --panel-line: #c8cec8;
        --control-line: #c5cbc6;
        --control-line-soft: #b7beb8;

        /* ---------- marca ---------- */
        --green: #176b45;
        --green-dark: #0f4d32;
        --green-900: #0b3e28;
        --green-soft: #e4f0e8;

        /* Realce do cartão da integração preferida. Tokens próprios porque a receita não
           sobrevive à troca de tema: no claro é um verde pálido com borda discreta; no
           escuro a mesma dupla vira um bloco saturado, e o que funciona é quase nenhum
           fundo, com a barra lateral carregando o sinal. */
        --tile-preferred-bg: #eaf4ee;
        --tile-preferred-border: #b7d8c5;
        --tile-preferred-bar: var(--green);
        --on-accent: #ffffff;
        --on-soft-accent: #0f4d32;
        /* O acento quando ele é *texto* ou ícone sobre uma superfície comum, e não preenchimento.
           Os dois papéis não podem compartilhar um token: --green-dark é escuro o bastante para
           receber texto branco por cima, o que é exatamente o que o torna ilegível como texto no
           tema escuro (1,64:1 sobre a superfície). */
        --accent-ink: #0f4d32;
        /* A bolha do usuário precisa do seu próprio par de tokens, e não de --green-dark:
           aquele é preenchimento de botão e serve bem sobre o canvas claro, mas no tema
           escuro fica a 1,78:1 do fundo — a bolha praticamente some. Separar permite
           clarear só a bolha no escuro sem mexer nos botões nem no anel de foco. */
        --user-bubble: #0f4d32;
        --on-user-bubble: #ffffff;
        --assistant-ring: #b9c6bd;
        --glow-accent: rgba(23, 107, 69, 0.26);
        --grid-tint: rgba(23, 107, 69, 0.035);

        /* ---------- semântico ---------- */
        --danger: #a43b35;
        --danger-bg: #fbeceb;
        --danger-border: #eabdb8;
        --status-idle: #a7ada8;
        --status-live: #20a464;
        --status-live-ring: rgba(32, 164, 100, 0.12);
        --warn-bg: #fff8d8;
        --warn-border: #d2c89d;
        --warn-ink: #514717;

        /* ---------- controles ----------
           A seta do <select> é desenhada com dois gradientes, e não com um SVG embutido, porque
           assim ela é currentcolor: acompanha o tema claro e o escuro, o estado desabilitado e o
           alto contraste do sistema sem precisar de uma segunda cópia da imagem por tema.
           Em tokens porque os três seletores do app têm alturas diferentes e só o espaçamento
           muda entre eles — a seta em si tem de ser a mesma em todos. */
        --select-arrow: linear-gradient(45deg, transparent 50%, currentcolor 50%),
            linear-gradient(135deg, currentcolor 50%, transparent 50%);
        --select-arrow-size: 5px 5px, 5px 5px;

        /* ---------- utilidades de superfície ---------- */
        --code-bg: #f6f7f4;
        --scrim: rgba(23, 32, 27, 0.45);
        --glass-header: rgba(255, 254, 250, 0.94);
        --glass-footer: rgba(243, 241, 235, 0.96);

        /* ---------- Google (cores de marca do provedor, fixas nos dois temas) ---------- */
        --google-ink: #27312b;
        --google-line: #cfd3ce;

        /* ---------- escada de elevação ----------
           Uma sombra só (--shadow) servia para cinco alturas diferentes ao mesmo tempo — nada
           media "mais perto" de nada. Três níveis, usados deliberadamente: elev-1 para controles
           discretos, elev-2 para o que hoje já usava a sombra original (sem mudança visual),
           elev-3 só para o modal, que é a única superfície que deveria dominar a tela. */
        --shadow-1: 0 2px 8px rgba(23, 32, 27, 0.06);
        --shadow-2: 0 12px 36px rgba(23, 32, 27, 0.09);
        --shadow-3: 0 24px 64px rgba(15, 23, 19, 0.22);

        /* ---------- escala de tipo (títulos e texto de destaque) ----------
           Cobre os tamanhos que eram escolhidos caso a caso; legendas e rótulos pequenos (11–14px)
           permanecem literais nesta passada — já são consistentes dentro do próprio contexto e o
           ganho de tokenizá-los não paga o risco mecânico de reescrever ~20 regras a mais. */
        --text-heading-sm: 1.25rem;
        --text-heading-md: 1.5rem;
        --text-heading-lg: 1.75rem;
        --text-display-compact: 2.625rem;
        --text-display-sm: clamp(2.125rem, 6vw, 3.25rem);
        --text-display-lg: clamp(2.125rem, 6vw, 3.5rem);
    }

    /* Preferência do sistema: aplica-se sempre que a pessoa não escolheu um tema à mão. */
    @media (prefers-color-scheme: dark) {
        :root:not([data-theme="light"]) {
            color-scheme: dark;

            --canvas: #12181a;
            --surface: #1a2226;
            --surface-strong: #202b30;
            --surface-hover: #26333a;

            --ink: #e9efe9;
            --ink-muted: #9fada3;
            --placeholder: #87958d;

            --line: #26332f;
            --line-hover: #46605c;
            --line-control: #69837a;
            --panel-line: #35453f;
            --control-line: #384843;
            --control-line-soft: #3c4c46;

            --green: #4fb489;
            --green-dark: #0f4d32;
            --green-900: #08301f;
            --green-soft: #17301f;
            --tile-preferred-bg: rgba(79, 180, 137, 0.07);
            --tile-preferred-border: #2c4a3c;
            --tile-preferred-bar: var(--green);
            --on-accent: #ffffff;
            --on-soft-accent: #8fe0bd;
            --accent-ink: #4fb489;
            /* Clareada em relação ao tema claro: sobre o canvas escuro ela sobe de 1,78:1
               para 2,75:1, e o texto branco ainda fica em 6,5:1. */
            --user-bubble: #226b4b;
            --on-user-bubble: #ffffff;
            --assistant-ring: #345048;
            --glow-accent: rgba(79, 180, 137, 0.3);
            --grid-tint: rgba(79, 180, 137, 0.05);

            --danger: #e8897c;
            --danger-bg: #3a201d;
            --danger-border: #6b3a34;
            --status-idle: #8a978d;
            --status-live: #4fc98c;
            --status-live-ring: rgba(79, 201, 140, 0.18);
            --warn-bg: #3a3218;
            --warn-border: #6b5d2e;
            --warn-ink: #f0dfa0;

            --code-bg: #16201e;
            --scrim: rgba(0, 0, 0, 0.6);
            --glass-header: rgba(26, 34, 38, 0.85);
            --glass-footer: rgba(18, 24, 26, 0.9);

            --google-ink: #dfe6e1;
            --google-line: #3a4a44;

            --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.28);
            --shadow-2: 0 12px 36px rgba(0, 0, 0, 0.38);
            --shadow-3: 0 24px 64px rgba(0, 0, 0, 0.55);
        }
    }

    /* Preferência explícita da pessoa (guardada no perfil), que sempre vence a do sistema —
       inclusive quando ela pede escuro num sistema claro. */
    :root[data-theme="dark"] {
        color-scheme: dark;

        --canvas: #12181a;
        --surface: #1a2226;
        --surface-strong: #202b30;
        --surface-hover: #26333a;

        --ink: #e9efe9;
        --ink-muted: #9fada3;
        --placeholder: #87958d;

        --line: #26332f;
        --line-hover: #46605c;
        --line-control: #69837a;
        --panel-line: #35453f;
        --control-line: #384843;
        --control-line-soft: #3c4c46;

        --green: #4fb489;
        --green-dark: #0f4d32;
        --green-900: #08301f;
        --green-soft: #17301f;
        --tile-preferred-bg: rgba(79, 180, 137, 0.07);
        --tile-preferred-border: #2c4a3c;
        --tile-preferred-bar: var(--green);
        --on-accent: #ffffff;
        --on-soft-accent: #8fe0bd;
        --accent-ink: #4fb489;
        --user-bubble: #226b4b;
        --on-user-bubble: #ffffff;
        --assistant-ring: #345048;
        --glow-accent: rgba(79, 180, 137, 0.3);
        --grid-tint: rgba(79, 180, 137, 0.05);

        --danger: #e8897c;
        --danger-bg: #3a201d;
        --danger-border: #6b3a34;
        --status-idle: #8a978d;
        --status-live: #4fc98c;
        --status-live-ring: rgba(79, 201, 140, 0.18);
        --warn-bg: #3a3218;
        --warn-border: #6b5d2e;
        --warn-ink: #f0dfa0;

        --code-bg: #16201e;
        --scrim: rgba(0, 0, 0, 0.6);
        --glass-header: rgba(26, 34, 38, 0.85);
        --glass-footer: rgba(18, 24, 26, 0.9);

        --google-ink: #dfe6e1;
        --google-line: #3a4a44;

        --shadow-1: 0 2px 8px rgba(0, 0, 0, 0.28);
        --shadow-2: 0 12px 36px rgba(0, 0, 0, 0.38);
        --shadow-3: 0 24px 64px rgba(0, 0, 0, 0.55);
    }
}

@layer base {
    * {
        box-sizing: border-box;
    }

    html,
    body {
        height: 100%;
    }

    body {
        margin: 0;
        overflow: hidden;
        color: var(--ink);
        background:
            linear-gradient(var(--grid-tint) 1px, transparent 1px),
            linear-gradient(90deg, var(--grid-tint) 1px, transparent 1px),
            var(--canvas);
        background-size: 32px 32px;
        font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
    }

    /* select faltava aqui, e era essa a origem das "letras menores": sem font: inherit o
       navegador desenha o campo com a fonte de sistema dele (~13px, outra família), então no
       formulário do perfil Idioma e Região saíam visivelmente menores que o input de Nome logo
       acima. Dois dos três seletores do app corrigiam isso por conta própria; o do perfil não. */
    button,
    textarea,
    input,
    select {
        font: inherit;
    }

    button {
        cursor: pointer;
    }

    /* Aparência comum a todo <select>: o desenho nativo muda de forma entre Windows, macOS e
       Android, e o campo destoava dos inputs ao lado dele em cada plataforma. Com appearance:
       none a moldura passa a ser nossa e a seta vem dos tokens, igual nos três seletores.
       Os componentes ajustam só espaçamento, cor de fundo e borda por cima disto. */
    select {
        max-width: 100%;
        padding: 10px 34px 10px 12px;
        border: 1px solid var(--line-control);
        border-radius: 9px;
        color: var(--ink);
        background-color: var(--surface);
        background-image: var(--select-arrow);
        background-repeat: no-repeat;
        background-position: right 15px center, right 10px center;
        background-size: var(--select-arrow-size);
        appearance: none;
        cursor: pointer;
        text-overflow: ellipsis;
        transition: border-color 140ms ease;
    }

    select:hover:not(:disabled) {
        border-color: var(--line-hover);
    }

    select:disabled {
        cursor: default;
        opacity: 0.6;
    }

    /* A lista aberta é desenhada pelo sistema a partir das cores do próprio <select>, e as
       <option> não herdam as dele em todos os navegadores: sem isto o app no tema escuro abre um
       menu claro. */
    option {
        color: var(--ink);
        background-color: var(--surface);
    }

    /* input e select faltavam aqui: sem eles, os campos do perfil e do login ficavam sem
       anel de foco e o único indicador era a cor da borda, que sozinha é fraca demais para
       quem navega por teclado (WCAG 2.4.11). */
    button:focus-visible,
    textarea:focus-visible,
    input:focus-visible,
    select:focus-visible,
    a:focus-visible {
        outline: 3px solid var(--green-dark);
        outline-offset: 2px;
    }
}

@layer components {
    .app-shell {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        height: 100vh;
        height: 100dvh;
    }

    .app-header {
        z-index: 2;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 24px;
        min-height: 72px;
        padding: 12px clamp(18px, 4vw, 56px);
        border-bottom: 1px solid var(--line);
        background: var(--glass-header);
        backdrop-filter: blur(14px);
    }

    .brand {
        display: inline-flex;
        align-items: center;
        gap: 11px;
        color: var(--ink);
        text-decoration: none;
    }

    .brand-mark {
        display: grid;
        width: 36px;
        height: 36px;
        place-items: center;
        border: 1px solid var(--green-dark);
        border-radius: 50%;
        color: var(--surface);
        background: var(--green-dark);
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-sm);
    }

    .brand-name {
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-md);
        font-weight: 600;
    }

    .integration-actions {
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .connection-status {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        color: var(--ink-muted);
        font-size: 13px;
        white-space: nowrap;
    }

    .status-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--status-idle);
    }

    .connection-status.is-connected {
        color: var(--accent-ink);
    }

    .connection-status.is-connected .status-dot {
        background: var(--status-live);
        box-shadow: 0 0 0 4px var(--status-live-ring);
    }

    .google-button {
        display: inline-flex;
        min-height: 42px;
        align-items: center;
        gap: 10px;
        padding: 0 15px;
        border: 1px solid var(--google-line);
        border-radius: 6px;
        color: var(--google-ink);
        background: var(--surface-strong);
        font-weight: 650;
        white-space: nowrap;
        box-shadow: var(--shadow-1);
    }

    .google-button:hover:not(:disabled) {
        border-color: var(--line-hover);
        background: var(--surface-hover);
    }

    .google-button:disabled {
        cursor: default;
        opacity: 0.68;
    }

    .google-mark {
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-sm);
        font-weight: 700;
        /* Cores oficiais da marca do Google — fixas nos dois temas, como o próprio "G" do Google
           também não se retema. */
        background: conic-gradient(from -45deg, #4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0);
        background-clip: text;
        color: transparent;
    }

    .account-area {
        display: flex;
        position: relative;
        gap: 10px;
        align-items: center;
    }

    /* ---------- alternância de tema ---------- */
    /* Seletor de idioma: pílula com bandeira + código, dropdown no padrão do menu de conta. */
    .language-menu {
        position: relative;
        flex: 0 0 auto;
    }

    .language-toggle {
        display: flex;
        height: 42px;
        align-items: center;
        gap: 7px;
        padding: 0 12px;
        border: 1px solid var(--line-control);
        border-radius: 999px;
        color: var(--ink);
        background: var(--surface);
        cursor: pointer;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.04em;
        transition: border-color 120ms ease, background 120ms ease;
    }

    .language-toggle:hover {
        border-color: var(--ink-muted);
    }

    .language-flag {
        width: 20px;
        height: 14px;
        border-radius: 2px;
        /* O branco da bandeira americana some no fundo claro sem este traço. */
        box-shadow: 0 0 0 1px var(--line-control);
        flex: 0 0 auto;
    }

    .language-flag[hidden] {
        display: none;
    }

    .language-caret {
        width: 10px;
        height: 6px;
        color: var(--ink-muted);
    }

    .language-dropdown {
        position: absolute;
        top: calc(100% + 10px);
        right: 0;
        z-index: 3;
        display: flex;
        width: 220px;
        flex-direction: column;
        gap: 2px;
        padding: 8px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface-strong);
        box-shadow: var(--shadow-2);
        animation: enter 160ms ease-out both;
    }

    .language-dropdown[hidden] {
        display: none;
    }

    .language-option {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 12px;
        border: none;
        border-radius: 8px;
        color: var(--ink);
        background: transparent;
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

    .language-option:hover {
        background: var(--green-soft);
    }

    .language-option-name {
        flex: 1;
    }

    .language-option-check {
        visibility: hidden;
        color: var(--ink-muted);
    }

    .language-option.is-current .language-option-check {
        visibility: visible;
    }

    .theme-toggle {
        display: grid;
        width: 42px;
        height: 42px;
        flex: 0 0 auto;
        place-items: center;
        border: 1px solid var(--line-control);
        border-radius: 999px;
        color: var(--ink);
        background: var(--surface);
        cursor: pointer;
        transition: border-color 120ms ease, background 120ms ease;
    }

    .theme-toggle:hover {
        border-color: var(--line-hover);
        background: var(--surface-hover);
    }

    .theme-toggle:focus-visible {
        outline: 2px solid var(--green);
        outline-offset: 2px;
    }

    .theme-icon {
        width: 19px;
        height: 19px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.7;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    /* Mostra o ícone do tema que o clique vai ativar, não o do tema atual: o botão é a ação. */
    .theme-toggle[data-theme="light"] .theme-icon-sun,
    .theme-toggle[data-theme="dark"] .theme-icon-moon {
        display: none;
    }

    @media (prefers-reduced-motion: reduce) {
        .theme-toggle {
            transition: none;
        }
    }

    .login-button {
        display: inline-flex;
        align-items: center;
        min-height: 42px;
        padding: 0 20px;
        border: 1px solid var(--green-dark);
        border-radius: 999px;
        color: var(--on-accent);
        background: var(--green-dark);
        font-weight: 650;
        white-space: nowrap;
    }

    .login-button:hover {
        background: var(--green);
        border-color: var(--green);
    }

    .account-menu[hidden],
    .login-button[hidden] {
        display: none;
    }

    .account-trigger {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        min-height: 42px;
        padding: 4px 14px 4px 4px;
        border: 1px solid var(--line);
        border-radius: 999px;
        background: var(--surface-strong);
        box-shadow: var(--shadow-1);
    }

    .account-trigger:hover {
        border-color: var(--line-hover);
        background: var(--surface-hover);
    }

    .account-avatar-img,
    .account-avatar-fallback {
        width: 32px;
        height: 32px;
        border-radius: 50%;
    }

    .account-avatar-img {
        object-fit: cover;
    }

    .account-avatar-img[hidden],
    .account-avatar-fallback[hidden] {
        display: none;
    }

    .account-avatar-fallback {
        display: grid;
        place-items: center;
        background: var(--green-dark);
        color: var(--surface);
        font-weight: 650;
        font-size: 14px;
    }

    .account-name {
        max-width: 160px;
        overflow: hidden;
        color: var(--ink);
        font-weight: 600;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .account-dropdown {
        position: absolute;
        top: calc(100% + 10px);
        right: 0;
        z-index: 3;
        display: flex;
        width: 200px;
        flex-direction: column;
        padding: 8px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface-strong);
        box-shadow: var(--shadow-2);
        animation: enter 160ms ease-out both;
    }

    .account-dropdown[hidden] {
        display: none;
    }

    .account-dropdown-item {
        display: block;
        padding: 10px 12px;
        border: none;
        border-radius: 8px;
        color: var(--ink);
        background: transparent;
        font: inherit;
        text-align: left;
        text-decoration: none;
    }

    .account-dropdown-item:hover {
        background: var(--green-soft);
    }

    .account-dropdown-action {
        width: 100%;
        color: var(--danger);
    }

    /* Flex + margin:auto no cartão em vez de place-items:center: quando o modal fica mais alto que a
       viewport (modo "criar conta" em tela baixa), a centralização por grid corta o topo e o
       conteúdo fica inalcançável; assim ele rola por inteiro. */
    .modal-overlay {
        position: fixed;
        inset: 0;
        z-index: 10;
        display: flex;
        padding: 24px 16px;
        align-items: center;
        justify-content: center;
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--scrim);
        backdrop-filter: blur(2px);
    }

    .modal-overlay[hidden] {
        display: none;
    }

    /* O confirm de exclusão: o mesmo shell dos modais, encolhido ao tamanho de uma decisão. O
       botão perigoso é o único preenchido com --danger no app — a cor conta o custo do clique, e
       o texto usa a superfície para manter contraste nos dois temas. */
    .confirm-dialog {
        width: min(360px, 100%);
        padding: 24px;
    }

    .confirm-dialog-title {
        margin: 0;
        font-size: 17px;
        font-weight: 700;
        overflow-wrap: anywhere;
    }

    .confirm-dialog-message {
        margin: 10px 0 0;
        color: var(--ink-muted);
        font-size: 14px;
        line-height: 1.5;
        overflow-wrap: anywhere;
    }

    .confirm-dialog-actions {
        display: flex;
        margin-top: 22px;
        gap: 10px;
        justify-content: flex-end;
    }

    .confirm-dialog-actions button {
        padding: 8px 16px;
        border-radius: 10px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
    }

    .confirm-dialog-cancel {
        border: 1px solid var(--control-line);
        background: transparent;
        color: var(--ink);
    }

    .confirm-dialog-cancel:hover {
        border-color: var(--line-hover);
        background: var(--surface-hover);
    }

    .confirm-dialog-danger {
        border: 1px solid transparent;
        background: var(--danger);
        color: var(--surface-strong);
    }

    .confirm-dialog-danger:hover {
        filter: brightness(0.94);
    }

    /* Nunca mais alto que a viewport: acima disso o próprio cartão rola, para que o botão de envio e
       o alternador de modo continuem alcançáveis em telas baixas em vez de ficarem fora da tela.
       A sombra é a única superfície do app em elev-3: é o que deve dominar a tela quando aberta. */
    .modal-card {
        position: relative;
        width: min(400px, 100%);
        max-height: calc(100dvh - 48px);
        margin: auto;
        padding: 32px 28px 28px;
        border-radius: 16px;
        background: var(--surface-strong);
        box-shadow: var(--shadow-3);
        flex: 0 0 auto;
        overflow-y: auto;
        overscroll-behavior: contain;
        animation: enter 220ms ease-out both;
    }

    /* Em telas baixas o ritmo vertical encolhe para o diálogo caber inteiro sem rolagem, que é o
       caso comum em celular no modo "criar conta" (quatro campos em vez de dois). */
    @media (max-height: 760px) {
        .modal-card {
            padding: 22px 22px 20px;
        }

        .login-modal h2 {
            font-size: 21px;
        }

        .login-modal-subtitle {
            margin-bottom: 16px;
        }

        .login-modal-divider {
            margin: 13px 0;
        }

        .login-modal-field {
            margin-top: 7px;
            gap: 4px;
        }

        .login-modal-field input {
            padding: 9px 12px;
        }

        .login-submit-button {
            margin-top: 13px;
        }

        .login-mode-toggle {
            margin-top: 11px;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .modal-card {
            animation: none;
        }
    }

    .modal-close {
        position: absolute;
        top: 14px;
        right: 14px;
        display: grid;
        width: 32px;
        height: 32px;
        place-items: center;
        border: none;
        border-radius: 50%;
        color: var(--ink-muted);
        background: transparent;
        font-size: var(--text-heading-sm);
        line-height: 1;
    }

    .modal-close:hover {
        background: var(--canvas);
    }

    .login-modal h2 {
        margin: 0 0 8px;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-md);
    }

    .login-modal-subtitle {
        margin: 0 0 24px;
        color: var(--ink-muted);
        font-size: 14px;
    }

    /* Carries the reason the modal opened by itself, so it has to read as the point of the dialog
       rather than as the usual quiet helper line. */
    .login-modal-subtitle.is-prompt {
        padding: 11px 14px;
        border-left: 3px solid var(--green);
        border-radius: 0 8px 8px 0;
        background: var(--green-soft);
        color: var(--on-soft-accent);
        font-weight: 600;
    }

    .google-signin-container {
        display: flex;
        justify-content: center;
        min-height: 44px;
    }

    .login-modal-divider {
        display: flex;
        align-items: center;
        margin: 20px 0;
        color: var(--ink-muted);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }

    .login-modal-divider::before,
    .login-modal-divider::after {
        flex: 1;
        height: 1px;
        background: var(--line);
        content: "";
    }

    .login-modal-divider span {
        padding: 0 12px;
    }

    .login-password-form {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .login-modal-field {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-top: 10px;
    }

    .login-modal-field[hidden] {
        display: none;
    }

    .login-modal-field input {
        padding: 11px 14px;
        border: 1px solid var(--line-control);
        border-radius: 8px;
        color: var(--ink);
        background: var(--canvas);
    }

    .login-modal-field input:focus-visible {
        border-color: var(--green);
        outline: none;
    }

    .login-submit-button {
        width: 100%;
        margin-top: 18px;
    }

    .login-mode-toggle {
        display: block;
        width: 100%;
        margin-top: 16px;
        padding: 0;
        border: none;
        background: transparent;
        color: var(--accent-ink);
        font-size: 13px;
        font-weight: 650;
        text-align: center;
    }

    .login-mode-toggle:hover {
        text-decoration: underline;
    }

    .login-modal-error {
        margin: 16px 0 0;
        color: var(--danger);
        font-size: 13px;
        text-align: center;
    }

    .login-modal-error[hidden] {
        display: none;
    }

    .terms-checkbox-label {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        margin-top: 6px;
        color: var(--ink-muted);
        font-size: 13px;
        line-height: 1.4;
    }

    .terms-checkbox-label input {
        margin-top: 2px;
        accent-color: var(--green);
    }

    .terms-link {
        color: var(--accent-ink);
        text-decoration: underline;
    }

    .login-forgot-link {
        display: block;
        margin-top: 10px;
        color: var(--accent-ink);
        font-size: 13px;
        text-align: right;
    }

    .login-forgot-link[hidden] {
        display: none;
    }

    .login-forgot-link:hover {
        text-decoration: underline;
    }

    .google-signup-account {
        margin: -8px 0 20px;
        color: var(--ink-muted);
        font-size: 13px;
        font-weight: 600;
    }

    .terms-modal {
        width: min(560px, 100%);
    }

    .terms-updated {
        margin: 0 0 20px;
        color: var(--ink-muted);
        font-size: 13px;
    }

    .terms-body h3 {
        margin: 18px 0 6px;
        font-size: 15px;
    }

    .terms-body h3:first-child {
        margin-top: 0;
    }

    .terms-body p {
        margin: 0 0 4px;
        color: var(--ink-muted);
        font-size: 14px;
        line-height: 1.6;
    }

    .chat-main {
        position: relative;
        min-height: 0;
        overflow-y: auto;
        scrollbar-color: var(--line-hover) transparent;
        scrollbar-width: thin;
    }

    /* Cobre a área de rolagem inteira e centraliza o conteúdo. Ao contrário do posicionamento por
       translate, isto acomoda a apresentação (bem mais alta que a saudação) sem estourar para fora
       da tela: se não couber, rola dentro do próprio bloco. */
    .empty-state {
        position: absolute;
        display: grid;
        padding: 24px clamp(16px, 4vw, 32px);
        inset: 0;
        place-items: center;
        overflow-y: auto;
        text-align: center;
        animation: enter 420ms ease-out both;
    }

    .empty-state[hidden] {
        display: none;
    }

    .welcome,
    .intro {
        width: min(680px, 100%);
    }

    .welcome[hidden],
    .intro[hidden] {
        display: none;
    }

    /* ---------- apresentação para visitante sem sessão ---------- */

    .intro {
        display: flex;
        width: min(760px, 100%);
        flex-direction: column;
        align-items: center;
        gap: 0;
    }

    .intro-mark {
        display: block;
        width: 46px;
        height: 46px;
        margin-bottom: 20px;
        border-radius: 14px;
        box-shadow: 0 8px 22px var(--glow-accent);
    }

    .intro-title {
        margin: 0;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-display-sm);
        font-weight: 500;
        line-height: 1.06;
        letter-spacing: -0.015em;
        text-wrap: balance;
    }

    .intro-lede {
        max-width: 46ch;
        margin: 16px 0 0;
        color: var(--ink-muted);
        font-size: clamp(15px, 2.2vw, 17px);
        line-height: 1.55;
        text-wrap: pretty;
    }

    .intro-hint {
        margin: 30px 0 12px;
        color: var(--green);
        font-size: 12px;
        font-weight: 750;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .intro-cards {
        display: grid;
        width: 100%;
        gap: 10px;
        grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    }

    .intro-card {
        display: flex;
        padding: 13px 15px;
        border: 1px solid var(--line);
        border-radius: 13px;
        background: var(--surface);
        color: inherit;
        cursor: pointer;
        flex-direction: column;
        gap: 5px;
        text-align: left;
        transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
    }

    .intro-card:hover {
        border-color: var(--green);
        background: var(--surface-strong);
        transform: translateY(-2px);
    }

    .intro-card:focus-visible {
        border-color: var(--green);
        outline: 2px solid var(--green);
        outline-offset: 2px;
    }

    .intro-card-more {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: auto;
        margin: 18px auto 0;
        padding: 8px 18px;
        border: 1px dashed var(--line);
        border-radius: 999px;
        background: transparent;
        color: var(--green);
        font-size: 13px;
        font-weight: 650;
        text-align: center;
    }

    .intro-card-more:hover {
        background: var(--surface);
    }

    .intro-card-label {
        color: var(--green);
        font-size: 11px;
        font-weight: 750;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .intro-card-prompt {
        color: var(--ink);
        font-size: 14px;
        line-height: 1.4;
    }

    .intro-footnote {
        margin: 26px 0 0;
        color: var(--ink-muted);
        font-size: 13px;
        text-wrap: pretty;
    }

    @media (prefers-reduced-motion: reduce) {
        .empty-state {
            animation: none;
        }

        .intro-card {
            transition: none;
        }

        .intro-card:hover {
            transform: none;
        }

        .new-messages-button {
            animation: none;
        }
    }

    .eyebrow {
        margin: 0 0 13px;
        color: var(--green);
        font-size: 12px;
        font-weight: 750;
        letter-spacing: 0;
    }

    /* Escopado ao estado de saudação: a apresentação do visitante tem a própria escala de tipo, e
       um seletor em .empty-state venceria .intro-title por especificidade. */
    .welcome h1 {
        margin: 0;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-display-lg);
        font-weight: 500;
        line-height: 1.08;
    }

    .welcome p:last-child {
        margin: 18px 0 0;
        color: var(--ink-muted);
        font-size: 17px;
    }

    .messages {
        display: flex;
        width: min(880px, calc(100% - 36px));
        min-height: 100%;
        margin: 0 auto;
        padding: 42px 0 56px;
        flex-direction: column;
        justify-content: flex-end;
        gap: 24px;
    }

    .message {
        display: flex;
        gap: 12px;
        align-items: flex-start;
        animation: message-in 240ms ease-out both;
    }

    .message.user {
        justify-content: flex-end;
    }

    /* The article itself is the horizontal row (mark + bubble); the footer (timestamp, actions)
       has to sit below the bubble rather than beside it, so it nests inside this vertical stack
       instead of being another direct sibling of body. */
    .message-stack {
        display: flex;
        min-width: 0;
        flex-direction: column;
    }

    .message.user .message-stack {
        align-items: flex-end;
    }

    .message-content {
        max-width: min(720px, 82%);
        white-space: pre-wrap;
        /* break-word, não anywhere: os dois quebram uma palavra que realmente não cabe, mas
           `anywhere` também entra no cálculo de min-content, o que deixa o flex encolher a
           bolha quase até zero e faz o texto quebrar muito antes do necessário. */
        overflow-wrap: break-word;
        line-height: 1.58;
    }

    /* O raio era 8px 8px 2px 8px: um canto quase reto embaixo à direita, imitando a cauda que
       aponta para o avatar de quem falou. Só que o lado do usuário não tem avatar — a marca
       circular existe apenas no assistente. A cauda apontava para o vazio e lia como erro, não
       como intenção. Uniforme, então, e em 14px: fica entre a família de controles (6–8px) e a
       de cartões (12–16px), que é o que uma bolha é. */
    .message.user .message-content {
        max-width: min(620px, 80%);
        padding: 12px 16px;
        border-radius: 14px;
        color: var(--on-user-bubble);
        background: var(--user-bubble);
        line-height: 1.5;
    }

    /* A seleção padrão do navegador é pensada para texto escuro sobre fundo claro; dentro da
       bolha ela deixava texto branco sobre azul-claro. */
    .message.user .message-content::selection {
        color: var(--user-bubble);
        background: var(--on-user-bubble);
    }

    /* Em alto contraste do sistema, background e color são substituídos pelas cores do usuário,
       e a bolha desapareceria: sem borda, o que separa usuário de assistente é só o fundo. */
    @media (forced-colors: active) {
        .message.user .message-content {
            border: 1px solid CanvasText;
        }
    }

    /* The assistant's reply is real Markdown now (real <p>/<ul>/<pre> elements from
       core/markdown.ts), not raw text relying on pre-wrap to fold its newlines into line breaks —
       carrying pre-wrap into it would double the vertical rhythm on top of each block's own
       margin. The user's own bubble keeps pre-wrap; it is still plain text. */
    .message.assistant .message-content {
        white-space: normal;
    }

    .message-content :is(h4, h5, h6) {
        margin: 14px 0 6px;
        font-family: Georgia, "Times New Roman", serif;
        font-weight: 600;
        line-height: 1.3;
    }

    .message-content :is(h4, h5, h6):first-child {
        margin-top: 0;
    }

    .message-content h4 {
        font-size: 17px;
    }

    .message-content h5 {
        font-size: 16px;
    }

    .message-content h6 {
        font-size: 15px;
    }

    .message-content p {
        margin: 0 0 10px;
        /* Evita a última linha com uma palavra só. Navegador que não conhece ignora. */
        text-wrap: pretty;
    }

    .message-content ul,
    .message-content ol {
        margin: 0 0 10px;
        padding-left: 22px;
    }

    .message-content li {
        margin: 2px 0;
    }

    .message-content > :last-child {
        margin-bottom: 0;
    }

    .message-content pre {
        max-width: 100%;
        margin: 0 0 10px;
        padding: 10px 12px;
        overflow-x: auto;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: var(--code-bg);
    }

    .message-content pre code {
        font: 13px/1.5 Consolas, "Courier New", monospace;
        white-space: pre;
    }

    .message-content :not(pre) > code {
        padding: 0.1em 0.4em;
        border-radius: 4px;
        background: var(--code-bg);
        font: 0.9em/1 Consolas, "Courier New", monospace;
    }

    .message-content a {
        color: var(--accent-ink);
        text-decoration-color: var(--line-hover);
    }

    .message-content a:hover {
        text-decoration-thickness: 2px;
    }

    /* ---------- blocos (resultado estruturado) ----------
       Um bloco é o resultado que a tool devolveu, renderizado como componente em vez de prosa.
       Fica acima do texto da resposta, e o texto abaixo lê como a interpretação dele. */

    .block {
        max-width: min(720px, 100%);
        margin-bottom: 10px;
        border: 1px solid var(--panel-line);
        border-left: 3px solid var(--green);
        border-radius: 6px;
        background: var(--surface);
        overflow: hidden;
    }

    /* Quando nenhum renderer reconhece o tipo, o bloco exibe o próprio texto de fallback — que é um
       caminho normal de renderização, não um estado de erro, então não se distingue visualmente de
       uma resposta comum. */
    .block-fallback {
        padding: 12px 14px;
        line-height: 1.55;
    }

    .block-fallback > :first-child { margin-top: 0; }
    .block-fallback > :last-child { margin-bottom: 0; }

    .block-body {
        padding: 12px 14px;
    }

    .block-row {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 14px;
        padding: 5px 0;
    }

    .block-row + .block-row {
        border-top: 1px solid var(--line);
    }

    .block-row-label {
        color: var(--ink-muted);
        font-size: 14px;
    }

    .block-row-value {
        color: var(--ink);
        font-weight: 650;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    /* ---------- finance.spending ---------- */

    .finance-spending-header {
        display: flex;
        align-items: baseline;
        gap: 10px;
        flex-wrap: wrap;
        margin-bottom: 10px;
    }

    .finance-spending-total {
        color: var(--ink);
        font-size: 22px;
        font-variant-numeric: tabular-nums;
    }

    .finance-spending-period {
        color: var(--ink-muted);
        font-size: 13px;
    }

    .finance-spending-breakdown {
        display: flex;
        flex-direction: column;
    }

    .finance-spending-row {
        padding: 7px 0;
    }

    .finance-spending-row + .finance-spending-row {
        border-top: 1px solid var(--line);
    }

    .finance-spending-row-line {
        display: flex;
        justify-content: space-between;
        gap: 14px;
        margin-bottom: 5px;
    }

    .finance-spending-bar-track {
        height: 5px;
        border-radius: 999px;
        background: var(--line);
        overflow: hidden;
    }

    .finance-spending-bar-fill {
        height: 100%;
        border-radius: inherit;
        background: var(--green);
    }

    /* ---------- finance.transactions ---------- */

    .finance-transactions-header {
        margin-bottom: 8px;
    }

    .finance-transactions-period {
        color: var(--ink-muted);
        font-size: 13px;
    }

    .finance-transactions-list {
        display: flex;
        flex-direction: column;
    }

    .finance-transactions-row {
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr) auto;
        align-items: baseline;
        gap: 12px;
        padding: 7px 0;
    }

    .finance-transactions-row + .finance-transactions-row {
        border-top: 1px solid var(--line);
    }

    .finance-transactions-date {
        color: var(--ink-muted);
        font-size: 12px;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .finance-transactions-detail {
        display: flex;
        min-width: 0;
        align-items: baseline;
        gap: 8px;
        flex-wrap: wrap;
    }

    .finance-transactions-label {
        overflow: hidden;
        color: var(--ink);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .finance-transactions-category {
        flex: 0 0 auto;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .finance-transactions-amount {
        font-weight: 650;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .finance-transactions-debit {
        color: var(--ink);
    }

    .finance-transactions-credit {
        color: var(--green);
    }

    .finance-transactions-neutral {
        color: var(--ink-muted);
    }

    .finance-transactions-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- finance.budget-set ---------- */

    .finance-budget-set {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .finance-budget-set-category {
        overflow: hidden;
        color: var(--ink);
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .finance-budget-set-details {
        color: var(--ink-muted);
        font-size: 12px;
        font-variant-numeric: tabular-nums;
    }

    /* ---------- finance.expense-created ---------- */

    .finance-expense-created {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .finance-expense-created-heading {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 14px;
    }

    .finance-expense-created-title {
        overflow: hidden;
        color: var(--ink);
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .finance-expense-created-amount {
        flex: 0 0 auto;
        color: var(--ink);
        font-weight: 650;
        font-variant-numeric: tabular-nums;
    }

    .finance-expense-created-details {
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- finance write results ---------- */

    .finance-write-result {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .finance-write-result-heading {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 14px;
    }

    .finance-write-result-title {
        overflow: hidden;
        color: var(--ink);
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .finance-write-result-amount {
        flex: 0 0 auto;
        color: var(--ink);
        font-weight: 650;
        font-variant-numeric: tabular-nums;
    }

    .finance-write-result-credit {
        color: var(--green);
    }

    .finance-write-result-details {
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- catalog and mutation results ---------- */

    .finance-catalog,
    .mutation-result {
        display: flex;
        flex-direction: column;
    }

    .finance-catalog-row {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 14px;
        padding: 7px 0;
    }

    .finance-catalog-row + .finance-catalog-row {
        border-top: 1px solid var(--line);
    }

    .finance-catalog-title,
    .mutation-result-title {
        overflow: hidden;
        color: var(--ink);
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .finance-catalog-value {
        flex: 0 0 auto;
        color: var(--ink);
        font-variant-numeric: tabular-nums;
    }

    .finance-catalog-meta,
    .finance-catalog-more,
    .mutation-result-details {
        color: var(--ink-muted);
        font-size: 12px;
    }

    .finance-catalog-more {
        margin-top: 6px;
    }

    .mutation-result {
        gap: 5px;
    }

    /* ---------- finance.budgets ---------- */

    .finance-budgets-period {
        display: block;
        margin-bottom: 8px;
        color: var(--ink-muted);
        font-size: 13px;
    }

    .finance-budgets-list {
        display: flex;
        flex-direction: column;
    }

    .finance-budgets-row {
        padding: 8px 0;
    }

    .finance-budgets-row + .finance-budgets-row {
        border-top: 1px solid var(--line);
    }

    .finance-budgets-row-line,
    .finance-budgets-summary {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 14px;
    }

    .finance-budgets-category {
        min-width: 0;
        overflow: hidden;
        color: var(--ink);
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .finance-budgets-amount,
    .finance-budgets-percentage,
    .finance-budgets-remaining {
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .finance-budgets-amount {
        color: var(--ink-muted);
        font-size: 12px;
    }

    .finance-budgets-bar-track {
        height: 5px;
        margin: 5px 0;
        overflow: hidden;
        border-radius: 999px;
        background: var(--line);
    }

    .finance-budgets-bar-fill {
        height: 100%;
        border-radius: inherit;
        background: var(--green);
    }

    .finance-budgets-summary {
        color: var(--ink-muted);
        font-size: 12px;
    }

    .finance-budgets-row.is-over-budget .finance-budgets-bar-fill {
        background: var(--danger);
    }

    .finance-budgets-row.is-over-budget .finance-budgets-remaining {
        color: var(--danger);
        font-weight: 650;
    }

    .finance-budgets-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- calendar.events ---------- */

    .calendar-events-header {
        margin-bottom: 8px;
    }

    .calendar-events-period {
        color: var(--ink-muted);
        font-size: 13px;
    }

    .calendar-events-list {
        display: flex;
        flex-direction: column;
    }

    .calendar-events-row {
        display: grid;
        grid-template-columns: 108px minmax(0, 1fr) auto;
        align-items: baseline;
        gap: 12px;
        padding: 7px 0;
    }

    .calendar-events-row + .calendar-events-row {
        border-top: 1px solid var(--line);
    }

    .calendar-events-row.is-cancelled {
        opacity: 0.6;
    }

    .calendar-events-row.is-cancelled .calendar-events-title {
        text-decoration: line-through;
    }

    .calendar-events-when {
        color: var(--ink-muted);
        font-size: 12px;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .calendar-events-detail {
        display: flex;
        min-width: 0;
        align-items: baseline;
        gap: 8px;
        flex-wrap: wrap;
    }

    .calendar-events-title {
        overflow: hidden;
        color: var(--ink);
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .calendar-events-location {
        flex: 0 0 auto;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .calendar-events-status {
        flex: 0 0 auto;
        padding: 1px 8px;
        border-radius: 999px;
        font-size: 11px;
        font-weight: 650;
        white-space: nowrap;
    }

    .calendar-events-status-tentative {
        color: var(--warn-ink);
        background: var(--warn-bg);
    }

    .calendar-events-status-cancelled {
        color: var(--danger);
        background: var(--danger-bg);
    }

    .calendar-events-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- email.messages ---------- */

    .email-messages-list {
        display: flex;
        flex-direction: column;
    }

    .email-messages-row {
        display: grid;
        grid-template-columns: minmax(96px, 0.7fr) minmax(0, 1.6fr) auto;
        align-items: baseline;
        gap: 12px;
        padding: 7px 0;
    }

    .email-messages-row + .email-messages-row {
        border-top: 1px solid var(--line);
    }

    .email-messages-sender,
    .email-messages-subject,
    .email-messages-snippet {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .email-messages-sender {
        color: var(--ink);
        font-weight: 650;
    }

    .email-messages-detail {
        display: flex;
        min-width: 0;
        align-items: baseline;
        gap: 8px;
    }

    .email-messages-subject {
        flex: 0 1 auto;
        color: var(--ink);
    }

    .email-messages-snippet {
        min-width: 0;
        flex: 1 1 auto;
        color: var(--ink-muted);
        font-size: 13px;
    }

    .email-messages-snippet::before {
        content: "—";
        margin-right: 8px;
    }

    .email-messages-date {
        color: var(--ink-muted);
        font-size: 12px;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .email-messages-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- web.search.results ---------- */

    .web-search-list {
        display: flex;
        flex-direction: column;
    }

    .web-search-row {
        display: flex;
        min-width: 0;
        flex-direction: column;
        gap: 3px;
        padding: 8px 0;
    }

    .web-search-row + .web-search-row {
        border-top: 1px solid var(--line);
    }

    .web-search-title {
        overflow: hidden;
        color: var(--ink);
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    a.web-search-title {
        text-decoration: none;
    }

    a.web-search-title:hover,
    a.web-search-title:focus-visible {
        text-decoration: underline;
    }

    .web-search-meta {
        display: flex;
        align-items: baseline;
        gap: 8px;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .web-search-date {
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .web-search-snippet {
        display: -webkit-box;
        overflow: hidden;
        color: var(--ink-muted);
        font-size: 13px;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .web-search-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- location.place.details / location.place.reviews ---------- */

    .place-details-title,
    .place-reviews-title {
        font-weight: 700;
    }

    a.place-details-title {
        color: inherit;
        text-decoration: underline;
    }

    .place-details-meta,
    .place-reviews-header {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 12px;
        margin-top: 4px;
        font-size: 13px;
        color: var(--ink-muted);
    }

    .place-details-closed {
        margin-top: 4px;
        font-size: 13px;
        font-weight: 600;
        color: var(--danger, #b3261e);
    }

    .place-details-hours {
        margin-top: 8px;
        font-size: 13px;
    }

    .place-details-hours summary {
        cursor: pointer;
        color: var(--ink-muted);
    }

    .place-details-hours-line {
        margin: 2px 0 0 12px;
        color: var(--ink-muted);
    }

    .place-reviews-list {
        display: grid;
        gap: 10px;
        margin-top: 8px;
    }

    .place-reviews-text {
        margin: 0;
        padding-left: 10px;
        border-left: 2px solid var(--line-control);
    }

    .place-reviews-meta {
        display: flex;
        gap: 10px;
        margin-top: 2px;
        font-size: 12px;
        color: var(--ink-muted);
    }

    .place-reviews-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* O selo da fonte quando ela não é a implícita (Tripadvisor ao lado das do Google). */
    .place-reviews-site {
        padding: 1px 8px;
        border: 1px solid var(--line-control);
        border-radius: 999px;
        font-size: 11px;
        font-weight: 600;
    }

    /* ---------- travel.hotel.offers ---------- */

    .travel-hotels-period {
        font-weight: 700;
    }

    .travel-hotels-list {
        display: grid;
        gap: 10px;
        margin-top: 8px;
    }

    .travel-hotel-head {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
    }

    .travel-hotel-name {
        font-weight: 600;
    }

    a.travel-hotel-name {
        color: inherit;
        text-decoration: underline;
    }

    .travel-hotel-price {
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
        font-weight: 700;
    }

    .travel-hotel-meta {
        margin-top: 2px;
        font-size: 12px;
        color: var(--ink-muted);
    }

    .travel-hotels-more,
    .travel-hotels-collected {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* A lista de chaves de capability no modal de integração do perfil. Monoespaçada de
       propósito: são identificadores técnicos, e a fonte diz isso antes de qualquer rótulo. */
    .integration-tools-hint {
        margin: 0 0 8px;
        font-size: 12px;
        color: var(--ink-muted);
    }

    .integration-tools-list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .integration-tool-chip {
        padding: 3px 10px;
        border: 1px solid var(--line-control);
        border-radius: 999px;
        background: var(--surface-sunken, transparent);
        font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
        font-size: 11.5px;
        letter-spacing: 0.01em;
        color: var(--ink-muted);
        white-space: nowrap;
    }

    /* ---------- news.headlines ---------- */

    .news-headlines-list {
        display: grid;
        gap: 10px;
    }

    .news-headline-title {
        font-weight: 600;
    }

    a.news-headline-title {
        color: inherit;
        text-decoration: none;
    }

    a.news-headline-title:hover,
    a.news-headline-title:focus-visible {
        text-decoration: underline;
    }

    .news-headline-meta {
        display: block;
        margin-top: 2px;
        font-size: 12px;
        color: var(--ink-muted);
    }

    .news-headlines-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- shopping.offers ---------- */

    .shopping-offers-list {
        display: grid;
        gap: 10px;
    }

    .shopping-offer-head {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
    }

    .shopping-offer-title {
        font-weight: 600;
    }

    a.shopping-offer-title {
        color: inherit;
        text-decoration: underline;
    }

    .shopping-offer-price {
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
        font-weight: 700;
    }

    .shopping-offer-meta {
        margin-top: 2px;
        font-size: 12px;
        color: var(--ink-muted);
    }

    .shopping-offers-more,
    .shopping-offers-collected {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- finance.market.quote ---------- */

    .market-quote-header {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 4px 10px;
    }

    .market-quote-title {
        font-weight: 700;
    }

    .market-quote-symbol {
        font-size: 12px;
        color: var(--ink-muted);
    }

    .market-quote-line {
        display: flex;
        align-items: baseline;
        gap: 12px;
        margin-top: 4px;
    }

    .market-quote-price {
        font-size: 22px;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
    }

    .market-quote-change {
        font-size: 13px;
        font-weight: 600;
    }

    .market-quote-change.is-up {
        color: var(--success, #1a7f37);
    }

    .market-quote-change.is-down {
        color: var(--danger, #b3261e);
    }

    .market-quote-collected {
        margin-top: 6px;
        font-size: 12px;
        color: var(--ink-muted);
    }

    /* ---------- social.profile ---------- */

    .social-profile-header {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: space-between;
        gap: 4px 12px;
    }

    .social-profile-title {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 4px 8px;
    }

    .social-profile-name {
        font-weight: 700;
    }

    .social-profile-username,
    .social-profile-network {
        color: var(--ink-muted);
        font-size: 13px;
    }

    .social-profile-verified {
        padding: 1px 8px;
        border: 1px solid var(--line-control);
        border-radius: 999px;
        font-size: 11px;
        font-weight: 600;
    }

    .social-profile-bio {
        margin-top: 4px;
        font-size: 13px;
        color: var(--ink-muted);
    }

    .social-profile-counts {
        margin-top: 6px;
        font-size: 13px;
        font-variant-numeric: tabular-nums;
    }

    .social-profile-posts {
        display: grid;
        gap: 8px;
        margin-top: 8px;
    }

    .social-profile-post-caption {
        margin: 0;
        padding-left: 10px;
        border-left: 2px solid var(--line-control);
    }

    .social-profile-post-meta {
        display: block;
        margin-top: 2px;
        font-size: 12px;
        color: var(--ink-muted);
    }

    a.social-profile-post-meta {
        text-decoration: none;
    }

    a.social-profile-post-meta:hover,
    a.social-profile-post-meta:focus-visible {
        text-decoration: underline;
    }

    .social-profile-footer {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: space-between;
        gap: 4px 12px;
        margin-top: 8px;
        font-size: 12px;
    }

    .social-profile-link {
        color: inherit;
        font-weight: 600;
    }

    .social-profile-collected {
        color: var(--ink-muted);
    }

    /* O caminho da busca quando o modelo refinou os termos. Discreto de propósito: explica de onde
       vieram as fontes sem competir com elas. */
    .web-search-queries {
        margin: 0 0 8px;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- web.driver.plan ---------- */

    .web-driver-plan-summary {
        color: var(--ink);
        font-weight: 650;
    }

    /* Passos numerados pelo próprio <ol>: a ordem é o conteúdo aqui, e numerar no texto faria a
       lista discordar dela mesma quando o servidor cortasse o fim. */
    .web-driver-plan-steps {
        display: flex;
        margin: 8px 0 0;
        flex-direction: column;
        gap: 4px;
        padding-left: 20px;
        color: var(--ink);
        font-size: 13px;
    }

    .web-driver-plan-more {
        margin: 6px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* O limite do produto: fica visualmente separado porque é a informação que muda a decisão de
       aprovar, não um detalhe do plano. */
    .web-driver-plan-boundary {
        margin: 10px 0 0;
        border-left: 2px solid var(--line);
        padding-left: 8px;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .web-driver-plan-cost {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
        font-variant-numeric: tabular-nums;
    }

    /* ---------- travel.flight.offers ---------- */

    .travel-offers-list {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .travel-offer-row {
        padding: 9px 11px;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: var(--surface-strong);
    }

    /* Voo à esquerda, preço à direita: comparar uma lista de passagens é ler a coluna de preços de
       cima a baixo, e ela precisa estar alinhada para isso funcionar. */
    .travel-offer-head {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
    }

    .travel-offer-flight {
        color: var(--ink);
        font-weight: 650;
    }

    .travel-offer-price {
        color: var(--ink);
        font-weight: 650;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .travel-offer-meta {
        margin: 4px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* O valor que a companhia realmente cobra. Discreto porque o usuário compara em reais, mas
       presente porque é ele que vai aparecer na fatura. */
    .travel-offer-original {
        margin: 2px 0 0;
        color: var(--ink-muted);
        font-size: 11px;
        font-variant-numeric: tabular-nums;
    }

    .travel-offers-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* O carimbo de coleta é a única defesa contra o usuário tratar um preço morto como vivo, então
       ele fica visível — discreto, mas não escondido. */
    .travel-offers-collected {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .travel-offers-sandbox {
        margin: 0 0 8px;
        border: 1px solid var(--line);
        border-radius: 6px;
        padding: 6px 9px;
        color: var(--ink-muted);
        font-size: 12px;
        font-weight: 650;
    }

    /* ---------- travel.booking.handoff ---------- */

    .travel-handoff-trip {
        color: var(--ink);
        font-weight: 650;
    }

    .travel-handoff-note {
        margin: 6px 0 0;
        color: var(--ink-muted);
        font-size: 13px;
    }

    /* O link é a entrega deste cartão, como no handoff do browser. */
    .travel-handoff-link {
        display: inline-block;
        margin: 12px 0 0;
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 7px 12px;
        color: var(--ink);
        font-size: 13px;
        font-weight: 650;
        text-decoration: none;
    }

    .travel-handoff-link:hover,
    .travel-handoff-link:focus-visible {
        border-color: var(--ink-muted);
    }

    .travel-handoff-disclosure {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- web.driver.handoff ---------- */

    .web-driver-handoff-summary {
        color: var(--ink);
        font-weight: 650;
    }

    .web-driver-handoff-reason {
        margin: 6px 0 0;
        color: var(--ink-muted);
        font-size: 13px;
    }

    /* O link é a entrega deste cartão, então ele se parece com o botão principal e não com um link
       no meio de um texto. */
    .web-driver-handoff-link {
        display: inline-block;
        margin: 12px 0 0;
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 7px 12px;
        color: var(--ink);
        font-size: 13px;
        font-weight: 650;
        text-decoration: none;
    }

    .web-driver-handoff-link:hover,
    .web-driver-handoff-link:focus-visible {
        border-color: var(--ink-muted);
    }

    /* ---------- email.thread ---------- */

    .email-thread-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .email-thread-row {
        padding: 10px 11px;
        border: 1px solid var(--line);
        border-radius: 6px;
        background: var(--surface-strong);
    }

    .email-thread-header {
        display: flex;
        min-width: 0;
        align-items: baseline;
        justify-content: space-between;
        gap: 12px;
    }

    .email-thread-sender {
        min-width: 0;
        overflow: hidden;
        color: var(--ink);
        font-size: 13px;
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .email-thread-date {
        flex: 0 0 auto;
        color: var(--ink-muted);
        font-size: 12px;
        font-variant-numeric: tabular-nums;
    }

    .email-thread-subject {
        display: block;
        margin-top: 4px;
        color: var(--ink);
        font-size: 13px;
        font-weight: 650;
    }

    .email-thread-body {
        display: block;
        margin-top: 5px;
        color: var(--ink-muted);
        font-size: 13px;
        line-height: 1.45;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    .email-thread-truncated,
    .email-thread-more {
        display: block;
        margin: 7px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .email-thread-truncated {
        font-style: italic;
    }

    /* ---------- tasks.items ---------- */

    .task-items-list {
        display: flex;
        flex-direction: column;
    }

    .task-items-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: baseline;
        gap: 12px;
        padding: 7px 0;
    }

    .task-items-row + .task-items-row {
        border-top: 1px solid var(--line);
    }

    .task-items-row.is-completed {
        opacity: 0.65;
    }

    .task-items-detail {
        display: flex;
        min-width: 0;
        align-items: baseline;
        gap: 8px;
    }

    .task-items-title,
    .task-items-notes {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .task-items-title {
        flex: 0 1 auto;
        color: var(--ink);
        font-weight: 650;
    }

    .task-items-row.is-completed .task-items-title {
        text-decoration: line-through;
    }

    .task-items-notes {
        min-width: 0;
        flex: 1 1 auto;
        color: var(--ink-muted);
        font-size: 13px;
    }

    .task-items-notes::before {
        content: "—";
        margin-right: 8px;
    }

    .task-items-due {
        color: var(--ink-muted);
        font-size: 12px;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .task-items-status {
        padding: 1px 8px;
        border-radius: 999px;
        color: var(--on-soft-accent);
        background: var(--green-soft);
        font-size: 11px;
        font-weight: 650;
        white-space: nowrap;
    }

    .task-items-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- tasks.item-created ---------- */

    .task-item-created {
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .task-item-created-title {
        min-width: 0;
    }

    .task-item-created-name {
        overflow: hidden;
        color: var(--ink);
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .task-item-created-details {
        color: var(--ink-muted);
        font-size: 12px;
    }

    /* ---------- tasks.lists ---------- */

    .task-lists-list {
        display: flex;
        flex-direction: column;
    }

    .task-lists-row {
        display: block;
        padding: 7px 0;
        overflow: hidden;
        color: var(--ink);
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .task-lists-row + .task-lists-row {
        border-top: 1px solid var(--line);
    }

    .task-lists-more {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .block-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 14px;
        border-top: 1px solid var(--line);
        background: var(--surface-strong);
    }

    .block-action {
        min-height: 36px;
        padding: 0 14px;
        border: 1px solid var(--control-line);
        border-radius: 6px;
        color: var(--ink);
        background: var(--surface-strong);
        font-size: 13px;
        font-weight: 650;
    }

    .block-action:hover:not(:disabled) {
        border-color: var(--green);
        background: var(--green-soft);
    }

    .block-action.primary {
        border-color: var(--green-dark);
        color: var(--on-accent);
        background: var(--green-dark);
    }

    .block-action.primary:hover:not(:disabled) {
        background: var(--green-900);
    }

    /* Um plano de navegação aprovado leva quarenta segundos executando antes de o César responder.
       Nesse tempo o botão já estava desabilitado, mas continuava com a mesma cara de botão vivo:
       sem hover apagado nem opacidade, o usuário aperta "Confirmar" mais três vezes achando que o
       primeiro clique não pegou. O estado é o mesmo para o botão em voo e para o já gasto — em
       ambos não há nada a fazer com ele. */
    .block-action:disabled {
        opacity: 0.55;
        cursor: default;
    }

    /* Hidden until the message is hovered or one of its own actions has focus, so the thread does
       not carry a permanent row of timestamps and buttons under every single bubble. Touch
       screens have no hover to reveal it with, so they get it visible unconditionally instead —
       otherwise Copy and Resend would be unreachable there. */
    .message-footer {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-top: 5px;
        opacity: 0;
        transition: opacity 120ms ease;
    }

    .message:hover .message-footer,
    .message:focus-within .message-footer {
        opacity: 1;
    }

    @media (hover: none) {
        .message-footer {
            opacity: 1;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .message-footer {
            transition: none;
        }
    }

    .message-footer time {
        color: var(--ink-muted);
        font-size: 11px;
        font-variant-numeric: tabular-nums;
    }

    .message-actions {
        display: flex;
        gap: 4px;
    }

    /* 24px é o mínimo de alvo da WCAG 2.5.8; o botão tinha ~20px de altura. Em ponteiro
       grosso vai a 32px, onde o dedo — e não o cursor — é quem precisa acertar. */
    .message-action {
        display: inline-flex;
        min-height: 24px;
        padding: 3px 10px;
        align-items: center;
        border: 1px solid var(--line);
        border-radius: 999px;
        color: var(--ink-muted);
        background: transparent;
        font-size: 11px;
        font-weight: 650;
    }

    @media (pointer: coarse) {
        .message-action {
            min-height: 32px;
            padding: 6px 13px;
        }
    }

    .message-action:hover {
        border-color: var(--line-hover);
        color: var(--ink);
        background: var(--surface-hover);
    }

    .assistant-mark {
        display: grid;
        width: 30px;
        height: 30px;
        flex: 0 0 30px;
        place-items: center;
        border: 1px solid var(--assistant-ring);
        border-radius: 50%;
        color: var(--on-soft-accent);
        background: var(--green-soft);
        font-family: Georgia, "Times New Roman", serif;
        font-weight: 700;
    }

    .message.error .message-content {
        color: var(--danger);
    }

    /* O que sobrou do painel de confirmação depois que ele virou o bloco action.confirm: só a
       tipografia. A moldura, a faixa de acento e a linha de ações agora vêm de .block, que as
       aplica igualmente a todo tipo de bloco. */

    .confirmation-description {
        margin: 0;
        color: var(--ink);
        font-weight: 650;
    }

    /* Campo rotulado dos cartões de aprovação ricos (regra proativa): rótulo curto em caixa alta
       discreta, valor em prosa. */
    .confirmation-field {
        margin: 0 0 10px;
    }

    .confirmation-field:last-child {
        margin-bottom: 0;
    }

    .confirmation-field-label {
        display: block;
        margin-bottom: 2px;
        color: var(--ink-muted);
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .confirmation-details {
        margin-top: 10px;
        color: var(--ink-muted);
        font-size: 13px;
    }

    .confirmation-details summary {
        width: fit-content;
        cursor: pointer;
        color: var(--accent-ink);
        font-weight: 650;
    }

    .confirmation-details pre {
        max-height: 180px;
        margin: 10px 0 0;
        padding: 10px;
        overflow: auto;
        border: 1px solid var(--line);
        border-radius: 4px;
        background: var(--code-bg);
        font: 12px/1.45 Consolas, "Courier New", monospace;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    /* ---------- cartão de automação disparada ----------
       Não é bolha de conversa: ninguém digitou aquilo — uma condição criada pelo usuário
       aconteceu. O cartão tem identidade própria: badge de raio, kicker em caixa alta e o nome
       da regra como título. */

    .automation-card {
        margin: 18px auto;
        max-width: 560px;
        width: 100%;
        padding: 14px 16px;
        border: 1px solid var(--tile-preferred-border);
        border-left: 4px solid var(--green);
        border-radius: 10px;
        background: var(--tile-preferred-bg);
        box-shadow: var(--shadow-2);
    }

    .automation-card-header {
        display: flex;
        gap: 8px;
        align-items: center;
        margin-bottom: 8px;
    }

    .automation-card-badge {
        display: grid;
        place-items: center;
        flex: none;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: var(--green-soft);
        border: 1px solid var(--tile-preferred-border);
        font-size: 13px;
        line-height: 1;
    }

    .automation-card-kicker {
        flex: 1;
        min-width: 0;
        color: var(--accent-ink);
        font-size: 11px;
        font-weight: 750;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .automation-card-header time {
        flex: none;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .automation-card-title {
        margin: 0 0 6px;
        color: var(--ink);
        font-weight: 700;
        font-size: 15px;
    }

    .automation-card-body {
        margin: 0;
        color: var(--ink);
        font-size: 14px;
        line-height: 1.5;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
    }

    .confirmation-status {
        min-height: 20px;
        margin: 10px 0 0;
        color: var(--ink-muted);
        font-size: 13px;
    }

    .typing-dots {
        display: inline-flex;
        gap: 5px;
        padding-top: 10px;
    }

    .typing-dots span {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--green);
        animation: typing 900ms infinite ease-in-out;
    }

    .typing-dots span:nth-child(2) {
        animation-delay: 120ms;
    }

    .typing-dots span:nth-child(3) {
        animation-delay: 240ms;
    }

    /* The container is just a stack of rows now — one call to notice.show() no longer erases
       whatever the previous one was showing. */
    .notice {
        position: fixed;
        z-index: 5;
        top: 84px;
        left: 50%;
        display: flex;
        width: min(520px, calc(100% - 32px));
        flex-direction: column;
        gap: 8px;
        translate: -50% 0;
    }

    .notice[hidden] {
        display: none;
    }

    .notice-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 11px 14px;
        border: 1px solid var(--warn-border);
        border-radius: 6px;
        color: var(--warn-ink);
        background: var(--warn-bg);
        box-shadow: var(--shadow-2);
        font-size: 14px;
        text-align: left;
        animation: enter 180ms ease-out both;
    }

    .notice-item span {
        flex: 1;
    }

    /* Errors get their own color, distinct from the informational amber — and, unlike info rows,
       do not disappear on a timer (see notice.ts), so they carry the dismiss button below instead. */
    .notice-item.notice-error {
        border-color: var(--danger-border);
        color: var(--danger);
        background: var(--danger-bg);
    }

    .notice-dismiss {
        display: grid;
        width: 22px;
        height: 22px;
        flex: 0 0 auto;
        place-items: center;
        border: none;
        border-radius: 50%;
        color: inherit;
        background: transparent;
        font-size: 15px;
        line-height: 1;
        opacity: 0.7;
    }

    .notice-dismiss:hover {
        opacity: 1;
        background: rgba(0, 0, 0, 0.08);
    }

    @media (prefers-reduced-motion: reduce) {
        .notice-item {
            animation: none;
        }
    }

    .composer-area {
        z-index: 2;
        padding: 14px max(18px, calc((100% - 920px) / 2)) 20px;
        border-top: 1px solid var(--line);
        background: var(--glass-footer);
        backdrop-filter: blur(14px);
    }

    /* Quatro colunas: anexo, campo, microfone, Enviar. */
    .composer {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        gap: 10px;
        align-items: end;
        padding: 8px 8px 8px 16px;
        border: 1px solid var(--line-control);
        border-radius: 8px;
        background: var(--surface-strong);
        box-shadow: var(--shadow-2);
    }

    .attachment-preview {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: 46px minmax(0, 1fr) 34px;
        align-items: center;
        gap: 10px;
        min-height: 58px;
        padding: 6px 8px;
        border-bottom: 1px solid var(--line);
    }

    .attachment-preview[hidden] {
        display: none;
    }

    .attachment-preview img {
        width: 46px;
        height: 46px;
        object-fit: cover;
        border: 1px solid var(--line);
        border-radius: 4px;
        background: var(--canvas);
    }

    .attachment-preview img[hidden] {
        display: none;
    }

    .attachment-meta {
        min-width: 0;
    }

    .attachment-meta strong,
    .attachment-meta span {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .attachment-meta strong {
        font-size: 14px;
    }

    .attachment-meta span {
        margin-top: 3px;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .attach-button,
    .remove-attachment-button {
        display: grid;
        place-items: center;
        border: 1px solid var(--control-line);
        color: var(--accent-ink);
        background: var(--surface-strong);
        font-weight: 700;
    }

    .attach-button {
        width: 42px;
        height: 42px;
        border-radius: 6px;
        font-size: 24px;
        line-height: 1;
    }

    .remove-attachment-button {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        font-size: 14px;
    }

    .attach-button:hover:not(:disabled),
    .remove-attachment-button:hover:not(:disabled) {
        border-color: var(--green);
        background: var(--green-soft);
    }

    .composer:focus-within {
        border-color: var(--green);
    }

    .composer textarea {
        width: 100%;
        max-height: 156px;
        padding: 9px 0;
        resize: none;
        overflow-y: hidden;
        border: 0;
        outline: 0;
        color: var(--ink);
        background: transparent;
        line-height: 1.45;
    }

    .composer textarea::placeholder {
        color: var(--placeholder);
    }

    .send-button {
        min-width: 82px;
        min-height: 42px;
        padding: 0 17px;
        border: 1px solid var(--green-dark);
        border-radius: 6px;
        color: var(--on-accent);
        background: var(--green-dark);
        font-weight: 700;
    }

    .send-button:hover:not(:disabled) {
        background: var(--green-900);
    }

    .send-button:disabled,
    .composer textarea:disabled,
    .attach-button:disabled,
    .mic-button:disabled,
    .remove-attachment-button:disabled {
        cursor: not-allowed;
        opacity: 0.58;
    }

    /* ---------- entrada por voz ---------- */

    /* Entre o campo e o Enviar. Mesma família visual do botão de anexo: contorno, não
       preenchimento — o Enviar continua sendo o único botão sólido. */
    .mic-button {
        display: grid;
        place-items: center;
        width: 42px;
        height: 42px;
        border: 1px solid var(--control-line);
        border-radius: 6px;
        color: var(--accent-ink);
        background: var(--surface-strong);
    }

    .mic-button:hover:not(:disabled) {
        border-color: var(--green);
        background: var(--green-soft);
    }

    /* Ditar e escrever são modos exclusivos do mesmo espaço: enquanto grava, o painel é o
       composer. Esconder (e não sobrepor) evita foco alcançável por teclado em controles
       invisíveis. */
    .composer.is-recording .attach-button,
    .composer.is-recording textarea,
    .composer.is-recording .mic-button,
    .composer.is-recording .send-button,
    .composer.is-recording .attachment-preview {
        display: none;
    }

    .recorder-panel {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 12px;
        align-items: center;
        min-height: 42px;
    }

    .recorder-panel[hidden] {
        display: none;
    }

    .recorder-live,
    .recorder-transcribing {
        display: flex;
        gap: 12px;
        align-items: center;
        min-width: 0;
    }

    .recorder-live[hidden],
    .recorder-transcribing[hidden] {
        display: none;
    }

    .recorder-dot {
        flex: none;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background: var(--danger);
        animation: recorder-pulse 1.4s ease-in-out infinite;
    }

    @keyframes recorder-pulse {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.35; }
    }

    .recorder-timer {
        flex: none;
        min-width: 44px;
        color: var(--ink);
        font-weight: 650;
        font-variant-numeric: tabular-nums;
    }

    /* O nível de cada barra chega por JS; aqui mora só a moldura. overflow escondido porque as
       barras crescem a partir do centro e não podem empurrar a altura do composer. */
    .recorder-bars {
        display: flex;
        flex: 1;
        gap: 3px;
        align-items: center;
        min-width: 0;
        height: 30px;
        overflow: hidden;
    }

    .recorder-bars span {
        flex: 1;
        min-height: 4px;
        height: 4px;
        max-width: 6px;
        border-radius: 3px;
        background: var(--green);
        transition: height 90ms ease-out;
    }

    .recorder-transcribing {
        color: var(--ink-muted);
        font-size: 14px;
    }

    .recorder-spinner {
        flex: none;
        width: 16px;
        height: 16px;
        border: 2px solid var(--line);
        border-top-color: var(--green);
        border-radius: 50%;
        animation: recorder-spin 0.8s linear infinite;
    }

    @keyframes recorder-spin {
        to { rotate: 1turn; }
    }

    .recorder-cancel-button,
    .recorder-stop-button {
        display: grid;
        place-items: center;
        width: 42px;
        height: 42px;
        border-radius: 6px;
    }

    .recorder-cancel-button {
        border: 1px solid var(--control-line);
        color: var(--danger);
        background: var(--surface-strong);
    }

    .recorder-cancel-button:hover:not(:disabled) {
        border-color: var(--danger-border);
        background: var(--danger-bg);
    }

    /* O gesto principal do painel — parar e virar texto — herda o sólido do Enviar, porque é o
       Enviar deste modo. */
    .recorder-stop-button {
        border: 1px solid var(--green-dark);
        color: var(--on-accent);
        background: var(--green-dark);
    }

    .recorder-stop-button:hover:not(:disabled) {
        background: var(--green-900);
    }

    .recorder-cancel-button:disabled,
    .recorder-stop-button:disabled {
        cursor: not-allowed;
        opacity: 0.58;
    }

    .skip-link {
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 20;
        padding: 10px 16px;
        border-radius: 6px;
        color: var(--on-accent);
        background: var(--green-dark);
        font-weight: 650;
        text-decoration: none;
        translate: 0 -140%;
        transition: translate 140ms ease-out;
    }

    .skip-link:focus-visible {
        translate: 0 0;
    }

    @media (prefers-reduced-motion: reduce) {
        .skip-link {
            transition: none;
        }
    }

    .sr-only {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    /* height fixa, não auto: o <body> é overflow:hidden (o chat precisa da página travada),
       então um shell com height:auto cresce além da viewport, é cortado pelo body, e o
       próprio overflow-y:auto dele nunca ativa — nada rola. Limitando a altura, o shell vira
       o contêiner de rolagem. Era um bug latente aqui, que só apareceu quando a página Sobre
       ficou mais alta que a tela. */
    .profile-shell,
    .page-shell {
        display: block;
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
        scrollbar-color: var(--line-hover) transparent;
        scrollbar-width: thin;
    }

    .profile-shell {
        --shell-measure: 940px;
    }

    /* Dentro de um shell que rola, o cabeçalho gruda no topo: numa página longa a marca, o
       tema e o menu de conta continuam alcançáveis sem voltar ao início. */
    .profile-shell > .app-header,
    .page-shell > .app-header {
        position: sticky;
        top: 0;
    }

    /* ---------- rodapé institucional ---------- */
    /* A largura acompanha a medida da página em que o rodapé foi inserido, para a linha do
       topo dele bater com a coluna do conteúdo em vez de ultrapassá-la. */
    .site-footer {
        display: flex;
        width: min(var(--shell-measure, 940px), calc(100% - 40px));
        margin: 0 auto;
        padding: 20px 0 max(24px, env(safe-area-inset-bottom));
        border-top: 1px solid var(--line);
        gap: 8px 24px;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }

    /* Dentro da tela inicial do chat o contêiner já limita e centraliza; aplicar a medida
       de novo criaria um recuo duplo. */
    .intro .site-footer {
        width: 100%;
        margin-top: 12px;
    }

    .site-footer-legal {
        color: var(--ink-muted);
        font-size: 13px;
    }

    .site-footer-nav {
        display: flex;
        gap: 20px;
    }

    /* 24px de alvo mínimo (WCAG 2.5.8) sem engordar o texto: o padding vertical cresce,
       e a margem negativa devolve o espaço para o rodapé não ficar alto demais. */
    .site-footer-nav a {
        display: inline-flex;
        align-items: center;
        min-height: 24px;
        margin: -4px 0;
        padding: 4px 0;
        color: var(--ink-muted);
        font-size: 13px;
        text-decoration: none;
    }

    .site-footer-nav a:hover {
        color: var(--ink);
        text-decoration: underline;
    }

    @media (pointer: coarse) {
        .site-footer-nav a {
            min-height: 32px;
        }
    }

    /* ---------- páginas de conteúdo (Sobre, Contato) ---------- */
    .page-shell {
        --shell-measure: 720px;
    }

    .page-main {
        width: min(720px, calc(100% - 40px));
        margin: 0 auto;
        padding: 48px 0 56px;
    }

    .page-header {
        margin-bottom: 40px;
    }

    /* Não usa --text-display-sm (34–52px): aquela é a escala do hero da home, e num texto
       corrido de 720px ela grita. Esta fica entre o heading grande e o display. */
    .page-header h1 {
        margin: 10px 0 0;
        font-family: Georgia, "Times New Roman", serif;
        font-size: clamp(1.75rem, 4vw, 2.5rem);
        line-height: 1.15;
    }

    .page-lede {
        margin: 18px 0 0;
        color: var(--ink-muted);
        font-size: 18px;
        line-height: 1.6;
        text-wrap: pretty;
    }

    .page-section {
        margin-top: 36px;
    }

    .page-section h2 {
        margin: 0 0 12px;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-sm);
    }

    /* 66ch é a faixa em que a linha ainda é confortável de ler; acima disso o olho perde
       o começo da linha seguinte. */
    .page-section p {
        margin: 0 0 14px;
        line-height: 1.68;
        text-wrap: pretty;
    }

    .page-section p:last-child {
        margin-bottom: 0;
    }

    .page-list {
        max-width: 66ch;
        margin: 0;
        padding-left: 20px;
        line-height: 1.68;
    }

    .page-list li {
        margin-bottom: 8px;
    }

    .page-list li:last-child {
        margin-bottom: 0;
    }

    .page-section a,
    .page-list a {
        color: var(--accent-ink);
        text-decoration-color: var(--line-hover);
        text-underline-offset: 2px;
    }

    .page-section a:hover,
    .page-list a:hover {
        text-decoration-thickness: 2px;
    }

    /* ---------- página de integrações ---------- */
    /* Mais larga que Sobre/Contato: aqui o conteúdo é uma grade de cartões, não prosa, e a
       medida de leitura de 66ch não se aplica. */
    .page-main-wide {
        width: min(1000px, calc(100% - 40px));
    }

    .page-shell:has(.page-main-wide) {
        --shell-measure: 1000px;
    }

    .section-heading {
        margin: 0 0 20px;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-md);
    }

    .integration-hero {
        margin-bottom: 52px;
        padding: 28px;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: var(--surface-strong);
        box-shadow: var(--shadow-2);
    }

    .integration-hero-top {
        display: flex;
        gap: 18px;
        flex-wrap: wrap;
        align-items: center;
    }

    .integration-logo {
        display: grid;
        width: 56px;
        height: 56px;
        flex: 0 0 auto;
        place-items: center;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: var(--canvas);
        font-family: Georgia, "Times New Roman", serif;
        font-size: 26px;
        font-weight: 700;
    }

    .integration-hero-text {
        flex: 1 1 260px;
        min-width: 0;
    }

    .integration-hero-text h2 {
        margin: 0;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-md);
    }

    .integration-hero-text p {
        margin: 4px 0 0;
        color: var(--ink-muted);
        font-size: 15px;
    }

    .integration-cta {
        flex: 0 0 auto;
        text-decoration: none;
    }

    .integration-cta.is-connected .google-mark {
        color: var(--on-soft-accent);
    }

    /* Números do topo. <dl> e não uma lista solta: cada valor é a definição de um rótulo. */
    .integration-stats {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        margin: 26px 0 0;
        padding-top: 22px;
        border-top: 1px solid var(--line);
        gap: 18px;
    }

    .integration-stats dt {
        color: var(--ink-muted);
        font-size: 12px;
        font-weight: 650;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .integration-stats dd {
        margin: 4px 0 0;
        font-family: Georgia, "Times New Roman", serif;
        font-size: 26px;
    }

    .integration-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        margin: 0;
        padding: 0;
        gap: 14px;
        list-style: none;
    }

    .integration-item {
        display: flex;
        padding: 22px;
        border: 1px solid var(--line);
        border-radius: 14px;
        flex-direction: column;
        gap: 8px;
        background: var(--surface);
    }

    .integration-item h3 {
        margin: 0;
        font-family: Georgia, "Times New Roman", serif;
        font-size: 17px;
    }

    .integration-item p {
        margin: 0;
        flex: 1 1 auto;
        color: var(--ink-muted);
        font-size: 14px;
        line-height: 1.6;
        text-wrap: pretty;
    }

    .integration-count {
        color: var(--on-soft-accent);
        font-size: 12px;
        font-weight: 650;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

    /* Localização não é uma conexão que o usuário faz; a borda tracejada separa o cartão dos
       que exigem uma ação dele. */
    .integration-item-builtin {
        border-style: dashed;
        background: none;
    }

    .integration-notes {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
        gap: 22px;
    }

    .integration-note h3 {
        margin: 0 0 6px;
        font-size: 15px;
        font-weight: 650;
    }

    .integration-note p {
        max-width: none;
        margin: 0;
        color: var(--ink-muted);
        font-size: 14px;
        line-height: 1.6;
    }

    .contact-primary {
        margin: 0 0 14px;
        font-size: 20px;
    }

    .contact-primary a {
        font-weight: 650;
        /* Um e-mail longo não pode empurrar a largura da página num celular estreito. */
        overflow-wrap: break-word;
    }

    .profile-main {
        display: flex;
        width: min(940px, calc(100% - 40px));
        margin: 0 auto;
        padding: 40px 0 64px;
        flex-direction: column;
        gap: 20px;
    }

    .profile-main[hidden] {
        display: none;
    }

    .profile-layout {
        display: grid;
        grid-template-columns: 216px minmax(0, 1fr);
        gap: 32px;
        align-items: start;
    }

    .profile-sidebar {
        display: flex;
        position: sticky;
        top: 24px;
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
    }

    .profile-nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    /* A aba ativa é marcada por uma faixa de acento à esquerda, não só por peso de fonte:
       cor sozinha não é indicador suficiente (WCAG 1.4.1). */
    .profile-nav-item {
        position: relative;
        padding: 10px 14px;
        border: none;
        border-radius: 8px;
        background: none;
        color: var(--ink-muted);
        font: inherit;
        font-size: 15px;
        text-align: left;
        cursor: pointer;
        transition: background 120ms ease, color 120ms ease;
    }

    .profile-nav-item::before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0;
        width: 3px;
        height: 0;
        border-radius: 0 3px 3px 0;
        background: var(--green);
        transform: translateY(-50%);
        transition: height 140ms ease;
    }

    .profile-nav-item:hover {
        background: var(--surface-hover);
        color: var(--ink);
    }

    .profile-nav-item.is-active {
        background: var(--green-soft);
        color: var(--on-soft-accent);
        font-weight: 650;
    }

    .profile-nav-item.is-active::before {
        height: 60%;
    }

    .profile-nav-item:focus-visible {
        outline: 2px solid var(--green);
        outline-offset: 2px;
    }

    .profile-sidebar-footer {
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding-top: 16px;
        border-top: 1px solid var(--line);
    }

    .profile-terms-link {
        color: var(--ink-muted);
        font-size: 13px;
        text-decoration: underline;
    }

    .profile-sections {
        display: flex;
        flex-direction: column;
        gap: 20px;
        min-width: 0;
    }

    .profile-card-header {
        margin-bottom: 24px;
    }

    .profile-card-header-row {
        display: flex;
        gap: 16px;
        align-items: flex-start;
        justify-content: space-between;
    }

    .profile-card-hint {
        margin: 6px 0 0;
        color: var(--ink-muted);
        font-size: 14px;
    }

    .usage-month-nav {
        display: flex;
        flex: 0 0 auto;
        gap: 6px;
    }

    .usage-month-button {
        display: grid;
        width: 34px;
        height: 34px;
        place-items: center;
        border: 1px solid var(--line-control);
        border-radius: 8px;
        color: var(--ink);
        background: var(--surface-strong);
        font-size: 15px;
        line-height: 1;
        cursor: pointer;
    }

    .usage-month-button:hover:not(:disabled) {
        border-color: var(--line-hover);
        background: var(--surface-hover);
    }

    .usage-month-button:disabled {
        color: var(--ink-muted);
        cursor: default;
        opacity: 0.5;
    }

    /* Enquanto um mês carrega, o conteúdo anterior fica visível mas esmaecido: trocar por
       um vazio faria a tela piscar a cada passo de navegação. */
    .usage-body.is-loading {
        opacity: 0.45;
        pointer-events: none;
        transition: opacity 120ms ease;
    }

    /* O saldo é do ciclo, não do mês: fica destacado acima da grade de totais, que muda
       conforme a navegação entre meses. */
    .credits-summary {
        padding: 20px;
        border: 1px solid transparent;
        border-radius: 12px;
        margin: 0 0 20px;
        background: var(--green-soft);
        color: var(--on-soft-accent);
    }

    .credits-summary-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 16px;
    }

    .credits-summary .usage-total-label,
    .credits-summary .usage-total-hint {
        display: block;
        color: var(--on-soft-accent);
        opacity: 0.75;
    }

    .credits-balance {
        display: block;
        font-family: Georgia, "Times New Roman", serif;
        font-size: 32px;
        line-height: 1.1;
    }

    .credits-meter {
        height: 10px;
        border-radius: 5px;
        margin: 16px 0 6px;
        background: rgb(0 0 0 / 12%);
        overflow: hidden;
    }

    .credits-meter-fill {
        display: block;
        width: 0;
        height: 100%;
        border-radius: 5px;
        background: var(--on-soft-accent);
        transition: width 200ms ease;
    }

    /* Barra cheia é o mesmo estado do chat bloqueado; a cor precisa dizer isso sem texto. */
    .credits-meter.is-exhausted .credits-meter-fill {
        background: #b3261e;
    }

    .credits-meter-label {
        font-size: 12px;
        opacity: 0.75;
    }

    /* O botão fica sobre o cartão verde-claro do saldo, onde o verde-escuro padrão do
       .save-button perde contraste. Aqui ele vira sólido e ganha relevo: é a única ação
       possível de quem chegou no limite, e precisa ser a coisa mais visível do cartão. */
    .credits-buy {
        padding: 13px 26px;
        box-shadow: 0 2px 10px rgb(15 77 50 / 28%);
        flex-shrink: 0;
        font-size: 15px;
        font-weight: 700;
        white-space: nowrap;
        transition: transform 120ms ease, box-shadow 120ms ease;
    }

    .credits-buy:hover:not(:disabled) {
        box-shadow: 0 4px 16px rgb(15 77 50 / 34%);
        transform: translateY(-1px);
    }

    .credits-buy:active:not(:disabled) {
        box-shadow: 0 1px 6px rgb(15 77 50 / 30%);
        transform: translateY(0);
    }

    @media (prefers-reduced-motion: reduce) {
        .credits-buy {
            transition: none;
        }

        .credits-buy:hover:not(:disabled) {
            transform: none;
        }
    }

    .credits-modal-body {
        margin: 0 0 20px;
        color: var(--ink-muted);
    }

    .credits-package-list {
        display: grid;
        gap: 8px;
        padding: 0;
        margin: 0 0 20px;
        list-style: none;
    }

    .credits-package {
        width: 100%;
        padding: 14px 16px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: transparent;
        color: inherit;
        font: inherit;
        text-align: left;
        cursor: pointer;
    }

    .credits-package:hover {
        background: var(--surface-hover);
    }

    .credits-package.is-selected {
        border-color: var(--green);
        background: var(--green-soft);
        color: var(--on-soft-accent);
    }

    .credits-modal-loading {
        margin: 0 0 20px;
        color: var(--ink-muted);
        font-size: 14px;
    }

    .credits-modal-buy {
        width: 100%;
        padding: 14px 22px;
        font-size: 15px;
        font-weight: 700;
    }

    .usage-totals {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
        gap: 12px;
        margin: 0 0 28px;
    }

    .usage-total {
        display: flex;
        padding: 18px;
        border: 1px solid var(--line);
        border-radius: 12px;
        flex-direction: column;
        gap: 4px;
    }

    /* O total gasto é o número que a pessoa veio ver; recebe a cor da marca. */
    .usage-total-primary {
        border-color: transparent;
        background: var(--green-soft);
    }

    .usage-total-primary .usage-total-label,
    .usage-total-primary .usage-total-hint {
        color: var(--on-soft-accent);
        opacity: 0.75;
    }

    .usage-total-primary .usage-total-value {
        color: var(--on-soft-accent);
    }

    .usage-total-label {
        color: var(--ink-muted);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .usage-total-value {
        font-family: Georgia, "Times New Roman", serif;
        font-size: 24px;
    }

    .usage-total-hint {
        color: var(--ink-muted);
        font-size: 12px;
    }

    .usage-subtitle {
        margin: 0 0 10px;
        font-size: 13px;
        font-weight: 600;
        color: var(--ink-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .usage-list,
    .usage-bars {
        display: flex;
        margin: 0 0 24px;
        padding: 0;
        flex-direction: column;
        gap: 2px;
        list-style: none;
    }

    .usage-list-item {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 2px 12px;
        padding: 10px 0;
        border-bottom: 1px solid var(--line);
        align-items: baseline;
    }

    .usage-list-label {
        font-size: 15px;
    }

    .usage-list-value {
        grid-row: 1 / span 2;
        grid-column: 2;
        align-self: center;
        font-variant-numeric: tabular-nums;
    }

    .usage-list-detail {
        grid-column: 1;
        color: var(--ink-muted);
        font-size: 12px;
        font-variant-numeric: tabular-nums;
    }

    .usage-bar-item {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr) 76px;
        gap: 10px;
        padding: 4px 0;
        align-items: center;
    }

    .usage-bar-label,
    .usage-bar-value {
        color: var(--ink-muted);
        font-size: 12px;
        font-variant-numeric: tabular-nums;
    }

    .usage-bar-value {
        text-align: right;
    }

    .usage-bar-track {
        height: 8px;
        border-radius: 4px;
        background: var(--surface-hover);
        overflow: hidden;
    }

    .usage-bar-fill {
        display: block;
        height: 100%;
        border-radius: 4px;
        background: var(--green);
    }

    .usage-empty {
        margin: 0;
        color: var(--ink-muted);
        font-size: 14px;
    }

    /* ---------- Ações Agendadas ---------- */

    .rules-list {
        display: flex;
        margin: 0 0 16px;
        padding: 0;
        flex-direction: column;
        gap: 12px;
        list-style: none;
    }

    .rule-item {
        padding: 14px 16px;
        border: 1px solid var(--line);
        border-radius: 10px;
        background: var(--surface);
    }

    .rule-item-header {
        display: flex;
        gap: 8px;
        align-items: center;
    }

    .rule-item-name {
        flex: 1;
        min-width: 0;
        font-size: 15px;
        overflow-wrap: anywhere;
    }

    .rule-item-paused {
        padding: 2px 8px;
        border-radius: 999px;
        background: var(--surface-hover);
        color: var(--ink-muted);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .rule-item-buttons {
        display: flex;
        gap: 6px;
    }

    .rule-item-button {
        padding: 4px 10px;
        border: 1px solid var(--control-line);
        border-radius: 8px;
        background: transparent;
        color: var(--ink);
        font-size: 13px;
        cursor: pointer;
    }

    .rule-item-button:hover {
        border-color: var(--line-hover);
        background: var(--surface-hover);
    }

    .rule-item-button-danger {
        color: var(--danger, #a3352c);
    }

    .rule-item-condition {
        margin: 8px 0 0;
        font-size: 14px;
        overflow-wrap: anywhere;
    }

    .rule-item-actions {
        display: flex;
        margin: 8px 0 0;
        padding: 0;
        flex-direction: column;
        gap: 4px;
        list-style: none;
    }

    .rule-item-actions li {
        display: flex;
        gap: 8px;
        align-items: baseline;
        justify-content: space-between;
        font-size: 14px;
        color: var(--ink-muted);
    }

    .rule-item-actions li > span:first-child {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .rule-item-mode {
        flex-shrink: 0;
        font-size: 12px;
        color: var(--ink-muted);
    }

    .rule-item-interval {
        margin: 10px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .rules-filter {
        display: flex;
        gap: 10px;
        align-items: center;
        margin: 0 0 12px;
    }

    .rules-filter .field-label {
        margin: 0;
    }

    .rule-item-button-primary {
        border-color: var(--green);
        color: var(--accent-ink);
        background: var(--green-soft);
        font-weight: 700;
    }

    .rule-item-last-check {
        margin: 4px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    .rules-form {
        display: flex;
        margin: 0 0 20px;
        padding: 16px;
        flex-direction: column;
        gap: 14px;
        border: 1px solid var(--panel-line);
        border-radius: 10px;
        background: var(--surface);
    }

    /* Um display explícito vence o atributo [hidden] do UA; sem esta regra, Cancelar marcava o
       formulário como oculto e ele continuava na tela. Mesmo padrão de .attachment-preview. */
    .rules-form[hidden] {
        display: none;
    }

    .rules-form-title {
        margin: 0;
        font-size: 16px;
    }

    .rule-action-list {
        display: flex;
        margin: 0;
        padding: 0;
        flex-direction: column;
        gap: 10px;
        list-style: none;
    }

    .rule-action-row {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .rule-action-controls {
        display: flex;
        gap: 8px;
        align-items: center;
        justify-content: space-between;
    }

    .rule-add-action,
    .rule-action-remove,
    .rule-cancel-button {
        padding: 6px 12px;
        border: 1px solid var(--control-line);
        border-radius: 8px;
        background: transparent;
        color: var(--ink);
        font-size: 13px;
        cursor: pointer;
        align-self: flex-start;
    }

    .rule-add-action:hover,
    .rule-action-remove:hover,
    .rule-cancel-button:hover {
        border-color: var(--line-hover);
        background: var(--surface-hover);
    }

    .rules-interval-field select {
        max-width: 260px;
    }

    .rules-note {
        margin: 8px 0 0;
        color: var(--ink-muted);
        font-size: 12px;
    }

    @media (max-width: 720px) {
        .profile-layout {
            grid-template-columns: minmax(0, 1fr);
        }

        .profile-sidebar {
            position: static;
            flex-direction: row;
            align-items: center;
            gap: 12px;
        }

        .profile-nav {
            flex-direction: row;
            flex-wrap: wrap;
        }
    }

    .profile-card {
        position: relative;
        padding: 28px;
        border: 1px solid var(--line);
        border-radius: 16px;
        background: var(--surface-strong);
        box-shadow: var(--shadow-2);
        animation: enter 240ms ease-out both;
    }

    .profile-card[hidden] {
        display: none;
    }

    /* ---------- esqueleto de carregamento ----------
       A página nasce visível e vai preenchendo. Só a identidade recebe shimmer, porque é
       o único bloco cujo espaço final é conhecido; o formulário fica desabilitado, o que
       já comunica "ainda não dá para mexer" sem inventar caixas falsas. */
    .profile-main.is-loading .profile-identity-name,
    .profile-main.is-loading .profile-identity-email {
        border-radius: 4px;
        color: transparent;
        background: var(--surface-hover);
        animation: profile-skeleton 1.4s ease-in-out infinite;
    }

    .profile-main.is-loading .profile-identity-name {
        width: 108px;
    }

    .profile-main.is-loading .profile-identity-email {
        width: 132px;
        margin-top: 4px;
    }

    .profile-main.is-loading .profile-avatar-fallback {
        background: var(--surface-hover);
        color: transparent;
        animation: profile-skeleton 1.4s ease-in-out infinite;
    }

    @keyframes profile-skeleton {
        0%, 100% { opacity: 1; }
        50% { opacity: 0.45; }
    }

    @media (prefers-reduced-motion: reduce) {
        .profile-main.is-loading .profile-identity-name,
        .profile-main.is-loading .profile-identity-email,
        .profile-main.is-loading .profile-avatar-fallback {
            animation: none;
        }
    }

    .forgot-password-main {
        display: flex;
        width: min(420px, calc(100% - 40px));
        margin: 0 auto;
        padding: 64px 0;
        flex-direction: column;
    }

    .forgot-password-card {
        text-align: center;
    }

    .forgot-password-card h1 {
        margin: 0 0 10px;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-md);
    }

    .forgot-password-subtitle {
        margin: 0 0 24px;
        color: var(--ink-muted);
        font-size: 14px;
    }

    .forgot-password-form {
        display: flex;
        flex-direction: column;
        gap: 6px;
        text-align: left;
    }

    .forgot-password-form input {
        padding: 11px 14px;
        margin-bottom: 10px;
        border: 1px solid var(--line-control);
        border-radius: 8px;
        color: var(--ink);
        background: var(--canvas);
    }

    .forgot-password-form input:focus-visible {
        border-color: var(--green);
        outline: none;
    }

    .forgot-password-form .save-button {
        width: 100%;
    }

    .forgot-password-notice {
        margin: 20px 0 0;
        padding: 12px 14px;
        border: 1px solid var(--warn-border);
        border-radius: 8px;
        background: var(--warn-bg);
        color: var(--warn-ink);
        font-size: 13px;
        text-align: left;
    }

    .forgot-password-notice[hidden] {
        display: none;
    }

    .forgot-password-back {
        display: block;
        margin-top: 20px;
        color: var(--accent-ink);
        font-size: 13px;
    }

    .forgot-password-back:hover {
        text-decoration: underline;
    }

    /* Rotulado e em fluxo normal: era uma seta sozinha posicionada de forma absoluta
       contra o card, que deixou de ser o pai quando o perfil ganhou navegação própria. */
    .profile-back-button {
        display: flex;
        padding: 0;
        border: none;
        background: none;
        gap: 8px;
        align-items: center;
        color: var(--ink-muted);
        font: inherit;
        font-size: 13px;
        text-align: left;
        cursor: pointer;
    }

    .profile-back-button:hover {
        color: var(--ink);
    }

    .profile-card h1 {
        margin: 0 0 20px;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-lg);
    }

    .profile-card h2 {
        margin: 0 0 8px;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-sm);
    }

    .profile-identity {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0;
    }

    .profile-identity-text {
        display: flex;
        min-width: 0;
        flex-direction: column;
    }

    /* Nome e e-mail truncam em vez de quebrar: um e-mail longo empurraria a coluna
       inteira e desalinharia o grid. */
    .profile-identity-name,
    .profile-identity-email {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .profile-identity-name {
        color: var(--ink);
        font-size: 15px;
        font-weight: 650;
    }

    .profile-identity-email {
        color: var(--ink-muted);
        font-size: 12px;
    }

    .profile-avatar-img,
    .profile-avatar-fallback {
        width: 44px;
        height: 44px;
        flex: 0 0 auto;
        border-radius: 50%;
    }

    .profile-avatar-img {
        object-fit: cover;
    }

    .profile-avatar-img[hidden],
    .profile-avatar-fallback[hidden] {
        display: none;
    }

    .profile-avatar-fallback {
        display: grid;
        place-items: center;
        background: var(--green-dark);
        color: var(--surface);
        font-weight: 650;
        font-size: 18px;
    }

    .profile-form {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .profile-fieldset {
        display: flex;
        margin: 0;
        padding: 0;
        border: none;
        flex-direction: column;
        gap: 18px;
    }

    .field {
        display: flex;
        min-width: 0;
        flex-direction: column;
        gap: 6px;
    }

    .field-row {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 18px;
    }

    .field-label {
        color: var(--ink-muted);
        font-size: 13px;
        font-weight: 650;
        letter-spacing: 0.02em;
        text-transform: uppercase;
    }

    .field-note {
        margin: 0;
        color: var(--ink-muted);
        font-size: 13px;
    }

    .field-error {
        margin: 0;
        color: var(--danger);
        font-size: 13px;
    }

    .profile-form input.is-invalid {
        border-color: var(--danger);
    }

    .profile-form-footer {
        display: flex;
        margin-top: 26px;
        padding-top: 20px;
        border-top: 1px solid var(--line);
        gap: 14px;
        align-items: center;
        justify-content: flex-end;
    }

    .profile-dirty-hint {
        margin-right: auto;
        color: var(--ink-muted);
        font-size: 13px;
    }

    .profile-form input,
    .profile-form select {
        padding: 11px 14px;
        border: 1px solid var(--line-control);
        border-radius: 8px;
        color: var(--ink);
        background-color: var(--canvas);
    }

    /* Fundo pela longa e não pelo atalho background: o atalho zeraria a seta que a base
       desenha. O padding à direita abre o espaço dela sem mexer nas outras três bordas, para o
       campo continuar alinhado com o input de Nome. */
    .profile-form select {
        padding-right: 36px;
    }

    /* A borda verde acompanha o anel herdado do reset; ela reforça o foco, não o substitui. */
    .profile-form input:focus-visible,
    .profile-form select:focus-visible {
        border-color: var(--green);
    }

    /* O fieldset inteiro fica desabilitado enquanto o perfil carrega. Com appearance: none o
       navegador não esmaece mais o select sozinho, então os dois tipos de campo passam a declarar
       o mesmo estado — caso contrário, no carregamento, só os selects pareceriam bloqueados. */
    .profile-form input:disabled,
    .profile-form select:disabled {
        cursor: default;
        opacity: 0.6;
    }

    .save-button {
        padding: 12px 22px;
        border: none;
        border-radius: 999px;
        color: var(--surface);
        background: var(--green-dark);
        font-weight: 650;
    }

    .save-button:hover:not(:disabled) {
        background: var(--green);
    }

    .save-button:disabled {
        cursor: default;
        opacity: 0.68;
    }

    .integration-hint {
        margin: 0 0 18px;
        color: var(--ink-muted);
        font-size: 14px;
    }

    .integration-row {
        display: flex;
        align-items: center;
        gap: 16px;
        flex-wrap: wrap;
    }

    .provider-preferences {
        margin-top: 28px;
        padding-top: 20px;
        border-top: 1px solid var(--line);
    }

    .provider-preferences-title {
        margin: 0 0 6px;
        font-size: 15px;
    }

    .provider-preferences-empty {
        margin-top: 28px;
        padding-top: 20px;
        border-top: 1px solid var(--line);
        color: var(--ink-muted);
        font-size: 14px;
    }

    .provider-preference-list {
        list-style: none;
        margin: 16px 0 0;
        padding: 0;
        display: grid;
        gap: 12px;
    }

    /* Controle segmentado: com duas ou três opções por família, mostrar todas de uma vez custa
       menos espaço do que um dropdown e responde sem clique a pergunta que a seção faz. */
    .provider-preference {
        display: flex;
        min-width: 0;
        gap: 16px;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }

    .provider-preference-label {
        flex: 0 0 auto;
        font-size: 14px;
        font-weight: 650;
    }

    /* Família sem alternativa: mesmo alinhamento das que têm seletor, sem moldura de controle —
       nada aqui é clicável, e uma pílula sugeriria que é. */
    .provider-preference-fixed {
        display: flex;
        padding: 8px 4px;
        gap: 8px;
        align-items: center;
        color: var(--ink-muted);
        font-size: 13px;
    }

    /* A moldura fica no contêiner e o select entra sem borda própria: assim a marca do provider
       escolhido e o campo leem como um controle só, e não como um ícone solto ao lado de um
       dropdown. */
    .provider-preference-control {
        display: flex;
        min-width: 0;
        max-width: 100%;
        padding: 4px 4px 4px 7px;
        border: 1px solid var(--line-control);
        border-radius: 10px;
        gap: 8px;
        align-items: center;
        background: var(--surface);
        transition: border-color 140ms ease;
    }

    .provider-preference-control:hover {
        border-color: var(--line-hover);
    }

    .provider-preference-control:focus-within {
        border-color: var(--green);
        outline: 2px solid var(--green);
        outline-offset: 1px;
    }

    .provider-preference-control:has(.provider-preference-select:disabled) {
        cursor: progress;
        opacity: 0.6;
    }

    /* A moldura e a marca do provider pertencem ao contêiner, então este é o único <select> do app
       que abre mão da borda e do raio da base. Cores, seta e cursor continuam vindo de lá — o que
       sobra aqui é o encaixe dentro da moldura e um corpo menor, porque a linha compete com o
       rótulo da família ao lado. */
    .provider-preference-select {
        padding: 4px 24px 4px 2px;
        border: 0;
        border-radius: 0;
        background-position: right 12px center, right 7px center;
        font-size: 14px;
    }

    /* Quem esmaece durante a troca é o contêiner inteiro, marca junto. Sem isto as duas opacidades
       se multiplicam e o campo some enquanto a preferência salva. */
    .provider-preference-select:disabled {
        opacity: 1;
    }

    /* O anel de foco fica no contêiner, que envolve marca e campo: dois anéis concêntricos
       repetiriam a mesma informação e o de dentro cortaria a moldura. */
    .provider-preference-select:focus,
    .provider-preference-select:focus-visible {
        outline: none;
    }

    .provider-option-mark {
        display: grid;
        width: 22px;
        height: 22px;
        flex: 0 0 auto;
        place-items: center;
        border: 1px solid var(--line);
        border-radius: 7px;
        background: var(--surface);
        font-family: Georgia, "Times New Roman", serif;
        font-size: 12px;
        font-weight: 700;
    }

    /* A marca do Google pinta a própria letra com background-clip: text e color: transparent, então
       precisa vencer a regra de background acima — do contrário sobra só o glifo invisível. */
    .provider-option-mark.integration-catalog-logo-google {
        border-color: var(--line);
        color: transparent;
        background: conic-gradient(from -45deg, #4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0);
        background-clip: text;
    }

    @media (prefers-reduced-motion: reduce) {
        .provider-preference-control {
            transition: none;
        }
    }

    @keyframes enter {
        from {
            opacity: 0;
            transform: translateY(12px);
        }
    }

    @keyframes message-in {
        from {
            opacity: 0;
            transform: translateY(7px);
        }
    }

    @keyframes typing {
        0%, 60%, 100% {
            opacity: 0.35;
            transform: translateY(0);
        }
        30% {
            opacity: 1;
            transform: translateY(-3px);
        }
    }

    @keyframes history-spin {
        to {
            transform: rotate(360deg);
        }
    }

    .history-loading {
        position: absolute;
        top: 50%;
        left: 50%;
        display: flex;
        translate: -50% -50%;
        align-items: center;
        gap: 10px;
        padding: 11px 18px;
        border: 1px solid var(--line);
        border-radius: 999px;
        background: var(--surface);
        box-shadow: var(--shadow-2);
        color: var(--ink-muted);
        font-size: 14px;
        animation: enter 320ms ease-out both;
    }

    .history-loading[hidden] {
        display: none;
    }

    .history-spinner {
        width: 15px;
        height: 15px;
        border: 2px solid var(--green-soft);
        border-top-color: var(--green);
        border-radius: 50%;
        animation: history-spin 720ms linear infinite;
    }

    /* position:absolute against .chat-main (the scroll container, position:relative) rather than
       sticky: its containing block is the viewport of .chat-main, not the scrolled content, so it
       stays pinned to the bottom of what is visible no matter how far up the thread is scrolled —
       the same technique .empty-state already uses with inset:0. */
    .new-messages-button {
        position: absolute;
        bottom: 18px;
        left: 50%;
        z-index: 1;
        display: inline-flex;
        width: fit-content;
        align-items: center;
        gap: 8px;
        translate: -50% 0;
        padding: 9px 16px;
        border: 1px solid var(--green-dark);
        border-radius: 999px;
        color: var(--on-accent);
        background: var(--green-dark);
        font-weight: 650;
        font-size: 13px;
        box-shadow: var(--shadow-2);
        animation: enter 180ms ease-out both;
    }

    .new-messages-button[hidden] {
        display: none;
    }

    .new-messages-button:hover {
        background: var(--green);
        border-color: var(--green);
    }

    .history-divider {
        display: flex;
        align-items: center;
        gap: 12px;
        margin: 2px 0 6px;
        color: var(--ink-muted);
        font-size: 12px;
        letter-spacing: 0.02em;
    }

    .history-divider::before,
    .history-divider::after {
        height: 1px;
        background: var(--line);
        content: "";
        flex: 1;
    }

    @media (prefers-reduced-motion: reduce) {
        .history-spinner {
            animation-duration: 2.4s;
        }

        .history-loading {
            animation: none;
        }
    }

    @media (max-width: 680px) {
        .app-header {
            min-height: 64px;
            padding: 10px 14px;
        }

        .brand-name,
        .connection-status {
            display: none;
        }

        .integration-actions {
            gap: 8px;
        }

        .google-button {
            min-height: 42px;
            padding: 0 12px;
            font-size: 14px;
        }

        .messages {
            width: calc(100% - 24px);
            padding: 28px 0 34px;
            gap: 20px;
        }

        .empty-state h1 {
            font-size: var(--text-display-compact);
        }

        .message-content {
            max-width: 86%;
        }

        /* Em telas estreitas as ações do bloco dividem a largura igualmente em vez de se
           empilharem à direita, para o alvo de toque ser maior que o rótulo. */
        .block-actions {
            display: grid;
            grid-template-columns: 1fr 1fr;
        }

        .block-action {
            min-width: 0;
        }

        .composer-area {
            padding: 10px 10px max(10px, env(safe-area-inset-bottom));
        }

        .composer {
            padding-left: 8px;
        }

        .send-button {
            min-width: 68px;
            padding: 0 12px;
        }
    }

    @media (max-width: 360px) {
        .block-actions {
            grid-template-columns: 1fr;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            scroll-behavior: auto !important;
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
        }
    }
}

/* ---------- catálogo e modal de integrações ---------- */
@layer components {
    .integration-group + .integration-group {
        margin-top: 52px;
        padding-top: 44px;
        border-top: 1px solid var(--line);
    }

    .integration-group-header {
        display: flex;
        margin-bottom: 22px;
        gap: 24px;
        align-items: flex-end;
        justify-content: space-between;
    }

    .integration-group-header .section-heading {
        margin-bottom: 8px;
    }

    .integration-group-header p:not(.integration-group-kicker) {
        max-width: 60ch;
        margin: 0;
        color: var(--ink-muted);
        line-height: 1.55;
    }

    .integration-group-kicker {
        margin: 0 0 7px;
        color: var(--green);
        font-size: 11px;
        font-weight: 750;
        letter-spacing: 0.06em;
    }

    .integration-group-count {
        flex: 0 0 auto;
        color: var(--ink-muted);
        font-size: 13px;
        white-space: nowrap;
    }

    /* auto-fill em vez de um número fixo de colunas: com centenas de integrações a grade tem de
       usar toda a largura disponível, e uma trilha mínima de 200px mantém nome e categoria em
       uma linha legível em qualquer viewport sem precisar de breakpoint por contagem. */
    .integration-tile-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        margin: 0;
        padding: 0;
        gap: 12px;
        list-style: none;
    }

    .integration-tile {
        display: flex;
        width: 100%;
        height: 100%;
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 13px;
        gap: 12px;
        align-items: center;
        color: inherit;
        background: var(--surface);
        font: inherit;
        text-align: left;
        transition: border-color 140ms ease, background 140ms ease, transform 140ms ease,
            box-shadow 140ms ease;
    }

    .integration-tile:hover {
        border-color: var(--green);
        background: var(--surface-strong);
        box-shadow: var(--shadow-1);
        transform: translateY(-2px);
    }

    .integration-tile:focus-visible {
        border-color: var(--green);
        outline: 2px solid var(--green);
        outline-offset: 2px;
    }

    .integration-tile.is-active {
        border-color: var(--green-soft);
    }

    .integration-tile-logo {
        display: grid;
        width: 38px;
        height: 38px;
        flex: 0 0 auto;
        place-items: center;
        border: 1px solid var(--green-soft);
        border-radius: 11px;
        color: var(--accent-ink);
        background: var(--surface-hover);
        font-family: Georgia, "Times New Roman", serif;
        font-size: 18px;
        font-weight: 700;
    }

    .integration-tile .integration-catalog-logo-google {
        border-color: var(--line);
        background-color: var(--canvas);
    }

    .integration-tile-text {
        display: flex;
        min-width: 0;
        flex: 1;
        flex-direction: column;
        gap: 2px;
    }

    /* O nome é o que se procura numa lista longa: nunca quebra em duas linhas, para que todos os
       cartões tenham a mesma altura e a varredura vertical não trave. */
    .integration-tile-name {
        overflow: hidden;
        font-size: 14px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .integration-tile-category {
        overflow: hidden;
        color: var(--ink-muted);
        font-size: 12px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Situação pela cor do cartão inteiro, não por um selo: o selo comia a largura de que o nome
       precisa, e é o nome que se procura numa lista longa. Cor sozinha não é acessível, então
       cada cartão carrega a mesma informação no aria-label, e a preferida — a única distinção
       entre dois cartões igualmente ativos — ganha também a estrela. */
    .integration-tile-managed {
        position: relative;
        padding-left: 17px;
    }

    .integration-tile-managed::before {
        position: absolute;
        top: 10px;
        bottom: 10px;
        left: 0;
        width: 3px;
        border-radius: 0 3px 3px 0;
        background: transparent;
        content: "";
    }

    .integration-tile-managed.is-active {
        border-color: var(--green-soft);
        background: var(--surface);
    }

    .integration-tile-managed.is-active::before {
        background: var(--status-live);
    }

    .integration-tile-managed.is-preferred {
        border-color: var(--tile-preferred-border);
        background: var(--tile-preferred-bg);
    }

    .integration-tile-managed.is-preferred::before {
        background: var(--tile-preferred-bar);
    }

    /* Apagada de propósito: o cartão inativo continua legível e clicável, mas não disputa a
       atenção com os que estão em uso. */
    .integration-tile-managed.is-inactive {
        border-style: dashed;
        background: var(--canvas);
    }

    .integration-tile-managed.is-inactive .integration-tile-name {
        color: var(--ink-muted);
        font-weight: 600;
    }

    .integration-tile-managed.is-inactive .integration-tile-logo {
        border-color: var(--line);
        color: var(--ink-muted);
        background: var(--surface);
    }

    .integration-tile-managed.is-unavailable {
        border-style: dashed;
        background: var(--canvas);
        opacity: 0.62;
    }

    .integration-tile-star {
        align-self: flex-start;
        flex: 0 0 auto;
        color: var(--green);
        font-size: 12px;
        line-height: 1.2;
    }

    .integration-catalog-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin: 0;
        padding: 0;
        gap: 14px;
        list-style: none;
    }

    .integration-catalog-card {
        display: flex;
        width: 100%;
        height: 100%;
        min-height: 190px;
        padding: 22px;
        border: 1px solid var(--line);
        border-radius: 15px;
        gap: 16px;
        color: inherit;
        background: var(--surface);
        font: inherit;
        text-align: left;
        transition: border-color 140ms ease, background 140ms ease, transform 140ms ease,
            box-shadow 140ms ease;
    }

    .integration-catalog-card:hover {
        border-color: var(--green);
        background: var(--surface-strong);
        box-shadow: var(--shadow-1);
        transform: translateY(-2px);
    }

    .integration-catalog-card:focus-visible {
        border-color: var(--green);
        outline: 2px solid var(--green);
        outline-offset: 2px;
    }

    .integration-catalog-logo,
    .integration-detail-logo {
        display: grid;
        width: 48px;
        height: 48px;
        flex: 0 0 auto;
        place-items: center;
        border: 1px solid var(--green-soft);
        border-radius: 13px;
        color: var(--accent-ink);
        background: var(--surface-hover);
        font-family: Georgia, "Times New Roman", serif;
        font-size: 22px;
        font-weight: 700;
    }

    .integration-catalog-logo-google {
        color: transparent;
        background: conic-gradient(from -45deg, #4285f4 0 25%, #34a853 0 50%, #fbbc05 0 75%, #ea4335 0);
        background-clip: text;
    }

    .integration-catalog-card .integration-catalog-logo-google,
    .integration-detail-logo.integration-catalog-logo-google {
        border-color: var(--line);
        background-color: var(--canvas);
    }

    .integration-catalog-content {
        display: flex;
        min-width: 0;
        flex: 1;
        flex-direction: column;
    }

    .integration-catalog-heading {
        display: flex;
        gap: 10px;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }

    .integration-catalog-heading strong {
        font-family: Georgia, "Times New Roman", serif;
        font-size: 18px;
    }

    /* Categoria: taxonomia, não estado. Deliberadamente quieta — descreve o que a integração é,
       algo que não muda e que ninguém abre o modal para descobrir. */
    .integration-category-chip {
        display: inline-flex;
        width: fit-content;
        align-items: center;
        padding: 4px 9px;
        border: 1px solid var(--line);
        border-radius: 999px;
        color: var(--ink-muted);
        background: var(--canvas);
        font-size: 11px;
        font-weight: 650;
        letter-spacing: 0.02em;
        white-space: nowrap;
    }

    /* Situação: o fato que muda, e o motivo de o modal existir. Ponto colorido + caixa alta o
       separam das categorias mesmo de relance, e a cor nunca vai sozinha — o texto diz o mesmo,
       para quem não distingue as cores e para quem lê por leitor de tela. */
    .integration-state {
        display: inline-flex;
        width: fit-content;
        align-items: center;
        gap: 7px;
        padding: 5px 11px;
        border: 1px solid var(--line);
        border-radius: 999px;
        color: var(--ink-muted);
        background: var(--surface-hover);
        font-size: 10px;
        font-weight: 750;
        letter-spacing: 0.07em;
        text-transform: uppercase;
        white-space: nowrap;
    }

    .integration-state::before {
        width: 7px;
        height: 7px;
        flex: none;
        border-radius: 50%;
        background: var(--status-idle);
        content: "";
    }

    .integration-state-active,
    .integration-state-always {
        border-color: var(--green-soft);
        color: var(--accent-ink);
    }

    .integration-state-active::before,
    .integration-state-always::before,
    .integration-state-preferred::before {
        background: var(--status-live);
        box-shadow: 0 0 0 3px var(--status-live-ring);
    }

    /* Preferida é um degrau acima de ativa, e as duas aparecem lado a lado na mesma lista: o
       preenchimento é o que as separa quando ambas estão verdes. */
    .integration-state-preferred {
        border-color: var(--tile-preferred-border);
        color: var(--accent-ink);
        background: var(--tile-preferred-bg);
    }

    .integration-state-inactive {
        background: var(--canvas);
    }

    .integration-state-unavailable {
        border-color: var(--danger-border);
        color: var(--danger);
        background: var(--danger-bg);
    }

    .integration-state-unavailable::before {
        background: var(--danger);
    }

    .integration-catalog-summary {
        margin-top: 12px;
        color: var(--ink-muted);
        font-size: 14px;
        line-height: 1.55;
        text-wrap: pretty;
    }

    .integration-card-link {
        margin-top: auto;
        padding-top: 18px;
        color: var(--accent-ink);
        font-size: 13px;
        font-weight: 650;
    }

    .integration-card-link span {
        display: inline-block;
        margin-left: 3px;
        transition: transform 140ms ease;
    }

    .integration-catalog-card:hover .integration-card-link span {
        transform: translateX(3px);
    }

    .integration-modal {
        width: min(680px, 100%);
        padding: 30px;
    }

    .integration-modal-header {
        display: flex;
        padding-right: 34px;
        gap: 18px;
        align-items: flex-start;
    }

    .integration-detail-logo {
        width: 58px;
        height: 58px;
        border-radius: 15px;
        font-size: 26px;
    }

    /* Situação, nome, resumo e categorias empilhados numa ordem só: o que mudou, o que é, o que
       faz, e por último em que áreas entra. */
    .integration-modal-heading {
        display: flex;
        min-width: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    /* Título e situação na mesma linha. Centralizado, e não pela linha de base: a pílula é
       maiúscula pequena com borda e padding, e alinhá-la pela base a faria flutuar contra um
       título serifado bem maior. O wrap existe porque nome longo e "PREFERIDA" não cabem juntos
       em tela estreita — e aí a pílula desce inteira, em vez de espremer o título. */
    .integration-modal-titlebar {
        display: flex;
        min-width: 0;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }

    .integration-modal-header h2 {
        margin: 0;
        font-family: Georgia, "Times New Roman", serif;
        font-size: var(--text-heading-md);
    }

    .integration-modal-header p {
        margin: 0;
        color: var(--ink-muted);
        font-size: 14px;
        line-height: 1.55;
    }

    .integration-modal-content {
        margin-top: 26px;
        padding-top: 24px;
        border-top: 1px solid var(--line);
    }

    .integration-modal-content[hidden] {
        display: none;
    }

    .integration-modal-content section + section {
        margin-top: 26px;
    }

    .integration-modal-content h3 {
        margin: 0 0 9px;
        font-family: Georgia, "Times New Roman", serif;
        font-size: 18px;
    }

    .integration-modal-content section > p:last-child {
        margin: 0;
        color: var(--ink-muted);
        font-size: 14px;
        line-height: 1.65;
    }

    .integration-feature-list {
        display: grid;
        margin: 0;
        padding: 0;
        gap: 10px;
        list-style: none;
    }

    .integration-feature-list li {
        display: flex;
        padding: 13px 14px;
        border: 1px solid var(--line);
        border-radius: 11px;
        gap: 11px;
        background: var(--surface);
    }

    .integration-feature-check {
        display: grid;
        width: 22px;
        height: 22px;
        flex: 0 0 auto;
        place-items: center;
        border-radius: 50%;
        color: var(--accent-ink);
        background: var(--green-soft);
        font-size: 12px;
        font-weight: 750;
    }

    .integration-feature-list strong {
        font-size: 14px;
    }

    .integration-feature-list p {
        margin: 3px 0 0;
        color: var(--ink-muted);
        font-size: 13px;
        line-height: 1.5;
    }

    .integration-modal-footer {
        display: flex;
        margin-top: 26px;
        padding-top: 20px;
        border-top: 1px solid var(--line);
        gap: 12px;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
    }

    .integration-modal-session-note,
    .integration-modal-error {
        margin: 0 auto 0 0;
        color: var(--ink-muted);
        font-size: 13px;
    }

    .integration-modal-error {
        color: var(--danger);
    }

    /* No catálogo esta ação é um <a> (leva ao perfil) e no perfil é um <button>. O sublinhado do
       link não faz sentido num elemento que já se apresenta como botão. */
    .integration-modal-action {
        display: inline-flex;
        width: auto;
        min-width: 112px;
        margin: 0;
        align-items: center;
        justify-content: center;
        text-decoration: none;
    }

    /* O display acima vence o display:none do agente de usuário para [hidden], então sem esta
       regra a ação escondida (nativa, indisponível ou estado ainda não carregado) continua na
       tela como um botão verde vazio. */
    .integration-modal-action[hidden] {
        display: none;
    }

    .integration-modal-action.is-destructive {
        border: 1px solid var(--danger);
        color: var(--danger);
        background: transparent;
    }

    .integration-modal-action.is-destructive:hover:not(:disabled) {
        color: var(--surface-strong);
        background: var(--danger);
    }

    @media (max-width: 700px) {
        .integration-catalog-grid {
            grid-template-columns: 1fr;
        }

        .integration-group-header {
            align-items: flex-start;
            flex-direction: column;
            gap: 10px;
        }

        .integration-modal {
            padding: 24px 20px 20px;
        }
    }

    @media (max-width: 460px) {
        .integration-catalog-card {
            min-height: 0;
            padding: 18px;
        }

        .integration-catalog-logo {
            width: 42px;
            height: 42px;
        }

        .integration-modal-header {
            padding-right: 26px;
            flex-direction: column;
        }
    }

    @media (prefers-reduced-motion: reduce) {
        .integration-catalog-card,
        .integration-tile,
        .integration-card-link span {
            transition: none;
        }

        .integration-catalog-card:hover,
        .integration-tile:hover {
            transform: none;
        }
    }
}

/* ---------- filtro de categoria e grade do perfil ---------- */
@layer components {
    .integration-filter {
        display: flex;
        margin-bottom: 22px;
        gap: 10px;
        flex-wrap: wrap;
        align-items: center;
    }

    .integration-filter-label {
        color: var(--ink-muted);
        font-size: 13px;
        font-weight: 650;
    }

    /* Borda, cores, seta e comportamento vêm da base; aqui fica só o que é deste filtro: a
       largura mínima que impede o campo de encolher até o nome da categoria não caber. */
    .integration-filter-select {
        min-width: 200px;
        padding: 9px 32px 9px 12px;
    }

    .integration-filter-select:focus-visible {
        border-color: var(--green);
        outline: 2px solid var(--green);
        outline-offset: 1px;
    }

    .integration-group-empty {
        margin: 0;
        color: var(--ink-muted);
        font-size: 14px;
    }

    .integration-subgroup + .integration-subgroup {
        margin-top: 26px;
    }

    .integration-subgroup-title {
        margin: 0 0 10px;
        color: var(--ink-muted);
        font-size: 12px;
        font-weight: 750;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    #integrationsCard .integration-filter {
        margin-top: 18px;
    }

    /* Sem trilhas ainda desenhadas a grade tem altura zero e o card colapsa antes do fetch. */
    #userNativeGrid[aria-busy="true"] {
        min-height: 66px;
    }

    .integration-modal-pills {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }
}
