/* ════════════════════════════════════════════════════════════════════════
   Ada Panel — tema "neural / futurista"
   Glass + glow + aurora animada. Layout: sidebar | lista | detalhe (+ grafo).
   Paleta ADA: azul elétrico + cyan + branco/prata, dourado raro.
   ════════════════════════════════════════════════════════════════════════ */

:root {
    /* base profunda — tint navy (não preto puro, combina com a ADA) */
    --bg: #030912;
    --bg-1: #060f1e;
    --bg-2: #0a1530;
    --bg-3: #11203a;
    --glass: rgba(43, 168, 255, 0.04);
    --glass-strong: rgba(43, 168, 255, 0.08);
    --border: rgba(43, 168, 255, 0.12);
    --border-soft: rgba(43, 168, 255, 0.07);

    /* texto — prata (o cabelo da ADA) */
    --text: #e8ecf6;
    --text-dim: #8b97b8;
    --text-faint: #4a5570;

    /* acentos — azul elétrico + cyan + branco (a energia da ADA) */
    --c-cyan: #4DD0FF;
    --c-blue: #2BA8FF;
    --c-violet: #6080c8;        /* violeta discreto, puxado pro azul-arroxeado */
    --c-pink: #F5C451;          /* dourado raro — emblemas/detalhes da ADA */
    --gold: #F5C451;            /* token semântico explícito pro dourado */
    --accent: #2BA8FF;          /* azure — o azul-assinatura da ADA */
    --accent-grad: linear-gradient(120deg, var(--c-cyan), var(--c-blue) 50%, #E8F1FF);
    --glow-cyan: 0 0 28px rgba(77, 208, 255, 0.45);
    --glow-violet: 0 0 32px rgba(43, 168, 255, 0.50);

    /* estados */
    --good: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --crit: #fb7185;

    /* tipos de memória */
    --t-user: #93c5fd;
    --t-feedback: #F5C451;
    --t-project: #6ee7b7;
    --t-reference: #4DD0FF;

    --radius: 12px;
    --radius-lg: 18px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
/* O atributo `hidden` precisa vencer regras como .modal/.app-shell que setam `display`.
   Sem isto, o backdrop do .modal (position:fixed; inset:0; z-index:60) fica SEMPRE por cima
   e engole o clique no login — bug que travou o painel após a queda de energia (11/06). */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
    font-family: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(43, 168, 255, 0.30); }

/* scrollbars discretas */
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.16); }
*::-webkit-scrollbar-track { background: transparent; }

/* ───────────────── fundo animado ───────────────── */
.bg-aurora, .bg-grid, .bg-stars {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
}
.bg-aurora {
    background:
        radial-gradient(50% 40% at 18% 12%, rgba(43, 168, 255, 0.20), transparent 60%),
        radial-gradient(45% 45% at 85% 18%, rgba(77, 208, 255, 0.15), transparent 60%),
        radial-gradient(50% 50% at 70% 92%, rgba(43, 168, 255, 0.13), transparent 60%),
        radial-gradient(60% 60% at 25% 85%, rgba(77, 208, 255, 0.10), transparent 65%),
        radial-gradient(35% 35% at 55% 50%, rgba(232, 241, 255, 0.06), transparent 70%);
    /* só transform/opacity (composited na GPU) — SEM filter:blur animado, que
       re-rasterizava a camada inteira a cada frame e pesava o site. */
    animation: aurora 28s ease-in-out infinite alternate;
    will-change: transform;
}
@keyframes aurora {
    0%   { transform: translate3d(0, 0, 0) scale(1.05); opacity: 0.75; }
    40%  { transform: translate3d(-1.5%, 0.8%, 0) scale(1.09); opacity: 0.95; }
    100% { transform: translate3d(-2%, 1.5%, 0) scale(1.13); opacity: 1; }
}
.bg-grid {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 40%, #000 30%, transparent 80%);
    opacity: 0.6;
}
.bg-stars { opacity: 0.5; }

