/* ============================================================
   ATLAS BRAIN CORE — Atlas.css
   Design: Sci-fi terminal premium, nível produto
   ============================================================ */

/* ── Reset & Tokens ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* ── Fundos (navy, igual à Landing) ── */
    --void:       #080f1d;
    --surface-1:  #0c1729;
    --surface-2:  #0f1e38;
    --surface-3:  #142244;
    --surface-4:  #1a2d58;

    /* ── Accent (teal Atlas, equilibrado) ── */
    --accent:     #22d3ee;
    --accent-2:   #0891b2;
    --accent-dim: rgba(34, 211, 238, 0.08);
    --accent-brd: rgba(34, 211, 238, 0.2);
    --accent-glow:0 0 16px rgba(34, 211, 238, 0.2);

    /* ── Texto ── */
    --text-1:     #f0f4ff;
    --text-2:     #8ba8c8;
    --text-3:     #4a5e80;

    /* ── Estados ── */
    --danger:     #f43f5e;
    --success:    #10b981;

    --sidebar-w:  280px;
    --radius:     14px;
    --radius-sm:  8px;

    --font-display: 'Syne', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
    --font-body:    'Inter', sans-serif;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

html, body {
    height: 100%;
    background: var(--void);
    color: var(--text-1);
    font-family: var(--font-body);
    overflow: hidden;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ============================================================
   TELA DE DESPERTAR
   ============================================================ */
#awakeScreen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: var(--void);
    transition: opacity 0.8s var(--ease-out);
    overflow: hidden;
}

#awakeScreen.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Rosto do Atlas desfocado como background */
#awakeScreen::before {
    content: '';
    position: absolute;
    inset: -10%;
    background: url('Aa17fc4a8ccc5496ab7bb17b8babe9b56O.jpg') center/cover no-repeat;
    opacity: 0.12;
    filter: blur(18px) saturate(0.6);
    transform: scale(1.1);
    z-index: 0;
}

/* Neural canvas background */
#neuralCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.7;
}

.awake-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 55% 65% at 50% 50%, transparent 10%, var(--void) 72%);
    z-index: 1;
}

.awake-noise {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    opacity: 0.4;
    z-index: 1;
}

.awake-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    position: relative;
    z-index: 2;
}

.atlas-orb {
    position: relative;
    width: 180px;
    height: 180px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.orb-img {
    width: 180px; height: 180px;
    border-radius: 50%;
    border: 1.5px solid var(--accent-brd);
    object-fit: cover;
    position: relative;
    z-index: 4;
    transition: filter 0.4s, transform 0.4s;
    filter: brightness(0.85) saturate(0.7);
    pointer-events: none; /* click vai pro .atlas-orb */
}

.atlas-orb:hover .orb-img {
    filter: brightness(1.1) saturate(1.2);
    transform: scale(1.03);
}

.orb-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid var(--accent-brd);
    animation: orbRotate linear infinite;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.orb-ring--1 { width: 230px; height: 230px; animation-duration: 12s; }
.orb-ring--2 { width: 270px; height: 270px; animation-duration: 20s; animation-direction: reverse; opacity: 0.4; }
.orb-ring--3 { width: 310px; height: 310px; animation-duration: 30s; opacity: 0.2; }

@keyframes orbRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

.atlas-orb::after {
    content: '';
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(34,211,238,0.12) 0%, transparent 70%);
    animation: orbPulse 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes orbPulse {
    0%, 100% { opacity: 0.5; transform: scale(0.95); }
    50%       { opacity: 1;   transform: scale(1.05); }
}

.awake-label {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-2);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    min-height: 1.2em;
    text-align: center;
    max-width: 320px;
}

.awake-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-3);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.hint-dot {
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent);
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.4; }
    50%       { opacity: 1; }
}

/* ============================================================
   APP SHELL
   ============================================================ */
#appShell {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    animation: appReveal 0.6s var(--ease-out) both;
}

@keyframes appReveal {
    from { opacity: 0; transform: scale(0.98); }
    to   { opacity: 1; transform: scale(1); }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface-1);
    border-right: 1px solid rgba(255,255,255,0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s var(--ease-out);
    position: relative;
    z-index: 10;
}

/* Mini sidebar — só ícones */
.sidebar.collapsed {
    width: 64px;
}

/* Esconde textos quando colapsado */
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-collapse-btn,
.sidebar.collapsed .new-chat-btn span,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .history-list,
.sidebar.collapsed .sidebar-exit span {
    display: none;
}

/* Layout geral colapsado */
.sidebar.collapsed .sidebar-top    { padding: 16px 0; align-items: center; gap: 12px; }
.sidebar.collapsed .sidebar-brand  { justify-content: center; width: 100%; }
.sidebar.collapsed .sidebar-footer { padding: 12px 0; display: flex; justify-content: center; }

