/* ==========================================================================
   Design system — Painel de Relatórios (Meta Ads)
   Leitura de design: dashboard B2B para agências apresentarem relatórios a
   clientes finais. Admin = denso e funcional. Área do cliente = cinemática,
   editorial, "modo apresentação". Um único acento (laranja da marca),
   superfícies quase-pretas (nunca #000 puro), sombras tingidas, tipografia
   Outfit em toda a hierarquia, movimento moderado e sempre motivado
   (revelar dados, guiar o olhar), nunca decorativo.
   ========================================================================== */

:root {
    /* Superfícies — nunca preto/branco puro */
    --bg: #0a0a0c;
    --bg-elevated: #111114;
    --surface: #16161a;
    --surface-2: #1c1c21;
    --surface-3: #232329;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);

    /* Texto */
    --text: #f4f4f3;
    --text-muted: #a6a6ad;
    --text-dim: #6f6f78;

    /* Acento único da marca — usado de forma idêntica em toda a aplicação */
    --accent: #ff7a1a;
    --accent-strong: #ffa04d;
    --accent-dim: rgba(255, 122, 26, 0.14);
    --accent-glow: rgba(255, 122, 26, 0.35);

    --success: #34d399;
    --success-dim: rgba(52, 211, 153, 0.14);
    --error: #f87171;
    --error-dim: rgba(248, 113, 113, 0.14);

    /* Escala de raio única (shape lock) */
    --r-sm: 10px;
    --r-md: 16px;
    --r-lg: 24px;
    --r-pill: 999px;

    /* Sombras tingidas, nunca cinza puro */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 32px -8px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    --shadow-glow: 0 0 0 1px rgba(255, 122, 26, 0.25), 0 8px 40px -8px rgba(255, 122, 26, 0.25);

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --dur: 240ms;

    --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-weight: 400;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font); font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; color: var(--text); }
h1 { font-size: clamp(1.6rem, 1.3rem + 1vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; font-weight: 600; }

a { color: var(--accent-strong); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--accent); text-decoration: underline; }

::selection { background: var(--accent-dim); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

small { color: var(--text-dim); }

/* ==========================================================================
   Login — tela cinemática
   ========================================================================== */
.login-page {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    background: var(--bg);
    overflow: hidden;
    padding: 24px;
}
.login-page::before,
.login-page::after {
    content: '';
    position: absolute;
    width: 640px;
    height: 640px;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.28;
    background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
    animation: float-blob 16s var(--ease) infinite alternate;
}
.login-page::before { top: -220px; left: -180px; }
.login-page::after { bottom: -260px; right: -200px; animation-delay: -8s; }
@keyframes float-blob {
    to { transform: translate(60px, 40px) scale(1.15); }
}
.login-box {
    position: relative;
    z-index: 1;
    background: linear-gradient(180deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    padding: 44px 40px;
    border-radius: var(--r-lg);
    width: 380px;
    max-width: 100%;
    box-shadow: var(--shadow-md);
    animation: rise-in 600ms var(--ease) both;
}
.login-box .login-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-strong);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}
.login-logo { display: block; height: 34px; width: auto; margin-bottom: 18px; }
.login-box h1 { font-size: 1.5rem; margin-bottom: 6px; }
.login-box .login-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
@keyframes rise-in {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Shell (sidebar + topbar + conteúdo)
   ========================================================================== */
.app-shell { display: flex; min-height: 100dvh; }

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
    position: sticky;
    top: 0;
    height: 100dvh;
    z-index: 40;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 15px;
    padding: 4px 10px 22px;
    color: var(--text);
    letter-spacing: -0.01em;
}
.sidebar .brand i { color: var(--accent); font-size: 20px; }
.sidebar .brand-logo { height: 28px; width: auto; display: block; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar nav a i { font-size: 18px; width: 20px; text-align: center; color: var(--text-dim); transition: color var(--dur); }
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a:hover i { color: var(--accent-strong); }
.sidebar nav a.active { background: var(--accent-dim); color: var(--text); border-left-color: var(--accent); }
.sidebar nav a.active i { color: var(--accent); }

.sidebar-footer {
    padding: 14px 10px 4px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted);
}
.sidebar-footer .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: #1a0d00; flex-shrink: 0;
}
.sidebar-footer .who { flex: 1; min-width: 0; }
.sidebar-footer .who strong { display: block; color: var(--text); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer a { color: var(--text-dim); font-size: 12px; }
.sidebar-footer a:hover { color: var(--error); }

.menu-toggle, .drawer-backdrop { display: none; }

.content { flex: 1; padding: 36px 44px; min-width: 0; }
.content > h1 { margin-bottom: 4px; }
.subtitle { color: var(--text-muted); margin: -2px 0 24px; font-size: 14px; }

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--r-sm);
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid transparent;
    animation: rise-in 300ms var(--ease) both;
}
.alert-success { background: var(--success-dim); color: var(--success); border-color: rgba(52, 211, 153, 0.25); }
.alert-error { background: var(--error-dim); color: var(--error); border-color: rgba(248, 113, 113, 0.25); }

/* ==========================================================================
   Botões
   ========================================================================== */
button, .btn, .btn-secondary, .btn-small, .btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    padding: 11px 20px;
    border-radius: var(--r-sm);
    background: var(--accent);
    color: #1a0d00;
    font-weight: 700;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    width: fit-content;
    text-decoration: none;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
button:hover, .btn:hover { background: var(--accent-strong); text-decoration: none; box-shadow: var(--shadow-glow); transform: translateY(-1px); }
button:active, .btn:active { transform: translateY(0); }
.btn-secondary { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn-small { padding: 7px 14px; font-size: 13px; margin: 12px 0; }
.btn-ghost { background: transparent; color: var(--text-muted); padding: 6px 10px; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }

/* ==========================================================================
   Forms
   ========================================================================== */
form.form { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
form.form-metrics { max-width: 680px; }
form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
form label small { font-weight: 400; color: var(--text-dim); }
form input[type=text], form input[type=email], form input[type=password], form input[type=date], form input[type=file], form select, form textarea {
    padding: 11px 13px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    border-radius: var(--r-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--dur), box-shadow var(--dur);
}
form textarea { resize: vertical; font-family: 'Poppins', monospace; }
form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
form label.checkbox { flex-direction: row; align-items: center; gap: 8px; }
form input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
fieldset { border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px 18px; margin: 0; background: var(--surface); }
fieldset legend { font-weight: 700; padding: 0 6px; color: var(--text); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }

/* ==========================================================================
   Tabelas
   ========================================================================== */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; margin-top: 18px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.05em; background: var(--surface-2); }
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table td a { color: var(--text-muted); font-size: 13px; }
.table td a:hover { color: var(--accent-strong); }

/* ==========================================================================
   Cards / cockpit do dashboard
   ========================================================================== */
.cards { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 18px; margin-bottom: 34px; }
.card {
    background: linear-gradient(160deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
}
.card.card--feature { background: linear-gradient(160deg, var(--surface-3), var(--surface-2)); box-shadow: var(--shadow-glow); }
.card.card--feature::after {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(circle at 100% 0%, var(--accent-dim), transparent 60%);
    pointer-events: none;
}
.card i { font-size: 22px; color: var(--accent); margin-bottom: 14px; display: block; }
.card-value { display: block; font-size: 2rem; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.card-label { color: var(--text-muted); font-size: 13px; margin-top: 2px; display: block; }

/* ==========================================================================
   Métricas cinematográficas — stat tiles
   ========================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.stat-tile {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 16px 16px 14px;
    transition: border-color var(--dur), transform var(--dur) var(--ease);
}
.stat-tile:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stat-tile i { font-size: 17px; color: var(--text-dim); }
.stat-tile--highlight { background: linear-gradient(160deg, var(--accent-dim), var(--surface-2)); border-color: rgba(255, 122, 26, 0.3); }
.stat-tile--highlight i { color: var(--accent); }
.stat-value { display: block; font-size: 1.35rem; font-weight: 800; color: var(--text); margin: 8px 0 2px; letter-spacing: -0.01em; }
.stat-label { display: block; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-label small { display: block; font-size: 11px; margin-top: 1px; }

.stat-grid--compact { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0; }
.stat-grid--compact .stat-tile { padding: 10px 12px; }
.stat-grid--compact .stat-value { font-size: 1rem; margin: 4px 0 1px; }
.stat-grid--compact i { font-size: 14px; }

/* ==========================================================================
   Funil de retenção de vídeo
   ========================================================================== */
.video-funnel { margin: 18px 0 6px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.video-funnel-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 12px; }
.funnel-row { display: grid; grid-template-columns: 90px 1fr 70px; align-items: center; gap: 12px; margin-bottom: 8px; }
.funnel-label { font-size: 12px; color: var(--text-muted); }
.funnel-track { height: 8px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.funnel-bar {
    height: 100%;
    width: 0;
    border-radius: var(--r-pill);
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    transition: width 900ms var(--ease);
}
.funnel-bar.is-visible { width: var(--funnel-pct); }
.funnel-value { font-size: 12px; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Árvore campanha > conjunto > anúncio (linha do tempo)
   ========================================================================== */
.tree { position: relative; }
.tree-node {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 22px 26px;
    margin: 20px 0;
    position: relative;
}
.tree-node.level-campaign { box-shadow: var(--shadow-md); }
.tree-node.level-adset { margin-left: 28px; border-left: 3px solid var(--accent); background: var(--surface-2); }
.tree-node.level-ad { margin-left: 28px; border-left: 3px solid var(--border-strong); background: var(--bg-elevated); padding: 16px 20px; }
.tree-node-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.tree-node h2, .tree-node h3, .tree-node h4 { margin: 0; }
.tree-node .eyebrow { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent-strong); margin-bottom: 4px; }
.tree-actions { font-size: 13px; display: flex; gap: 10px; flex-shrink: 0; }
.tree-actions a { color: var(--text-dim); }
.tree-actions a:hover { color: var(--accent-strong); }

.tree-readonly .tree-node { animation: none; }

/* Revelar ao rolar (reveal-on-scroll) */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 700ms var(--ease), transform 700ms var(--ease); }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ==========================================================================
   Hero do relatório (resumo cinemático no topo)
   ========================================================================== */
.report-hero {
    background: radial-gradient(circle at 15% 0%, var(--accent-dim), transparent 55%), linear-gradient(160deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 34px 38px;
    margin-bottom: 28px;
}
.report-hero .eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--accent-strong); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 10px; }
.report-hero h1 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.4rem); margin-bottom: 6px; }
.report-hero .period-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--surface-3); border: 1px solid var(--border-strong);
    padding: 6px 14px; border-radius: var(--r-pill); font-size: 13px; color: var(--text-muted); margin-bottom: 22px;
}
.report-hero .stat-grid { margin-top: 8px; margin-bottom: 0; }

/* ==========================================================================
   Comparativo de campanhas
   ========================================================================== */
.comparison { margin: 8px 0 40px; }
.comparison h2 { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; margin-bottom: 4px; }
.comparison h2 i { color: var(--accent); }
.comparison .comparison-hint { color: var(--text-muted); font-size: 13px; margin: 0 0 14px; }
.comparison-table .comparison-name { font-weight: 600; color: var(--text); }
.comparison-table td.best { color: var(--success); font-weight: 700; }
.comparison-table td.best i { color: var(--success); margin-left: 4px; font-size: 13px; }
.comparison-table small { display: block; color: var(--text-dim); font-weight: 400; margin-top: 1px; }

/* ==========================================================================
   Chips de contagem (hierarquia: quantos itens existem dentro)
   ========================================================================== */
.count-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600; color: var(--text-muted);
    background: var(--surface-3); border: 1px solid var(--border);
    padding: 4px 11px; border-radius: var(--r-pill); margin-left: 10px;
    vertical-align: middle; text-transform: none;
}

/* ==========================================================================
   Colapso de anúncios (evita a sensação de "tudo colado" quando há muitos)
   ========================================================================== */
details.ads-collapse { margin-top: 18px; }
details.ads-collapse > summary {
    cursor: pointer;
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-pill);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    transition: background var(--dur), color var(--dur);
}
details.ads-collapse > summary::-webkit-details-marker { display: none; }
details.ads-collapse > summary:hover { background: var(--surface-2); color: var(--text); }
details.ads-collapse > summary .toggle-icon { transition: transform var(--dur) var(--ease); display: inline-block; }
details.ads-collapse[open] > summary .toggle-icon { transform: rotate(90deg); }
details.ads-collapse[open] > summary { margin-bottom: 6px; }

/* Mais respiro entre irmãos, para a hierarquia campanha > conjunto > anúncio ficar clara */
.tree-node.level-campaign + .tree-node.level-campaign,
.tree-node.level-campaign { margin-top: 32px; }
.tree-node.level-adset { margin-top: 22px; margin-bottom: 22px; }
.tree-node.level-ad { margin-top: 14px; margin-bottom: 14px; }

/* ==========================================================================
   Insights do cliente (dashboard inicial)
   ========================================================================== */