@media (prefers-reduced-motion: reduce) {
    .bg-aurora { animation: none; }
    .login-logo, .brand-logo { animation: none; }
    .login-card::before { animation: none; }
    .modal-card::before { animation: none; }
    .btn-primary { animation: none; }
    .nav-item::after { animation: none !important; }
    * { animation-duration: 0.001ms !important; transition-duration: 0.06s !important; }
}

/* ════════════════════════════════════════════════════════════════════════
   LOGIN
   ════════════════════════════════════════════════════════════════════════ */
.login-screen {
    position: fixed; inset: 0; z-index: 50;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 22px;
    animation: fade-in 0.5s var(--ease);
}
.login-screen.hide { animation: fade-out 0.4s var(--ease) forwards; }
@keyframes fade-out { to { opacity: 0; visibility: hidden; transform: scale(0.98); } }

.login-card {
    position: relative;
    width: min(380px, 90vw);
    padding: 36px 32px 30px;
    background: linear-gradient(180deg, var(--glass-strong), var(--glass));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    animation: rise 0.6s var(--ease) both;
}
/* borda com brilho rotativo — sweep azul/cyan da ADA */
.login-card::before {
    content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
    background: conic-gradient(from var(--a, 0deg), transparent 0 60%, var(--c-cyan), var(--c-blue), #E8F1FF, transparent 80%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    animation: spin-border 5s linear infinite; opacity: 0.9;
}
@property --a { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@keyframes spin-border { to { --a: 360deg; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.97); } }
@keyframes fade-in { from { opacity: 0; } }

.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo, .brand-logo {
    width: 60px; height: 60px; margin: 0 auto 14px;
    display: grid; place-items: center;
    border-radius: 18px;
    background: var(--accent-grad);
    box-shadow: var(--glow-violet), 0 0 0 1px rgba(77, 208, 255, 0.25);
    position: relative;
    animation: float 5s var(--ease) infinite, logo-pulse 3s ease-in-out infinite;
}
.login-logo span, .brand-logo span {
    font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 30px;
    color: #06080f; text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
}
@keyframes float { 50% { transform: translateY(-7px); } }
@keyframes logo-pulse {
    0%, 100% { box-shadow: 0 0 32px rgba(43, 168, 255, 0.50), 0 0 0 1px rgba(77, 208, 255, 0.25); }
    50%       { box-shadow: 0 0 52px rgba(77, 208, 255, 0.75), 0 0 0 1px rgba(232, 241, 255, 0.45); }
}
.login-brand h1 {
    font-family: "Space Grotesk", sans-serif; margin: 0; font-size: 30px; letter-spacing: 1px;
    background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-brand p { margin: 4px 0 0; font-size: 12px; color: var(--text-dim); letter-spacing: 1.5px; text-transform: uppercase; }

.field { margin-bottom: 14px; }
.field label {
    display: block; font-size: 11px; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px;
}
.field input, #search-input, #graph-search {
    width: 100%; color: var(--text); font-size: 14px; font-family: inherit;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 13px;
    transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
.field input:focus, #search-input:focus, #graph-search:focus {
    outline: none; border-color: rgba(43, 168, 255, 0.75);
    box-shadow: 0 0 0 3px rgba(43, 168, 255, 0.18), var(--glow-cyan);
    background: rgba(0, 0, 0, 0.35);
}

.btn-primary {
    position: relative; width: 100%; margin-top: 8px;
    border: none; border-radius: 11px; padding: 12px 16px;
    font-family: inherit; font-size: 14px; font-weight: 600; color: #06080f;
    background: var(--accent-grad); background-size: 180% 180%;
    cursor: pointer; overflow: hidden;
    box-shadow: 0 8px 28px -8px rgba(43, 168, 255, 0.65);
    transition: transform 0.15s var(--ease), box-shadow 0.25s, filter 0.2s;
    animation: shift 6s ease infinite;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
@keyframes shift { 50% { background-position: 100% 50%; } }
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.1); box-shadow: 0 12px 34px -8px rgba(77, 208, 255, 0.75); }
.btn-primary:active { transform: translateY(0) scale(0.99); }
.btn-primary:focus-visible { outline: 3px solid var(--c-cyan); outline-offset: 3px; box-shadow: 0 0 0 5px rgba(77, 208, 255, 0.22); }
.btn-primary:disabled { filter: grayscale(0.4) brightness(0.8); cursor: progress; }
.spinner {
    width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(6, 8, 15, 0.35); border-top-color: #06080f;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-error, #pw-error {
    min-height: 18px; margin-top: 10px; font-size: 12.5px; color: var(--bad); text-align: center;
}
.login-error.show { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.login-foot { font-size: 11px; color: var(--text-faint); letter-spacing: 1.5px; text-transform: uppercase; z-index: 50; }

/* ════════════════════════════════════════════════════════════════════════
   APP SHELL
   ════════════════════════════════════════════════════════════════════════ */
.app-shell {
    position: relative; z-index: 1;
    display: grid;
    grid-template-columns: 268px 376px 1fr;
    height: 100vh;
    animation: fade-in 0.5s var(--ease);
}

/* ───────────────── sidebar ───────────────── */
.sidebar {
    grid-column: 1;
    /* fundo sólido com tint navy — sem backdrop-filter de tela cheia (caro de repintar) */
    background: linear-gradient(180deg, #08112a, #050c1c);
    border-right: 1px solid var(--border-soft);
    display: flex; flex-direction: column; padding: 18px 14px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 4px; }
.brand-logo { width: 42px; height: 42px; margin: 0; border-radius: 13px; animation: none; }
.brand-logo span { font-size: 22px; }
.brand-text h1 {
    margin: 0; font-family: "Space Grotesk", sans-serif; font-size: 22px; letter-spacing: 0.5px;
    background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-sub { font-size: 10px; color: var(--text-faint); letter-spacing: 1.5px; text-transform: uppercase; }

.search { position: relative; }
.search-icon {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; fill: none; stroke: var(--text-faint); stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round; pointer-events: none;
}
#search-input { padding-left: 34px; font-size: 13px; }
#search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
    background: #141826;
    border: 1px solid var(--border); border-radius: 12px;
    max-height: 360px; overflow-y: auto; padding: 5px;
    box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.7);
    display: none;
}
#search-results.open { display: block; animation: pop 0.18s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
.search-result {
    padding: 9px 10px; cursor: pointer; border-radius: 9px; font-size: 12px;
    transition: background 0.15s;
}
.search-result:hover { background: var(--glass-strong); }
.search-result .kind {
    display: inline-block; background: rgba(43, 168, 255, 0.16); color: var(--c-blue);
    padding: 1px 7px; border-radius: 5px; font-size: 9.5px; margin-right: 6px;
    text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
}

nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    background: transparent; border: 1px solid transparent; color: var(--text-dim);
    text-align: left; padding: 9px 11px; border-radius: 10px; cursor: pointer;
    font-family: inherit; font-size: 13.5px; font-weight: 500;
    transition: all 0.2s var(--ease); position: relative;
}
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; flex-shrink: 0; }
.nav-item:hover {
    background: rgba(43, 168, 255, 0.08); color: var(--text);
    border-color: rgba(43, 168, 255, 0.20);
    box-shadow: 0 0 14px -4px rgba(43, 168, 255, 0.25);
}
.nav-item:focus-visible {
    outline: 3px solid var(--c-cyan); outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(77, 208, 255, 0.18);
}
.nav-item.active {
    color: #fff; background: linear-gradient(100deg, rgba(43, 168, 255, 0.18), rgba(77, 208, 255, 0.10));
    border-color: rgba(43, 168, 255, 0.40);
    box-shadow: inset 0 0 0 1px rgba(77, 208, 255, 0.12), 0 4px 18px -8px rgba(43, 168, 255, 0.55);
}
.nav-item.active::before {
    content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent-grad); box-shadow: var(--glow-cyan);
}
.nav-item.active svg { opacity: 1; stroke: var(--c-cyan); }

