/* Jarvis: lista e conversa no padrão de app de mensagens. Mobile primeiro; cor só onde ela significa algo
   (acento do app, "esperando você", erro). Animações só em transform/opacity. */
:root {
  color-scheme: dark;
  --bg: #0d1214;
  --surface: #131b1e;
  --surface-2: #1b2529;
  --surface-3: #243136;
  --line: #222d31;
  --fg: #e8eef0;
  --muted: #8b9ba1;
  --accent: #5db4c5;
  --accent-ink: #06191d;
  --accent-soft: #163640;
  --bubble-out: #17434d;
  --bubble-out-fg: #eaf6f8;
  --bubble-in: #1b2529;
  --warn: #e3a948;
  --danger: #e5675d;
  --pattern: rgba(255, 255, 255, 0.035);
  --shadow: rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 0.35, 1);
  --vvh: 100dvh;
  --fs: 16px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f6f7;
  --surface: #ffffff;
  --surface-2: #e9eff1;
  --surface-3: #dbe5e8;
  --line: #dde6e9;
  --fg: #0f1a1d;
  --muted: #587077;
  --accent: #14788c;
  --accent-ink: #ffffff;
  --accent-soft: #d3eaf0;
  --bubble-out: #cfeaf0;
  --bubble-out-fg: #0b2b32;
  --bubble-in: #ffffff;
  --warn: #a8690a;
  --danger: #c4372d;
  --pattern: rgba(15, 26, 29, 0.045);
  --shadow: rgba(15, 26, 29, 0.18);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg: #f3f6f7;
    --surface: #ffffff;
    --surface-2: #e9eff1;
    --surface-3: #dbe5e8;
    --line: #dde6e9;
    --fg: #0f1a1d;
    --muted: #587077;
    --accent: #14788c;
    --accent-ink: #ffffff;
    --accent-soft: #d3eaf0;
    --bubble-out: #cfeaf0;
    --bubble-out-fg: #0b2b32;
    --bubble-in: #ffffff;
    --warn: #a8690a;
    --danger: #c4372d;
    --pattern: rgba(15, 26, 29, 0.045);
    --shadow: rgba(15, 26, 29, 0.18);
  }
}
:root[data-size="large"] { --fs: 18px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { font-size: var(--fs); background: var(--bg); }
html, body { margin: 0; color: var(--fg); font-family: "Segoe UI Variable Text", "SF Pro Text", Roboto, system-ui, sans-serif; line-height: 1.45; }
body { height: var(--vvh); overflow: hidden; overscroll-behavior: none; background: var(--bg); }
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.i { width: 1.375rem; height: 1.375rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i.big { width: 2.6rem; height: 2.6rem; }
.hint { color: var(--muted); font-size: 0.85rem; line-height: 1.4; margin: 0; }
.hint.pad { padding: 12px 18px 4px; }
.textbtn { color: var(--accent); font-weight: 600; min-height: 44px; padding: 0 14px; border-radius: 12px; }
.textbtn.danger { color: var(--danger); }
.textbtn.strong { color: var(--accent); }
.textbtn:active { background: var(--surface-2); }

/* ---------- splash ---------- */
#splash { position: fixed; inset: 0; z-index: 90; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); transition: opacity 0.3s ease-out; }
#splash.gone { opacity: 0; pointer-events: none; }
.splash-mark { width: 84px; height: 84px; border-radius: 26px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); animation: splash-in 0.5s var(--ease) both; }
.splash-mark .i { width: 40px; height: 40px; }
.splash-name { margin: 0; font-size: 1.3rem; font-weight: 600; letter-spacing: 0.02em; animation: splash-in 0.5s var(--ease) 0.08s both; }
@keyframes splash-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } }

/* ---------- estrutura ---------- */
#app { display: flex; flex-direction: column; height: 100%; max-width: 760px; margin: 0 auto; position: relative; background: var(--bg); }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.scroller { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

