/* Sistema de design do dashboard do agente-ze — 3 temas via data-theme.
   Nenhuma cor fora dos tokens. Trocado por [data-theme] no <html>; o servidor
   injeta o atributo a partir do cookie (sem flash).
   Mobile: nav horizontal vira BOTTOM NAV; tabelas viram cards. */

/* ---------------------------------------------------------------- fontes */
@font-face {
  font-family: "Geist web";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/static/fonts/Geist-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist web";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/static/fonts/Geist-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter var";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono web";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/JetBrainsMono.woff2") format("woff2");
}

/* ------------------------------------------------------------ escala/base */
:root {
  --font-ui: "Geist web", Geist, "Inter var", Inter, system-ui, -apple-system,
             "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono web", "JetBrains Mono", "Cascadia Code", "SF Mono",
               Consolas, ui-monospace, monospace;
  --text-xs: 0.75rem;      /* meta/label 11-12px */
  --text-sm: 0.8125rem;    /* 13px */
  --text-base: 0.84375rem; /* corpo 13.5px (handoff: 13.5-15px) */
  --text-md: 0.9375rem;    /* 15px */
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;      /* título de tela 20px/600 */
  --radius: 0.875rem;      /* card 14px */
  --radius-md: 0.75rem;    /* campo/botão 12px */
  --radius-sm: 0.5rem;     /* chip/tile 8px */
  --radius-lg: 1rem;       /* card grande 16px */
  --radius-pill: 999px;
  --bottomnav-h: 3.5rem;
  --tracking-tight: -0.02em;
}

/* --------------- semânticos: mesma identidade de matiz, L por tema (AA) --- */

/* tokens NOVOS do design premium com default derivado dos existentes —
   temas legados e temas custom (builder) funcionam sem redeclarar nada;
   os 3 temas base sobrescrevem com os valores exatos do handoff. */
:root {
  --line: color-mix(in srgb, var(--text) 8%, transparent);
  --header: var(--bg);
  --danger-ic: var(--danger);
  --warning-ic: var(--warning);
  --danger-bd: color-mix(in srgb, var(--danger) 32%, transparent);
  --warning-bd: color-mix(in srgb, var(--warning) 32%, transparent);
  --success-bd: color-mix(in srgb, var(--success) 35%, transparent);
  --info-bd: color-mix(in srgb, var(--info) 35%, transparent);
  --redacted-bd: color-mix(in srgb, var(--redacted) 40%, transparent);
  --secret-bd: color-mix(in srgb, var(--secret) 35%, transparent);
  /* chip de PII DENTRO da bolha do dono (fundo acento) */
  --upii-tx: var(--redacted);
  --upii-bg: var(--redacted-bg);
  --upii-bd: var(--redacted-bd);
}

/* AMOLED — base preta do design premium (handoff): acento menta #35d6a8
   (substitui o AMOLED monocromático anterior). */
[data-theme="amoled"] {
  --bg: #000000;
  --surface-1: #121815;
  --surface-2: #1a221e;
  --surface-3: #223029;
  --border: #1c2420;
  --border-strong: #2c3a33;
  --line: rgba(255,255,255,.07);
  --text: #f4f6f5;
  --text-muted: #8b938f;
  --text-faint: #5a635f;
  --accent: #35d6a8;
  --accent-hover: #2ba888;
  --on-accent: #06231b;
  --chat-bg: #000000;
  --header: #000000;
  --bubble-in: #121815; --on-bubble-in: #f4f6f5; --bubble-in-meta: #5a635f;
  --bubble-out: #12503f; --on-bubble-out: #e6faf2; --bubble-out-meta: #7fc9b3;

  --danger: #ff8478;   --danger-ic: #ff6b5e;
  --danger-bg: rgba(255,107,94,.09);  --danger-bd: rgba(255,107,94,.30);
  --warning: #f3ddb0;  --warning-ic: #e6a94a;
  --warning-bg: rgba(230,169,74,.10); --warning-bd: #4a3d17;
  --success: #3ecf8e;
  --success-bg: rgba(62,207,142,.10); --success-bd: rgba(62,207,142,.35);
  --info: #5b9dff;
  --info-bg: rgba(91,157,255,.10);    --info-bd: rgba(91,157,255,.35);
  --redacted: #cabffb;
  --redacted-bg: rgba(157,140,245,.16); --redacted-bd: rgba(157,140,245,.40);
  --secret: #d977c8;
  --secret-bg: rgba(217,119,200,.12); --secret-bd: rgba(217,119,200,.35);
  --upii-tx: #cabffb; --upii-bg: rgba(157,140,245,.20);
  --upii-bd: rgba(157,140,245,.45);
  --appr-once: #3ecf8e;    --appr-once-bg: rgba(62,207,142,.10);
  --appr-session: #5b9dff; --appr-session-bg: rgba(91,157,255,.10);
  --appr-always: #f4f6f5;  --appr-always-bg: transparent;
  --appr-deny: #ff8478;    --appr-deny-bg: rgba(255,107,94,.09);
  --diff-add-fg: #3ecf8e;  --diff-add-bg: rgba(62,207,142,.10);
  --diff-del-fg: #ff8478;  --diff-del-bg: rgba(255,107,94,.09);
}

/* Grafite: grafite quente + acento jade-fósforo (tensão quente/frio). */
[data-theme="dark"] {
  --bg: #131412;
  --surface-1: #1b1c19;
  --surface-2: #232521;
  --surface-3: #2c2e29;
  --border: #33352f;
  --border-strong: #454840;
  --text: #eae9e2;
  --text-muted: #a6a89b;
  --text-faint: #6f7167;
  --accent: #45c7a9;
  --accent-hover: #66d9be;
  --on-accent: #06231c;
  --chat-bg: #141513;
  --bubble-in: #232521; --on-bubble-in: #eae9e2; --bubble-in-meta: #8a8c81;
  --bubble-out: #2f8a74; --on-bubble-out: #eafdf7; --bubble-out-meta: #bfe9dd;

  --danger: #f5726f;   --danger-bg: #3a1e1d;
  --warning: #e8b84b;  --warning-bg: #332810;
  --success: #59c98a;  --success-bg: #16321f;
  --info: #549fe0;     --info-bg: #132c40;
  --redacted: #b98fe0; --redacted-bg: #291d3d;
  --secret: #ab9c80;   --secret-bg: #282213;
  --appr-once: #59c98a;    --appr-once-bg: #16321f;
  --appr-session: #549fe0; --appr-session-bg: #132c40;
  --appr-always: #8393f0;  --appr-always-bg: #1e2140;
  --appr-deny: #f5726f;    --appr-deny-bg: #3a1e1d;
  --diff-add-fg: #84d8a6;  --diff-add-bg: #16321f;
  --diff-del-fg: #e89b98;  --diff-del-bg: #3a1e1d;
}

/* Claro — base clara do design premium (acento verde escurecido p/ AA em
   botões preenchidos; NUNCA usar o menta #35d6a8 como fundo de botão aqui). */
[data-theme="light"] {
  --bg: #f4f6f5;
  --surface-1: #ffffff;
  --surface-2: #eef1f0;
  --surface-3: #e4e9e6;
  --border: #e4e9e6;
  --border-strong: #c9d2ce;
  --line: #eef1f0;
  --text: #14201c;
  --text-muted: #5c6b64;
  --text-faint: #9aa8a2;
  --accent: #0f9d78;
  --accent-hover: #0c8163;
  --on-accent: #ffffff;
  --chat-bg: #f4f6f5;
  --header: #ffffff;
  --bubble-in: #ffffff; --on-bubble-in: #14201c; --bubble-in-meta: #9aa8a2;
  --bubble-out: #0f9d78; --on-bubble-out: #ffffff; --bubble-out-meta: #d6f5ea;

  --danger: #a5291a;   --danger-ic: #d23f2d;
  --danger-bg: #fdeeec;  --danger-bd: #f3ccc6;
  --warning: #8a5c08;  --warning-ic: #b0740f;
  --warning-bg: #fdf4e3; --warning-bd: #f0dcae;
  --success: #0f8f56;  --success-bg: #e9f8f0;  --success-bd: #bfe8d3;
  --info: #2d6fe0;     --info-bg: #eaf1fe;     --info-bd: #c6dafa;
  --redacted: #6d54d6; --redacted-bg: #f0edfd; --redacted-bd: #d6cdf8;
  --secret: #b23a9e;   --secret-bg: #faeaf6;   --secret-bd: #eccbe3;
  /* na bolha do dono (fundo acento cheio) o chip de PII vira branco */
  --upii-tx: #ffffff; --upii-bg: rgba(255,255,255,.22);
  --upii-bd: rgba(255,255,255,.50);
  --appr-once: #0f8f56;    --appr-once-bg: #e9f8f0;
  --appr-session: #2d6fe0; --appr-session-bg: #eaf1fe;
  --appr-always: #14201c;  --appr-always-bg: transparent;
  --appr-deny: #a5291a;    --appr-deny-bg: #fdeeec;
  --diff-add-fg: #0f8f56;  --diff-add-bg: #e9f8f0;
  --diff-del-fg: #a5291a;  --diff-del-bg: #fdeeec;
}

/* Petróleo — dark de assinatura do design premium (verde-petróleo profundo). */
[data-theme="petroleo"] {
  --bg: #0b1210;
  --surface-1: #16211d;
  --surface-2: #223029;
  --surface-3: #2a3b33;
  --border: #223029;
  --border-strong: #35493f;
  --line: rgba(255,255,255,.06);
  --text: #eaf1ee;
  --text-muted: #86988f;
  --text-faint: #69827a;
  --accent: #3ddcae;
  --accent-hover: #2ba888;
  --on-accent: #06231b;
  --chat-bg: #0b1210;
  --header: #0b1210;
  --bubble-in: #16211d; --on-bubble-in: #eaf1ee; --bubble-in-meta: #69827a;
  --bubble-out: #1c5a48; --on-bubble-out: #e8faf3; --bubble-out-meta: #8fd3bf;

  --danger: #ff8478;   --danger-ic: #ff6b5e;
  --danger-bg: rgba(255,107,94,.09);  --danger-bd: rgba(255,107,94,.30);
  --warning: #f3ddb0;  --warning-ic: #e6a94a;
  --warning-bg: rgba(230,169,74,.10); --warning-bd: #4a3d17;
  --success: #3ecf8e;
  --success-bg: rgba(62,207,142,.10); --success-bd: rgba(62,207,142,.35);
  --info: #5b9dff;
  --info-bg: rgba(91,157,255,.10);    --info-bd: rgba(91,157,255,.35);
  --redacted: #cabffb;
  --redacted-bg: rgba(157,140,245,.16); --redacted-bd: rgba(157,140,245,.40);
  --secret: #d977c8;
  --secret-bg: rgba(217,119,200,.12); --secret-bd: rgba(217,119,200,.35);
  --upii-tx: #cabffb; --upii-bg: rgba(157,140,245,.20);
  --upii-bd: rgba(157,140,245,.45);
  --appr-once: #3ecf8e;    --appr-once-bg: rgba(62,207,142,.10);
  --appr-session: #5b9dff; --appr-session-bg: rgba(91,157,255,.10);
  --appr-always: #eaf1ee;  --appr-always-bg: transparent;
  --appr-deny: #ff8478;    --appr-deny-bg: rgba(255,107,94,.09);
  --diff-add-fg: #3ecf8e;  --diff-add-bg: rgba(62,207,142,.10);
  --diff-del-fg: #ff8478;  --diff-del-bg: rgba(255,107,94,.09);
}

/* Black Pitch: preto puro como o AMOLED, mas com acento fosco (baixo brilho)
   e contraste mais suave — pediram um preto "menos claro" no acento. */
[data-theme="black-pitch"] {
  --bg: #000000;
  --surface-1: #0b0b0d;
  --surface-2: #141417;
  --surface-3: #1c1c20;
  --border: #232327;
  --border-strong: #313138;
  --text: #d7d7db;
  --text-muted: #8f8f98;
  --text-faint: #5c5c64;
  /* acento cinza escuro neutro (era teal "azul pastel"); texto claro nele */
  --accent: #575759;
  --accent-hover: #6f6f72;
  --on-accent: #f3f3f4;
  --chat-bg: #000000;
  --bubble-in: #141417; --on-bubble-in: #d7d7db; --bubble-in-meta: #7c7c84;
  --bubble-out: #34343a; --on-bubble-out: #ededf0; --bubble-out-meta: #9a9aa2;

  --danger: #e06b6b;   --danger-bg: #331414;
  --warning: #d8b45a;  --warning-bg: #322a10;
  --success: #59c088;  --success-bg: #102b1d;
  --info: #5a9fd4;     --info-bg: #0d2334;
  --redacted: #b28fd6; --redacted-bg: #241733;
  --secret: #ab9c80;   --secret-bg: #242012;
  --appr-once: #59c088;    --appr-once-bg: #102b1d;
  --appr-session: #5a9fd4; --appr-session-bg: #0d2334;
  --appr-always: #8090e0;  --appr-always-bg: #191c33;
  --appr-deny: #e06b6b;    --appr-deny-bg: #331414;
  --diff-add-fg: #84d0a6;  --diff-add-bg: #102b1d;
  --diff-del-fg: #e09a9a;  --diff-del-bg: #331414;
}

