/* ============================================================
   CIBE IA — style.css
   Assistente Inteligente para Projetos · Base developed by Brian Lewis
   Dark futuristic premium theme
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Surfaces */
  --bg-0: #050508;
  --bg-1: #0a0a12;
  --bg-2: #10101c;
  --bg-3: #161627;
  --glass: rgba(13, 13, 24, 0.72);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);

  /* Text */
  --tx-1: #f2f3f8;
  --tx-2: #a7abc4;
  --tx-3: #6b7092;

  /* Accent (overridden by [data-accent]) */
  --acc-1: #7c6cff;
  --acc-2: #4da3ff;
  --acc-3: #38e8d2;
  --accent-gradient: linear-gradient(135deg, var(--acc-1), var(--acc-2) 55%, var(--acc-3));
  --glow: rgba(124, 108, 255, 0.35);

  /* Shape & motion */
  --radius: 14px;
  --radius-sm: 10px;
  --speed: 0.22s;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --font-ui: "Inter", "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;

  --scale: 100%;
}

/* Desktop companion: controlled local-project access */
.project-modal { width: min(920px, calc(100vw - 32px)); }
.project-body { display: grid; gap: 14px; }
.project-root { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--tx-2); overflow-wrap: anywhere; }
.project-field { display: grid; gap: 7px; color: var(--tx-2); font-size: .84rem; }
.project-field select, #project-check, .project-field textarea, .project-field input {
  width: 100%; color: var(--tx-1); background: var(--bg-2, #111119); border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
.project-field textarea { resize: vertical; min-height: 260px; font: 13px/1.55 Consolas, "Courier New", monospace; tab-size: 2; }
.project-inline { display: grid; grid-template-columns: 1fr auto; gap: 9px; }
.project-command-box { display: grid; gap: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(74,163,255,.045); }
.project-command-box > div:first-child { display: grid; gap: 4px; }
.project-command-box small { color: var(--tx-2); line-height: 1.45; }
.project-command-box .project-field textarea { min-height: 105px; }
.project-command-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.project-checkbox { display: flex; align-items: center; gap: 8px; color: var(--tx-2); font-size: .78rem; }
.project-checkbox input { accent-color: var(--acc-2); }
.project-save { width: auto; }
.project-output { max-height: 260px; overflow: auto; white-space: pre-wrap; color: #c7d2fe; background: #080811; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.full-access-box { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 16px; border: 1px solid rgba(77,163,255,.3); border-radius: 14px; background: linear-gradient(135deg, rgba(77,163,255,.09), rgba(124,108,255,.05)); }
.full-access-box.is-enabled { border-color: rgba(56,232,210,.52); box-shadow: 0 0 24px rgba(56,232,210,.1); background: linear-gradient(135deg, rgba(56,232,210,.11), rgba(77,163,255,.05)); }
.full-access-copy { display: grid; gap: 5px; }
.full-access-copy small { color: var(--tx-2); line-height: 1.45; }
.full-access-status { display: inline-flex; align-items: center; gap: 7px; width: fit-content; color: #9ca3c3; font-size: .72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.full-access-status i { width: 8px; height: 8px; border-radius: 50%; background: #6b7092; box-shadow: 0 0 0 4px rgba(107,112,146,.12); }
.full-access-status[data-enabled="true"] { color: #57f2d7; }
.full-access-status[data-enabled="true"] i { background: #38e8d2; box-shadow: 0 0 0 4px rgba(56,232,210,.14), 0 0 16px rgba(56,232,210,.65); }
.full-access-toggle { white-space: nowrap; }
.full-access-box.is-enabled .full-access-toggle { border-color: rgba(56,232,210,.55); color: #57f2d7; }
@media (max-width: 720px) { .full-access-box { grid-template-columns: 1fr; } .full-access-toggle { width: 100%; } }
.settings-access-card { display: grid; gap: 9px; padding: 15px; border: 1px solid var(--line-strong); border-radius: 12px; background: linear-gradient(135deg, rgba(77,163,255,.07), rgba(124,108,255,.035)); }
.settings-access-card.is-enabled { border-color: rgba(56,232,210,.48); background: linear-gradient(135deg, rgba(56,232,210,.1), rgba(77,163,255,.045)); box-shadow: 0 0 22px rgba(56,232,210,.08); }
.settings-access-card > p { color: var(--tx-2); font-size: .8rem; line-height: 1.5; }
.settings-access-status { display: inline-flex; align-items: center; gap: 7px; width: fit-content; color: var(--tx-3); font-size: .69rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.settings-access-status i { width: 8px; height: 8px; border-radius: 50%; background: #6b7092; box-shadow: 0 0 0 4px rgba(107,112,146,.12); }
.settings-access-status[data-enabled="true"] { color: #57f2d7; }
.settings-access-status[data-enabled="true"] i { background: #38e8d2; box-shadow: 0 0 0 4px rgba(56,232,210,.14), 0 0 16px rgba(56,232,210,.6); }
.settings-access-toggle, .settings-access-download { width: fit-content; margin-top: 2px; }

html[data-accent="violet"] { --acc-1:#a55cff; --acc-2:#e05cff; --acc-3:#ff8ad1; --glow: rgba(190,92,255,.35); }
html[data-accent="cyan"]   { --acc-1:#22d3ee; --acc-2:#38bdf8; --acc-3:#34d399; --glow: rgba(56,189,248,.35); }
html[data-accent="ember"]  { --acc-1:#ff7a59; --acc-2:#ffb35c; --acc-3:#ffd166; --glow: rgba(255,138,89,.32); }
html[data-accent="rose"]   { --acc-1:#fb5c8d; --acc-2:#e05ca8; --acc-3:#b78cff; --glow: rgba(251,92,141,.32); }

/* ---------- 2. Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--scale); height: 100%; }

body {
  height: 100%;
  font-family: var(--font-ui);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(124,108,255,.09), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(56,232,210,.06), transparent 60%),
    var(--bg-0);
  color: var(--tx-1);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--acc-2); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
[hidden] { display: none !important; }

/* Authentication */
.auth-screen {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  padding: 24px;
  overflow-y: auto;
  background: var(--bg-0);
}
.auth-aurora {
  position: fixed; inset: 0; pointer-events: none;
  background:
    radial-gradient(700px 420px at 20% 10%, rgba(124,108,255,.18), transparent 70%),
    radial-gradient(650px 400px at 85% 90%, rgba(56,232,210,.10), transparent 70%);
}
.auth-card {
  position: relative;
  width: min(100%, 540px);
  padding: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: rgba(13,13,24,.9);
  box-shadow: 0 30px 100px rgba(0,0,0,.65), 0 0 60px var(--glow);
  backdrop-filter: blur(24px);
}
.auth-brand { display: flex; align-items: center; gap: 15px; margin-bottom: 24px; }
.auth-brand img { width: 54px; height: 54px; filter: drop-shadow(0 0 18px var(--glow)); }
.auth-brand h1 { font-size: 1.45rem; }
.auth-brand p { margin-top: 3px; color: var(--tx-2); font-size: .86rem; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border-radius: 12px; background: rgba(0,0,0,.3); margin-bottom: 20px; }
.auth-tab { padding: 10px; border-radius: 9px; color: var(--tx-2); font-weight: 650; font-size: .88rem; }
.auth-tab.active { color: #fff; background: linear-gradient(135deg, rgba(124,108,255,.8), rgba(77,163,255,.7)); box-shadow: 0 5px 18px var(--glow); }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; }
.auth-form label > span { color: var(--tx-2); font-size: .78rem; font-weight: 600; }
.auth-form input {
  width: 100%; padding: 11px 13px;
  color: var(--tx-1); background: rgba(0,0,0,.32);
  border: 1px solid var(--line-strong); border-radius: 10px; outline: none;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.auth-form input:focus { border-color: var(--acc-1); box-shadow: 0 0 0 3px rgba(124,108,255,.15); }
.auth-form input::placeholder { color: var(--tx-3); }
.auth-submit { margin-top: 3px; padding: 12px 18px; border-radius: 10px; background: var(--accent-gradient); color: #fff; font-weight: 750; box-shadow: 0 6px 22px var(--glow); }
.auth-submit:hover { filter: brightness(1.09); }
.auth-qr-button { padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--tx-2); font-size: .82rem; }
.auth-qr-button:hover { color: var(--tx-1); border-color: var(--acc-2); background: rgba(77,163,255,.08); }
.qr-login-panel { display: flex; flex-direction: column; align-items: center; gap: 11px; text-align: center; }
.qr-login-panel h3 { font-size: 1rem; }
.qr-login-panel p, #qr-login-status { color: var(--tx-2); font-size: .78rem; }
#login-qr-image { width: min(280px, 75vw); padding: 10px; border-radius: 14px; background: #fff; }
.auth-submit:disabled { opacity: .65; cursor: wait; }
.auth-message { padding: 10px 12px; margin-bottom: 15px; border: 1px solid rgba(255,92,108,.4); border-radius: 10px; background: rgba(255,92,108,.09); color: #ffb3bc; font-size: .82rem; }
.auth-message.success { border-color: rgba(56,232,210,.4); color: #a9f5e8; background: rgba(56,232,210,.08); }
.auth-privacy, .auth-credits { color: var(--tx-3); font-size: .7rem; text-align: center; line-height: 1.5; }
.auth-credits { margin-top: 20px; }
.auth-download-link { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--tx-1); background: rgba(77,163,255,.06); transition: .2s ease; }
.auth-download-link:hover { border-color: rgba(56,232,210,.45); background: rgba(56,232,210,.09); transform: translateY(-1px); text-decoration: none; }
.auth-download-link svg { width: 21px; height: 21px; fill: none; stroke: var(--acc-3); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.auth-download-link span { display: flex; flex-direction: column; gap: 2px; }
.auth-download-link strong { font-size: .82rem; }
.auth-download-link small { color: var(--tx-2); font-size: .7rem; }
.user-summary { display: flex; align-items: center; gap: 10px; padding: 8px 9px 10px; }
.user-avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 10px; background: var(--accent-gradient); color: #fff; font-size: .72rem; font-weight: 800; }
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-details strong, .user-details small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-details strong { font-size: .8rem; }
.user-details small { color: var(--tx-3); font-size: .68rem; margin-top: 2px; }
.logout-link { color: #ff9ca7; }
.pro-link { color: #f8d477; background: linear-gradient(90deg, rgba(248,192,73,.10), rgba(124,108,255,.08)); border-color: rgba(248,192,73,.18); }
.admin-link { color: #8fdcff; background: rgba(77,163,255,.08); border-color: rgba(77,163,255,.18); }
.admin-modal { max-width: 1050px; }
.admin-body { gap: 22px; }
.admin-body section { display: flex; flex-direction: column; gap: 12px; }
.admin-body h3 { font-size: .95rem; }
.admin-metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
.admin-metrics > div { padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); display: flex; flex-direction: column; gap: 6px; }
.admin-metrics span { color: var(--tx-3); font-size: .7rem; }
.admin-metrics strong { font-size: 1.1rem; color: #a9f5e8; }
.admin-section-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.admin-section-head p, #admin-team-count { color: var(--tx-3); font-size: .72rem; margin-top: 3px; }
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 680px; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: .75rem; }
.admin-table th { color: var(--tx-3); text-transform: uppercase; letter-spacing: .06em; font-size: .64rem; }
.admin-table tr:last-child td { border-bottom: 0; }
.role-select { padding: 7px 9px; border-radius: 8px; color: var(--tx-1); background: var(--bg-3); border: 1px solid var(--line-strong); }
.pro-modal { max-width: 570px; }
.pro-body { gap: 16px; }
.pro-hero { text-align: center; padding: 8px 10px 2px; }
.pro-badge { display: inline-block; padding: 4px 9px; border-radius: 99px; background: linear-gradient(135deg,#ffd76a,#e79b28); color: #261600; font-size: .65rem; font-weight: 900; letter-spacing: .12em; }
.pro-hero h3 { margin-top: 10px; font-size: 1.25rem; }
.pro-hero p { margin: 5px 0 10px; color: var(--tx-2); font-size: .84rem; }
.pro-hero > strong { font-size: 1.55rem; color: #f8d477; }
.pro-hero > small { color: var(--tx-3); }
.pro-benefits { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); }
.pro-benefits li { color: var(--tx-2); font-size: .78rem; }
.pro-active { padding: 13px; text-align: center; color: #a9f5e8; border: 1px solid rgba(56,232,210,.35); border-radius: 11px; background: rgba(56,232,210,.07); }
.pro-checkout-form { display: flex; flex-direction: column; gap: 13px; }
.pro-checkout-form fieldset { border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.pro-checkout-form legend { grid-column: 1/-1; margin-bottom: 7px; color: var(--tx-2); font-size: .78rem; font-weight: 650; }
.payment-option { display: flex; align-items: center; gap: 9px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 11px; cursor: pointer; }
.payment-option.active { border-color: var(--acc-1); background: rgba(124,108,255,.1); }
.payment-option span { display: flex; flex-direction: column; gap: 2px; }
.payment-option small { color: var(--tx-3); font-size: .68rem; }
.plan-option { display: flex; align-items: center; gap: 9px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 11px; cursor: pointer; }
.plan-option.active { border-color: #f8c049; background: rgba(248,192,73,.08); }
.plan-option span { display: flex; flex: 1; flex-direction: column; gap: 2px; }
.plan-option small { color: var(--tx-3); font-size: .68rem; }
.plan-option b { color: #f8d477; font-size: .9rem; }
.pro-cpf-field, .pix-result label { display: flex; flex-direction: column; gap: 6px; color: var(--tx-2); font-size: .78rem; }
.pro-cpf-field input, #pix-code { padding: 11px 13px; color: var(--tx-1); background: rgba(0,0,0,.3); border: 1px solid var(--line-strong); border-radius: 10px; outline: none; }
.pro-safe { text-align: center; color: var(--tx-3); font-size: .7rem; }
.pix-result { display: flex; flex-direction: column; align-items: center; gap: 11px; padding: 15px; border: 1px solid rgba(56,232,210,.28); border-radius: 12px; }
.pix-result > p { color: #a9f5e8; font-weight: 700; }
#pix-qr { width: min(240px, 75vw); background: #fff; padding: 8px; border-radius: 10px; }
.pix-result label { width: 100%; }
#pix-code { width: 100%; min-height: 78px; resize: none; font-family: var(--font-mono); font-size: .72rem; }
.pix-result > small { color: var(--tx-3); text-align: center; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,.2); }
::-webkit-scrollbar-track { background: transparent; }

kbd {
  font-family: var(--font-mono); font-size: .72em;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; color: var(--tx-2);
}

.muted { color: var(--tx-2); }
.center { text-align: center; }

/* ---------- 3. App layout ---------- */
#app {
  display: grid;
  grid-template-columns: 288px 1fr;
  height: 100vh;
  height: 100dvh;
}

.only-mobile { display: none !important; }

/* ---------- 4. Sidebar ---------- */
#sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 14px;
  background: var(--glass);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-right: 1px solid var(--line);
  z-index: 40;
  min-height: 0;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 6px 10px;
}
.sidebar-brand img { width: 38px; height: 38px; filter: drop-shadow(0 0 12px var(--glow)); }
.brand-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.brand-text span {
  font-weight: 700; font-size: 1.02rem; letter-spacing: .02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text small { color: var(--tx-3); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }

.btn-new-chat {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-gradient);
  color: #fff; font-weight: 600; font-size: .92rem;
  box-shadow: 0 4px 22px var(--glow), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform var(--speed) var(--ease), box-shadow var(--speed) var(--ease), filter var(--speed);
}
.btn-new-chat:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 6px 28px var(--glow); }
.btn-new-chat:active { transform: translateY(0) scale(.98); }
.btn-new-chat svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.sidebar-section { min-height: 0; display: flex; flex-direction: column; }
.history-section { flex: 1; }

.section-label {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px;
  font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--tx-3);
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px;
  color: var(--tx-2);
  transition: background var(--speed), color var(--speed), transform var(--speed);
}
.icon-btn:hover { background: rgba(255,255,255,.07); color: var(--tx-1); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.tiny { width: 26px; height: 26px; opacity: .7; }
.icon-btn.tiny svg { width: 15px; height: 15px; }
.icon-btn.tiny:hover { opacity: 1; color: #ff7a8a; }

#history-list { overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 2px; }
.history-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--tx-2); font-size: .86rem;
  border: 1px solid transparent;
  transition: background var(--speed), color var(--speed), border-color var(--speed);
}
.history-item svg { width: 15px; height: 15px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; opacity: .75; }
.history-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.history-item:hover { background: rgba(255,255,255,.05); color: var(--tx-1); }
.history-item.active {
  background: linear-gradient(90deg, rgba(124,108,255,.16), rgba(56,232,210,.07));
  border-color: rgba(124,108,255,.35); color: var(--tx-1);
}
.history-empty { padding: 10px; font-size: .8rem; color: var(--tx-3); text-align: center; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }
.side-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--tx-2); font-size: .88rem;
  transition: background var(--speed), color var(--speed);
}
.side-link svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side-link:hover { background: rgba(255,255,255,.06); color: var(--tx-1); }

.sidebar-footer { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.conn-status { display: flex; align-items: center; gap: 8px; font-size: .76rem; color: var(--tx-2); }
.conn-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #555; flex-shrink: 0;
  transition: background var(--speed), box-shadow var(--speed);
}
.conn-status.online .dot { background: var(--acc-3); box-shadow: 0 0 10px var(--acc-3); animation: pulse-dot 2.4s infinite; }
.conn-status.offline .dot { background: #ff5c6c; box-shadow: 0 0 10px rgba(255,92,108,.7); }
.attribution { font-size: .68rem; color: var(--tx-3); letter-spacing: .02em; }

/* ---------- 5. Topbar ---------- */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 15, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10;
}
.topbar-title { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; font-weight: 600; font-size: .95rem; }
.topbar-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title .spark { width: 16px; height: 16px; fill: none; stroke: url(#ag); stroke: var(--acc-2); stroke-width: 1.8; animation: spin-slow 14s linear infinite; }
.conn-status.top { font-size: .72rem; }

/* ---------- 6. Welcome screen ---------- */
#welcome-screen {
  position: relative; flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px;
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
#welcome-screen.leaving { opacity: 0; transform: translateY(-14px) scale(.985); pointer-events: none; }

#brain-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.welcome-content { position: relative; text-align: center; margin-top: 120px; animation: rise-in .8s var(--ease) both; }
.welcome-content h1 {
  font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 800; letter-spacing: -.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 26px var(--glow));
}
.welcome-content p { margin-top: 6px; color: var(--tx-2); font-size: clamp(.95rem, 2vw, 1.08rem); letter-spacing: .04em; }
.welcome-content small { display: block; margin-top: 14px; color: var(--tx-3); font-size: .74rem; letter-spacing: .06em; }

.suggestions {
  position: relative;
  display: grid; grid-template-columns: repeat(2, minmax(0, 260px));
  gap: 10px; margin-top: 34px;
  animation: rise-in .8s .15s var(--ease) both;
}
.suggestion-chip {
  padding: 12px 16px; text-align: left;
  font-size: .84rem; color: var(--tx-2);
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(8px);
  transition: border-color var(--speed), color var(--speed), transform var(--speed), background var(--speed);
}
.suggestion-chip:hover {
  border-color: rgba(124,108,255,.45); color: var(--tx-1);
  background: rgba(124,108,255,.07);
  transform: translateY(-2px);
}

/* ---------- 7. Chat ---------- */
#chat-section { flex: 1; min-height: 0; display: flex; }
#messages {
  flex: 1; overflow-y: auto;
  padding: 26px 20px 10px;
  scroll-behavior: auto;
}
.msg-col { max-width: 820px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

.message { display: flex; gap: 13px; animation: msg-in .35s var(--ease) both; max-width: 100%; }
.message .avatar {
  width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700;
}
.message.user { flex-direction: row-reverse; }
.message.user .avatar {
  background: var(--bg-3); border: 1px solid var(--line-strong); color: var(--tx-2);
}
.message.ai .avatar {
  background: var(--accent-gradient);
  box-shadow: 0 0 16px var(--glow);
  color: #fff;
}
.message.ai .avatar img { width: 21px; height: 21px; }

.bubble-wrap { min-width: 0; max-width: calc(100% - 47px); display: flex; flex-direction: column; gap: 5px; }
.message.user .bubble-wrap { align-items: flex-end; }
.msg-author { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--tx-3); padding: 0 4px; }

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .93rem; line-height: 1.65;
  word-wrap: break-word; overflow-wrap: break-word;
  border: 1px solid var(--line);
}
.message.user .bubble {
  background: linear-gradient(135deg, rgba(124,108,255,.18), rgba(77,163,255,.10));
  border-color: rgba(124,108,255,.30);
  border-bottom-right-radius: 5px;
  white-space: pre-wrap;
}
.message.ai .bubble {
  background: rgba(255,255,255,.028);
  border-bottom-left-radius: 5px;
}
.message.error .bubble {
  background: rgba(255,92,108,.08);
  border-color: rgba(255,92,108,.35);
  color: #ffb3bc;
}

/* Imagens geradas ficam privadas e são carregadas pela rota autenticada. */
.generated-image-bubble {
  width: min(620px, 100%);
  padding: 9px !important;
  overflow: hidden;
}
.generated-image {
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 11px;
  background: #080811;
  border: 1px solid var(--line);
}
.generated-image-caption {
  padding: 9px 6px 3px;
  color: var(--tx-2);
  font-size: .78rem;
  line-height: 1.45;
}
.generated-image-actions { display: flex; justify-content: flex-end; padding: 7px 5px 3px; }
.image-download-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border: 1px solid rgba(77,163,255,.35); border-radius: 9px;
  color: #bfe4ff; background: rgba(77,163,255,.09); font-size: .74rem; font-weight: 650;
}
.image-download-btn:hover { background: rgba(77,163,255,.17); text-decoration: none; }
.image-download-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Lightweight streaming text; Markdown is formatted once when complete. */
.bubble.streaming { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.streaming::after {
  content: ""; display: inline-block;
  width: 8px; height: 15px; margin-left: 3px; vertical-align: -2px;
  background: var(--acc-2); border-radius: 2px;
  animation: caret-blink 0.9s steps(2) infinite;
}

/* Typing indicator */
.typing-dots { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing-dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--acc-2); opacity: .5;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }

/* --- Markdown content --- */
.md > * + * { margin-top: .7em; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; margin-top: 1.1em; font-weight: 700; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.22em; } .md h3 { font-size: 1.1em; } .md h4 { font-size: 1em; }
.md p { white-space: pre-wrap; }
.md strong { color: #fff; }
.md a { text-decoration: underline; text-underline-offset: 3px; }
.md ul, .md ol { padding-left: 1.4em; display: flex; flex-direction: column; gap: .3em; }
.md ul li { list-style: disc; } .md ol li { list-style: decimal; }
.md li::marker { color: var(--acc-2); }
.md blockquote {
  border-left: 3px solid var(--acc-1);
  padding: 4px 14px; color: var(--tx-2);
  background: rgba(124,108,255,.06); border-radius: 0 8px 8px 0;
}
.md hr { border: none; border-top: 1px solid var(--line-strong); margin: 1.2em 0; }
.md code.inline {
  font-family: var(--font-mono); font-size: .86em;
  background: rgba(124,108,255,.13); color: #cdc4ff;
  border: 1px solid rgba(124,108,255,.22);
  padding: 1px 6px; border-radius: 6px;
}
.md table { border-collapse: collapse; width: 100%; font-size: .88em; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line-strong); padding: 7px 12px; text-align: left; }
.md th { background: rgba(255,255,255,.04); font-weight: 600; }

/* Code blocks */
.code-block {
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #0b0b14;
  box-shadow: 0 8px 26px rgba(0,0,0,.35);
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 8px 7px 14px;
  background: rgba(255,255,255,.035);
  border-bottom: 1px solid var(--line);
  font-size: .72rem; color: var(--tx-3);
  font-family: var(--font-mono); letter-spacing: .04em;
}
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 7px;
  font-size: .72rem; color: var(--tx-2); font-family: var(--font-ui);
  border: 1px solid var(--line);
  transition: all var(--speed);
}
.copy-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.copy-btn:hover { color: var(--tx-1); border-color: var(--line-strong); background: rgba(255,255,255,.05); }
.copy-btn.copied { color: var(--acc-3); border-color: rgba(56,232,210,.4); }
.code-block pre { overflow-x: auto; padding: 14px 16px; }
.code-block code { font-family: var(--font-mono); font-size: .82rem; line-height: 1.6; color: #dfe2f1; }

/* Syntax colors */
.tk-kw { color: #c792ea; } .tk-str { color: #a5e29f; } .tk-num { color: #f79d6c; }
.tk-com { color: #5d6484; font-style: italic; } .tk-fn { color: #7cc7ff; }
.tk-op { color: #89ddff; } .tk-tag { color: #ff8095; } .tk-attr { color: #ffcb6b; }

/* ---------- 8. Composer ---------- */
#composer-wrap {
  padding: 10px 20px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-0) 55%, transparent);
}
#composer {
  display: flex; align-items: flex-end; gap: 10px;
  max-width: 820px; margin: 0 auto;
  padding: 10px 10px 10px 18px;
  background: rgba(18, 18, 32, 0.85);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 10px 40px rgba(0,0,0,.45), 0 0 0 0 var(--glow);
  transition: border-color var(--speed), box-shadow var(--speed);
}
#composer:focus-within {
  border-color: rgba(124,108,255,.55);
  box-shadow: 0 10px 40px rgba(0,0,0,.45), 0 0 24px var(--glow);
}
#composer.drop-target { border-color: rgba(56,232,210,.7); box-shadow: 0 10px 40px rgba(0,0,0,.45), 0 0 26px rgba(56,232,210,.25); }
#message-input {
  flex: 1; resize: none; border: none; outline: none; background: none;
  max-height: 180px; min-height: 24px;
  padding: 6px 0; font-size: .95rem; line-height: 1.5;
  color: var(--tx-1);
}
#message-input::placeholder { color: var(--tx-3); }

#btn-send, #btn-stop, #btn-image, #btn-attach {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--speed);
}
#btn-image {
  color: #8fdcff;
  border: 1px solid rgba(77,163,255,.25);
  background: rgba(77,163,255,.08);
}
#btn-attach {
  color: #d1b4ff;
  border: 1px solid rgba(180,130,255,.25);
  background: rgba(153,95,255,.08);
}
#btn-attach svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#btn-attach:hover:not(:disabled) { color: #fff; border-color: rgba(180,130,255,.55); background: rgba(153,95,255,.16); transform: translateY(-1px); }
#btn-attach:disabled { opacity: .35; cursor: not-allowed; }
#btn-image svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#btn-image:hover:not(:disabled) { color: #fff; border-color: rgba(56,232,210,.45); background: rgba(56,232,210,.12); transform: translateY(-1px); }
#btn-image:disabled { opacity: .35; cursor: not-allowed; }

.image-attachment {
  display: flex; align-items: center; gap: 10px; max-width: 820px; margin: 9px auto 0;
  padding: 8px 10px; border: 1px solid rgba(153,95,255,.34); border-radius: 12px;
  background: rgba(35,24,66,.58); color: var(--tx-2);
}
.image-attachment[hidden] { display: none; }
.image-attachment img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.image-attachment-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.image-attachment-info strong, .image-attachment-info span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-attachment-info strong { font-size: .78rem; color: var(--tx-1); }
.image-attachment-info span { font-size: .68rem; color: var(--tx-3); }
.attached-image { display: block; width: min(100%, 420px); max-height: 360px; object-fit: contain; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.18); }
.attached-image-caption { margin-top: 0; }
#btn-send svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#btn-send {
  background: var(--accent-gradient); color: #fff;
  box-shadow: 0 3px 16px var(--glow);
}
#btn-send:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
#btn-send:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
#btn-stop {
  background: rgba(255,92,108,.14); color: #ff8a97;
  border: 1px solid rgba(255,92,108,.4);
  animation: pulse-border 1.6s infinite;
}
#btn-stop svg { width: 17px; height: 17px; fill: currentColor; }
#btn-stop:hover { background: rgba(255,92,108,.24); }

.composer-hint {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; max-width: 820px; margin: 8px auto 0;
  font-size: .7rem; color: var(--tx-3);
}
.model-picker { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
#composer-model {
  max-width: min(330px, 48vw); padding: 4px 28px 4px 9px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--tx-2); font: inherit;
  cursor: pointer; outline: none;
}
#composer-model:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(119, 93, 255, .15); }

/* ---------- 9. Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(3, 3, 8, 0.66);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in .2s var(--ease);
}
.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%; max-width: 520px;
  max-height: min(86vh, 720px);
  display: flex; flex-direction: column;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0,0,0,.6), 0 0 60px var(--glow);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  animation: modal-in .3s var(--ease);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { display: flex; align-items: center; gap: 10px; font-size: 1rem; font-weight: 700; }
.modal-head h2 svg { width: 18px; height: 18px; fill: none; stroke: var(--acc-2); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; }

.settings-group h3 {
  font-size: .7rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--tx-3); margin-bottom: 12px;
}
.identity-row { display: flex; gap: 14px; align-items: center; }
.identity-row img { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); filter: drop-shadow(0 0 10px var(--glow)); }
.kv { font-size: .9rem; }
.kv-grid { display: grid; grid-template-columns: auto 1fr; gap: 7px 18px; font-size: .87rem; }
.kv-grid .k { color: var(--tx-3); }
.kv-grid .v { color: var(--tx-1); font-family: var(--font-mono); font-size: .82rem; }
.hint { font-size: .76rem; color: var(--tx-3); margin-top: 10px; line-height: 1.5; }
.hint code { font-family: var(--font-mono); font-size: .92em; color: var(--acc-2); background: rgba(124,108,255,.1); padding: 1px 5px; border-radius: 5px; }

.field-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 9px 0; font-size: .88rem; color: var(--tx-2);
}
.field-row output { font-size: .78rem; color: var(--tx-3); min-width: 42px; text-align: right; }
input[type="range"] { accent-color: var(--acc-1); width: 150px; }

.swatches { display: flex; gap: 9px; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform var(--speed), border-color var(--speed), box-shadow var(--speed);
}
.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: #fff; box-shadow: 0 0 12px var(--sw-glow); }
.swatch[data-accent="aurora"] { background: linear-gradient(135deg,#7c6cff,#38e8d2); --sw-glow: rgba(124,108,255,.6); }
.swatch[data-accent="violet"] { background: linear-gradient(135deg,#a55cff,#ff8ad1); --sw-glow: rgba(190,92,255,.6); }
.swatch[data-accent="cyan"]   { background: linear-gradient(135deg,#22d3ee,#34d399); --sw-glow: rgba(34,211,238,.6); }
.swatch[data-accent="ember"]  { background: linear-gradient(135deg,#ff7a59,#ffd166); --sw-glow: rgba(255,122,89,.6); }
.swatch[data-accent="rose"]   { background: linear-gradient(135deg,#fb5c8d,#b78cff); --sw-glow: rgba(251,92,141,.6); }

.switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; z-index: 1; }
.switch i {
  position: absolute; inset: 0; border-radius: 99px;
  background: var(--bg-3); border: 1px solid var(--line-strong);
  transition: background var(--speed);
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--tx-2);
  transition: transform var(--speed) var(--ease), background var(--speed);
}
.switch input:checked + i { background: rgba(124,108,255,.35); border-color: rgba(124,108,255,.5); }
.switch input:checked + i::after { transform: translateX(20px); background: #fff; }

.danger-zone { border-top: 1px solid var(--line); padding-top: 16px; }
.btn-danger {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: .85rem; color: #ff8a97;
  background: rgba(255,92,108,.09);
  border: 1px solid rgba(255,92,108,.35);
  transition: all var(--speed);
}
.btn-danger svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.btn-danger:hover { background: rgba(255,92,108,.18); }

/* Credits */
.credit-card {
  width: 100%; padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  text-align: center;
}
.credit-card.primary {
  border-color: rgba(124,108,255,.4);
  background: linear-gradient(160deg, rgba(124,108,255,.12), rgba(56,232,210,.05));
  box-shadow: 0 0 30px rgba(124,108,255,.12);
}
.credit-role { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--tx-3); }
.credit-name { font-size: 1.15rem; font-weight: 700; margin-top: 5px; }
.credit-note { font-size: .78rem; color: var(--tx-2); margin-top: 7px; }
.credit-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn-outline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: .84rem; color: var(--tx-1);
  border: 1px solid var(--line-strong);
  transition: all var(--speed);
}
.btn-outline svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
#btn-official-channel svg { fill: currentColor; stroke: none; }
.btn-outline:hover { border-color: rgba(124,108,255,.5); background: rgba(124,108,255,.08); text-decoration: none; }

/* ---------- 10. Toasts ---------- */
#toast-container {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 200;
  align-items: center; pointer-events: none;
}
.toast {
  padding: 10px 18px;
  font-size: .84rem;
  background: var(--glass);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  backdrop-filter: blur(16px);
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  animation: toast-in .3s var(--ease);
}
.toast.out { animation: toast-out .3s var(--ease) forwards; }
.toast.success { border-color: rgba(56,232,210,.45); color: #a9f5e8; }
.toast.error { border-color: rgba(255,92,108,.45); color: #ffb3bc; }

/* ---------- 11. Keyframes ---------- */
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(18px); } }
@keyframes msg-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
@keyframes caret-blink { 50% { opacity: 0; } }
@keyframes spin-slow { to { transform: rotate(360deg); } }
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56,232,210,.5); }
  55% { box-shadow: 0 0 0 6px rgba(56,232,210,0); }
}
@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,92,108,.35); }
  55% { box-shadow: 0 0 0 7px rgba(255,92,108,0); }
}
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- 11b. Welcome screen (first visit) ---------- */
.welcome-overlay { background: rgba(3, 3, 8, 0.82); }