/* Botão nova conversa colapsado — ícone pill */
.sidebar.collapsed .new-chat-btn {
    justify-content: center;
    padding: 0;
    width: 40px; height: 40px;
    margin: 0 auto;
    border-radius: 12px;
    flex-shrink: 0;
    position: relative;
}

/* Botão sair colapsado */
.sidebar.collapsed .sidebar-exit {
    justify-content: center;
    padding: 0;
    width: 40px; height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
}

/* Tooltip genérico para itens colapsados */
.sidebar.collapsed [data-tip] {
    position: relative;
}
.sidebar.collapsed [data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-3);
    border: 1px solid rgba(34,211,238,0.18);
    color: var(--text-1);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    transform: translateY(-50%) translateX(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    z-index: 200;
}
.sidebar.collapsed [data-tip]:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Separador entre avatar e botões */
.sidebar.collapsed .sidebar-top::after {
    content: '';
    display: block;
    width: 32px;
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 0 auto;
}

/* Hover nos ícones da mini sidebar */
.sidebar.collapsed .new-chat-btn:hover {
    background: rgba(34,211,238,0.15);
    box-shadow: 0 0 12px rgba(34,211,238,0.2);
}
.sidebar.collapsed .sidebar-exit:hover {
    background: rgba(255,68,102,0.1);
    color: var(--danger);
}

/* Avatar na mini sidebar vira botão de expandir com hover */
.sidebar.collapsed .sidebar-logo-wrap:hover .sidebar-avatar {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(34,211,238,0.3);
}

.sidebar-top { padding: 20px 16px 12px; display: flex; flex-direction: column; gap: 16px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px;
    position: relative;
}

.sidebar-logo-wrap {
    width: 36px; height: 36px;
    flex-shrink: 0;
    cursor: pointer;
    position: relative;
    border-radius: 50%;
}

.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--accent-brd);
    display: block;
    transition: opacity 0.2s;
    position: relative;
    z-index: 1;
}

.logo-collapse-icon {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: opacity 0.2s, color 0.2s;
    z-index: 2;
    opacity: 0;
    color: var(--text-2);
}

/* ── Sidebar ABERTA: avatar visível, ícone de recolher aparece no hover ── */
.sidebar:not(.collapsed) .sidebar-avatar    { opacity: 1; }
.sidebar:not(.collapsed) .logo-collapse-icon { opacity: 0; }
.sidebar:not(.collapsed) .sidebar-logo-wrap:hover .sidebar-avatar { opacity: 0; }
.sidebar:not(.collapsed) .sidebar-logo-wrap:hover .logo-collapse-icon { opacity: 1; color: var(--accent); }

/* ── Sidebar FECHADA: avatar visível, ícone aparece no hover ── */
.sidebar.collapsed .sidebar-avatar          { opacity: 1; }
.sidebar.collapsed .logo-collapse-icon      {
    opacity: 0;
    background: var(--surface-3);
    border: 1px solid rgba(255,255,255,0.1);
}
.sidebar.collapsed .sidebar-logo-wrap:hover .sidebar-avatar    { opacity: 0; }
.sidebar.collapsed .sidebar-logo-wrap:hover .logo-collapse-icon { opacity: 1; color: var(--accent); }

.sidebar-name {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.1em;
    line-height: 1;
}

.sidebar-sub {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-3);
    letter-spacing: 0.08em;
    margin-top: 3px;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-brd);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.new-chat-btn:hover {
    background: rgba(34,211,238,0.15);
    box-shadow: var(--accent-glow);
}

.new-chat-btn i { font-size: 0.9rem; }

/* Histórico */
.sidebar-section-label {
    padding: 8px 20px 4px;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-3);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    flex-shrink: 0;
}



.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.06) transparent;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text-2);
    font-size: 0.82rem;
    line-height: 1.3;
    position: relative;
    min-width: 0;
}

.history-item:hover { background: rgba(255,255,255,0.04); color: var(--text-1); }
.history-item.active { background: var(--accent-dim); color: var(--accent); border-left: 2px solid var(--accent); }
.history-item i { flex-shrink: 0; font-size: 0.8rem; opacity: 0.6; }

.history-item-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8rem;
}

.history-item-del {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0;
    font-size: 0.8rem;
    transition: all 0.15s;
    flex-shrink: 0;
}

.history-item:hover .history-item-del { opacity: 1; }
.history-item-del:hover { color: var(--danger); background: rgba(255,68,102,0.1); }

.history-empty {
    padding: 24px 16px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-3);
    letter-spacing: 0.08em;
    line-height: 1.6;
}

/* Bloco de usuário no sidebar */
.sidebar-user-block {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-user-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent, #00f7ff);
    color: #000;
    font-weight: 800;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 8px rgba(0,247,255,0.35);
}
.sidebar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}
.sidebar-user-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-1, #e2e8f0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.03em;
}
.sidebar-user-role {
    font-size: 0.62rem;
    color: var(--accent, #00f7ff);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.7;
}
.sidebar.collapsed .sidebar-user-block { justify-content: center; padding: 8px 0 12px; }
.sidebar.collapsed .sidebar-user-info  { display: none; }

/* Footer sidebar */
.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
}