/* Nord: polar night azul-acinzentado + acento frost. */
[data-theme="nord"] {
  --bg: #2e3440;
  --surface-1: #333b49;
  --surface-2: #3b4252;
  --surface-3: #434c5e;
  --border: #4c566a;
  --border-strong: #5b6678;
  --text: #e5e9f0;
  --text-muted: #b4bcca;
  --text-faint: #808a9d;
  --accent: #88c0d0;
  --accent-hover: #a3d0dd;
  --on-accent: #12202a;
  --chat-bg: #2b303b;
  --bubble-in: #3b4252; --on-bubble-in: #e5e9f0; --bubble-in-meta: #8b93a3;
  --bubble-out: #4c6a8a; --on-bubble-out: #eaf0f7; --bubble-out-meta: #b8c6d8;

  --danger: #bf616a;   --danger-bg: #3a2b2e;
  --warning: #ebcb8b;  --warning-bg: #3a3323;
  --success: #a3be8c;  --success-bg: #2b3527;
  --info: #81a1c1;     --info-bg: #29333f;
  --redacted: #b48ead; --redacted-bg: #342b33;
  --secret: #c8a27f;   --secret-bg: #332b22;
  --appr-once: #a3be8c;    --appr-once-bg: #2b3527;
  --appr-session: #81a1c1; --appr-session-bg: #29333f;
  --appr-always: #5e81ac;  --appr-always-bg: #26303f;
  --appr-deny: #bf616a;    --appr-deny-bg: #3a2b2e;
  --diff-add-fg: #a3be8c;  --diff-add-bg: #2b3527;
  --diff-del-fg: #bf616a;  --diff-del-bg: #3a2b2e;
}

/* Gruvbox: retrô quente e terroso + acento verde-limão. */
[data-theme="gruvbox"] {
  --bg: #282828;
  --surface-1: #32302f;
  --surface-2: #3c3836;
  --surface-3: #504945;
  --border: #4c4642;
  --border-strong: #665c54;
  --text: #ebdbb2;
  --text-muted: #bdae93;
  --text-faint: #928374;
  --accent: #b8bb26;
  --accent-hover: #cdd23a;
  --on-accent: #23260a;
  --chat-bg: #242020;
  --bubble-in: #3c3836; --on-bubble-in: #ebdbb2; --bubble-in-meta: #a89984;
  --bubble-out: #5a6a2a; --on-bubble-out: #f4f0d8; --bubble-out-meta: #c2c79a;

  --danger: #fb4934;   --danger-bg: #3c2523;
  --warning: #fabd2f;  --warning-bg: #3a2f12;
  --success: #8ec07c;  --success-bg: #253026;
  --info: #83a598;     --info-bg: #24302e;
  --redacted: #d3869b; --redacted-bg: #3a2830;
  --secret: #c9b58c;   --secret-bg: #332c1c;
  --appr-once: #8ec07c;    --appr-once-bg: #253026;
  --appr-session: #83a598; --appr-session-bg: #24302e;
  --appr-always: #8f9fd0;  --appr-always-bg: #26293a;
  --appr-deny: #fb4934;    --appr-deny-bg: #3c2523;
  --diff-add-fg: #b8bb26;  --diff-add-bg: #2f3117;
  --diff-del-fg: #fb4934;  --diff-del-bg: #3c2523;
}

/* Solar: um CLARO alternativo, sépia quente (Solarized Light) — foregrounds
   escurecidos onde preciso para manter WCAG AA sobre o creme. */
[data-theme="solar"] {
  --bg: #fdf6e3;
  --surface-1: #fffdf6;
  --surface-2: #eee8d5;
  --surface-3: #e3ddc9;
  --border: #ddd6c1;
  --border-strong: #c7bfa6;
  --text: #073642;
  --text-muted: #586e75;
  --text-faint: #93a1a1;
  --accent: #1e78ba;
  --accent-hover: #175a8d;
  --on-accent: #ffffff;
  --chat-bg: #efe9d6;
  --bubble-in: #fffdf6; --on-bubble-in: #073642; --bubble-in-meta: #93a1a1;
  --bubble-out: #cfe6e2; --on-bubble-out: #0a4a44; --bubble-out-meta: #5a8078;

  --danger: #c8322f;   --danger-bg: #fbe3e0;
  --warning: #97710a;  --warning-bg: #f5ecc9;
  --success: #5f7000;  --success-bg: #eef0d4;
  --info: #197d75;     --info-bg: #d5efec;
  --redacted: #5b5fc0; --redacted-bg: #e6e6f5;
  --secret: #7a6a1f;   --secret-bg: #efe9cf;
  --appr-once: #5f7000;    --appr-once-bg: #eef0d4;
  --appr-session: #197d75; --appr-session-bg: #d5efec;
  --appr-always: #5b5fc0;  --appr-always-bg: #e6e6f5;
  --appr-deny: #c8322f;    --appr-deny-bg: #fbe3e0;
  --diff-add-fg: #4f6000;  --diff-add-bg: #eef0d4;
  --diff-del-fg: #a82a26;  --diff-del-bg: #fbe3e0;
}

/* Oceano: azul-petróleo profundo + acento ciano (preset novo estilo Telegram).
   Semânticos herdam do Grafite (mesma matiz/AA sobre escuro). */
[data-theme="ocean"] {
  --bg: #0e1b24;
  --surface-1: #13232f;
  --surface-2: #162a37;
  --surface-3: #1d3543;
  --border: #244050;
  --border-strong: #345365;
  --text: #dcecf3;
  --text-muted: #93aab7;
  --text-faint: #62808e;
  --accent: #4bc0e0;
  --accent-hover: #6fd2ec;
  --on-accent: #062430;
  --chat-bg: #0e1b24;
  --bubble-in: #162a37; --on-bubble-in: #dcecf3; --bubble-in-meta: #849aa7;
  --bubble-out: #2c6f8f; --on-bubble-out: #eafaff; --bubble-out-meta: #bfe0ec;

  --danger: #f5726f;   --danger-bg: #3a1e1d;
  --warning: #e8b84b;  --warning-bg: #332810;
  --success: #59c98a;  --success-bg: #16321f;
  --info: #549fe0;     --info-bg: #132c40;
  --redacted: #b98fe0; --redacted-bg: #291d3d;
  --secret: #ab9c80;   --secret-bg: #282213;
  --appr-once: #59c98a;    --appr-once-bg: #16321f;
  --appr-session: #549fe0; --appr-session-bg: #132c40;
  --appr-always: #8393f0;  --appr-always-bg: #1e2140;
  --appr-deny: #f5726f;    --appr-deny-bg: #3a1e1d;
  --diff-add-fg: #84d8a6;  --diff-add-bg: #16321f;
  --diff-del-fg: #e89b98;  --diff-del-bg: #3a1e1d;
}

/* Ameixa: roxo-uva noturno + acento lavanda (preset novo). */
[data-theme="plum"] {
  --bg: #15121c;
  --surface-1: #1d1928;
  --surface-2: #221c2e;
  --surface-3: #2b2439;
  --border: #352c46;
  --border-strong: #493d5f;
  --text: #e9e2f2;
  --text-muted: #a99cbf;
  --text-faint: #7c7090;
  --accent: #b98cff;
  --accent-hover: #cba8ff;
  --on-accent: #1e1030;
  --chat-bg: #15121c;
  --bubble-in: #221c2e; --on-bubble-in: #e9e2f2; --bubble-in-meta: #948aa8;
  --bubble-out: #6b3f9e; --on-bubble-out: #f5eefe; --bubble-out-meta: #d3c2ea;

  --danger: #f5726f;   --danger-bg: #3a1e1d;
  --warning: #e8b84b;  --warning-bg: #332810;
  --success: #59c98a;  --success-bg: #16321f;
  --info: #549fe0;     --info-bg: #132c40;
  --redacted: #b98fe0; --redacted-bg: #291d3d;
  --secret: #ab9c80;   --secret-bg: #282213;
  --appr-once: #59c98a;    --appr-once-bg: #16321f;
  --appr-session: #549fe0; --appr-session-bg: #132c40;
  --appr-always: #8393f0;  --appr-always-bg: #1e2140;
  --appr-deny: #f5726f;    --appr-deny-bg: #3a1e1d;
  --diff-add-fg: #84d8a6;  --diff-add-bg: #16321f;
  --diff-del-fg: #e89b98;  --diff-del-bg: #3a1e1d;
}

/* Floresta: verde-musgo escuro + acento menta (preset novo). */
[data-theme="forest"] {
  --bg: #0f1913;
  --surface-1: #14211a;
  --surface-2: #182620;
  --surface-3: #1f3329;
  --border: #26402f;
  --border-strong: #35543f;
  --text: #dceee3;
  --text-muted: #93b09c;
  --text-faint: #5f7f6b;
  --accent: #5fd39a;
  --accent-hover: #7fe0b0;
  --on-accent: #06231a;
  --chat-bg: #0f1913;
  --bubble-in: #182620; --on-bubble-in: #dceee3; --bubble-in-meta: #82a48c;
  --bubble-out: #2f7d54; --on-bubble-out: #eafcf1; --bubble-out-meta: #bfe6cf;

  --danger: #f5726f;   --danger-bg: #3a1e1d;
  --warning: #e8b84b;  --warning-bg: #332810;
  --success: #59c98a;  --success-bg: #16321f;
  --info: #549fe0;     --info-bg: #132c40;
  --redacted: #b98fe0; --redacted-bg: #291d3d;
  --secret: #ab9c80;   --secret-bg: #282213;
  --appr-once: #59c98a;    --appr-once-bg: #16321f;
  --appr-session: #549fe0; --appr-session-bg: #132c40;
  --appr-always: #8393f0;  --appr-always-bg: #1e2140;
  --appr-deny: #f5726f;    --appr-deny-bg: #3a1e1d;
  --diff-add-fg: #84d8a6;  --diff-add-bg: #16321f;
  --diff-del-fg: #e89b98;  --diff-del-bg: #3a1e1d;
}

/* ------------------------------------------------------------ elementos */
* { box-sizing: border-box; }
html { color-scheme: dark; }
[data-theme="light"], [data-theme="solar"] { color-scheme: light; }
/* o atributo `hidden` sempre esconde — senão um `display:` de classe (ex:
   .notif-banner{display:flex}) sobrepõe o [hidden] da UA e o elemento não some */
[hidden] { display: none !important; }

/* densidade: escala a fonte-raiz — como tudo é rem, encolhe/cresce junto
   (cabe mais na tela do celular). Inputs no mobile ficam em 16px fixo p/
   não dar zoom no iOS, independente disto. */
html[data-density="compact"] { font-size: 87.5%; }
html[data-density="large"]   { font-size: 112.5%; }

/* tipo de fonte da interface (troca --font-ui; --font-mono segue no código) */
html[data-font="system"] { --font-ui: system-ui, -apple-system, "Segoe UI",
  Roboto, sans-serif; }
html[data-font="serif"] { --font-ui: Georgia, "Noto Serif", "Times New Roman",
  serif; }
html[data-font="mono"] { --font-ui: var(--font-mono); }

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

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

/* ---- a11y: skip-link (aparece só com foco de teclado) ---- */
.skip-link { position: absolute; left: -9999px; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: .5rem 1rem; border-radius: var(--radius-sm); }
.skip-link:focus { left: .5rem; top: .5rem; }

/* mobile não tem header: a bottom nav (slot do meio = página atual) já diz
   onde você está, liberando o topo da tela. Desktop usa a sidebar. */
.brand { font-weight: 650; color: var(--text); letter-spacing: .01em; }
main { max-width: 74rem; margin: 1.5rem auto; padding: 0 1rem; min-width: 0; }

/* ---- sidebar (desktop) — mobile usa bottom nav ---- */
.sidebar { display: none; }
@media (min-width: 641px) {
  .shell { display: grid; grid-template-columns: 14rem minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--surface-1); border-right: 1px solid var(--border);
    padding: 1rem 0 .8rem;
  }
  .sidebar .brand { display: block; padding: 0 1rem .8rem; font-size: var(--text-lg); }
  .sidebar nav { display: flex; flex-direction: column; flex: 1; }
  .sidebar nav h3 {
    margin: .9rem 1rem .25rem; font-size: var(--text-xs); font-weight: 600;
    text-transform: uppercase; letter-spacing: .07em; color: var(--text-faint);
  }
  .sidebar nav a {
    display: block; padding: .38rem 1rem; color: var(--text-muted);
    font-size: var(--text-sm); border-left: 2px solid transparent;
  }
  .sidebar nav a:hover { color: var(--text); background: var(--surface-2);
    text-decoration: none; }
  .sidebar nav a[aria-current="page"] {
    color: var(--accent); font-weight: 600; background: var(--surface-2);
    border-left-color: var(--accent);
  }
  .sidebar-foot { padding: .8rem 1rem 0; border-top: 1px solid var(--border);
    margin-top: .8rem; }
  .settings-link { display: flex; align-items: center; gap: .5rem;
    color: var(--text-muted); font-size: var(--text-sm); padding: .3rem 0; }
  .settings-link:hover { color: var(--accent); text-decoration: none; }
  .settings-link[aria-current="page"] { color: var(--accent); font-weight: 600; }
  .settings-link svg { width: 18px; height: 18px; }
}