.sidebar footer { margin-top: auto; display: flex; flex-direction: column; gap: 9px; }
#sync-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--glass); border: 1px solid var(--border); color: var(--text-dim);
    padding: 9px; border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 12px;
    transition: all 0.2s;
}
#sync-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#sync-btn:hover { color: var(--text); border-color: rgba(43, 168, 255, 0.45); background: var(--glass-strong); box-shadow: 0 0 14px -4px rgba(43, 168, 255, 0.30); }
#sync-btn:focus-visible { outline: 3px solid var(--c-cyan); outline-offset: 2px; }
#sync-btn:active svg { animation: spin 0.7s linear; }
.health { font-size: 10.5px; color: var(--text-faint); text-align: center; letter-spacing: 0.3px; }
.health.ok::before { content: '●'; color: var(--good); margin-right: 5px; filter: drop-shadow(0 0 4px var(--good)); }
.health.bad::before { content: '●'; color: var(--bad); margin-right: 5px; filter: drop-shadow(0 0 4px var(--bad)); }

.user-bar {
    display: flex; align-items: center; gap: 8px;
    padding-top: 9px; border-top: 1px solid var(--border-soft);
}
.user-chip {
    display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0;
    font-size: 12.5px; color: var(--text); font-weight: 500;
}
.user-chip #user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 8px var(--good); flex-shrink: 0; }
.icon-btn {
    display: grid; place-items: center; width: 30px; height: 30px; flex-shrink: 0;
    background: var(--glass); border: 1px solid var(--border); border-radius: 9px;
    color: var(--text-dim); cursor: pointer; transition: all 0.18s;
}
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: var(--text); border-color: rgba(43, 168, 255, 0.45); transform: translateY(-1px); box-shadow: 0 0 12px -3px rgba(43, 168, 255, 0.30); }
.icon-btn:focus-visible { outline: 3px solid var(--c-cyan); outline-offset: 2px; }
#logout-btn:hover { color: var(--bad); border-color: rgba(248, 113, 113, 0.45); box-shadow: none; }