.appbar { flex: none; display: flex; align-items: center; gap: 4px; min-height: 58px; padding: env(safe-area-inset-top) 6px 0 16px; background: var(--bg); }
.appbar h1 { margin: 0; flex: 1; min-width: 0; font-size: 1.2rem; font-weight: 650; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar h1.brand { flex: none; font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; }
.appbar .back { margin-left: -10px; }
.appbar:has(.back) { padding-left: 6px; }
button.icon { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--fg); flex: none; transition: background-color 0.15s, transform 0.12s; }
button.icon:active { background: var(--surface-2); transform: scale(0.94); }
button.icon.mini { width: 34px; height: 34px; color: var(--muted); }
.status { margin-left: auto; font-size: 0.78rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding-right: 2px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status[data-state="on"] .sdot { background: var(--accent); }
.selbar { background: var(--surface); }
.sel-count { flex: 1; font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- busca e tags ---------- */
.searchbar { flex: none; padding: 2px 14px 10px; }
.search { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 8px 0 14px; border-radius: 23px; background: var(--surface-2); color: var(--muted); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; font-size: 1rem; color: var(--fg); height: 100%; }
.search input::placeholder { color: var(--muted); }
.search:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.search input::-webkit-search-cancel-button { display: none; }
.chips { flex: none; display: flex; gap: 8px; padding: 0 14px 10px; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px; background: var(--surface-2); color: var(--fg); font-size: 0.92rem; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; transition: background-color 0.15s, color 0.15s, transform 0.12s; }
.chip:active { transform: scale(0.96); }
.chip .n { font-size: 0.8rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.chip[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); font-weight: 600; }
.chip[aria-selected="true"] .n { color: var(--accent); }
.chip .pip { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }

/* ---------- lista de conversas ---------- */
.archived-row { width: 100%; display: flex; align-items: center; gap: 14px; padding: 8px 16px; min-height: 56px; text-align: left; }
.archived-row:active { background: var(--surface); }
.ar-ico { width: 52px; display: grid; place-items: center; color: var(--muted); }
.ar-label { flex: 1; font-weight: 600; line-height: 1.35; }
.ar-count { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.chat-list { list-style: none; margin: 0; padding: 0 0 120px; }
.chat-row { position: relative; display: flex; align-items: center; gap: 14px; padding: 10px 16px; min-height: 74px; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; transition: background-color 0.12s; }
.chat-row:active { background: var(--surface); }
.chat-row[aria-selected="true"] { background: var(--accent-soft); }
.chat-row .body { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 4px 0; }
.chat-row + .chat-row .body::before { content: ""; position: absolute; left: 82px; right: 0; top: 0; height: 1px; background: var(--line); }
.chat-row[aria-selected="true"] + .chat-row .body::before, .chat-row[aria-selected="true"] .body::before { opacity: 0; }
.line1, .line2 { display: flex; align-items: center; gap: 8px; min-width: 0; }
.name { flex: 1; min-width: 0; font-weight: 600; font-size: 1.02rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time { flex: none; font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chat-row.unread .time { color: var(--accent); font-weight: 600; }
.chat-row.unread .name { font-weight: 700; }
.preview { flex: 1; min-width: 0; font-size: 0.9rem; color: var(--muted); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.preview > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.preview .i { width: 1rem; height: 1rem; }
.preview .proj { color: var(--fg); font-weight: 500; flex: none; max-width: 40%; opacity: 0.8; }
.preview.live { color: var(--accent); }
.preview.need { color: var(--warn); }
.preview.fail { color: var(--danger); }
.chat-row.unread .preview { color: var(--fg); }
.badges { display: flex; align-items: center; gap: 6px; flex: none; }
.badges .i { width: 1rem; height: 1rem; color: var(--muted); }
.ub { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.ub.need { background: var(--warn); color: #1d1405; }
.ub.dot { min-width: 12px; width: 12px; height: 12px; padding: 0; }
.avatar { position: relative; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 1.15rem; background: var(--surface-3); color: var(--fg); letter-spacing: 0; }
.avatar.accent { background: var(--accent-soft); color: var(--accent); }
.avatar.lg { width: 64px; height: 64px; }
.avatar.xl { width: 132px; height: 132px; }
.avatar.xl .i { width: 54px; height: 54px; }
.avatar.sm { width: 40px; height: 40px; font-size: 1rem; }
.avatar .tick { position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: none; place-items: center; border: 2px solid var(--bg); }
.avatar .tick .i { width: 11px; height: 11px; stroke-width: 3; }
.chat-row[aria-selected="true"] .avatar .tick { display: grid; }
.avatar .busy { position: absolute; inset: -3px; border-radius: 50%; border: 2px solid transparent; border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sec-title { padding: 14px 18px 4px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.03em; color: var(--muted); text-transform: none; }
.snippet { font-size: 0.88rem; }
.snippet mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

.empty-state { display: grid; justify-items: center; gap: 8px; padding: 56px 32px; text-align: center; color: var(--muted); }
.empty-state .es-title { margin: 6px 0 0; color: var(--fg); font-weight: 600; font-size: 1.05rem; }
.empty-state .es-text { margin: 0; max-width: 32ch; line-height: 1.45; font-size: 0.92rem; }
.empty-state .textbtn { margin-top: 6px; }
.gate { margin: 12px 16px; padding: 16px; border-radius: 16px; background: var(--surface); display: grid; gap: 12px; line-height: 1.45; }
.gate p { margin: 0; }

.fabs { position: absolute; right: 16px; bottom: 16px; display: grid; justify-items: center; gap: 12px; z-index: 5; pointer-events: none; }
.fab { pointer-events: auto; width: 58px; height: 58px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 8px 22px var(--shadow); transition: transform 0.14s; }
.fab:active { transform: scale(0.94); }
.fab.mini-fab { width: 46px; height: 46px; border-radius: 15px; background: var(--surface-3); color: var(--fg); box-shadow: 0 6px 16px var(--shadow); }
.fab .i { width: 1.5rem; height: 1.5rem; }
.fab.mini-fab .i { width: 1.25rem; height: 1.25rem; }

/* skeleton no formato da linha, com fade para o conteúdo */
.sk-row { display: flex; align-items: center; gap: 14px; padding: 10px 16px; min-height: 74px; }
.sk { background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: sh 1.4s linear infinite; border-radius: 8px; }
.sk.av { width: 52px; height: 52px; border-radius: 50%; flex: none; }
.sk-lines { flex: 1; display: grid; gap: 9px; }
.sk-lines .sk { height: 13px; }
.sk-lines .sk:first-child { width: 48%; }
.sk-lines .sk:last-child { width: 78%; }
@keyframes sh { to { background-position: -200% 0; } }
.fade-in { animation: fade 0.22s ease-out both; }
@keyframes fade { from { opacity: 0; } }

/* ---------- abas ---------- */
#tabs { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); }
#tabs[hidden] { display: none; }
.tab { position: relative; min-height: 58px; display: grid; justify-items: center; align-content: center; gap: 3px; color: var(--muted); font-size: 0.72rem; font-weight: 500; }
.tab.active { color: var(--fg); font-weight: 650; }
.tab.active .i { color: var(--accent); }
.tab:active .i { transform: scale(0.9); }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 0.68rem; font-weight: 700; display: grid; place-items: center; font-style: normal; font-variant-numeric: tabular-nums; }

/* ---------- avisos (cartões) ---------- */
.feed { list-style: none; margin: 0; padding: 4px 14px 20px; display: grid; gap: 12px; }
.card { background: var(--surface); border-radius: 16px; padding: 14px; display: grid; gap: 10px; animation: fade 0.2s ease-out; }
.card h2 { margin: 0; font-size: 1rem; line-height: 1.4; font-weight: 600; }
.card.done { opacity: 0.6; }
.card pre { margin: 0; padding: 10px; background: var(--bg); border-radius: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; font-size: 0.82rem; max-height: 40vh; }
.card .open-chat { justify-self: start; }
.meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tag { border-radius: 8px; padding: 1px 8px; background: var(--surface-2); color: var(--muted); display: inline-flex; align-items: center; gap: 5px; line-height: 1.5; font-size: 0.78rem; }
.tag .i { width: 13px; height: 13px; }
.tag.warn { color: var(--warn); }
.tag.fail { color: var(--danger); }
.tag.live { color: var(--accent); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions button { min-height: 46px; border-radius: 14px; font-weight: 600; background: var(--surface-2); }
.actions button.primary { background: var(--accent); color: var(--accent-ink); }

/* ---------- ajustes ---------- */
.me { display: flex; align-items: center; gap: 16px; padding: 14px 18px 18px; }
.me-name { margin: 0; font-size: 1.25rem; font-weight: 650; line-height: 1.35; }
.me-sub { margin: 0; color: var(--muted); font-size: 0.88rem; }
.set-list { list-style: none; margin: 0; padding: 0 0 24px; }
.set-row { width: 100%; display: flex; align-items: center; gap: 16px; padding: 10px 18px; min-height: 68px; text-align: left; }
.set-row:active { background: var(--surface); }
.set-row .ai { background: var(--surface-2); }
.set-row .ai, .opt .ai { width: 44px; height: 44px; border-radius: 14px; background: var(--surface-3); color: var(--accent); display: grid; place-items: center; flex: none; }
.set-row .st { flex: 1; min-width: 0; display: grid; gap: 1px; }
.set-row b { font-weight: 600; line-height: 1.35; }
.set-row small { color: var(--muted); font-size: 0.84rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-row > .i:last-child { color: var(--muted); width: 1.1rem; height: 1.1rem; }
.set-row.danger b, .set-row.danger .ai { color: var(--danger); }
.set-form { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.form-body { padding: 8px 18px 20px; display: grid; align-content: start; gap: 18px; }
.form-foot { flex: none; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
.form-foot[hidden] { display: none; }
button.primary { width: 100%; min-height: 52px; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-weight: 650; font-size: 1rem; transition: transform 0.12s; }
button.primary:active { transform: scale(0.985); }
button.outline { width: 100%; min-height: 50px; border-radius: 16px; box-shadow: inset 0 0 0 1.5px var(--line); font-weight: 600; }
button.outline.danger { color: var(--danger); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--danger) 50%, transparent); }
.field { display: grid; gap: 7px; font-size: 0.86rem; color: var(--muted); }
.field > span { font-weight: 500; }
select, .field input[type="text"] { width: 100%; min-height: 50px; padding: 0 14px; font-size: 1rem; color: var(--fg); background: var(--surface-2); border: 0; border-radius: 14px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; }
.group-title { margin: 6px 0 -6px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.03em; color: var(--muted); }
.switch-row { display: flex; align-items: center; gap: 14px; min-height: 52px; color: var(--fg); font-size: 1rem; }
.switch-row .tx { flex: 1; display: grid; gap: 2px; line-height: 1.35; }
.switch-row small { color: var(--muted); font-size: 0.82rem; }
.switch { appearance: none; width: 52px; height: 32px; border-radius: 16px; background: var(--surface-3); position: relative; flex: none; cursor: pointer; transition: background-color 0.18s; margin: 0; }
.switch::after { content: ""; position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--fg); transition: transform 0.18s var(--ease); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); background: var(--accent-ink); }
.radio-list { display: grid; gap: 8px; }
.radio { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 14px; background: var(--surface-2); color: var(--fg); cursor: pointer; }
.radio input { appearance: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); margin: 0; flex: none; display: grid; place-items: center; }
.radio input:checked { border-color: var(--accent); }
.radio input:checked::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.radio:has(input:checked) { box-shadow: inset 0 0 0 1.5px var(--accent); }
.kv { display: grid; gap: 12px; margin: 0; }
.kv div { display: grid; gap: 2px; }
.kv dt { font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; line-height: 1.4; word-break: break-word; }

/* ---------- conversa: cabeçalho e faixas ---------- */
.chatbar { gap: 2px; padding-right: 4px; background: var(--surface); }
.chat-head { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; padding: 6px 4px; border-radius: 12px; }
.chat-head .avatar { width: 42px; height: 42px; font-size: 1rem; }
.ch-text { min-width: 0; display: grid; }
.ch-title { font-weight: 650; font-size: 1.02rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-sub { font-size: 0.78rem; color: var(--muted); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-sub.live { color: var(--accent); }
.temp-banner { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; background: var(--accent-soft); color: var(--fg); font-size: 0.84rem; line-height: 1.35; }
.temp-banner p { margin: 0; flex: 1; }
.temp-banner .i { color: var(--accent); width: 1.1rem; height: 1.1rem; }
.statusbar { flex: none; display: flex; gap: 8px; padding: 8px 14px; overflow-x: auto; scrollbar-width: none; background: var(--surface); border-top: 1px solid var(--line); align-items: center; }
.statusbar::-webkit-scrollbar { display: none; }
.statusbar .tag { flex: none; }
.statusbar a { flex: none; color: var(--accent); font-size: 0.82rem; font-weight: 600; text-decoration: none; padding: 2px 6px; }
.banner { flex: none; margin: 0; padding: 8px 16px; background: var(--surface); color: var(--muted); font-size: 0.82rem; line-height: 1.4; border-top: 1px solid var(--line); }

/* ---------- conversa: mensagens ---------- */
.chat-bg { background-color: var(--bg); background-image: radial-gradient(var(--pattern) 1.4px, transparent 1.6px), radial-gradient(var(--pattern) 1px, transparent 1.2px); background-size: 34px 34px, 34px 34px; background-position: 0 0, 17px 17px; scroll-behavior: auto; }
.thread { list-style: none; margin: 0; padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; margin: 10px 0 6px; padding: 4px 12px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 0.76rem; font-weight: 500; }
.msg { position: relative; max-width: min(86%, 560px); padding: 7px 10px 6px; border-radius: 14px; line-height: 1.45; word-break: break-word; box-shadow: 0 1px 1px var(--shadow); }
.msg.user { align-self: flex-end; background: var(--bubble-out); color: var(--bubble-out-fg); }
.msg.assistant { align-self: flex-start; background: var(--bubble-in); }
.msg.first { margin-top: 6px; }
.msg.user.first { border-top-right-radius: 4px; }
.msg.assistant.first { border-top-left-radius: 4px; }
.msg .txt { white-space: pre-wrap; }
.msg .txt a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.msg.user .txt a { color: inherit; }
.msg .txt code { font: 0.86em ui-monospace, "Cascadia Code", Consolas, monospace; background: color-mix(in srgb, var(--fg) 12%, transparent); padding: 1px 5px; border-radius: 5px; }
.msg pre.code { margin: 6px 0; padding: 10px 12px; border-radius: 10px; background: var(--bg); overflow-x: auto; font: 0.82rem/1.45 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre; max-width: 100%; }
.msg pre.code code { background: none; padding: 0; font: inherit; }
.msg .meta2 { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; font-size: 0.68rem; color: color-mix(in srgb, currentColor 58%, transparent); font-variant-numeric: tabular-nums; line-height: 1.2; }
.msg .meta2 .i { width: 14px; height: 14px; }
.msg.error { align-self: flex-start; background: color-mix(in srgb, var(--warn) 14%, var(--bubble-in)); color: var(--fg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 50%, transparent); }
.msg.status, .sys { align-self: center; max-width: 90%; background: var(--surface-2); color: var(--muted); font-size: 0.8rem; padding: 4px 12px; border-radius: 10px; box-shadow: none; text-align: center; }
.tools { align-self: flex-start; max-width: 92%; }
.tools > button { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border-radius: 15px; background: var(--surface-2); color: var(--muted); font-size: 0.78rem; font-weight: 500; }
.tools > button .i { width: 13px; height: 13px; transition: transform 0.15s; }
.tools.open > button .i { transform: rotate(180deg); }
.tools ul { list-style: none; margin: 6px 0 2px; padding: 0 0 0 10px; border-left: 2px solid var(--line); display: grid; gap: 3px; }
.tools li { font: 0.74rem/1.4 ui-monospace, Consolas, monospace; color: var(--muted); word-break: break-word; }
.thread > .card { align-self: stretch; margin: 6px 0; background: var(--surface); box-shadow: 0 1px 2px var(--shadow); }
.typing { align-self: flex-start; display: inline-flex; gap: 5px; padding: 12px 14px; border-radius: 14px; background: var(--bubble-in); margin-top: 6px; box-shadow: 0 1px 1px var(--shadow); }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.thumbs { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 0 5px; }
.thumbs img, .media { display: block; width: min(220px, 56vw); max-height: 260px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.thumbs.multi img { width: calc(50% - 2px); height: 120px; }
.filecard { display: flex; align-items: center; gap: 10px; min-width: 210px; max-width: 100%; padding: 8px; margin: 0 0 5px; border-radius: 12px; background: color-mix(in srgb, var(--fg) 8%, transparent); text-align: left; width: 100%; }
.filecard .fi { width: 40px; height: 44px; border-radius: 9px; background: color-mix(in srgb, var(--fg) 12%, transparent); display: grid; place-items: center; flex: none; }
.filecard .ft { flex: 1; min-width: 0; display: grid; }
.filecard b { font-weight: 600; font-size: 0.9rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filecard small { font-size: 0.74rem; opacity: 0.7; }
.filecard .go { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--fg) 10%, transparent); }
.filecard .go .i { width: 17px; height: 17px; }
.filecard[data-state="loading"] .go { animation: spin 0.9s linear infinite; }
.vthumb { position: relative; display: block; margin: 0 0 5px; border-radius: 10px; overflow: hidden; width: min(220px, 56vw); aspect-ratio: 16/10; background: var(--surface-3); color: #fff; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb .pl { position: absolute; inset: 0; display: grid; place-items: center; }
.vthumb .pl span { width: 48px; height: 48px; border-radius: 50%; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; }
.vbadge { position: absolute; left: 8px; bottom: 6px; font-size: 0.72rem; background: rgba(0, 0, 0, 0.55); border-radius: 8px; padding: 1px 7px; }

.voice { display: flex; align-items: center; gap: 10px; min-width: 230px; padding: 2px 0 4px; }
.voice .vplay { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--fg) 14%, transparent); flex: none; }
.voice .vplay .i { width: 18px; height: 18px; }
.voice .bars { flex: 1; display: flex; align-items: center; gap: 2px; height: 26px; }
.voice .bars i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: color-mix(in srgb, currentColor 55%, transparent); }
.voice .dur { font-size: 0.74rem; font-variant-numeric: tabular-nums; opacity: 0.75; flex: none; }
.voice-note { margin: 2px 0 0; font-size: 0.88rem; opacity: 0.92; }

.to-bottom { position: absolute; right: 14px; bottom: calc(var(--cw, 70px) + 10px); width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2); color: var(--fg); display: grid; place-items: center; box-shadow: 0 3px 10px var(--shadow); z-index: 4; }
.tb-n { position: absolute; top: -8px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 0.7rem; font-weight: 700; display: grid; place-items: center; }

/* ---------- compositor ---------- */
#composer-wrap { position: relative; flex: none; background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
#composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px; }
.pill { flex: 1; min-width: 0; display: flex; align-items: flex-end; border-radius: 24px; background: var(--surface-2); padding: 2px 2px; }
.pill button.icon { color: var(--muted); width: 44px; height: 44px; }
#msg { flex: 1; min-width: 0; resize: none; background: none; border: 0; outline: 0; font-size: 1rem; line-height: 1.4; min-height: 44px; max-height: 132px; padding: 10px 2px; color: var(--fg); }
#msg::placeholder { color: var(--muted); }
.round { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-3); color: var(--fg); display: grid; place-items: center; flex: none; touch-action: none; user-select: none; -webkit-user-select: none; transition: transform 0.12s; }
.round.solid { background: var(--accent); color: var(--accent-ink); }
.round.stop { background: var(--danger); color: #fff; }
#mic { background: var(--accent); color: var(--accent-ink); will-change: transform; }
#mic.holding { transition: none; z-index: 8; box-shadow: 0 8px 22px var(--shadow); }
.att-tray { display: flex; gap: 10px; padding: 10px 14px 2px; overflow-x: auto; scrollbar-width: none; }
.att { position: relative; flex: none; }
.att .thumb { width: 66px; height: 66px; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); position: relative; }
.att .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att.doc .thumb { width: 150px; justify-items: start; padding: 0 12px; grid-auto-flow: column; gap: 8px; place-items: center start; }
.att.doc .nm { display: grid; min-width: 0; }
.att.doc .nm b { font-size: 0.8rem; line-height: 1.35; font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 96px; }
.att.doc .nm small { font-size: 0.7rem; color: var(--muted); }
.att.loading .thumb::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 55%, transparent); }
.att.loading .thumb::before { content: ""; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, var(--fg) 30%, transparent); border-top-color: var(--fg); animation: spin 0.8s linear infinite; z-index: 1; }
.att.error .thumb { box-shadow: inset 0 0 0 2px var(--danger); }
.att .x { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--fg); display: grid; place-items: center; box-shadow: 0 1px 4px var(--shadow); z-index: 2; }
.att .x .i { width: 12px; height: 12px; stroke-width: 2.6; }
.att .vb { position: absolute; left: 4px; bottom: 3px; color: #fff; z-index: 1; }
.att .vb .i { width: 15px; height: 15px; }

/* gravação de áudio */
.recbar { position: absolute; z-index: 7; left: 10px; right: 66px; bottom: calc(8px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.rec-row { display: flex; align-items: center; gap: 6px; min-height: 48px; min-width: 0; }
.rec-mid { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; border-radius: 24px; background: var(--surface-2); overflow: hidden; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); flex: none; animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; flex: none; min-width: 2.4em; }
.rec-slide { flex: 1; min-width: 0; display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.88rem; white-space: nowrap; overflow: hidden; justify-content: center; will-change: transform, opacity; }
.rec-slide .i { width: 1rem; height: 1rem; }
.wave { flex: 1; min-width: 0; display: none; align-items: center; justify-content: flex-start; gap: 3px; height: 28px; overflow: hidden; }
.wave i { flex: none; width: 3px; height: 100%; border-radius: 2px; background: var(--accent); transform: scaleY(var(--h, 0.2)); transform-origin: center; opacity: 0.6; }
.recbar.live .wave i { animation: wv 0.8s ease-in-out infinite alternate; animation-delay: var(--d, 0s); opacity: 1; }
@keyframes wv { from { transform: scaleY(var(--h, 0.2)); } to { transform: scaleY(1); } }
.rec-trash, .rec-pause, .rec-send { display: none; }
.rec-trash { color: var(--danger); }
.rec-text { display: none; margin: 0; padding: 0 14px 2px; color: var(--muted); font-size: 0.82rem; line-height: 1.4; max-height: 3.6em; overflow: hidden; }
.rec-lock { position: absolute; right: -52px; bottom: 68px; width: 44px; height: 92px; border-radius: 22px; background: var(--surface-3); color: var(--fg); display: grid; justify-items: center; align-content: space-evenly; box-shadow: 0 6px 16px var(--shadow); will-change: transform; }
.rec-lock .i { width: 1.1rem; height: 1.1rem; }
.rec-lock .chev { color: var(--muted); }
.recbar[data-locked="true"] { left: 0; right: 0; bottom: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: var(--bg); }
.recbar[data-locked="true"] .rec-trash, .recbar[data-locked="true"] .rec-pause, .recbar[data-locked="true"] .rec-send { display: inline-grid; }
.recbar[data-locked="true"] .rec-slide, .recbar[data-locked="true"] ~ .never { display: none; }
.recbar[data-locked="true"] .wave { display: flex; }
.recbar[data-locked="true"] .rec-text { display: block; }
.recbar[data-locked="true"] .rec-lock { display: none; }
.recbar[data-paused="true"] .rec-dot { animation: none; background: var(--muted); }
.recbar[data-cancel="true"] .rec-dot { background: var(--danger); }
.rec-send { background: var(--accent); color: var(--accent-ink); }

/* ---------- menus, folhas e diálogos ---------- */
.menu { position: fixed; z-index: 60; min-width: 220px; max-width: calc(100vw - 24px); padding: 6px; border-radius: 16px; background: var(--surface-3); box-shadow: 0 12px 34px var(--shadow); display: grid; transform-origin: top right; animation: pop 0.16s var(--ease); }
.menu button { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: 10px; text-align: left; font-size: 0.96rem; color: var(--fg); }
.menu button:active { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu button .i { width: 1.15rem; height: 1.15rem; color: var(--muted); }
.menu button.danger .i { color: var(--danger); }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 4px 6px; }
.attach-menu { transform-origin: bottom left; padding: 8px; min-width: 240px; }
.attach-menu .ai { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.attach-menu button .i { color: inherit; }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } }

dialog { border: 0; padding: 0; color: var(--fg); background: var(--surface); }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog.sheet { width: 100%; max-width: 560px; margin: auto auto 0; padding: 8px 18px calc(16px + env(safe-area-inset-bottom)); border-radius: 24px 24px 0 0; max-height: 88dvh; overflow-y: auto; }
dialog.sheet[open] { animation: sheet-in 0.4s var(--ease); }
@keyframes sheet-in { from { transform: translateY(100%); } }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--surface-3); margin: 4px auto 12px; }
dialog h2 { margin: 0 0 6px; font-size: 1.2rem; line-height: 1.4; font-weight: 650; }
dialog.alert { width: min(88vw, 360px); border-radius: 24px; padding: 22px 22px 12px; margin: auto; }
dialog.alert[open] { animation: pop 0.2s var(--ease); }
dialog.alert form { display: grid; gap: 14px; }
.alert-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.opt-list { list-style: none; margin: 14px 0 6px; padding: 0; display: grid; gap: 8px; }
.opt { width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 18px; background: var(--surface-2); text-align: left; transition: transform 0.12s; }
.opt:active { transform: scale(0.985); }
.opt .ot { display: grid; gap: 1px; line-height: 1.35; }
.opt .ot small { color: var(--muted); font-size: 0.82rem; }
#new-sheet .field { margin: 10px 0 4px; }
#new-sheet .textbtn { width: 100%; }
.info-list { margin: 12px 0; display: grid; gap: 12px; }
.info-list div { display: grid; gap: 2px; }
.info-list dt { font-size: 0.78rem; color: var(--muted); }
.info-list dd { margin: 0; line-height: 1.4; word-break: break-word; }
.info-list a { color: var(--accent); }

#toast { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px; background: var(--fg); color: var(--bg); font-size: 0.9rem; line-height: 1.4; z-index: 70; box-shadow: 0 8px 22px var(--shadow); animation: fade 0.2s ease-out; text-align: center; }

/* ---------- ligação ---------- */
#call { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: calc(24px + env(safe-area-inset-top)) 20px calc(22px + env(safe-area-inset-bottom)); overflow-y: auto; background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 20%, var(--bg)), var(--bg) 72%); }
.call-title { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.4; max-width: 90%; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-avatar { position: relative; margin-top: 26px; display: grid; place-items: center; width: 132px; height: 132px; transition: transform 0.25s var(--ease); }
.call-avatar .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; }
#call[data-state="listening"] .call-avatar { transform: scale(1.05); }
#call[data-state="listening"] .ring { animation: ring 2.2s ease-out infinite; }
#call[data-state="listening"] .ring.r2 { animation-delay: 1.1s; }
#call[data-state="speaking"] .avatar { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 35%, transparent); }
#call[data-state="thinking"] .avatar { opacity: 0.8; }
@keyframes ring { from { transform: scale(1); opacity: 0.5; } to { transform: scale(1.7); opacity: 0; } }
.call-name { margin: 10px 0 0; font-size: 1.6rem; font-weight: 650; line-height: 1.3; }
.call-timer { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.call-state { margin: 4px 0 0; font-weight: 600; font-size: 1.05rem; line-height: 1.4; min-height: 1.5em; color: var(--accent); }
.call-text { margin: 0; color: var(--muted); max-width: 520px; text-align: center; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.call-perms { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 520px; display: grid; gap: 12px; }
.call-controls { margin-top: auto; width: 100%; max-width: 420px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-top: 14px; }
.ctl { display: grid; justify-items: center; gap: 8px; font-size: 0.78rem; color: var(--fg); padding: 6px 0; }
.ctl-ico { width: 64px; height: 64px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; transition: background-color 0.15s, transform 0.12s; }
.ctl:active .ctl-ico { transform: scale(0.94); }
.ctl[aria-pressed="true"] .ctl-ico { background: var(--fg); color: var(--bg); }
.ctl.end .ctl-ico { background: var(--danger); color: #fff; }
.ctl.end .i { transform: rotate(135deg); }
#call[data-ready="true"] { cursor: pointer; }
#call[data-ready="true"] .call-controls .ctl:not(.end) { opacity: 0.35; pointer-events: none; }

/* ---------- performance e acessibilidade ---------- */
:root[data-perf="lite"] .sk, :root[data-perf="lite"] .rec-dot, :root[data-perf="lite"] .recbar.live .wave i, :root[data-perf="lite"] #call .ring { animation: none !important; }
@media (prefers-reduced-motion: reduce) {
  .sk, .typing i, .rec-dot, .recbar.live .wave i, #call .ring, .avatar .busy { animation: none !important; }
  .card, .fade-in, #toast, .menu, dialog[open], .splash-mark, .splash-name { animation: none !important; }
  .chip, .fab, button.icon, .opt, .round { transition: none; }
}
@media (hover: hover) {
  .chat-row:hover { background: var(--surface); }
  .chip:hover, button.icon:hover { background: var(--surface-3); }
  .chip[aria-selected="true"]:hover { background: var(--accent-soft); }
  .set-row:hover { background: var(--surface); }
  .menu button:hover { background: var(--surface-2); }
}

/* cor de identidade do projeto (só no avatar) */
.avatar[data-h] { background: hsl(var(--h) 26% 30%); color: hsl(var(--h) 70% 90%); }
:root[data-theme="light"] .avatar[data-h] { background: hsl(var(--h) 45% 86%); color: hsl(var(--h) 55% 22%); }
@media (prefers-color-scheme: light) { :root[data-theme="auto"] .avatar[data-h] { background: hsl(var(--h) 45% 86%); color: hsl(var(--h) 55% 22%); } }
.att .pct { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 0.66rem; font-weight: 700; z-index: 2; color: var(--fg); font-variant-numeric: tabular-nums; }
.toast-act { color: var(--bg); margin-left: 8px; min-height: 32px; padding: 0 8px; }
.rec-trash { color: var(--danger); }

/* escolha da voz (Ajustes > Voz e ligação) */
.voice-picker { display: grid; gap: 10px; }
.voice-row .vn { flex: 1; min-width: 0; line-height: 1.35; padding: 8px 0; }
.voice-row .textbtn { margin-right: -8px; flex: none; }
.more-voices > summary { min-height: 48px; display: flex; align-items: center; color: var(--muted); font-weight: 600; cursor: pointer; }
.more-voices[open] > summary { margin-bottom: 8px; }