/* ---- bottom nav + sheet (mobile; escondidos no desktop) ---- */
.bottomnav, .navsheet, .navsheet-toggle, .navsheet-backdrop { display: none; }

/* ---- theme toggle ---- */
.theme-toggle { display: flex; flex-wrap: wrap; gap: 2px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 2px; }
.theme-toggle a {
  font-size: var(--text-xs); padding: 3px 9px; border-radius: var(--radius-pill);
  color: var(--text-muted); line-height: 1.4;
}
.theme-toggle a:hover { color: var(--text); text-decoration: none; }
.theme-toggle a[aria-current="true"] { background: var(--accent); color: var(--on-accent); }

.density-toggle a { min-width: 1.7rem; text-align: center; font-weight: 600; }

/* dropdown de tema (7 paletas + Sistema): select nativo estilizado pra casar
   com o design — sem aparência de widget do SO. Caret próprio no wrapper
   (o <select> não aceita ::after). */
.select-wrap { position: relative; display: inline-block; max-width: 100%; }
.select-wrap::after {   /* caret ▾ desenhado com 2 bordas (segue o tema) */
  content: ""; position: absolute; right: .85rem; top: 50%; width: .5rem;
  height: .5rem; pointer-events: none; border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg); }
.theme-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  width: auto; min-width: 13rem; max-width: 100%;
  padding: .5rem 2.2rem .5rem .8rem; cursor: pointer; line-height: 1.35;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-family: var(--font-ui); font-size: var(--text-base); }
.theme-select:hover { border-color: var(--accent); }
.theme-select option, .theme-select optgroup {   /* onde o SO respeita */
  background: var(--surface-1); color: var(--text); }

h1 { font-size: var(--text-xl); font-weight: 600;
  letter-spacing: var(--tracking-tight); margin: 0 0 1rem; }
h2 { font-size: var(--text-md); font-weight: 600;
  letter-spacing: var(--tracking-tight); margin: 0 0 .7rem; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 1rem;        /* fase 4: card 16px */
  padding: 1rem;
  margin-bottom: 1rem;
}

/* ---- tabelas ---- */
table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); }
th, td { border: 1px solid var(--border); padding: .4rem .6rem; text-align: left;
  vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; color: var(--text-muted); }
tr:hover td { background: var(--surface-2); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.scroll-hint { display: none; font-size: var(--text-xs); color: var(--text-faint);
  margin: 0 0 .4rem; }

/* ---- código / mono ---- */
code, pre, .mono { font-family: var(--font-mono); }
code { font-size: .85em; background: var(--surface-2); padding: 1px 5px;
  border-radius: 4px; }
pre {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: .7rem .85rem; overflow-x: auto; font-size: var(--text-sm);
  line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  border-radius: var(--radius-sm);
}

/* ---- botões / inputs ---- */
button, .btn {
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 600;
  background: var(--accent); color: var(--on-accent); border: 0;
  border-radius: var(--radius-md); padding: .45rem .9rem; cursor: pointer;
  transition: background-color .15s ease, color .15s ease,
              border-color .15s ease;
}
button:hover, .btn:hover, button:active, .btn:active {
  background: var(--accent-hover); }
button.danger { background: var(--danger-bg); color: var(--danger);
  border: 1px solid var(--danger); }
button.danger:hover { background: var(--danger); color: var(--bg); }
button.ghost { background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: .45rem .55rem; font-family: var(--font-ui);
  font-size: var(--text-sm); background: var(--surface-1); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea { font-family: var(--font-mono); }
form.inline { display: inline-block; margin: .15rem .4rem .15rem 0;
  vertical-align: middle; }
label { font-size: var(--text-sm); color: var(--text-muted); }
input.short { width: 6rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: .6rem .9rem; }
.form-grid label { display: flex; flex-direction: column; gap: .25rem; }
td.actions { white-space: nowrap; }

/* grupo de botões (purges, toggles): respiro entre eles, empilha no mobile */
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem .6rem; align-items: center;
  margin: .6rem 0 .2rem; }
.btn-row form.inline { margin: 0; }

/* formulário de uma linha: campos ROTULADOS lado a lado, empilha no mobile
   (nunca input solto no meio de frase — era isso que encavalava) */
.form-row { display: flex; flex-wrap: wrap; gap: .6rem .9rem; align-items: flex-end;
  margin: .6rem 0 .2rem; }
.form-row label { display: flex; flex-direction: column; gap: .25rem; }
.form-row input[type=text], .form-row input[type=password] { width: 15rem; }
.form-row input[type=number] { width: 7rem; }
.form-row select { width: auto; min-width: 9rem; }

/* ---- toggle switch (liga/desliga sem botão de submit visível) ---- */
.toggle { display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track { position: relative; width: 42px; height: 24px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background .15s ease; flex: 0 0 auto; }
.toggle-thumb { position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--text-faint);
  transition: left .15s ease, background .15s ease; }
.toggle input:checked + .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { left: calc(100% - 20px - 2px);
  background: #fff; }
/* switch estático (indicador on/off, sem form) — design .sw 42x24 */
.sw { width: 42px; height: 24px; border-radius: 999px; flex-shrink: 0;
  position: relative; display: inline-block; }
.sw::after { content: ""; position: absolute; top: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; }
.sw-on { background: var(--accent); } .sw-on::after { right: 2px; }
.sw-off { background: var(--surface-2); border: 1px solid var(--border); }
.sw-off::after { left: 2px; background: var(--text-faint); }
.tfoot .sw::after { content: none; }   /* ponto de status 9px não leva knob */
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }
/* linha: descrição à esquerda, toggle à direita */
.row-toggle { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin: .3rem 0; }
.row-toggle > span { min-width: 0; }

/* ações empilhadas numa célula (ex.: ativar + duplicar em /personas) */
.row-actions { display: flex; flex-direction: column; gap: .5rem; align-items: stretch; }
.row-actions form.inline { margin: 0; display: flex; gap: .4rem; }
.persona-dup { flex-wrap: wrap; }
.persona-dup input[type=text] { flex: 1 1 8rem; min-width: 0; }

/* ---- chip removível (dicionário PII, tags): termo + × pequeno ---- */
.chip-list { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; padding: 0; margin: .4rem 0; }
.chip-rm { display: inline-flex; align-items: center; gap: .1rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: .28rem .3rem .28rem .7rem;
  font-size: var(--text-sm); max-width: 100%; }
.chip-rm span { min-width: 0; overflow-wrap: anywhere; }
.chip-rm form.inline { margin: 0; display: inline-flex; }
.chip-x { min-height: auto !important; width: 1.5rem; height: 1.5rem; padding: 0;
  border-radius: 50%; background: transparent; color: var(--text-faint);
  font-size: 1.05rem; line-height: 1; display: grid; place-items: center; }
.chip-x:hover { background: var(--danger-bg); color: var(--danger); }

/* ---- badges / status ---- */
.badge { display: inline-block; font-size: var(--text-xs); font-weight: 600;
  padding: 1px .5rem; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-muted); }
.badge.ok, .ok { color: var(--success); }
.badge.err, .err { color: var(--danger); }
.badge.warn, .warn { color: var(--warning); }
.badge.info { color: var(--info); }
.pill { display: inline-block; font-size: var(--text-xs); font-weight: 600;
  padding: 1px .55rem; border-radius: var(--radius-pill); }
.pill.danger { color: var(--danger); background: var(--danger-bg); }
.pill.warning { color: var(--warning); background: var(--warning-bg); }
.pill.success { color: var(--success); background: var(--success-bg); }
.pill.info { color: var(--info); background: var(--info-bg); }

.redacted, .chip-redacted { font-family: var(--font-mono); font-size: .85em;
  color: var(--redacted); background: var(--redacted-bg);
  border: 1px solid var(--redacted-bd);
  padding: 1px 5px; border-radius: 6px; }
.secret, .chip-secret { font-family: var(--font-mono); font-size: .85em;
  color: var(--secret); background: var(--secret-bg);
  border: 1px solid var(--secret-bd);
  padding: 1px 5px; border-radius: 6px; }
/* chip de PII dentro da bolha do dono (fundo acento): variante própria */
.msg.user .chip-redacted { color: var(--upii-tx); background: var(--upii-bg);
  border-color: var(--upii-bd); }

.appr-once { color: var(--appr-once); background: var(--appr-once-bg);
  padding: 1px .55rem; border-radius: var(--radius-pill); font-size: var(--text-xs); }
.appr-session { color: var(--appr-session); background: var(--appr-session-bg);
  padding: 1px .55rem; border-radius: var(--radius-pill); font-size: var(--text-xs); }
.appr-always { color: var(--appr-always); background: var(--appr-always-bg);
  padding: 1px .55rem; border-radius: var(--radius-pill); font-size: var(--text-xs); }
.appr-deny { color: var(--appr-deny); background: var(--appr-deny-bg);
  padding: 1px .55rem; border-radius: var(--radius-pill); font-size: var(--text-xs); }

/* ---- trace viewer ---- */
.pblock { font-family: var(--font-mono); font-size: var(--text-sm);
  line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: .5rem .7rem; margin: .4rem 0; }
.pblock > .pblock-tag { display: block; font-family: var(--font-ui);
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin-bottom: .3rem; }
.pblock.memory { border-left-color: var(--info); }
.pblock.skill, .pblock.pinned_skill { border-left-color: var(--success); }
.pblock.persona { border-left-color: var(--warning); }
.pblock.user_md { border-left-color: var(--accent); }
.pblock.untrusted_content, .pblock.family_mode { border-left-color: var(--danger); }
.pblock.safety_rules { border-left-color: var(--redacted); }
.pblock.tool_result { border-left-color: var(--secret); }

/* ---- diff ---- */
.diff { font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.5;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; }
.diff .line { padding: 1px .7rem; white-space: pre-wrap; word-break: break-word; }
.diff .add { background: var(--diff-add-bg); color: var(--diff-add-fg); }
.diff .del { background: var(--diff-del-bg); color: var(--diff-del-fg); }
.diff .ctx { color: var(--text-muted); }
.diff .hunk { color: var(--text-faint); background: var(--surface-2); }

/* ---- chat web (F2) — redesign estilo app de mensagens (Telegram) ---- */
.chat-card { display: flex; flex-direction: column; position: relative;
  height: calc(100vh - 9.5rem); min-height: 22rem;
  background: var(--chat-bg); padding: 0; overflow: hidden; }
.chat-sub { margin: 0 0 .5rem; font-size: var(--text-xs); color: var(--text-faint); }

/* header da conversa: avatar + nome + status + busca */
.chat-appbar { display: flex; align-items: center; gap: .75rem; flex: 0 0 auto;
  padding: .8rem 1rem .7rem; padding-top: max(.8rem, env(safe-area-inset-top));
  background: var(--header); border-bottom: 1px solid var(--line); }
/* avatar: tile 40px de canto 12 sobre superfície (design premium) */
.chat-avatar { width: 2.5rem; height: 2.5rem; border-radius: .75rem;
  flex: 0 0 auto; display: grid; place-items: center; font-size: 1.25rem;
  color: var(--text); overflow: hidden;
  background: var(--surface-1); border: 1px solid var(--border); }
/* avatar por imagem: preenche o tile */
.chat-avatar img, .em-av img, .avatar-preview img { width: 100%; height: 100%;
  object-fit: cover; border-radius: inherit; display: block; }
.chat-avatar:has(img), .em-av:has(img), .avatar-preview:has(img) {
  background: none; border: 0; }

/* configuração do avatar (em /settings) */
.avatar-set { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.avatar-preview { width: 3.5rem; height: 3.5rem; font-size: 1.9rem; }
.avatar-controls { flex: 1; min-width: 14rem; display: flex; flex-direction: column;
  gap: .6rem; }
.avatar-quick { display: flex; flex-wrap: wrap; gap: .3rem; }
.avatar-quick-b { font-size: 1.2rem; line-height: 1; padding: .35rem .5rem;
  min-height: auto; background: var(--surface-2); border: 1px solid var(--border); }
.avatar-quick-b:hover { background: var(--surface-3); }
.avatar-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.avatar-emoji-in { width: 5rem; text-align: center; }
.chat-who { flex: 1; min-width: 0; line-height: 1.2; }
.chat-who b { display: block; font-size: 1rem; font-weight: 600;
  color: var(--text); }
.chat-who small { display: flex; align-items: center; gap: .32rem;
  font-size: var(--text-xs); color: var(--success); }
.chat-who small .live-dot { width: .375rem; height: .375rem; border-radius: 50%;
  background: var(--success); flex: 0 0 auto; }
.chat-who small.processing .live-dot { background: var(--warning); }
.chat-who small.offline .live-dot { background: var(--danger);
  animation: ze-blink 1s steps(2, start) infinite; }
@keyframes ze-blink { 50% { opacity: .3; } }
.chat-appbar-btn { flex: 0 0 auto; width: 2.3rem; height: 2.3rem; padding: 0;
  border-radius: 50%; border: 0; background: transparent; color: var(--text-muted);
  cursor: pointer; display: grid; place-items: center; min-height: auto; }
.chat-appbar-btn:hover { background: var(--surface-2); color: var(--text); }
.chat-appbar-btn.active { color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent); }
.chat-appbar-btn svg { width: 20px; height: 20px; }
/* aviso do canal (dispensável) vira uma faixa fina sob o header */
.chat-note { margin: 0; padding: .4rem .7rem; }
/* aviso do canal: dispensável (a escolha some pra sempre via localStorage) */
.chat-note { display: flex; align-items: flex-start; gap: .5rem;
  margin: 0 0 .5rem; font-size: var(--text-xs); color: var(--text-faint);
  line-height: 1.45; }