.welcome-modal {
  position: relative;
  width: 100%; max-width: 480px;
  max-height: 92dvh;
  overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  gap: 18px;
  padding: 44px 36px 30px;
  text-align: center;
  background: var(--glass);
  border: 1px solid rgba(124, 108, 255, 0.28);
  border-radius: 24px;
  box-shadow:
    0 40px 120px rgba(0, 0, 0, 0.65),
    0 0 80px rgba(124, 108, 255, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  animation: wm-in .55s var(--ease) both;
}
@keyframes wm-in {
  from { opacity: 0; transform: translateY(26px) scale(.96); }
}

.wm-aurora {
  position: absolute; inset: -1px;
  border-radius: inherit;
  background:
    radial-gradient(340px 190px at 50% -8%, rgba(124,108,255,.22), transparent 70%),
    radial-gradient(280px 170px at 85% 108%, rgba(56,232,210,.12), transparent 70%);
  pointer-events: none;
}
.welcome-modal > * { position: relative; }

.wm-logo {
  width: 74px; height: 74px;
  filter: drop-shadow(0 0 26px var(--glow));
  animation: wm-float 5s ease-in-out infinite;
}
@keyframes wm-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

#wm-title { font-size: 1.55rem; font-weight: 800; letter-spacing: -.01em; }
#wm-title .grad {
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.wm-text { display: flex; flex-direction: column; gap: 10px; }
.wm-text p { font-size: .9rem; line-height: 1.65; color: var(--tx-2); }
.wm-text strong { color: var(--tx-1); }
.wm-text p:nth-child(1) { animation: rise-in .6s .15s var(--ease) both; }
.wm-text p:nth-child(2) { animation: rise-in .6s .25s var(--ease) both; }

#wm-channel-card {
  display: flex; align-items: center; gap: 13px;
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: rgba(37, 211, 102, 0.07);
  border: 1px solid rgba(37, 211, 102, 0.3);
  transition: all var(--speed) var(--ease);
  animation: rise-in .6s .35s var(--ease) both;
}
#wm-channel-card:hover {
  background: rgba(37, 211, 102, 0.13);
  border-color: rgba(37, 211, 102, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 8px 26px rgba(37, 211, 102, 0.16);
  text-decoration: none;
}
.wa-icon svg { width: 24px; height: 24px; fill: #25d366; }
#wm-channel-card .wm-card-text { flex: 1; text-align: left; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#wm-channel-card small { font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--tx-3); }
#wm-channel-card strong { font-size: .95rem; color: var(--tx-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#wm-channel-card .arrow { width: 16px; height: 16px; fill: none; stroke: var(--tx-3); stroke-width: 1.9; stroke-linecap: round; transition: transform var(--speed), stroke var(--speed); }
#wm-channel-card:hover .arrow { transform: translateX(3px); stroke: #25d366; }

.wm-actions {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%;
  animation: rise-in .6s .45s var(--ease) both;
}
.btn-wm-primary {
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700; font-size: .93rem; color: #fff;
  background: var(--accent-gradient);
  box-shadow: 0 6px 26px var(--glow), inset 0 1px 0 rgba(255,255,255,.25);
  transition: all var(--speed) var(--ease);
}
.btn-wm-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-wm-primary:active { transform: scale(.98); }
.btn-wm-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600; font-size: .88rem; color: #4be08a;
  border: 1px solid rgba(37, 211, 102, 0.35);
  background: rgba(37, 211, 102, 0.06);
  transition: all var(--speed) var(--ease);
}
.btn-wm-outline svg { width: 17px; height: 17px; fill: currentColor; }
.btn-wm-outline:hover { background: rgba(37, 211, 102, 0.13); transform: translateY(-1px); text-decoration: none; }