/* ───────────────── lista ───────────────── */
.list-pane {
    grid-column: 2;
    border-right: 1px solid var(--border-soft);
    overflow-y: auto; padding: 18px 14px;
    background: rgba(8, 10, 16, 0.4);
}
.list-pane h2, .graph-toolbar h2 {
    margin: 0 0 14px 4px; font-size: 11px; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600;
}
.list-item {
    background: var(--glass); border: 1px solid var(--border-soft);
    padding: 12px 13px; border-radius: var(--radius); margin-bottom: 9px; cursor: pointer;
    transition: all 0.2s var(--ease); position: relative; overflow: hidden;
    animation: item-in 0.4s var(--ease) both;
}
@keyframes item-in { from { opacity: 0; transform: translateY(8px); } }
.list-item::after {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
    background: var(--accent-grad); opacity: 0; transition: opacity 0.2s;
}
.list-item:hover { border-color: rgba(43, 168, 255, 0.38); background: var(--glass-strong); transform: translateX(2px); box-shadow: 0 4px 20px -8px rgba(43, 168, 255, 0.25); }
.list-item.active {
    border-color: rgba(43, 168, 255, 0.55);
    background: linear-gradient(100deg, rgba(43, 168, 255, 0.12), rgba(77, 208, 255, 0.07));
    box-shadow: 0 6px 24px -12px rgba(43, 168, 255, 0.65);
}
.list-item.active::after { opacity: 1; }
.list-item .title { font-size: 13.5px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.list-item .meta { font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }

.tag {
    display: inline-block; padding: 2px 8px; border-radius: 20px;
    background: var(--glass-strong); color: var(--text-dim);
    font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    border: 1px solid var(--border-soft);
}
.tag.type-user      { background: rgba(196, 181, 253, 0.14); color: var(--t-user); border-color: rgba(196, 181, 253, 0.25); }
.tag.type-feedback  { background: rgba(253, 186, 116, 0.14); color: var(--t-feedback); border-color: rgba(253, 186, 116, 0.25); }
.tag.type-project   { background: rgba(110, 231, 183, 0.14); color: var(--t-project); border-color: rgba(110, 231, 183, 0.25); }
.tag.type-reference { background: rgba(125, 211, 252, 0.14); color: var(--t-reference); border-color: rgba(125, 211, 252, 0.25); }
.sev-low { color: var(--text-dim); }
.sev-medium { color: var(--warn); }
.sev-high { color: var(--bad); }
.sev-critical { color: var(--crit); font-weight: 700; text-shadow: 0 0 10px rgba(251, 113, 133, 0.5); }

/* ───────────────── detalhe ───────────────── */
.detail-pane {
    grid-column: 3; overflow-y: auto; padding: 30px 38px; background: rgba(7, 8, 13, 0.3);
}
.detail-empty {
    color: var(--text-faint); padding: 80px 20px; text-align: center; font-size: 14px;
}
.detail-empty-glyph { font-size: 44px; margin-bottom: 14px; opacity: 0.4; animation: float 5s var(--ease) infinite; }
.detail-pane > * { animation: fade-in 0.4s var(--ease); }
.detail-pane h1 { margin: 0 0 6px; font-family: "Space Grotesk", sans-serif; font-size: 26px; font-weight: 600; }
.detail-pane .meta-row {
    color: var(--text-dim); font-size: 12px; margin-bottom: 22px;
    padding-bottom: 14px; border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.detail-pane h2 {
    font-size: 12px; color: var(--c-blue); text-transform: uppercase; letter-spacing: 1.5px;
    margin: 26px 0 9px; font-weight: 600;
}
.detail-pane p, .detail-pane li { line-height: 1.7; color: var(--text); }
.content-render { font-size: 14.5px; }
.detail-pane code {
    background: rgba(43, 168, 255, 0.10); padding: 2px 7px; border-radius: 6px;
    font-family: "Cascadia Code", Consolas, monospace; font-size: 88%; color: var(--c-cyan);
    border: 1px solid rgba(43, 168, 255, 0.18);
}
.detail-pane pre {
    background: rgba(0, 0, 0, 0.4); border: 1px solid var(--border); padding: 14px;
    border-radius: var(--radius); overflow-x: auto;
}
.detail-pane pre code { background: none; border: none; color: var(--text); padding: 0; }
.detail-pane a { color: var(--c-cyan); text-decoration: none; border-bottom: 1px solid rgba(77, 208, 255, 0.30); transition: border-color 0.2s; }
.detail-pane a:hover { border-color: var(--c-cyan); }
.detail-pane blockquote {
    border-left: 3px solid; border-image: var(--accent-grad) 1;
    padding-left: 14px; color: var(--text-dim); margin: 14px 0;
}
.detail-pane table { border-collapse: collapse; margin: 14px 0; width: 100%; font-size: 13px; }
.detail-pane th, .detail-pane td { border: 1px solid var(--border); padding: 8px 11px; text-align: left; }
.detail-pane th { background: var(--glass-strong); color: var(--text); font-weight: 600; }

.actions { display: flex; gap: 9px; margin-top: 26px; }
.actions button, .ghost-btn {
    background: var(--glass); border: 1px solid var(--border); color: var(--text);
    padding: 8px 16px; border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 12.5px;
    transition: all 0.18s var(--ease);
}
.actions button:hover, .ghost-btn:hover { border-color: rgba(43, 168, 255, 0.50); background: var(--glass-strong); transform: translateY(-1px); box-shadow: 0 0 14px -4px rgba(43, 168, 255, 0.25); }
.actions button:focus-visible, .ghost-btn:focus-visible { outline: 3px solid var(--c-cyan); outline-offset: 2px; }
.actions button.primary {
    background: var(--accent-grad); color: #06080f; border: none; font-weight: 600;
    box-shadow: 0 6px 22px -8px rgba(43, 168, 255, 0.65);
}
.actions button.primary:focus-visible { outline: 3px solid var(--c-cyan); outline-offset: 3px; box-shadow: 0 0 0 5px rgba(77, 208, 255, 0.22); }

.editor textarea {
    width: 100%; min-height: 380px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border);
    color: var(--text); padding: 14px; border-radius: var(--radius);
    font-family: "Cascadia Code", Consolas, monospace; font-size: 13px; line-height: 1.7; resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.editor textarea:focus, .editor input:focus, .editor select:focus { outline: none; border-color: rgba(43, 168, 255, 0.65); box-shadow: 0 0 0 3px rgba(43, 168, 255, 0.14), var(--glow-cyan); }
.editor input[type="text"], .editor select {
    width: 100%; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border); color: var(--text);
    padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; font-family: inherit; font-size: 13px;
}
.editor label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; display: block; margin: 10px 0 5px; }