.chat-note[hidden] { display: none; }
.chat-note-txt { flex: 1; min-width: 0; }
.chat-note-x { flex: 0 0 auto; background: transparent; border: 0; cursor: pointer;
  color: var(--text-faint); font-size: .9rem; line-height: 1; padding: .1rem .35rem;
  border-radius: var(--radius-sm); min-height: auto; }
.chat-note-x:hover { color: var(--text); background: var(--surface-2); }
.notif-banner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  background: var(--info-bg); border: 1px solid var(--info);
  border-radius: var(--radius-sm); padding: .5rem .7rem; margin: .4rem .6rem 0;
  font-size: var(--text-sm); }
.notif-banner button { background: var(--info); color: var(--bg); }
#chat-log { flex: 1; overflow-y: auto; overflow-x: clip; display: flex;
  flex-direction: column; gap: 9px; padding: .875rem .875rem .4rem;
  background: var(--chat-bg); scroll-behavior: smooth; }
/* pílula de data no fluxo ("hoje · 18:44" / "05/07") */
.chat-day { align-self: center; font-size: 11px; color: var(--text-faint);
  background: var(--surface-1); border: 1px solid var(--line);
  border-radius: var(--radius-pill); padding: 4px 12px; }
/* bolha base (largura de leitura confortável: 82% no mobile, teto no desktop).
   overflow-wrap: anywhere (não break-word!) — só o `anywhere` entra no cálculo
   de min-content: token comprido sem espaço (`gemini/gemini-2.5-...`) quebra
   em vez de alargar a bolha e criar scroll horizontal da página no mobile. */
.msg { position: relative; max-width: min(88%, 34rem); min-width: 0;
  padding: 11px 13px 7px;
  border-radius: 1.125rem; font-size: var(--text-base); line-height: 1.45;
  overflow-wrap: anywhere; }
/* o gap uniforme de 9px do design já dá o respiro entre grupos */
.msg.grp-start { margin-top: 0; }
.msg p { margin: .25em 0; }
.msg p:first-child { margin-top: 0; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: .35em 0; padding-left: 1.2em; }
.msg li { margin: .12em 0; }
.msg a { text-decoration: underline; text-underline-offset: 2px; }
.msg blockquote { margin: .4em 0; padding: .15em 0 .15em .7em;
  border-left: 3px solid color-mix(in srgb, currentColor 35%, transparent);
  color: color-mix(in srgb, currentColor 82%, transparent); }
.msg img { max-width: 260px; width: 100%; border-radius: .7rem; display: block; }
/* player de áudio com waveform (nota de voz) */
.chat-audio { display: flex; align-items: center; gap: .6rem; min-width: 12rem;
  max-width: 100%; padding: .1rem 0; }
.chat-audio audio { display: none; }
.ca-play { flex: 0 0 auto; width: 2.2rem; height: 2.2rem; min-width: 2.2rem;
  min-height: 2.2rem; aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%;
  cursor: pointer; background: var(--accent); color: var(--on-accent);
  display: inline-flex; align-items: center; justify-content: center; }
.ca-play svg { width: 15px; height: 15px; display: block; }
.ca-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 1.6rem;
  min-width: 5rem; }
.ca-wave i { flex: 1; min-width: 2px; border-radius: 2px;
  background: color-mix(in srgb, currentColor 30%, transparent); }
.ca-wave i.on { background: color-mix(in srgb, var(--accent) 85%, transparent); }
.msg.user .ca-wave i.on { background: color-mix(in srgb, var(--on-bubble-out) 75%, transparent); }
.ca-dur { flex: 0 0 auto; font-size: 11px; color: var(--bubble-in-meta);
  font-variant-numeric: tabular-nums; }
.msg.user .ca-dur { color: var(--bubble-out-meta); }

/* ---- menu de ações da mensagem (copiar / selecionar / responder) ---- */
.msg-menu { position: fixed; z-index: 60; min-width: 11rem; background: var(--surface-1);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: .3rem;
  box-shadow: 0 10px 34px rgba(0,0,0,.4); }
.msg-menu-item { display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .6rem .7rem; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: var(--text-sm); text-align: left; cursor: pointer;
  border-radius: var(--radius-sm); min-height: auto; }