.wm-attribution { font-size: .7rem; letter-spacing: .05em; color: var(--tx-3); animation: fade-in .8s .6s both; }

/* Settings inputs */
.field-row.col { flex-direction: column; align-items: stretch; gap: 7px; }
.text-input {
  width: 100%;
  padding: 10px 13px;
  font-size: .87rem;
  color: var(--tx-1);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  transition: border-color var(--speed), box-shadow var(--speed);
}
.text-input:focus {
  border-color: rgba(124, 108, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 108, 255, 0.14);
}
.text-input::placeholder { color: var(--tx-3); }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.btn-outline.subtle { color: var(--tx-2); }

@media (max-width: 560px) {
  .auth-screen { padding: 0; align-items: end; }
  .auth-card { width: 100%; padding: 25px 20px; border-radius: 24px 24px 0 0; max-height: 96dvh; overflow-y: auto; }
  .auth-grid { grid-template-columns: 1fr; }
  .pro-benefits, .pro-checkout-form fieldset { grid-template-columns: 1fr; }
  .admin-metrics { grid-template-columns: 1fr 1fr; }
  .welcome-modal { padding: 34px 22px 24px; border-radius: 22px 22px 0 0; max-width: 100%; }
  .welcome-overlay { align-items: flex-end; padding: 0; }
  #wm-title { font-size: 1.32rem; }
  .wm-logo { width: 62px; height: 62px; }
}

/* ---------- 12. Responsive ---------- */
#sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 35;
  background: rgba(3,3,8,.6);
  backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .3s var(--ease);
}

@media (max-width: 940px) {
  .only-mobile { display: inline-flex !important; }

  #app { grid-template-columns: 1fr; }

  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(310px, 86vw);
    transform: translateX(-102%);
    transition: transform .32s var(--ease);
    box-shadow: 30px 0 80px rgba(0,0,0,.5);
  }
  body.sidebar-open #sidebar { transform: translateX(0); }
  body.sidebar-open #sidebar-backdrop { display: block; opacity: 1; }

  #topbar { padding: 10px 14px; }
  #messages { padding: 18px 12px 8px; }
  #composer-wrap { padding-left: 12px; padding-right: 12px; }
  .composer-hint > span:first-child { display: none; }
  .model-picker { display: inline-flex; }
  #composer-model { max-width: min(330px, 72vw); }
  .conn-status.top span:last-child { display: none; }
}

@media (max-width: 560px) {
  .suggestions { grid-template-columns: 1fr; width: 100%; max-width: 340px; }
  .welcome-content { margin-top: 90px; }
  .bubble-wrap { max-width: calc(100% - 42px); }
  .message .avatar { width: 29px; height: 29px; border-radius: 9px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { max-width: 100%; border-radius: 22px 22px 0 0; max-height: 92dvh; animation: sheet-in .32s var(--ease); }
  .composer-hint { justify-content: center; }
  .field-row { flex-wrap: wrap; }
}

@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }

@media (min-width: 1800px) {
  #messages .msg-col { max-width: 940px; }
  #composer { max-width: 940px; }
}

/* ---------- 13. Accessibility / motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
  #messages { scroll-behavior: auto; }
}

html.no-animations *,
html.no-animations *::before,
html.no-animations *::after {
  animation: none !important;
  transition: none !important;
}