.links-row { font-size: 12px; margin-top: 16px; display: flex; flex-wrap: wrap; gap: 6px; }
.link-chip {
    display: inline-flex; align-items: center; background: var(--glass); border: 1px solid var(--border);
    padding: 4px 11px; border-radius: 20px; cursor: pointer; color: var(--c-blue);
    transition: all 0.18s; font-size: 11.5px;
}
.link-chip:hover { border-color: rgba(43, 168, 255, 0.55); background: rgba(43, 168, 255, 0.12); transform: translateY(-1px); box-shadow: var(--glow-cyan); }
.link-chip.missing { color: var(--text-faint); border-style: dashed; }

/* ════════════════════════════════════════════════════════════════════════
   GRAFO (estilo Obsidian)
   ════════════════════════════════════════════════════════════════════════ */
.graph-pane { grid-column: 2 / 4; position: relative; display: none; overflow: hidden; background: radial-gradient(ellipse at center, rgba(13, 16, 26, 0.4), rgba(7, 8, 13, 0.6)); }
.app-shell.graph-mode #list, .app-shell.graph-mode #detail { display: none; }
.app-shell.graph-mode .graph-pane { display: block; }
#graph-canvas { position: absolute; inset: 0; }
#graph-canvas canvas { display: block; }

.graph-toolbar {
    position: absolute; top: 16px; left: 18px; right: 18px; z-index: 5;
    display: flex; align-items: center; gap: 14px; pointer-events: none; flex-wrap: wrap;
}
.graph-toolbar h2 { margin: 0; pointer-events: auto; }
.graph-stats { font-size: 11px; color: var(--text-dim); pointer-events: auto; }
.graph-actions { margin-left: auto; display: flex; gap: 8px; pointer-events: auto; }
#graph-search {
    width: 200px; padding: 8px 12px; font-size: 12.5px;
    background: rgba(17, 20, 31, 0.9); backdrop-filter: blur(10px);
}
.ghost-btn { font-size: 12.5px; padding: 8px 14px; backdrop-filter: blur(10px); background: rgba(17, 20, 31, 0.9); }