.msg-menu-item:hover { background: var(--surface-2); }
.msg-menu-item svg { width: 17px; height: 17px; color: var(--text-muted); flex: 0 0 auto; }
/* pré-visualização do que vai ser copiado (quote dentro da bolha do dono) */
.msg-reply { border-left: 3px solid color-mix(in srgb, currentColor 45%, transparent);
  padding: .05rem .5rem; margin-bottom: .3rem; font-size: var(--text-xs);
  color: color-mix(in srgb, currentColor 80%, transparent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* modo de seleção múltipla — dá espaço nas laterais e põe o check na borda
   EXTERNA de cada bolha (não flutuando no meio da tela) */
#chat-log.sel-mode { padding-left: 2.3rem; padding-right: 2.3rem; }
#chat-log.sel-mode .msg.ze, #chat-log.sel-mode .msg.user { cursor: pointer; }
.msg-check { position: absolute; top: 50%; transform: translateY(-50%);
  width: 1.2rem; height: 1.2rem; border-radius: 50%; border: 2px solid var(--border-strong);
  background: var(--surface-1); }
.msg.ze .msg-check { left: -1.85rem; }
.msg.user .msg-check { right: -1.85rem; }
.msg.selected .msg-check { background: var(--accent); border-color: var(--accent); }
.msg.selected .msg-check::after { content: "✓"; position: absolute; inset: 0;
  display: grid; place-items: center; color: var(--on-accent); font-size: 12px; }
.msg.selected { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px; }
.sel-bar { position: absolute; top: 0; left: 0; right: 0; z-index: 8; display: flex;
  align-items: center; gap: .6rem; padding: .55rem .7rem;
  padding-top: max(.55rem, env(safe-area-inset-top));
  background: var(--surface-1); border-bottom: 1px solid var(--border); }
.sel-bar .sel-cancel { width: 2.2rem; height: 2.2rem; border: 0; background: transparent;
  color: var(--text-muted); border-radius: 50%; cursor: pointer; font-size: 1.05rem;
  display: grid; place-items: center; min-height: auto; }
.sel-bar .sel-count { flex: 1; font-weight: 650; color: var(--text); font-size: var(--text-sm); }
.sel-bar .sel-copy { border: 0; background: var(--accent); color: var(--on-accent);
  border-radius: var(--radius-pill); padding: .45rem 1.1rem; font: inherit; font-weight: 600;
  cursor: pointer; min-height: auto; }
.sel-bar .sel-copy:disabled { opacity: .5; cursor: default; }
/* banner "respondendo a…" acima do composer */
.reply-quote { display: flex; align-items: center; gap: .6rem; margin: 0 .55rem;
  padding: .5rem .7rem; background: var(--surface-2);
  border-left: 3px solid var(--accent); border-radius: var(--radius-sm); }
.reply-quote .rq-text { flex: 1; min-width: 0; font-size: var(--text-xs);
  color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-quote .rq-text b { color: var(--accent); font-weight: 600; }
.reply-quote .rq-x { flex: 0 0 auto; width: 1.8rem; height: 1.8rem; border: 0;
  background: transparent; color: var(--text-muted); border-radius: 50%; cursor: pointer;
  min-height: auto; }
.reply-quote .rq-x:hover { background: var(--surface-3); color: var(--text); }
/* toast (feedback de copiado) */
.chat-toast { position: fixed; left: 50%; bottom: 6rem; transform: translateX(-50%);
  z-index: 70; background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  padding: .5rem 1rem; font-size: var(--text-sm); box-shadow: 0 4px 16px rgba(0,0,0,.3);
  animation: ze-toast 1.8s ease forwards; }
@keyframes ze-toast { 0%, 78% { opacity: 1; } 100% { opacity: 0; } }
/* código: superfície própria, rola na horizontal, nunca vaza a bolha */
.msg pre { position: relative; margin: .45em 0; padding: .55rem 2.2rem .55rem .65rem;
  border-radius: .6rem;
  overflow-x: auto; background: color-mix(in srgb, #000 24%, var(--bubble-in));
  border: 1px solid var(--border); font-family: var(--font-mono);
  font-size: var(--text-xs); line-height: 1.5; }
/* botão de copiar SÓ o código (canto da caixa; alvo confortável no toque) */
.code-copy { position: absolute; top: .3rem; right: .3rem; width: 1.7rem;
  height: 1.7rem; min-height: auto; padding: 0; display: grid;
  place-items: center; border: 1px solid var(--border);
  border-radius: .45rem; background: var(--surface-1);
  color: var(--text-muted); cursor: pointer; opacity: .75; }
.code-copy:hover { opacity: 1; background: var(--surface-2);
  color: var(--text); }
.code-copy svg { width: 13px; height: 13px; }
.msg :not(pre) > code { font-family: var(--font-mono); font-size: .92em;
  background: color-mix(in srgb, #000 16%, var(--bubble-in));
  border-radius: .3rem; padding: .05em .35em; overflow-wrap: anywhere; }
/* realce de sintaxe (Pygments) — cores por token; escuras por padrão */
.msg .hl { margin: 0; padding: 0; background: none; border: 0; }
.msg pre .c, .msg pre .ch, .msg pre .cm, .msg pre .cp, .msg pre .c1, .msg pre .cs {
  color: #7b8496; font-style: italic; }
.msg pre .k, .msg pre .kc, .msg pre .kd, .msg pre .kn, .msg pre .kp, .msg pre .kr,
.msg pre .kt, .msg pre .ow { color: #c99bf0; }
.msg pre .s, .msg pre .sa, .msg pre .sb, .msg pre .sc, .msg pre .dl, .msg pre .sd,
.msg pre .s2, .msg pre .se, .msg pre .sh, .msg pre .si, .msg pre .sx, .msg pre .sr,
.msg pre .s1, .msg pre .ss { color: #9fd67a; }
.msg pre .m, .msg pre .mb, .msg pre .mf, .msg pre .mh, .msg pre .mi, .msg pre .il,
.msg pre .mo { color: #f0b866; }
.msg pre .nf, .msg pre .fm { color: #82aaff; }
.msg pre .nc, .msg pre .nn, .msg pre .ne { color: #ffd479; }
.msg pre .nb, .msg pre .bp, .msg pre .nd { color: #5ec8c8; }
.msg pre .o, .msg pre .p { color: color-mix(in srgb, var(--on-bubble-in) 78%, transparent); }
.msg pre .err { color: var(--danger); }
/* temas claros: tokens escuros p/ contraste no fundo claro do código */
:is([data-theme="light"],[data-theme="solar"]) .msg pre .c,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .cm,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .c1 { color: #6a737d; }
:is([data-theme="light"],[data-theme="solar"]) .msg pre .k,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .kd,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .kn,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .kt,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .ow { color: #8250df; }
:is([data-theme="light"],[data-theme="solar"]) .msg pre .s,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .s1,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .s2 { color: #0a7d3f; }
:is([data-theme="light"],[data-theme="solar"]) .msg pre .m,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .mi,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .mf { color: #b35900; }
:is([data-theme="light"],[data-theme="solar"]) .msg pre .nf { color: #1f6fb8; }
:is([data-theme="light"],[data-theme="solar"]) .msg pre .nc,
:is([data-theme="light"],[data-theme="solar"]) .msg pre .nn { color: #7a5c00; }
:is([data-theme="light"],[data-theme="solar"]) .msg pre .nb { color: #0e7c8f; }
.msg .tbl-wrap { overflow-x: auto; margin: 9px 0 8px;
  border: 1px solid var(--border); border-radius: .625rem; }
.msg table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.msg th, .msg td { text-align: left; padding: 6px 9px;
  border-bottom: 1px solid var(--line); }
.msg tr:last-child td { border-bottom: 0; }
.msg th { background: var(--surface-2); font-weight: 600; }
.msg tr:last-child td { border-bottom: 0; }
/* saída (dono) vs entrada (Zé): cantos assimétricos (rabinho no grupo) —
   dono 18/18/6/18 preenchido com acento; Zé 18/18/18/6 superfície + borda */
.msg.user { align-self: flex-end; background: var(--bubble-out);
  color: var(--on-bubble-out); border-radius: 1.125rem 1.125rem .375rem 1.125rem; }
.msg.user a, .msg.user code { color: inherit; }
.msg.ze { align-self: flex-start; background: var(--bubble-in);
  color: var(--on-bubble-in); border: 1px solid var(--border);
  border-radius: 1.125rem 1.125rem 1.125rem .375rem; }
.msg.ze a { color: var(--accent); }
/* hora + status (✓ recebido) no rodapé da bolha */
.msg-meta { display: flex; gap: .3rem; justify-content: flex-end; align-items: center;
  margin-top: 3px; font-size: 10.5px; line-height: 1; color: var(--bubble-in-meta);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.msg.user .msg-meta { color: var(--bubble-out-meta); }
.msg-status { font-size: 11px; letter-spacing: -1.5px; }
/* "Zé está digitando…" — três bolinhas pulsando */
.msg.typing { align-self: flex-start; display: inline-flex; gap: 4px;
  align-items: center; padding: .6rem .72rem; background: var(--bubble-in);
  box-shadow: none; }
.msg.typing span { width: 7px; height: 7px; border-radius: 50%;
  background: var(--bubble-in-meta); animation: ze-typing 1.2s infinite ease-in-out; }
.msg.typing span:nth-child(2) { animation-delay: .2s; }
.msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ze-typing {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.msg.notice { align-self: center; max-width: 90%; text-align: center;
  background: var(--surface-1); border: 1px solid var(--line);
  color: var(--text-muted); font-size: var(--text-xs);
  border-radius: .875rem; padding: .55rem .8rem; }
/* guardrail: chip danger alinhado à esquerda (design premium) */
.msg.notice.danger { align-self: flex-start; text-align: left;
  background: var(--danger-bg); border: 1px solid var(--danger-bd);
  color: var(--danger); font-size: 12.5px; line-height: 1.45;
  border-radius: .875rem; padding: 10px 13px; }
/* resumo de tarefa ("✅ N ações · Xs · $Y") = chip de atividade mono central */
.msg.summary { align-self: center; color: var(--text-muted);
  font-family: var(--font-mono); font-size: 11px;
  background: var(--surface-1); border: 1px solid var(--line);
  border-radius: var(--radius-pill); padding: .32rem .8rem; }
.msg.media small { display: block; margin-top: .25rem; font-size: var(--text-xs);
  color: color-mix(in srgb, currentColor 72%, transparent); }
/* feed de atividade (o Zé "trabalhando"): linha elegante com spinner */
#chat-feed { display: flex; align-items: center; gap: .5rem; margin: .3rem auto;
  max-width: 92%; padding: .4rem .9rem;
  font-family: var(--font-mono); font-size: 11px; color: var(--text-muted);
  background: var(--surface-1); border: 1px solid var(--line);
  border-radius: var(--radius-pill); }
#chat-feed::before { content: ""; width: .8rem; height: .8rem; flex: 0 0 auto;
  border-radius: 50%; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); animation: ze-spin 1s linear infinite; }
@keyframes ze-spin { to { transform: rotate(360deg); } }
#chat-feed[hidden] { display: none; }
/* cartão de aprovação — card com cabeçalho, corpo e ações rotuladas */
#chat-approvals { padding: 0 .75rem; }
.appr-card { border: 1px solid var(--warning-bd); background: var(--surface-1);
  color: var(--text); border-radius: var(--radius-lg); padding: 0;
  overflow: hidden; margin: .5rem 0; font-size: var(--text-sm);
  box-shadow: 0 8px 20px -8px rgba(0,0,0,.7); }
[data-theme="light"] .appr-card, [data-theme="solar"] .appr-card {
  box-shadow: 0 8px 20px -8px rgba(0,0,0,.25); }
.appr-head { display: flex; align-items: center; gap: .5rem;
  padding: .6rem .8rem; background: var(--warning-bg); color: var(--warning);
  border-bottom: 1px solid var(--warning-bd);
  font-weight: 600; font-size: var(--text-sm); }
.appr-head .appr-ic { color: var(--warning-ic); display: inline-flex; }
.appr-head .appr-ic svg { width: 16px; height: 16px; }
.appr-body { padding: .75rem .8rem .1rem; }
.appr-body > *:first-child { margin-top: 0; }
.appr-body p { margin: .25rem 0; }
/* comando em mono "nu" (sem caixa), como no design */
.appr-body pre { margin: .4rem 0; background: transparent; border: 0;
  border-radius: 0; padding: 0; overflow-x: auto;
  font-family: var(--font-mono); font-size: 11px; line-height: 1.5;
  color: var(--text-muted); }
.appr-body code { font-family: var(--font-mono); }
/* ações em grade 2×2, 44px, ícone+rótulo lado a lado, cor por decisão
   (once=success, session=info, always=NEUTRO, deny=danger) */
.appr-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem;
  padding: .7rem .8rem .8rem; }
.appr-btn { display: flex; flex-direction: row; align-items: center;
  justify-content: center; gap: .4rem;
  min-height: 2.75rem; padding: .4rem .3rem; cursor: pointer;
  color: var(--text); background: transparent;
  border: 1px solid var(--border); border-radius: .7rem; }
.appr-btn .ab-emoji { font-size: 1rem; line-height: 1; display: inline-flex; }
.appr-btn .ab-emoji svg { width: 15px; height: 15px; display: block; }
.appr-btn .ab-label { font-size: 12.5px; font-weight: 600; color: inherit;
  line-height: 1; }
.appr-btn:hover { background: var(--surface-2); }
.appr-btn.ab-once { color: var(--appr-once); background: var(--appr-once-bg);
  border-color: var(--success-bd); }
.appr-btn.ab-once:hover { background: var(--success-bd); }
.appr-btn.ab-session { color: var(--appr-session);
  background: var(--appr-session-bg); border-color: var(--info-bd); }
.appr-btn.ab-session:hover { background: var(--info-bd); }
.appr-btn.ab-always { color: var(--text); background: transparent;
  border-color: var(--border); }
.appr-btn.ab-always:hover { background: var(--surface-2); }
.appr-btn.ab-deny { color: var(--appr-deny); background: var(--appr-deny-bg);
  border-color: var(--danger-bd); }
.appr-btn.ab-deny:hover { background: var(--danger-bd); }
.appr-btn.ab-deny .ab-label { color: inherit; }

/* menu clicável no chat (seletor do /model): chips discretos que enviam
   comandos — nada do botão global (accent cheio) que fica pesado em lista */
.menu-card { max-width: min(34rem, 96%); padding: .55rem .65rem .6rem; }
.menu-title { font-weight: 650; font-size: var(--text-sm); margin: 0 0 .5rem;
  color: var(--text-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.menu-row { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .35rem; }
.menu-row:last-child { margin-bottom: 0; }
.menu-btn { flex: 0 1 auto; min-height: 2.2rem; padding: .3rem .8rem;
  cursor: pointer; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: var(--text-sm); line-height: 1.25; text-align: center;
  overflow-wrap: anywhere; max-width: 100%; }
.menu-btn:hover { background: var(--surface-3); border-color: var(--accent); }
.menu-btn:active { transform: scale(.97); }

/* ---- badges de navegação (aprovações pendentes / intervenções críticas) ---- */
.nav-badge { display: inline-block; min-width: 1.15rem; padding: 0 .35rem;
  margin-left: .4rem; font-size: var(--text-xs); font-weight: 700; line-height: 1.3rem;
  text-align: center; border-radius: var(--radius-pill);
  background: var(--danger); color: var(--on-accent); vertical-align: middle; }
.bottomnav .nav-badge { position: absolute; top: 4px; margin: 0;
  transform: translateX(60%); line-height: 1.05rem; min-width: 1.05rem; }

/* ---- fila de aprovações (feature 1) ---- */
.appr-item .appr-head { display: flex; flex-wrap: wrap; gap: .5rem;
  align-items: center; margin-bottom: .5rem; }
.appr-item pre { max-height: 40vh; }

/* ---- intervenções: severidade colore a BORDA (esquerda no desktop; card
   inteiro no mobile) — sem barra solta em cima do "quando" ---- */
.iv-crit td { border-left: 3px solid var(--danger); }
.iv-warn td { border-left: 3px solid var(--warning); }
.iv-info td { border-left: 3px solid var(--info); }
@media (max-width: 640px) {
  /* no card empilhado, a cor vai na borda do card, não numa célula */
  .card > table tr.iv-crit { border-color: var(--danger); }
  .card > table tr.iv-warn { border-color: var(--warning); }
  .card > table tr.iv-info { border-color: var(--info); }
  .card > table tr.iv-crit td, .card > table tr.iv-warn td,
  .card > table tr.iv-info td { border-left: 0; }
}

/* ---- command palette (Cmd/Ctrl+K — feature 2) ---- */
.cmdk-fab { position: fixed; right: 1rem; z-index: 25;
  bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + .8rem);
  border-radius: var(--radius-pill); font-weight: 700; padding: .5rem .8rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.3); }
@media (min-width: 641px) { .cmdk-fab { bottom: 1rem; } }
.cmdk[hidden] { display: none !important; }
.cmdk { position: fixed; inset: 0; z-index: 60; display: flex;
  justify-content: center; align-items: flex-start; padding-top: 10vh; }
.cmdk-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.cmdk-box { position: relative; width: min(38rem, 92vw); background: var(--surface-1);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,.4); overflow: hidden; }
.cmdk-box input { border: 0; border-bottom: 1px solid var(--border);
  border-radius: 0; font-size: var(--text-base); padding: .8rem 1rem; }
.cmdk-list { list-style: none; margin: 0; padding: .3rem; max-height: 60vh;
  overflow-y: auto; }
.cmdk-list li { display: flex; gap: .6rem; align-items: center; padding: .5rem .6rem;
  border-radius: var(--radius-sm); font-size: var(--text-sm); cursor: pointer; }
.cmdk-list li.sel { background: var(--accent); color: var(--on-accent); }
.cmdk-list li.sel .cmdk-t { color: var(--on-accent); }
.cmdk-t { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); min-width: 4rem; }
.cmdk-empty { color: var(--text-faint); padding: .8rem; }

/* ---- busca global (feature 5) ---- */
.search-hit { padding: .5rem 0; border-top: 1px solid var(--border); }
.search-hit:first-child { border-top: 0; }
.search-snip { font-size: var(--text-sm); color: var(--text-muted);
  margin-top: .2rem; line-height: 1.5; word-break: break-word; }

/* ---- barra de progresso (custo do dia vs limite — feature 4) ---- */
.progress { height: .7rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  overflow: hidden; margin: .3rem 0; }
.progress-bar { height: 100%; background: var(--success); border-radius: inherit;
  transition: width .3s ease; }
.progress-bar.warn { background: var(--warning); }
.progress-bar.err { background: var(--danger); }
/* anexo "preso" no composer até enviar (imagem + pergunta vão juntas) */
#chat-staged { margin: .3rem .6rem 0; }
.staged-chip { display: inline-flex; align-items: center; gap: .5rem;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill); padding: .3rem .5rem .3rem .7rem;
  font-size: var(--text-sm); max-width: 100%; }
.staged-x { background: transparent; color: var(--text-muted); border: 0;
  padding: 0 .2rem; font-size: 1rem; cursor: pointer; line-height: 1; }
.staged-x:hover { color: var(--danger); background: transparent; }
/* composer estilo Telegram: pill ÚNICA com os botões DENTRO do campo */
#chat-form { display: flex; align-items: flex-end; gap: .1rem;
  margin: 8px 12px 10px;
  padding: 6px 6px 6px 14px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 1.5rem; }
#chat-form:focus-within { border-color: var(--accent); }
/* textarea segue a fonte da UI (data-font) e a densidade — NÃO o mono genérico */
#chat-text { flex: 1; min-width: 0; resize: none; overflow-y: auto;
  min-height: 2.5rem; max-height: 8rem; line-height: 1.35; padding: .62rem .5rem;
  border: 0; background: transparent; font-family: var(--font-ui);
  font-size: max(16px, 1rem); }   /* ≥16px: evita zoom no iOS + centra a 1 linha */
#chat-text:focus { outline: none; }
.chat-btn { flex: 0 0 auto; display: inline-flex; align-items: center;
  justify-content: center; width: 2.5rem; height: 2.5rem; padding: 0; border: 0;
  background: transparent; color: var(--text-muted); border-radius: 50%;
  cursor: pointer; min-height: auto; }
.chat-btn:hover { background: var(--surface-2); color: var(--text); }
.chat-btn svg { width: 22px; height: 22px; }
/* botão de AÇÃO (mic/enviar): círculo 44px preenchido com acento (design) */
.chat-btn.chat-send, #chat-mic { width: 2.75rem; height: 2.75rem;
  background: var(--accent); color: var(--on-accent); }
.chat-btn.chat-send:hover, #chat-mic:hover {
  background: var(--accent-hover); color: var(--on-accent); }
.chat-btn.chat-send svg, #chat-mic svg { width: 20px; height: 20px; }
/* troca anexar↔digitando e mic↔enviar (JS marca data-empty no form) */
#chat-form .chat-send { display: none; }
#chat-form[data-empty="0"] .chat-attach { display: none; }
#chat-form[data-empty="0"] #chat-mic { display: none; }
#chat-form[data-empty="0"] .chat-send { display: inline-flex; }
#chat-mic.recording { background: var(--danger-ic); color: #fff; }

/* seletor de emoji (com busca) — ancorado acima do composer */
.chat-emojipop { position: absolute; z-index: 20; right: .6rem; bottom: 4rem;
  width: 16rem; max-width: calc(100% - 1.2rem); background: var(--surface-1);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: .5rem; box-shadow: 0 12px 34px rgba(0,0,0,.4); }
.chat-emojipop[hidden] { display: none; }

/* dicas de comando (estilo Telegram): aparece ao digitar "/" */
.chat-cmds { position: absolute; z-index: 21; left: .6rem; right: .6rem; bottom: 4rem;
  max-height: 15rem; overflow-y: auto; background: var(--surface-1);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: .3rem; box-shadow: 0 12px 34px rgba(0,0,0,.4); }
.chat-cmds[hidden] { display: none; }
.chat-cmd { display: flex; flex-direction: column; align-items: flex-start; gap: .05rem;
  width: 100%; text-align: left; background: transparent; color: var(--text);
  border: 0; border-radius: var(--radius-sm); padding: .5rem .6rem; min-height: auto;
  cursor: pointer; }
.chat-cmd:hover, .chat-cmd.sel { background: var(--surface-2); }
.chat-cmd .cmd-name { font-family: var(--font-mono); font-size: var(--text-sm);
  color: var(--accent); font-weight: 600; }
.chat-cmd .cmd-desc { font-size: var(--text-xs); color: var(--text-muted); }
.chat-emoji-search { width: 100%; margin: 0 0 .4rem; padding: .5rem .6rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-family: var(--font-ui);
  font-size: var(--text-sm); }
.chat-emoji-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  max-height: 11rem; overflow-y: auto; }
.chat-emoji-grid button { border: 0; background: transparent; font-size: 1.25rem;
  padding: .25rem 0; border-radius: var(--radius-sm); cursor: pointer; line-height: 1;
  min-height: auto; }
.chat-emoji-grid button:hover { background: var(--surface-2); }
.chat-emoji-none { grid-column: 1 / -1; text-align: center; color: var(--text-faint);
  font-size: var(--text-xs); padding: 1rem 0; }

/* botão "rolar pro fim / não-lidas" (aparece só rolado pra cima) */
.chat-newpill { position: absolute; right: .8rem; bottom: 5rem; z-index: 15;
  display: none; align-items: center; gap: .4rem; cursor: pointer;
  padding: .4rem .7rem .4rem .55rem; background: var(--surface-1);
  border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 600; color: var(--text);
  box-shadow: 0 4px 14px rgba(0,0,0,.28); }
.chat-newpill.show { display: inline-flex; }
.chat-newpill svg { width: 15px; height: 15px; color: var(--accent); }
.chat-newpill .n { min-width: 1rem; padding: 0 .35rem; line-height: 1rem;
  background: var(--accent); color: var(--on-accent); border-radius: var(--radius-pill);
  font-size: 10px; text-align: center; }
.chat-newpill .n[hidden] { display: none; }  /* sem não-lidas: só a seta */

/* estado de conversa vazia (vira o único conteúdo do log) */
.chat-empty { display: none; flex: 1; flex-direction: column; align-items: center;
  justify-content: center; gap: .8rem; text-align: center; padding: 0 2rem;
  color: var(--text-muted); }
#chat-log.is-empty .chat-empty { display: flex; }
#chat-log.is-empty > *:not(.chat-empty) { display: none; }
.chat-empty .em-av { width: 4rem; height: 4rem; border-radius: 50%; display: grid;
  place-items: center; font-size: 2rem; background: var(--surface-2);
  border: 1px solid var(--border); }
.chat-empty h3 { margin: 0; font-size: var(--text-lg); color: var(--text); }
.chat-empty p { margin: 0; font-size: var(--text-sm); max-width: 26ch; line-height: 1.5; }

/* ============== componentes do design premium (fase 2: produto) ========= */

/* header de página (mobile): título 20/600 + sub 12 dim + ícone à direita */
.page-head { display: flex; align-items: center; gap: .75rem;
  margin: .1rem 0 .8rem; }
.page-head .ph-main { flex: 1; min-width: 0; }
.page-head .ph-title { font-size: 1.25rem; font-weight: 600;
  letter-spacing: var(--tracking-tight); margin: 0; }
.page-head .ph-title code { background: transparent; padding: 0;
  font-size: 1rem; }
.page-head .ph-sub { font-size: .75rem; color: var(--text-muted);
  margin-top: 1px; }
.page-head .ph-sub.mono { font-family: var(--font-mono); font-size: 11px; }
.page-head .ph-ic { color: var(--text-muted); display: inline-flex;
  flex: 0 0 auto; }
.page-head .ph-ic svg { width: 22px; height: 22px; }
.page-head .ph-back { color: var(--text-muted); display: inline-flex;
  flex: 0 0 auto; }
.page-head .ph-back svg { width: 22px; height: 22px; }
.page-head .ph-back:hover { color: var(--text); text-decoration: none; }
/* (o _page só emite o próprio header quando o body não traz um bespoke) */

/* barra de busca com ícone dentro (design) */
.searchbar { display: flex; align-items: center; gap: .55rem;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: .75rem; padding: 0 .8rem; margin: 0 0 .1rem; }
.searchbar svg { width: 18px; height: 18px; color: var(--text-muted);
  flex: 0 0 auto; }
.searchbar input { flex: 1; border: 0; background: transparent;
  padding: .65rem 0; min-height: auto; font-size: .875rem; }
.searchbar input:focus { outline: none; }

/* lista de linhas com tile de ícone semântico (traces, tarefas, …) */
.rlist { display: flex; flex-direction: column; gap: .5rem; }
.rrow { display: flex; align-items: center; gap: .75rem; padding: .75rem;
  border-radius: .8125rem; background: var(--surface-1);
  border: 1px solid var(--border); color: var(--text); }
a.rrow:hover { text-decoration: none; border-color: var(--accent);
  color: var(--text); }
.rtile { width: 2.375rem; height: 2.375rem; border-radius: .7rem;
  display: grid; place-items: center; flex: 0 0 auto; }
.rtile svg { width: 18px; height: 18px; }
.rtile.ok { background: var(--success-bg); border: 1px solid var(--success-bd);
  color: var(--success); }
.rtile.err { background: var(--danger-bg); border: 1px solid var(--danger-bd);
  color: var(--danger); }
.rtile.warn { background: var(--warning-bg); border: 1px solid var(--warning-bd);
  color: var(--warning-ic); }
.rtile.pii { background: var(--redacted-bg); border: 1px solid var(--redacted-bd);
  color: var(--redacted); }
.rtile.info { background: var(--info-bg); border: 1px solid var(--info-bd);
  color: var(--info); }
.rtile.neutral { background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-muted); }
/* ocupação da memória: nome à esquerda, contagem mono à direita */
.occ-row { margin: .6rem 0; }
.occ-head { display: flex; align-items: baseline; gap: .6rem;
  justify-content: space-between; margin-bottom: 4px; }
.occ-head span { font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted); }

/* rodapé do tile (atividade + ações compactas nas linhas de tarefa) */
.rfoot { flex-basis: 100%; min-width: 0; }
.rfoot small { display: block; margin-top: .35rem; font-size: 11px; }
.btn-row.rrow-actions { margin: .45rem 0 0; gap: .35rem .45rem;
  flex-direction: row; flex-wrap: wrap; align-items: center; }
.btn-row.rrow-actions button, .btn-row.rrow-actions .btn {
  min-height: 1.9rem; width: auto;
  padding: .2rem .65rem; font-size: 11px; border-radius: .5rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); }
.btn-row.rrow-actions button:hover { background: var(--surface-3); }
.btn-row.rrow-actions form.inline { width: auto; margin: 0; }
.btn-row.rrow-actions a { font-size: 11px; color: var(--text-muted); }
.rname a { color: inherit; }
.rmain { flex: 1; min-width: 0; }
.rname { font-size: .875rem; font-weight: 500; display: flex;
  align-items: center; gap: .4rem; overflow-wrap: anywhere; }
.rsub { font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted); overflow-wrap: anywhere; margin-top: 1px; }
.rside { text-align: right; flex: 0 0 auto; }
.rstatus { font-size: .75rem; }
.rstatus.ok { color: var(--success); } .rstatus.err { color: var(--danger); }
.rstatus.warn { color: var(--warning); }
.rtime { font-family: var(--font-mono); font-size: 11px;
  color: var(--text-faint); margin-top: 1px; }

/* chips de filtro (Todos / Falhas / …) */
.fchips { display: flex; gap: .45rem; flex-wrap: wrap; margin: .6rem 0 .1rem; }
.fchip { font-size: .75rem; padding: .34rem .85rem; border-radius: 999px;
  color: var(--text-muted); background: var(--surface-1);
  border: 1px solid var(--border); }
.fchip:hover { text-decoration: none; color: var(--text); }
.fchip.danger { color: var(--danger); background: var(--danger-bg);
  border-color: var(--danger-bd); }
.fchip.warning { color: var(--warning); background: var(--warning-bg);
  border-color: var(--warning-bd); }
.fchip.pii { color: var(--redacted); background: var(--redacted-bg);
  border-color: var(--redacted-bd); }
.fchip.on { background: var(--accent); color: var(--on-accent);
  border-color: var(--accent); font-weight: 600; }

/* rótulo de seção "nu" (conteúdo direto no fundo, sem card — design) */
.sec-label { font-size: .75rem; color: var(--text-muted);
  margin: 1rem 0 .5rem; }

/* grid de meta 2×2 (detalhe de trace) */
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
  background: var(--border); border: 1px solid var(--border);
  border-radius: .8125rem; overflow: hidden; margin: .2rem 0 .6rem; }
.meta-cell { background: var(--surface-1); padding: .7rem .8rem; }
.meta-k { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-faint); }
.meta-v { font-family: var(--font-mono); font-size: .8125rem; margin-top: 2px;
  overflow-wrap: anywhere; }
.meta-v.accent { color: var(--accent); }

/* bloco JSON mono colorido (chaves=info, strings=success) */
.json-block { font-family: var(--font-mono); font-size: .75rem;
  line-height: 1.65; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: .75rem; padding: .8rem;
  overflow-x: auto; margin: .4rem 0; white-space: pre-wrap;
  overflow-wrap: anywhere; }
.json-block .jk { color: var(--info); }
.json-block .js { color: var(--success); }

/* métrica grande (observabilidade) */
.metric-big { font-size: 2rem; font-weight: 600;
  letter-spacing: var(--tracking-tight); margin: .2rem 0 .1rem; }
.metric-sub { font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted); }
.metric-delta { font-size: .75rem; }

/* barras de custo por dia (a de hoje em acento) */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 66px;
  margin-top: 1rem; }
.bars i { flex: 1; background: var(--surface-2); border-radius: 4px 4px 0 0;
  min-height: 2px; }
.bars i.hoje { background: var(--accent); }
.bars-l { display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 9.5px; color: var(--text-faint);
  margin-top: 6px; }
.bars-l span { flex: 1; text-align: center; }

/* quebra por provider: monograma + barra de participação + valor mono */
.prov-row { display: flex; align-items: center; gap: .7rem; margin: .85rem 0; }
.prov-mono { width: 1.75rem; height: 1.75rem; border-radius: .5rem;
  color: #fff; font-weight: 700; font-size: .8125rem; display: grid;
  place-items: center; flex: 0 0 auto; }
.prov-main { flex: 1; min-width: 0; }
.prov-head { display: flex; justify-content: space-between;
  font-size: .8125rem; margin-bottom: 5px; }
.prov-head .v { font-family: var(--font-mono); color: var(--text-muted); }
.prov-bar { height: 6px; border-radius: 999px; background: var(--surface-2);
  overflow: hidden; }
.prov-bar > i { display: block; height: 100%; background: var(--accent);
  border-radius: 999px; }

/* título + descrição de seção (padrão único da página de config) */
.sec-title { font-size: .875rem; font-weight: 600;
  letter-spacing: var(--tracking-tight); margin: 0 0 3px; }
.sec-title .soft { font-weight: 400; color: var(--text-muted); }
.sec-desc { font-size: .75rem; color: var(--text-muted); line-height: 1.45;
  margin: 0 0 12px; }
/* campos empilhados: respiro entre um .fld e o próximo rótulo */
.fld + .lbl, .fld-gap { margin-top: 10px; }
/* botão de largura total (padrão do design p/ ação de card) */
.btn-full { width: 100%; min-height: 2.75rem; margin-top: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13.5px; }
button.ghost.btn-full { background: transparent;
  border: 1px solid var(--border); color: var(--text); }
button.ghost.btn-full:hover { background: var(--surface-2); }
/* grade 2-col de campos (desktop); empilha no mobile */
.fgrid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .fgrid2 { grid-template-columns: 1fr; } }