.sidebar-exit {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    text-decoration: none;
    font-size: 0.82rem;
    transition: all 0.2s;
}

.sidebar-exit:hover { background: rgba(255,68,102,0.08); color: var(--danger); }

/* Sidebar toggle */
.sidebar-toggle, .sidebar-toggle-inline {
    background: none;
    border: none;
    color: var(--text-2);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-toggle {
    position: fixed;
    top: 14px; left: 14px;
    z-index: 20;
    display: none;
}

.sidebar-toggle:hover,
.sidebar-toggle-inline:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-1);
}

/* ============================================================
   ÁREA PRINCIPAL DO CHAT
   ============================================================ */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface-2);
    position: relative;
    overflow: hidden;
    background-image:
        radial-gradient(ellipse 80% 40% at 50% 0%, rgba(0,100,180,0.06) 0%, transparent 60%),
        linear-gradient(180deg, var(--surface-2) 0%, var(--void) 100%);
}

/* Canvas neural no chat — bem discreto */
#chatNeuralCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
}

/* ── Topbar ── */
.chat-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
    background: rgba(7, 12, 20, 0.6);
    backdrop-filter: blur(12px);
    position: relative;
    z-index: 2;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chat-title-display {
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

.status-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    background: rgba(0,255,153,0.06);
    border: 1px solid rgba(0,255,153,0.15);
    border-radius: 20px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: #10b981;
    letter-spacing: 0.1em;
}

.status-dot {
    width: 6px; height: 6px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--success);
    animation: blink 2s ease-in-out infinite;
}

/* ── Mensagens ── */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 32px 0;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.06) transparent;
    position: relative;
    z-index: 2;
}

/* Estado vazio */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 24px;
    text-align: center;
    animation: fadeUp 0.6s var(--ease-out) both;
}

.empty-orb {
    width: 72px; height: 72px;
    border-radius: 50%;
    overflow: hidden;
    border: 1.5px solid var(--accent-brd);
    box-shadow: 0 0 30px rgba(34,211,238,0.15);
    margin-bottom: 8px;
}

.empty-orb img { width: 100%; height: 100%; object-fit: cover; }

.empty-state h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-1);
}

.empty-state p {
    font-size: 0.88rem;
    color: var(--text-2);
    max-width: 420px;
    line-height: 1.6;
}

.empty-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 12px;
}

.suggestion-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface-3);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    color: var(--text-2);
    font-family: var(--font-body);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background: var(--surface-4);
    border-color: var(--accent-brd);
    color: var(--text-1);
}

.suggestion-chip i { color: var(--accent); font-size: 0.85rem; }

/* Mensagens */
.msg-row {
    padding: 4px 0;
    animation: fadeUp 0.3s var(--ease-out) both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Atlas (esquerda) ── */
.msg-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 8px 24px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.msg-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
    overflow: hidden;
    border: 1px solid rgba(34,211,238,0.2);
}

.msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.msg-avatar.user-av {
    background: var(--surface-4);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
    font-size: 0.85rem;
}

.msg-body { flex: 1; min-width: 0; }

.msg-sender {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 5px;
}

.msg-row.atlas-row .msg-sender { color: var(--accent); }

.msg-content {
    font-size: 0.92rem;
    line-height: 1.75;
    color: var(--text-1);
    text-align: justify;
}

.msg-content p { margin-bottom: 8px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { color: var(--accent); font-weight: 600; }
.msg-content em { color: var(--text-2); font-style: italic; }

.msg-content h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-1);
    margin: 16px 0 8px;
}
.msg-content h3 {
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--text-1);
    margin: 14px 0 6px;
}
.msg-content h4 {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 12px 0 6px;
}

.msg-content ul, .msg-content ol {
    padding-left: 20px;
    margin: 6px 0 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.msg-content li {
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-1);
    list-style: none;
    position: relative;
    padding-left: 14px;
    counter-increment: ol-counter;
}
.msg-content ul li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-size: 0.7rem;
    top: 3px;
}
.msg-content ol {
    counter-reset: ol-counter;
}
.msg-content ol li::before {
    content: counter(ol-counter) '.';
    position: absolute;
    left: -4px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    top: 2px;
    min-width: 18px;
    text-align: right;
}

.msg-content hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.06);
    margin: 12px 0;
}

.msg-content pre {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(34,211,238,0.1);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 10px 0;
    overflow-x: auto;
}
.msg-content pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.82rem;
    color: var(--text-1);
}

.msg-content a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(34,211,238,0.3);
    transition: text-decoration-color 0.2s;
}
.msg-content a:hover { text-decoration-color: var(--accent); }
.msg-content code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    background: rgba(34,211,238,0.06);
    border: 1px solid rgba(34,211,238,0.12);
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--accent-2);
}

/* ── Mensagem do USUÁRIO — balão à direita ── */
.msg-row.user-row .msg-inner {
    flex-direction: row-reverse;  /* avatar à direita */
}

.msg-row.user-row .msg-body {
    display: flex;
    justify-content: flex-end;
}

.msg-row.user-row .msg-sender {
    text-align: right;
}

.msg-row.user-row .msg-content {
    background: var(--surface-3);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 18px 4px 18px 18px;
    padding: 10px 16px;
    display: inline-block;
    max-width: 520px;
    text-align: left;
}

/* ── Mensagem do ATLAS — sem balão ── */
.msg-row.atlas-row .msg-content {
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
}

/* Imagem */
.msg-image {
    max-width: 260px;
    border-radius: 12px;
    display: block;
    margin-bottom: 6px;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Ajuste do balão do user quando tem imagem */
.msg-row.user-row .msg-content {
    background: var(--surface-3);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 18px 4px 18px 18px;
    padding: 10px 14px;
    display: inline-block;
    max-width: 520px;
    text-align: left;
}

/* Sem balão quando só tem imagem sem texto */
.msg-row.user-row .msg-content:has(img):not(:has(span:not(:empty))) {
    background: transparent;
    border: none;
    padding: 0;
}

/* Loading state */
.loading-dots {
    display: flex;
    gap: 5px;
    padding: 6px 0;
}

.loading-dots span {
    width: 6px; height: 6px;
    background: var(--accent);
    border-radius: 50%;
    animation: dotBounce 1.2s ease-in-out infinite;
    opacity: 0.6;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%            { transform: scale(1);   opacity: 1; }
}

/* ── Input Zone ── */
.input-zone {
    padding: 16px 24px 20px;
    flex-shrink: 0;
    background: linear-gradient(0deg, var(--void) 60%, transparent);
    position: relative;
    z-index: 2;
}

.attachments-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    min-height: 0;
}

.preview-thumb {
    position: relative;
    width: 56px; height: 56px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--accent-brd);
    flex-shrink: 0;
}

.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }

.preview-remove {
    position: absolute;
    top: 2px; right: 2px;
    background: rgba(0,0,0,0.75);
    border: none;
    color: var(--danger);
    width: 18px; height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* PDF Status */
.pdf-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(34,211,238,0.04);
    border: 1px solid var(--accent-brd);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.pdf-status-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
}

.pdf-status-info i { font-size: 1.1rem; flex-shrink: 0; }
.pdf-name { font-family: var(--font-mono); font-size: 0.75rem; color: var(--accent); }
.pdf-meta { font-family: var(--font-mono); font-size: 0.6rem; color: var(--text-3); letter-spacing: 0.05em; margin-top: 2px; }

.pdf-remove {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.2s;
    padding: 4px;
}
.pdf-remove:hover { color: var(--danger); }

/* Input row */
.input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--surface-3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 10px 12px;
    transition: border-color 0.2s;
    max-width: 780px;
    margin: 0 auto;
    width: 100%;
}

.input-row:focus-within {
    border-color: var(--accent-brd);
    box-shadow: 0 0 0 1px rgba(34,211,238,0.1);
}

/* Menu de anexos */
.attach-menu-wrap { position: relative; }

.attach-btn {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.attach-btn:hover { color: var(--accent); background: var(--accent-dim); }
.attach-btn.open { color: var(--accent); transform: rotate(45deg); }

.attach-flyout {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    background: var(--surface-2);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    min-width: 150px;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
    z-index: 50;
}

.attach-flyout.open { display: flex; animation: slideUp 0.2s var(--ease-out); }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.attach-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}

.attach-option:hover { background: rgba(255,255,255,0.04); color: var(--text-1); }
.attach-option i { color: var(--accent); font-size: 0.9rem; width: 18px; text-align: center; }

/* Textarea */
#msgInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-1);
    font-family: var(--font-body);
    font-size: 0.92rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
    scrollbar-width: thin;
}

#msgInput::placeholder { color: var(--text-3); }
#msgInput:disabled { opacity: 0.5; cursor: not-allowed; }

/* Botão enviar */
.send-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--accent);
    border: none;
    color: var(--void);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    font-weight: 600;
}

.send-btn:hover:not(:disabled) {
    background: #33f5ff;
    box-shadow: var(--accent-glow);
}

.send-btn:disabled {
    background: var(--surface-4);
    color: var(--text-3);
    cursor: not-allowed;
}

/* ── Barra de uso de tokens ── */
.token-usage-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 780px;
    margin: 8px auto 0;
    padding: 0 2px;
}
.token-usage-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-3);
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.token-usage-left i { font-size: 0.65rem; color: var(--accent); opacity: 0.7; }
.token-plan-badge {
    font-family: var(--font-mono);
    font-size: 0.52rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-dim);
    border: 1px solid var(--accent-brd);
    border-radius: 4px;
    padding: 1px 5px;
    letter-spacing: 0.1em;
}
.token-track {
    flex: 1;
    height: 3px;
    background: rgba(255,255,255,0.06);
    border-radius: 99px;
    overflow: hidden;
}
.token-fill {
    height: 100%;
    width: 0%;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    transition: width 0.4s var(--ease-out), background 0.3s;
}
.token-fill.warn  { background: linear-gradient(90deg, #f7b731, #f0a500); }
.token-fill.limit { background: linear-gradient(90deg, var(--danger), #ff6688); }
#tokenUsageLabel.warn  { color: #f7b731; }
#tokenUsageLabel.limit { color: var(--danger); }

/* Limite atingido — bloqueia input */
.input-blocked .send-btn { opacity: 0.35; cursor: not-allowed; }
.token-limit-msg {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--danger);
    letter-spacing: 0.05em;
    margin-top: 4px;
    animation: fadeIn 0.3s;
}

.input-disclaimer {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-3);
    margin-top: 10px;
    letter-spacing: 0.05em;
    max-width: 780px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================================
   MODAL DE VOZ
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(12px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-modal {
    background: var(--surface-1);
    border: 1px solid rgba(34,211,238,0.2);
    border-radius: 24px;
    padding: 40px 35px 30px;
    width: 90%;
    max-width: 480px;
    text-align: center;
    position: relative;
    box-shadow: 0 0 60px rgba(34,211,238,0.1);
    overflow: hidden;
}

/* Cantos decorativos */
.corner {
    position: absolute;
    width: 16px; height: 16px;
    border-color: rgba(34,211,238,0.35);
    border-style: solid;
}
.corner.tl { top: 10px; left: 10px; border-width: 1px 0 0 1px; }
.corner.tr { top: 10px; right: 10px; border-width: 1px 1px 0 0; }
.corner.bl { bottom: 10px; left: 10px; border-width: 0 0 1px 1px; }
.corner.br { bottom: 10px; right: 10px; border-width: 0 1px 1px 0; }

.scan-line {
    position: absolute;
    top: -4px; left: -100%; right: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: voiceScan 3s linear infinite;
    opacity: 0;
}

@keyframes voiceScan {
    0%   { left: -100%; right: 100%; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { left: 100%; right: -100%; opacity: 0; }
}

.modal-close {
    position: absolute;
    top: 14px; right: 18px;
    background: none;
    border: none;
    color: rgba(255,80,80,0.7);
    font-size: 1.4rem;
    cursor: pointer;
    transition: 0.3s;
    line-height: 1;
}
.modal-close:hover { color: var(--danger); transform: scale(1.2); }

.voice-label-top {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.3em;
    color: rgba(34,211,238,0.4);
    margin-bottom: 6px;
}

.voice-title {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--accent);
    letter-spacing: 0.2em;
    margin-bottom: 20px;
}

.voice-orb-wrap {
    position: relative;
    width: 90px; height: 90px;
    margin: 0 auto 10px;
}

.voice-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(34,211,238,0.15);
    animation: voiceRingPulse 2s ease-in-out infinite;
    top: 50%; left: 50%; transform: translate(-50%,-50%);
}
.voice-ring.r1 { width: 114px; height: 114px; }
.voice-ring.r2 { width: 138px; height: 138px; animation-delay: 0.4s; opacity: 0.6; }

@keyframes voiceRingPulse {
    0%, 100% { transform: translate(-50%,-50%) scale(1); opacity: 0.6; }
    50%       { transform: translate(-50%,-50%) scale(1.08); opacity: 1; }
}

.voice-center {
    width: 90px; height: 90px;
    border-radius: 50%;
    background: rgba(34,211,238,0.06);
    border: 1.5px solid rgba(34,211,238,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    z-index: 2;
}

.voice-center:hover { background: rgba(34,211,238,0.12); }
#voiceMicIcon { font-size: 2rem; color: var(--accent); transition: 0.3s; pointer-events: none; }

.voice-status {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    color: rgba(34,211,238,0.4);
    text-transform: uppercase;
    margin-bottom: 16px;
    min-height: 16px;
}

.voice-visualizer {
    background: rgba(34,211,238,0.02);
    border: 1px solid rgba(34,211,238,0.1);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

#voiceCanvas { width: 100%; height: 80px; display: block; }

.viz-label {
    position: absolute;
    bottom: 6px; right: 10px;
    font-family: var(--font-mono);
    font-size: 0.52rem;
    letter-spacing: 0.2em;
    color: rgba(34,211,238,0.2);
}

.voice-transcript {
    background: rgba(0,0,0,0.3);
    border: 1px dashed rgba(34,211,238,0.2);
    border-radius: 10px;
    padding: 12px 16px;
    min-height: 52px;
    margin-bottom: 20px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: rgba(34,211,238,0.7);
    text-shadow: 0 0 8px rgba(34,211,238,0.3);
    text-align: left;
    line-height: 1.5;
}

.voice-actions { display: flex; gap: 10px; }

.voice-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-family: var(--font-display);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: 0.2s;
}

.voice-btn.primary {
    background: rgba(0,195,255,0.15);
    border: 1px solid rgba(0,195,255,0.4);
    color: var(--accent);
}
.voice-btn.primary:hover { background: rgba(0,195,255,0.25); }

.voice-btn.success {
    background: rgba(0,255,150,0.12);
    border: 1px solid rgba(0,255,150,0.3);
    color: var(--success);
}
.voice-btn.success:hover { background: rgba(0,255,150,0.22); }

.voice-btn.ghost {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.4);
    flex: none;
    padding: 12px 16px;
}
.voice-btn.ghost:hover { background: rgba(255,255,255,0.06); }

/* @keyframes globais */
@keyframes voiceRecordPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(0,247,255,0.3), 0 0 0 0 rgba(0,247,255,0.4); }
    50%       { box-shadow: 0 0 30px rgba(0,247,255,0.5), 0 0 0 14px rgba(0,247,255,0); }
}


/* ============================================================
   ABAS DA SIDEBAR + EDITOR DE BLOCOS
   ============================================================ */

/* ── Abas ── */
.sidebar-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px 0;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.sidebar-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 8px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 6px 6px 0 0;
    color: var(--text-3);
    font-family: var(--font-body);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.18s;
    margin-bottom: -1px;
}
.sidebar-tab i { font-size: 0.85rem; }
.sidebar-tab:hover { color: var(--text-2); background: rgba(255,255,255,0.03); }
.sidebar-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(34,211,238,0.04);
}

/* Esconder abas quando sidebar colapsada */
.sidebar.collapsed .sidebar-tabs { display: none; }

/* ── Painéis ── */
.sidebar-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.hidden-panel { display: none !important; }

/* ── Header das notas ── */
.notes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
    gap: 8px;
}
.notes-header-left  { flex: 1; min-width: 0; }
.notes-header-right { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }

.notes-title-input {
    background: none; border: none; outline: none;
    color: var(--text-1);
    font-family: var(--font-display);
    font-size: 0.85rem; font-weight: 600;
    width: 100%; padding: 0; display: block;
}
.notes-title-input:focus { color: var(--accent); }

.notes-meta { font-family: var(--font-mono); font-size: 0.58rem; color: var(--text-3); letter-spacing: 0.05em; margin-top: 2px; }

.notes-action-btn {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    background: none;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 6px;
    color: var(--text-3);
    font-size: 0.8rem;
    cursor: pointer; transition: all 0.15s;
}
.notes-action-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-1); border-color: rgba(255,255,255,0.14); }
.notes-action-btn.accent { border-color: rgba(255,68,102,0.2); color: rgba(255,68,102,0.5); }
.notes-action-btn.accent:hover { background: rgba(255,68,102,0.08); color: var(--danger); border-color: rgba(255,68,102,0.4); }

/* ── Slash menu ── */
.slash-menu {
    position: absolute;
    left: 8px; right: 8px;
    background: var(--surface-2);
    border: 1px solid rgba(34,211,238,0.15);
    border-radius: 10px;
    padding: 6px;
    display: none;
    flex-direction: column;
    gap: 2px;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    backdrop-filter: blur(12px);
    max-height: 280px;
    overflow-y: auto;
}
.slash-menu.open { display: flex; }

.slash-menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px; border-radius: 7px;
    cursor: pointer; transition: background 0.1s; color: var(--text-2);
}
.slash-menu-item:hover, .slash-menu-item.selected { background: var(--accent-dim); color: var(--text-1); }
.slash-menu-item i { font-size: 0.85rem; color: var(--accent); width: 16px; text-align: center; flex-shrink: 0; }
.slash-menu-item span  { font-size: 0.78rem; font-weight: 500; display: block; }
.slash-menu-item small { font-size: 0.64rem; color: var(--text-3); display: block; }

/* ── Canvas de blocos ── */
.blocks-canvas {
    flex: 1; overflow-y: auto;
    padding: 10px 6px 40px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.06) transparent;
    min-height: 0;
    position: relative;
}

/* ── Bloco base ── */
.block {
    display: flex; align-items: flex-start; gap: 2px;
    padding: 1px 4px;
    border-radius: 6px; position: relative;
    transition: background 0.1s; margin-bottom: 1px;
}
.block:hover   { background: rgba(255,255,255,0.02); }
.block.focused { background: rgba(34,211,238,0.03); }
.block.dragging  { opacity: 0.4; }
.block.drag-over { border-top: 2px solid var(--accent); }

.block-handle {
    width: 14px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    padding-top: 5px; color: var(--text-3);
    opacity: 0; cursor: grab; font-size: 0.65rem; transition: opacity 0.15s;
}
.block:hover .block-handle { opacity: 1; }
.block-handle:active { cursor: grabbing; }

.block-del {
    position: absolute; right: 4px; top: 3px;
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; border-radius: 4px;
    color: var(--text-3); font-size: 0.65rem;
    cursor: pointer; opacity: 0; transition: opacity 0.15s, background 0.15s;
}
.block:hover .block-del { opacity: 1; }
.block-del:hover { background: rgba(255,68,102,0.15); color: var(--danger); }

.block-content { flex: 1; min-width: 0; }
.block-inner   { display: flex; align-items: flex-start; gap: 6px; }

/* ── Editable ── */
.block-editable {
    flex: 1; outline: none;
    caret-color: var(--accent);
    color: var(--text-1);
    font-family: var(--font-body);
    font-size: 0.84rem; line-height: 1.65;
    min-height: 24px; word-break: break-word;
    padding: 2px 20px 2px 0;
}
.block-editable:empty::before {
    content: attr(data-placeholder);
    color: var(--text-3); pointer-events: none;
}

/* ── Tipos ── */
.block--h1 .block-editable { font-family: var(--font-display); font-size: 1.15rem; font-weight: 800; color: var(--text-1); line-height: 1.3; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 6px; margin-bottom: 2px; }
.block--h2 .block-editable { font-family: var(--font-display); font-size: 0.98rem; font-weight: 700; }
.block--h3 .block-editable { font-family: var(--font-display); font-size: 0.85rem; font-weight: 600; color: var(--accent); letter-spacing: 0.03em; }

.block--bullet .block-editable::before { content: '▸'; color: var(--accent); margin-right: 5px; font-size: 0.65rem; }

.block--quote {
    border-left: 2px solid var(--accent-brd);
    background: rgba(34,211,238,0.02);
    border-radius: 0 6px 6px 0;
    padding: 3px 6px; margin: 2px 0;
}
.block--quote .block-editable { font-style: italic; color: var(--text-2); font-size: 0.82rem; }

.block--code { background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.05); border-radius: 6px; margin: 3px 0; }
.block--code .block-editable { font-family: var(--font-mono); font-size: 0.75rem; color: #a8ff78; white-space: pre-wrap; line-height: 1.5; }

.block--divider { align-items: center; padding: 6px 4px; }
.block-divider-line { flex: 1; border: none; border-top: 1px solid rgba(255,255,255,0.07); margin: 0 6px; }

/* Todo */
.todo-check {
    width: 16px; height: 16px; flex-shrink: 0; margin-top: 5px;
    background: none; border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px; cursor: pointer; color: var(--text-3);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.72rem; transition: all 0.15s;
}
.todo-check:hover, .todo-check.checked { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* Atlas badge */
.block--atlas { background: rgba(34,211,238,0.02); border-radius: 6px; padding: 4px 6px; border: 1px solid rgba(34,211,238,0.07); }
.atlas-badge  { display: inline-flex; align-items: center; gap: 3px; font-family: var(--font-mono); font-size: 0.55rem; color: var(--accent); letter-spacing: 0.1em; margin-bottom: 2px; opacity: 0.7; }

/* ── Footer ── */
.notes-footer {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-top: 1px solid rgba(255,255,255,0.04);
    font-family: var(--font-mono); font-size: 0.58rem;
    color: var(--text-3); letter-spacing: 0.05em; flex-shrink: 0;
}
.notes-footer-sep { opacity: 0.3; }
.notes-saved-status { margin-left: auto; display: flex; align-items: center; gap: 3px; transition: color 0.3s; }
.notes-saved-status.flash { color: var(--success); }

/* ============================================================
   AUTH WALL MODAL
   ============================================================ */
.auth-wall-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(3, 5, 10, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease-out);
}
.auth-wall-overlay.open {
    opacity: 1;
    pointer-events: all;
}
.auth-wall-overlay.open .auth-wall-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.auth-wall-modal {
    background: var(--surface-2);
    border: 1px solid rgba(34, 211, 238, 0.28);
    border-radius: 24px;
    padding: 36px 32px 32px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 14px;
    transform: translateY(20px) scale(0.97);
    opacity: 0;
    transition: transform 0.35s var(--ease-out), opacity 0.35s var(--ease-out);
    box-shadow: 0 32px 80px rgba(0,0,0,0.75),
                0 0 0 1px rgba(34,211,238,0.1),
                0 0 40px rgba(34,211,238,0.07);
    position: relative;
}

.auth-wall-orb {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(34,211,238,0.4);
    box-shadow: 0 0 24px rgba(34,211,238,0.25), 0 0 0 6px rgba(34,211,238,0.06);
    margin-bottom: 4px;
}
.auth-wall-orb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-wall-tag {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--accent);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    opacity: 0.9;
}

.auth-wall-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-1);
    line-height: 1.3;
    margin: 0;
    max-width: 280px;
}

.auth-wall-sub {
    font-size: 0.81rem;
    color: var(--text-2);
    line-height: 1.65;
    max-width: 300px;
    margin: 0;
}

.auth-wall-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
}

.auth-wall-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 14px 20px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}
.auth-wall-btn i { font-size: 0.95rem; }

.auth-wall-btn.primary {
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
    color: #fff;
    box-shadow: 0 4px 18px rgba(8,145,178,0.4), 0 1px 0 rgba(255,255,255,0.08) inset;
}
.auth-wall-btn.primary:hover {
    background: linear-gradient(135deg, #0ea5c9 0%, #0891b2 100%);
    box-shadow: 0 8px 24px rgba(8,145,178,0.5);
    transform: translateY(-2px);
}

.auth-wall-btn.secondary {
    background: var(--surface-3);
    color: var(--text-1);
    border: 1px solid rgba(34,211,238,0.2);
}
.auth-wall-btn.secondary:hover {
    background: var(--surface-4);
    border-color: rgba(34,211,238,0.35);
    color: var(--accent);
}

.auth-wall-skip {
    background: none;
    border: none;
    color: var(--text-3);
    font-family: var(--font-body);
    font-size: 0.75rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s;
    margin-top: 4px;
}
.auth-wall-skip:hover { color: var(--text-2); }

/* Mini-login inline no auth wall */
.auth-wall-login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
}
.auth-wall-login-form input {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(0,247,255,0.18);
    border-radius: 8px;
    color: var(--text-1);
    font-size: 0.85rem;
    padding: 10px 14px;
    outline: none;
    transition: border-color .2s;
    width: 100%;
    box-sizing: border-box;
}
.auth-wall-login-form input:focus {
    border-color: rgba(0,247,255,0.5);
    background: rgba(0,247,255,0.04);
}
.aw-login-error {
    color: #ff6b6b;
    font-size: 0.78rem;
    text-align: center;
    padding: 4px 0;
}
.auth-wall-back {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 0.75rem;
    cursor: pointer;
    text-align: center;
    margin-top: 2px;
    transition: color .2s;
}
.auth-wall-back:hover { color: var(--accent); }

/* ============================================================
   BOTÃO NOTAS NO TOPBAR
   ============================================================ */
.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notes-toggle-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    background: var(--accent-dim);
    border: 1px solid var(--accent-brd);
    border-radius: 20px;
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.02em;
}
.notes-toggle-btn:hover,
.notes-toggle-btn.active {
    background: rgba(34,211,238,0.15);
    box-shadow: 0 0 14px rgba(34,211,238,0.2);
}
.notes-toggle-btn i { font-size: 0.85rem; }

/* ============================================================
   OVERLAY + PAINEL DIREITO DE NOTAS
   ============================================================ */
.notes-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    backdrop-filter: blur(2px);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease-out);
}
.notes-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.notes-right-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 480px;
    background: var(--surface-1);
    border-left: 1px solid rgba(34,211,238,0.1);
    display: flex;
    flex-direction: column;
    z-index: 301;
    transform: translateX(100%);
    transition: transform 0.35s var(--ease-out);
    box-shadow: -8px 0 40px rgba(0,0,0,0.5);
}
.notes-right-panel.open {
    transform: translateX(0);
}

/* ── Header do painel direito ── */
.notes-rp-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
    gap: 10px;
    background: var(--surface-2);
}
.notes-rp-title-wrap { flex: 1; min-width: 0; }
.notes-rp-label {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--accent);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.notes-rp-header .notes-title-input {
    font-size: 1rem;
    font-weight: 700;
}
.notes-rp-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* PDF button destaque */
.notes-pdf-btn {
    background: rgba(34,211,238,0.07) !important;
    border-color: rgba(34,211,238,0.2) !important;
    color: var(--accent) !important;
    font-size: 0.72rem !important;
    gap: 4px;
    padding: 0 8px !important;
    width: auto !important;
    font-family: var(--font-mono) !important;
    letter-spacing: 0.05em;
}
.notes-pdf-btn:hover {
    background: rgba(34,211,238,0.15) !important;
    box-shadow: 0 0 10px rgba(34,211,238,0.2) !important;
}

/* Close button */
.notes-close-btn {
    border-color: rgba(255,255,255,0.1) !important;
    margin-left: 4px;
}
.notes-close-btn:hover {
    background: rgba(255,68,102,0.08) !important;
    color: var(--danger) !important;
    border-color: rgba(255,68,102,0.3) !important;
}

/* ── Toolbar de formatação ── */
.notes-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
    flex-wrap: wrap;
    background: var(--surface-2);
}
.notes-tb-btn {
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-3);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}
.notes-tb-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-1);
    border-color: rgba(255,255,255,0.1);
}
.notes-tb-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-color: var(--accent-brd);
}
.notes-tb-sep {
    width: 1px; height: 18px;
    background: rgba(255,255,255,0.08);
    margin: 0 4px;
    flex-shrink: 0;
}