.graph-legend {
    position: absolute; bottom: 18px; left: 18px; z-index: 5;
    display: flex; flex-direction: column; gap: 6px;
    background: rgba(17, 20, 31, 0.85); backdrop-filter: blur(12px);
    border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-dim); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

.graph-tooltip {
    position: absolute; z-index: 6; pointer-events: none;
    background: rgba(6, 15, 36, 0.96); backdrop-filter: blur(10px);
    border: 1px solid rgba(43, 168, 255, 0.45); border-radius: 9px;
    padding: 7px 11px; font-size: 12px; color: var(--text);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.8), 0 0 18px -6px rgba(43, 168, 255, 0.25); max-width: 240px;
    transform: translate(-50%, calc(-100% - 12px));
}
.graph-tooltip .tt-type { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); }

/* ════════════════════════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════════════════════════ */
.modal {
    position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
    background: rgba(2, 6, 18, 0.75); backdrop-filter: blur(6px); animation: fade-in 0.25s var(--ease);
}
.modal-card {
    position: relative; width: min(380px, 90vw); padding: 26px;
    background: linear-gradient(180deg, var(--glass-strong), var(--glass));
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    backdrop-filter: blur(22px); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.85), 0 0 40px -15px rgba(43, 168, 255, 0.20);
    animation: rise 0.35s var(--ease) both;
}
/* borda giratória no modal — idêntica ao login-card */
.modal-card::before {
    content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
    background: conic-gradient(from var(--a, 0deg), transparent 0 60%, var(--c-cyan), var(--c-blue), #E8F1FF, transparent 80%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    animation: spin-border 5s linear infinite; opacity: 0.65; pointer-events: none;
}
.modal-card h2 { margin: 0 0 18px; font-family: "Space Grotesk", sans-serif; font-size: 19px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 18px; }

/* ════════════════════════════════════════════════════════════════════════
   EFEITOS NEON / ANIMAÇÕES ADICIONAIS
   ════════════════════════════════════════════════════════════════════════ */

/* Glow pulsante em elementos-chave de accent */
.nav-item.active .nav-icon,
.brand-logo,
.login-logo {
    filter: drop-shadow(0 0 6px rgba(77, 208, 255, 0.50));
}

/* rosto da ADA dentro do logo — recorta no quadrado arredondado; cai pro "A" se o PNG não existir */
.login-logo,
.brand-logo { position: relative; overflow: hidden; }
.login-logo img.ada-face,
.brand-logo img.ada-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    display: block;
    z-index: 1;
}
.login-logo img.ada-face.missing,
.brand-logo img.ada-face.missing { display: none; }
/* quando a face carrega, o "A" de fallback some */
.login-logo:has(img.ada-face:not(.missing)) span,
.brand-logo:has(img.ada-face:not(.missing)) span { opacity: 0; }