/* ícone inline de 16-18px (banner, headers de card) */
.ic18 { display: inline-flex; flex: 0 0 auto; }
.ic18 svg { width: 18px; height: 18px; }
.ic16 { display: inline-flex; flex: 0 0 auto; }
.ic16 svg { width: 16px; height: 16px; }
/* guarda: svg dentro de botão nunca fica sem tamanho (classes específicas
   como .chat-btn/.ab-emoji vencem por especificidade) */
button svg, .btn svg { width: 18px; height: 18px; }

/* empty state (design): ícone 72px em card + título + texto + CTA + link */
.empty-state { display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 40px 24px; gap: 6px; }
.empty-state .es-icon { width: 72px; height: 72px; border-radius: 20px;
  background: var(--surface-1); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--text-muted);
  margin-bottom: 8px; }
.empty-state .es-icon svg { width: 34px; height: 34px; }
.empty-state .es-title { font-size: 1rem; font-weight: 600;
  letter-spacing: var(--tracking-tight); }
.empty-state .es-text { font-size: .8125rem; color: var(--text-muted);
  line-height: 1.5; max-width: 240px; }
.empty-state .es-cta { display: inline-flex; align-items: center; gap: 8px;
  min-height: 2.75rem; padding: 0 22px; margin-top: 14px;
  border-radius: .7rem; font-weight: 600; font-size: 13.5px; }
.empty-state .es-cta svg { width: 17px; height: 17px; }
.empty-state .es-cta:hover { text-decoration: none; }
.empty-state .es-link { color: var(--text-muted); font-size: 12.5px;
  padding: 8px; margin-top: 2px; }

/* tabela de tiers do design (flex rows, monograma, mono) */
.tiers-box { border: 1px solid var(--border); border-radius: .75rem;
  overflow: hidden; background: var(--surface-1); }
.tiers-grid { width: max-content; min-width: 100%; font-size: 12.5px; }
.trow-p { display: flex; align-items: center;
  border-top: 1px solid var(--line); }
.trow-p:first-child { border-top: 0; }
.trow-p.thead { background: var(--surface-2); font-weight: 600;
  font-size: 11px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .06em; }
.tc-tier { width: 78px; padding: 9px 10px; flex-shrink: 0; }
.tc-n { width: 34px; padding: 9px 6px; flex-shrink: 0;
  font-family: var(--font-mono); }
.tc-model { flex: 1 0 auto; padding: 9px 10px; font-family: var(--font-mono);
  font-size: 11.5px; white-space: nowrap; }
.tc-model .tc-cost { display: block; font-size: 10px;
  color: var(--text-faint); margin-top: 1px; }
.tc-api { width: 60px; padding: 9px 10px; flex-shrink: 0; display: flex;
  align-items: center; gap: 3px; }
.tc-act { width: 72px; padding: 9px 8px 9px 0; flex-shrink: 0; display: flex;
  gap: 4px; justify-content: flex-end; }
.trow-p.thead .tc-act, .trow-p.thead .tc-api { font-size: 11px; }
button.tiny, .btn.tiny { min-height: 1.7rem; width: auto; padding: 0 .5rem;
  font-size: 11px; border-radius: .45rem; }
.fld button.tiny { flex: 0 0 auto; background: var(--surface-3);
  color: var(--text-muted); }
.fld button.tiny:hover { background: var(--accent); color: var(--on-accent); }
/* card de segredo (API key): borda orquídea do token --secret */
.card.secret-card { border-color: var(--secret); }

/* bottom sheet (seletor /model no chat; reutilizável) */
.sheet-wrap { position: fixed; inset: 0; z-index: 65; }
.sheet-wrap[hidden] { display: none !important; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(0,0,0,.5);
  backdrop-filter: blur(1px); -webkit-backdrop-filter: blur(1px); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--surface-1); border-top: 1px solid var(--border);
  border-radius: 1.375rem 1.375rem 0 0;
  padding: .6rem 1rem calc(env(safe-area-inset-bottom) + 1.1rem);
  box-shadow: 0 -22px 44px -18px rgba(0,0,0,.85);
  max-height: 78vh; overflow-y: auto; animation: ze-sheet-in .2s ease; }
@keyframes ze-sheet-in { from { transform: translateY(100%); }
  to { transform: translateY(0); } }
.sheet-handle { width: 38px; height: 4px; border-radius: 999px;
  background: var(--border-strong); margin: .15rem auto .9rem; }
.sheet-title { display: flex; align-items: center;
  justify-content: space-between; font-size: 1.05rem; font-weight: 600;
  letter-spacing: var(--tracking-tight); }
.sheet-x { width: 2rem; height: 2rem; border: 0; background: transparent;
  color: var(--text-muted); border-radius: 50%; cursor: pointer;
  min-height: auto; font-size: 1rem; padding: 0; }
.sheet-x:hover { background: var(--surface-2); color: var(--text); }
.sheet-sub { font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted); margin: .15rem 0 .9rem; white-space: pre-wrap;
  overflow-wrap: anywhere; }
.sheet-rows { display: flex; flex-direction: column; gap: .5rem; }
.sheet-row { display: flex; align-items: center; justify-content: center;
  gap: .5rem; width: 100%; text-align: center; padding: .7rem .75rem;
  border-radius: .75rem; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); font: inherit; font-size: .875rem; font-weight: 500;
  cursor: pointer; min-height: 2.75rem; overflow-wrap: anywhere; }
.sheet-row:hover { border-color: var(--accent); background: var(--bg); }
/* tile de provider: monograma + nome + sub mono; selecionado com check */
.sheet-row.tile { justify-content: flex-start; text-align: left;
  gap: .7rem; padding: 11px 12px; }
.sheet-row.tile.sel { border-color: var(--accent); }
.sheet-mono { width: 2rem; height: 2rem; border-radius: .5625rem;
  color: #fff; font-weight: 700; font-size: .9375rem; display: grid;
  place-items: center; flex: 0 0 auto; background: var(--surface-3); }
.sheet-main { flex: 1; min-width: 0; }
.sheet-name { display: block; font-size: .875rem; font-weight: 500; }
.sheet-msub { display: block; font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted); margin-top: 1px; }
.sheet-check { color: var(--accent); flex: 0 0 auto; display: inline-flex; }
.sheet-check svg { width: 20px; height: 20px; }
@media (min-width: 641px) {   /* desktop: vira um cartão central */
  .sheet { left: 50%; right: auto; bottom: 2.5rem; width: 26rem;
    transform: translateX(-50%); border: 1px solid var(--border);
    border-radius: 1.375rem; animation: none; }
}

/* ---- a11y / motion ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px;
  border-radius: 2px; }
html { transition: background-color .2s ease; }
.card, button, .btn, th, td, .theme-toggle a { transition:
  background-color .2s ease, color .2s ease, border-color .2s ease; }
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { transition: none !important; animation: none !important; }
}

/* =========================================================== MOBILE ===== */
@media (max-width: 640px) {
  main { margin: .5rem auto var(--bottomnav-h);
    padding: 0 .7rem calc(env(safe-area-inset-bottom) + .5rem); }
  /* título agora vem do .page-head (design) — visível também no mobile */
  /* chat = tela cheia estilo Telegram: card FIXO entre o topo e a bottom nav,
     fora do fluxo → o body não rola (fim do 2º scrollbar); só #chat-log rola.
     :has neutraliza as margens do main que antes empurravam o card p/ fora. */
  main:has(.chat-card) { margin: 0; padding: 0; }
  .chat-card {
    position: fixed; left: 0; right: 0; top: 0;
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    height: auto; margin: 0; border: 0; border-radius: 0; padding: 0;
  }
  /* ⌘K é atalho de teclado: sem sentido no mobile e ainda tampava o enviar */
  .cmdk-fab { display: none; }

  /* bottom nav: 4 primárias + Mais, fixa, zona do polegar */
  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--header); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a, .bottomnav label {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; min-height: var(--bottomnav-h);
    color: var(--text-faint); font-size: .66rem; text-decoration: none;
    cursor: pointer; padding: .3rem 0; position: relative;
  }
  .bottomnav svg { width: 22px; height: 22px; transition: none; }
  /* tela selecionada: ícone PREENCHIDO (variante fill própria) + acento */
  .bottomnav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
  .bottomnav a[aria-current="page"] svg { color: var(--accent); }

  /* sheet "Mais" (CSS-only via checkbox) */
  .navsheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,.5); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
    backdrop-filter: blur(1.5px); -webkit-backdrop-filter: blur(1.5px);
  }
  /* menu "Seções" (ZeMenu): sheet 22px + alça + grade de itens com ícone */
  .navsheet {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
    background: var(--surface-1); border-top: 1px solid var(--border);
    border-radius: 1.375rem 1.375rem 0 0;
    box-shadow: 0 -22px 44px -18px rgba(0,0,0,.7);
    padding: 10px 14px calc(env(safe-area-inset-bottom) + 18px);
    transform: translateY(100%); transition: transform .2s ease;
    max-height: calc(100vh - 74px); overflow-y: auto;
  }
  .navsheet-handle { width: 38px; height: 4px; border-radius: 999px;
    background: var(--border); margin: 2px auto 12px; }
  .navsheet-head { display: flex; align-items: center;
    justify-content: space-between; padding: 0 2px; }
  .navsheet-head .nh-title { font-weight: 600; font-size: 18px;
    letter-spacing: -0.01em; }
  .navsheet-head .sheet-x { display: grid; place-items: center; }
  .navsheet-sub { font-size: 12px; color: var(--text-muted);
    margin: 2px 2px 12px; }
  .navsheet .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .navsheet .mi { display: flex; align-items: center; gap: 12px;
    padding: 11px; border-radius: .875rem; background: var(--surface-1);
    border: 1px solid var(--border); color: var(--text); min-height: 60px; }
  .navsheet .mi:hover { text-decoration: none; border-color: var(--accent); }
  .navsheet .mt { width: 38px; height: 38px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; background: var(--tint-bg); color: var(--tint); }
  .navsheet .mt svg { width: 21px; height: 21px; fill: none;
    stroke: currentColor; stroke-width: 1.7; stroke-linecap: round;
    stroke-linejoin: round; }
  .navsheet .ml { font-size: 13.5px; font-weight: 500; line-height: 1.15;
    min-width: 0; }
  .navsheet .ml .nav-badge { position: static; transform: none;
    margin-left: .35rem; }
  .navsheet-toggle { display: none; }
  .navsheet-toggle:checked ~ .navsheet-backdrop { opacity: 1; pointer-events: auto; }
  .navsheet-toggle:checked ~ .navsheet { transform: translateY(0); }

  /* tabelas viram CARDS empilhados. `.card > table` (filho direto) exclui
     naturalmente as que estão em .table-scroll (pai = a div wrapper). */
  .card > table thead, table.stack thead { position: absolute; left: -9999px; }
  .card > table tr, table.stack tr {
    display: block; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--surface-2);
    margin-bottom: .55rem; padding: .3rem .55rem;
  }
  .card > table td, table.stack td {
    display: flex; justify-content: flex-start; gap: 1rem;
    border: 0; padding: .3rem 0; text-align: left;
    min-width: 0; word-break: break-word; overflow-wrap: anywhere;
  }
  /* rótulo EM CIMA (minúsculo, esmaecido) + valor EMBAIXO à esquerda — SÓ
     quando o JS marcou data-label. Empilhar (não label-esq/valor-dir) porque
     texto longo (descrição, gatilho, "o que barrou") alinhado à direita fica
     ilegível, colado na borda. */
  .card > table td[data-label], table.stack td[data-label] {
    flex-direction: column; align-items: stretch; gap: .1rem; text-align: left;
  }
  .card > table td[data-label]::before, table.stack td[data-label]::before {
    content: attr(data-label); color: var(--text-faint);
    font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
    text-align: left;
  }
  .card > table td:empty { display: none; }
  /* th de LINHA (ex: tabela de replay usa <th> como 1ª célula do corpo) */
  .card > table tbody th, table.stack tbody th {
    display: block; text-align: left; background: transparent; border: 0;
    padding: .3rem 0;
  }

  /* tabela genuinamente larga: mantém scroll contido, não vira card */
  .table-scroll table { display: table; width: max-content; min-width: 100%; }
  .table-scroll thead { position: static; }
  .table-scroll tr, .table-scroll td { display: table-row; }
  .table-scroll td { display: table-cell; text-align: left; padding: .3rem .45rem; }
  .table-scroll td::before { content: none; }
  .scroll-hint { display: block; }

  pre { font-size: var(--text-xs); }
  .form-grid { grid-template-columns: 1fr; }

  /* botões e formulários de linha empilham em coluna, largura total */
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-row form.inline { width: 100%; margin: 0; }
  .btn-row button, .btn-row .btn { width: 100%; }
  .form-row { flex-direction: column; align-items: stretch; }
  .form-row label { width: 100%; }
  .form-row input[type=text], .form-row input[type=password],
  .form-row input[type=number], .form-row select, .form-row button,
  .form-row .btn { width: 100%; }

  /* alvos de toque ≥44px por LARGURA (não só pointer:coarse): garante o mínimo
     no mobile mesmo em navegadores/densidades que reportam pointer:fine. O
     seletor cobre input SEM type (default text) — `input[type=text]` sozinho
     não casa `<input name=...>` sem type. Regras do chat vencem por classe. */
  button, .btn { min-height: 2.75rem; }
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]):not([type=color]):not([type=hidden]),
  select, textarea { min-height: 2.75rem; font-size: max(16px, 1rem); }
  /* formulários inline soltos (ex.: /models "modelo fixo") empilham e enchem
     a linha — nada de select/botão espremidos lado a lado */
  form.inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: stretch; }
  form.inline > select, form.inline > input[type=text],
  form.inline > input[type=number] { flex: 1 1 100%; }
  form.inline > button, form.inline > .btn { flex: 1 1 100%; }

  /* avatar (/settings): input de arquivo nativo é largo e estourava a borda;
     empilha e enche a linha, com os botões abaixo em largura total */
  .avatar-row { flex-direction: column; align-items: stretch; }
  .avatar-row input, .avatar-row button, .avatar-emoji-in { width: 100%; }
  .avatar-quick-b { min-height: 2.6rem; min-width: 2.9rem; font-size: 1.35rem; }
}

/* input de arquivo nativo nunca estoura o container (qualquer viewport) */
input[type=file] { max-width: 100%; box-sizing: border-box; }

/* desktop: garante que bottom nav/sheet fiquem escondidos */
@media (min-width: 641px) {
  .bottomnav, .navsheet, .navsheet-backdrop { display: none !important; }
}

/* alvos de toque ≥44px e fonte ≥16px nos campos (evita zoom iOS) */
@media (pointer: coarse) {
  button, .btn { min-height: 2.75rem; padding: .55rem 1rem; }
  input[type=text], input[type=password], input[type=number], select, textarea {
    font-size: max(16px, 1rem); min-height: 2.75rem;   /* nunca <16px: sem zoom iOS */
  }
  .theme-toggle a { padding: 7px 11px; }
}

/* ============ PWA / chat Fase B ============ */
/* aviso de sem-conexão (some sozinho ao reconectar) */
.offline-bar { background: var(--warning-bg); border: 1px solid var(--warning);
  color: var(--text); border-radius: var(--radius-sm); padding: .4rem .7rem;
  margin: .4rem .6rem 0; font-size: var(--text-xs); }

/* busca DENTRO da conversa (barra sob o header) */
.chat-search { margin: 0; padding: .5rem .6rem; background: var(--surface-1);
  border-bottom: 1px solid var(--border); }
.chat-search-form { display: flex; gap: .4rem; align-items: center; }
.chat-search-form input { flex: 1; min-width: 0; font-family: var(--font-ui);
  font-size: max(16px, 1rem); padding: .5rem .7rem; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); }
.chat-search-form .chat-btn { width: 2.4rem; height: 2.4rem; }
.chat-search-results { margin-top: .5rem; max-height: 42vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .2rem .6rem; background: var(--surface-1); }
.chat-search-results[hidden] { display: none; }
/* cada resultado é um botão que ocupa a linha toda, alinhado à esquerda */
.chat-search-results .search-hit { display: block; width: 100%; text-align: left;
  background: transparent; color: var(--text); border-radius: 0;
  font-size: var(--text-sm); cursor: pointer; }
.chat-search-results .search-hit:hover { background: var(--surface-2); }
.chat-search-results .search-when { display: block; margin-top: .2rem;
  color: var(--text-faint); font-size: 10px; }
.muted { color: var(--text-faint); font-size: var(--text-sm); }

/* janela de contexto do resultado ('pular pra') — overlay igual ao command palette */
.ctx-overlay { position: fixed; inset: 0; z-index: 70; display: flex;
  justify-content: center; align-items: center; padding: 1rem;
  background: rgba(0,0,0,.5); }
.ctx-box { position: relative; width: min(40rem, 94vw); max-height: 80vh;
  overflow-y: auto; display: flex; flex-direction: column; gap: .45rem;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.4);
  padding: .8rem; }
.ctx-head { display: flex; justify-content: space-between; align-items: center;
  font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); }
.ctx-close { background: transparent; color: var(--text-muted); border: 0;
  font-size: 1.1rem; padding: 0 .3rem; }
.ctx-close:hover { background: transparent; color: var(--text); }
.ctx-hit { outline: 2px solid var(--accent); }

/* ===================================================== TEMAS (Fase 2) ==== */
/* galeria de temas + construtor de tema custom (/themes) */
/* galeria de temas (design premium): card com mini-preview do chat */
.theme-gallery { display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.tcard { background: var(--surface-1); border: 1px solid var(--border);
  border-radius: .875rem; padding: 0; position: relative; overflow: hidden;
  text-decoration: none; color: var(--text); display: block; }
.tcard:hover { border-color: var(--border-strong); }
.tcard.active { border: 1.5px solid var(--accent);
  box-shadow: 0 0 0 3px var(--success-bg); }
.tcard .tick { position: absolute; top: 8px; right: 8px; z-index: 2;
  color: var(--accent); display: none; }
.tcard .tick svg { width: 18px; height: 18px; }
.tcard.active .tick { display: inline-flex; }
.tprev { padding: 12px; overflow: hidden; }
.tprev .b { display: inline-block; max-width: 86%;
  padding: 5px 9px; border-radius: 11px 11px 11px 4px;
  font-size: 10.5px; line-height: 1.25; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.tprev .me-row { text-align: right; margin-top: 6px; }
.tprev .b.me { border-radius: 11px 11px 4px 11px; }
.tfoot { display: flex; align-items: center; gap: 7px; padding: 9px 11px;
  background: var(--surface-1); }
.tfoot .sw { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.tfoot .nm { font-size: 13px; font-weight: 500; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; flex: 1; }
.tfoot .tag { font-size: 10px; padding: 2px 6px; border-radius: 5px;
  background: var(--surface-2); color: var(--text-muted); flex: none; }
.tfoot .tag.novo { color: var(--accent); background: var(--success-bg);
  border: 1px solid var(--success-bd); padding: 1px 6px; }
.tcard .tdel { position: absolute; top: 6px; left: 6px; z-index: 2;
  width: 1.3rem; height: 1.3rem; padding: 0; border: 0; border-radius: 50%;
  cursor: pointer; background: var(--surface-3); color: var(--text-muted);
  font-size: .8rem; line-height: 1; display: none; align-items: center;
  justify-content: center; }
.tcard:hover .tdel, .tcard.active .tdel { display: flex; }
.tcard .tdel:hover { background: var(--danger); color: #fff; }
.tcard.add { display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; border: 1.5px dashed var(--border);
  min-height: 132px; color: var(--text-muted); font-weight: 500;
  font-size: 12px; }
.tcard.add .plus { font-size: 24px; line-height: 1; color: var(--text-muted); }

/* bloco de tokens do tema ativo + campos do design (lbl/fld) */
.tok-block { font-family: var(--font-mono); font-size: 11px; line-height: 1.65;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: .75rem; padding: 12px; color: var(--text-muted);
  overflow-wrap: anywhere; }
.tok-block .tk { color: var(--info); }
.tok-block .tv-accent { color: var(--accent); }
.tok-block .faint { color: var(--text-faint); margin-top: 4px; }
/* fase 4: rótulo uppercase com tracking (padrão de TODA tela de config) */
.lbl { font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 5px; display: block; }
/* par rótulo/valor em pilha (regras, intervenções, checkpoints…) */
.kv { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-faint); }
.kv-v { font-size: .875rem; margin: 2px 0 12px; overflow-wrap: anywhere; }
.kv-v.mono { font-family: var(--font-mono); }
/* sub-card (bloco surf2 dentro de card) */
.subcard { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: .75rem; padding: 14px; }
/* checkbox nativo na cor do design */
input[type=checkbox], input[type=radio] { accent-color: var(--info); }
/* botões de ação de tarefa (ZeAgente): outline 40px, ícone colorido */
.tb { min-height: 40px; padding: 0 14px; border: 1px solid var(--border);
  border-radius: 10px; background: transparent; color: var(--text);
  font-weight: 500; font-size: 12.5px; display: inline-flex;
  align-items: center; gap: 6px; width: auto; }
.tb:hover { background: var(--surface-2); }
.tb .tb-ic { display: inline-flex; }
.tb .tb-ic svg { width: 14px; height: 14px; }
.tb.tb-ok { border-color: var(--success-bd); background: var(--success-bg);
  color: var(--success); }
.tb.tb-ok:hover { background: var(--success-bd); }
.tb.tb-danger { border-color: var(--danger-bd); background: var(--danger-bg);
  color: var(--danger); }
.tb.tb-danger:hover { background: var(--danger-bd); }
.task-actions { margin-top: 12px; }
/* chips de filtro com tinta semântica (tarefas) */
.fchip.t-info { color: var(--info); background: var(--info-bg);
  border-color: var(--info-bd); }
.fchip.t-warn { color: var(--warning); background: var(--warning-bg);
  border-color: var(--warning-bd); }
.fchip.t-ok { color: var(--success); background: var(--success-bg);
  border-color: var(--success-bd); }
.fchip.t-danger { color: var(--danger); background: var(--danger-bg);
  border-color: var(--danger-bd); }
.task-card { margin: 0; }
.task-card a:hover { text-decoration: none; color: var(--accent); }

/* pills de status com ícone (home) */
.stat-pill { font-family: var(--font-mono); font-size: 11.5px;
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 5px 11px; }
.stat-pill svg { width: 13px; height: 13px; }
.stat-pill.ok { color: var(--success); background: var(--success-bg);
  border: 1px solid var(--success-bd); }
.stat-pill.info { color: var(--info); background: var(--info-bg);
  border: 1px solid var(--info-bd); }
.stat-pill.warn { color: var(--warning); background: var(--warning-bg);
  border: 1px solid var(--warning-bd); }
.fld { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: .7rem; padding: 0 13px; min-height: 46px; display: flex;
  align-items: center; font-size: .875rem; gap: .5rem; }
.fld input, .fld select { border: 0; background: transparent; padding: 0;
  min-height: 44px; width: 100%; font-size: .875rem; }
.fld input:focus, .fld select:focus { outline: none; }
.fld.mono input { font-family: var(--font-mono); font-size: 12.5px; }

/* construtor */
.builder { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 640px) { .builder { grid-template-columns: 1fr; } }
.bfield { margin-bottom: .85rem; }
.bfield:last-of-type { margin-bottom: 0; }
.blabel { display: flex; align-items: center; justify-content: space-between;
  font-size: var(--text-sm); font-weight: 550; margin-bottom: .35rem; }
.blabel .h { font-weight: 400; color: var(--text-faint); font-size: var(--text-xs); }
.brow { display: flex; align-items: center; gap: .6rem; }
.brow input[type=color] { -webkit-appearance: none; appearance: none; width: 2.8rem;
  height: 2.1rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: none; padding: 0; cursor: pointer; flex: none; min-height: auto; }
.brow input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.brow input[type=color]::-webkit-color-swatch { border: none; border-radius: 4px; }
.brow .hx { font-family: var(--font-mono); font-size: var(--text-sm);
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .3rem .55rem; width: 6rem; text-align: center; }
.bseg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.bseg button { border: 0; background: none; color: var(--text-muted);
  font-family: var(--font-ui); font-size: var(--text-sm); font-weight: 550;
  padding: .3rem .8rem; border-radius: var(--radius-sm); cursor: pointer; min-height: auto; }
.bseg button.on { background: var(--surface-1); color: var(--text); }
.bname { width: 100%; margin-top: .3rem; font-family: var(--font-ui);
  font-size: var(--text-base); color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .65rem; }
.bname:focus { outline: none; border-color: var(--accent); }
.bsave { width: 100%; margin-top: .8rem; }
.bsave:disabled { opacity: .45; cursor: not-allowed; }

/* preview ao vivo */
.blive { border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.blive-bar { display: flex; align-items: center; gap: .55rem; padding: .55rem .75rem;
  font-size: var(--text-sm); }
.blive-av { width: 1.7rem; height: 1.7rem; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: .85rem; flex: none; }
.blive-chat { padding: .8rem; display: flex; flex-direction: column; gap: .4rem;
  min-height: 11rem; }
.blive .b { max-width: 82%; padding: .35rem .6rem; border-radius: .8rem; font-size: var(--text-sm);
  line-height: 1.35; }
.blive .b.ze { align-self: flex-start; border-bottom-left-radius: .2rem; }
.blive .b.me { align-self: flex-end; border-bottom-right-radius: .2rem; }
.blive-comp { display: flex; align-items: center; gap: .5rem; padding: .5rem .65rem;
  border-top: 1px solid rgba(128,128,128,.18); }
.blive-in { flex: 1; font-size: var(--text-xs); padding: .35rem .7rem; border-radius: var(--radius-pill); }
.blive-send { width: 1.9rem; height: 1.9rem; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: .85rem; }

/* leitura AA */
.baa { margin-top: .8rem; display: flex; flex-direction: column; gap: .4rem; }
.baa-row { display: flex; align-items: center; gap: .5rem; font-size: var(--text-sm); }
.baa-row .nm { color: var(--text-muted); flex: 1; }
.baa-row .rt { font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text-faint); min-width: 3.2rem; text-align: right; }
.baa-chip { font-size: 10px; font-weight: 600; padding: 1px .5rem;
  border-radius: var(--radius-pill); min-width: 4rem; text-align: center; }
.baa-chip.ok { background: var(--success-bg); color: var(--success); }
.baa-chip.bad { background: var(--danger-bg); color: var(--danger); }
.bwarn { margin-top: .7rem; font-size: var(--text-sm); color: var(--danger);
  background: var(--danger-bg); border: 1px solid var(--danger);
  border-radius: var(--radius-sm); padding: .5rem .65rem; display: none; }
.bwarn.show { display: block; }
.bderived { margin-top: .7rem; font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--text-faint); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .55rem .65rem; line-height: 1.7;
  word-break: break-all; }
.bderived b { color: var(--text-muted); font-weight: 600; }