.insights { margin-bottom: 40px; }
.insights h2 { display: flex; align-items: center; gap: 8px; }
.insights h2 i { color: var(--accent); }

.trend { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; margin-top: 4px; }
.trend-good { color: var(--success); }
.trend-bad { color: var(--error); }
.trend-neutral { color: var(--text-dim); }

.ad-highlight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.ad-highlight { border-radius: var(--r-md); padding: 18px 20px; border: 1px solid var(--border); }
.ad-highlight strong { display: block; font-size: 1.05rem; margin: 6px 0 4px; }
.ad-highlight-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.ad-highlight-meta { color: var(--text-muted); font-size: 12px; }
.ad-highlight--best { background: var(--success-dim); border-color: rgba(52, 211, 153, 0.25); }
.ad-highlight--best .ad-highlight-tag { color: var(--success); }
.ad-highlight--worst { background: var(--error-dim); border-color: rgba(248, 113, 113, 0.25); }
.ad-highlight--worst .ad-highlight-tag { color: var(--error); }

@media (max-width: 620px) {
    .ad-highlight-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 36px; color: var(--text-dim); margin-bottom: 12px; display: block; }

/* ==========================================================================
   Responsivo
   ========================================================================== */
@media (max-width: 900px) {
    .content { padding: 20px; }
    .cards { grid-template-columns: 1fr; }
    .report-hero { padding: 24px 22px; }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px; height: 40px;
        border-radius: var(--r-sm);
        background: var(--surface-2);
        border: 1px solid var(--border-strong);
        color: var(--text);
        font-size: 20px;
        position: fixed;
        top: 16px; left: 16px;
        z-index: 60;
        cursor: pointer;
    }

    .sidebar {
        position: fixed;
        left: 0; top: 0;
        transform: translateX(-100%);
        transition: transform var(--dur) var(--ease);
        box-shadow: var(--shadow-md);
        z-index: 55;
    }
    .sidebar.is-open { transform: translateX(0); }

    .drawer-backdrop {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 50;
    }
    .drawer-backdrop.is-open { display: block; }

    .funnel-row { grid-template-columns: 70px 1fr 50px; gap: 8px; }
}

@media (max-width: 620px) {
    .stat-grid, .stat-grid--compact { grid-template-columns: repeat(2, 1fr); }
    .tree-node.level-adset, .tree-node.level-ad { margin-left: 14px; }
    .table th, .table td { padding: 10px 12px; font-size: 13px; }
    .login-box { padding: 32px 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
    .reveal { opacity: 1; transform: none; }
}

/* ==========================================================================
   Chat de IA — cliente
   ========================================================================== */

.chat-hint {
    color: var(--text-muted);
    margin: -8px 0 16px;
    font-size: 14px;
}

.chat-shell {
    display: flex;
    flex-direction: column;
    height: min(72vh, 720px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.chat-thread {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-empty {
    margin: auto;
    text-align: center;
    color: var(--text-dim);
    max-width: 320px;
}
.chat-empty i { font-size: 32px; color: var(--accent); display: block; margin-bottom: 12px; }

.chat-bubble {
    max-width: 78%;
    padding: 12px 16px;
    border-radius: var(--r-md);
    line-height: 1.5;
    font-size: 14.5px;
    white-space: pre-wrap;
    word-break: break-word;
    animation: rise-in 320ms var(--ease) both;
}

.chat-bubble--user {
    align-self: flex-end;
    background: var(--accent);
    color: #1a0f04;
    border-bottom-right-radius: 4px;
}

.chat-bubble--assistant {
    align-self: flex-start;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-bubble--error {
    align-self: flex-start;
    background: var(--error-dim);
    color: var(--error);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.chat-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    border-bottom-left-radius: 4px;
}
.chat-typing span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    animation: chat-typing-bounce 1.1s var(--ease) infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}

.chat-composer textarea {
    flex: 1;
    resize: none;
    max-height: 140px;
    padding: 12px 14px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.4;
}
.chat-composer textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.chat-composer button {
    flex-shrink: 0;
    width: 44px; height: 44px;
    border-radius: var(--r-pill);
    border: none;
    background: var(--accent);
    color: #1a0f04;
    font-size: 18px;
    cursor: pointer;
    transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.chat-composer button:hover { background: var(--accent-strong); }
.chat-composer button:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 620px) {
    .chat-shell { height: min(80vh, 640px); border-radius: var(--r-md); }
    .chat-bubble { max-width: 90%; }
}