/* Shimmer sutil no bg-grid — "grade elétrica" */
.bg-grid {
    animation: grid-drift 40s linear infinite;
}
@keyframes grid-drift {
    0%   { background-position: 0 0; opacity: 0.55; }
    50%  { opacity: 0.70; }
    100% { background-position: 48px 48px; opacity: 0.55; }
}

/* Glow pulsante nos list-items ativos */
.list-item.active {
    animation: item-active-pulse 4s ease-in-out infinite;
}
@keyframes item-active-pulse {
    0%, 100% { box-shadow: 0 6px 24px -12px rgba(43, 168, 255, 0.55); }
    50%       { box-shadow: 0 6px 32px -10px rgba(77, 208, 255, 0.80); }
}

/* Linha accent no nav-item.active — pulsa junto */
.nav-item.active::before {
    animation: accent-bar-pulse 3s ease-in-out infinite;
}
@keyframes accent-bar-pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(77, 208, 255, 0.40); }
    50%       { box-shadow: 0 0 18px rgba(77, 208, 255, 0.80); }
}

/* Token dourado — destaque raro pra badges/emblemas */
.gold { color: var(--gold); }
.gold-glow { color: var(--gold); text-shadow: 0 0 12px rgba(245, 196, 81, 0.60); }

/* ───────────────── responsivo ───────────────── */
@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 240px 320px 1fr; }
}
@media (max-width: 860px) {
    .app-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .sidebar { grid-column: 1; grid-row: 1; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar footer { margin: 0; flex-direction: row; }
    .list-pane { grid-column: 1; grid-row: 2; }
    .detail-pane { display: none; }
    .graph-pane { grid-column: 1; grid-row: 2; }
    .chat-pane { grid-column: 1 !important; grid-row: 2 !important; }
}

/* ═══════════════ Falar com a Ada (chat) ═══════════════ */
.chat-pane { display: none; }
.app-shell.chat-mode #list,
.app-shell.chat-mode #detail,
.app-shell.chat-mode .graph-pane { display: none; }
.app-shell.chat-mode .chat-pane {
    display: flex; flex-direction: column;
    grid-column: 2 / -1; grid-row: 1;
    min-height: 0; height: 100vh;
    position: relative; z-index: 1;
    animation: fade-in 0.4s var(--ease);
}
.chat-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 22px; border-bottom: 1px solid var(--border-soft);
    background: rgba(10, 21, 48, 0.4); backdrop-filter: blur(10px);
}
.chat-title { display: flex; align-items: center; gap: 12px; }
.chat-title h2 { margin: 0; font-family: "Space Grotesk", sans-serif; font-size: 17px; letter-spacing: 0.4px; color: var(--text); }
.chat-sub { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.8px; }
.chat-ada-dot {
    width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
    background: var(--accent-grad); box-shadow: var(--glow-cyan);
    animation: logo-pulse 3s var(--ease) infinite;
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 24px 22px;
    display: flex; flex-direction: column; gap: 16px;
}
.chat-msg {
    max-width: 80%; padding: 12px 16px; border-radius: var(--radius-lg);
    font-size: 14px; line-height: 1.6; animation: fade-in 0.3s var(--ease);
}
.chat-msg.user {
    align-self: flex-end; color: var(--text);
    background: rgba(43, 168, 255, 0.16); border: 1px solid rgba(43, 168, 255, 0.30);
    border-bottom-right-radius: 4px;
}
.chat-msg.ada {
    align-self: flex-start; color: var(--text);
    background: var(--glass-strong); border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-msg.ada.err { border-color: rgba(248, 113, 113, 0.5); color: var(--bad); }
.chat-msg p:first-child { margin-top: 0; }
.chat-msg p:last-child { margin-bottom: 0; }
.chat-msg code { background: rgba(43, 168, 255, 0.10); padding: 1px 6px; border-radius: 5px; font-family: "Cascadia Code", Consolas, monospace; font-size: 88%; color: var(--c-cyan); }
.chat-msg pre { background: rgba(0, 0, 0, 0.4); border: 1px solid var(--border); padding: 12px; border-radius: var(--radius); overflow-x: auto; }
.chat-msg pre code { background: none; color: var(--text); padding: 0; }
.chat-used { font-size: 10.5px; color: var(--text-faint); margin-top: 9px; letter-spacing: 0.3px; }
.chat-typing { align-self: flex-start; display: flex; gap: 5px; align-items: center; padding: 6px 4px; }
.chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--c-cyan); animation: chat-blink 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }
.chat-empty { margin: auto; text-align: center; color: var(--text-faint); max-width: 380px; line-height: 1.6; }
.chat-empty .glyph { font-size: 38px; margin-bottom: 12px; opacity: 0.5; }
.chat-input {
    display: flex; gap: 10px; padding: 14px 18px;
    border-top: 1px solid var(--border-soft); background: rgba(10, 21, 48, 0.4);
}
.chat-input textarea {
    flex: 1; resize: none; max-height: 160px;
    background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); padding: 11px 14px;
    font-family: inherit; font-size: 14px; line-height: 1.4;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-input textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.chat-input button { align-self: flex-end; flex: 0 0 auto; width: auto; }
.nav-chat span { font-weight: 600; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 12px 0; cursor: pointer; }
.chk small { color: var(--text-faint); }
.field select {
    width: 100%; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); padding: 10px 12px;
    font-family: inherit; font-size: 14px; cursor: pointer;
}
.field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.field label small { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-faint); }
/* SSO: botao "Entrar com o Portal GR" + divisor */
.sso-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; width: 100%; margin-bottom: 4px; }
.login-or {
    display: flex; align-items: center; gap: 10px; margin: 14px 0 6px;
    color: var(--text-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
}
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }
