/* app.css — X1 OS (PWA). Mobile-first (360–430 px), bom também no desktop.
   Identidade: design system do ChatGPT. Cores, cantos, tamanhos e sombras vêm do pacote oficial @openai/apps-sdk-ui 0.2.2
   (licença MIT), resolvidos em valores fixos. A base é neutra; a cor de destaque é o azul da marca X1 (o da landing): botão principal,
   filtro escolhido, enviar, links, foco, e o gradiente na tela de entrada e na saudação da conversa. Referência: docs/DESIGN-SYSTEM.md.
   Tema: claro por padrão; a pessoa pode trocar para o escuro ou seguir o aparelho em Ajustes.
   Sem estilos inline no HTML/JS: tudo aqui (a CSP do servidor proíbe style inline). */

:root {
  color-scheme: dark;
  --bg: #212121;
  --sidebar: #181818;
  --surface: #212121;
  --surface-2: #303030;
  --surface-3: #393939;
  --elevated: #303030;
  --border: rgba(255, 255, 255, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.2);
  --border-focus: rgba(255, 255, 255, 0.5);
  --text: #ffffff;
  --muted: #afafaf;
  --faint: #8f8f8f;
  --link: #a8adff;
  --focus: #7c86ff;
  --danger: #ff6764;
  --danger-solid: #e02e2a;
  --danger-solid-hover: #ba2623;
  --danger-bg: rgba(250, 66, 62, 0.16);
  --ok: #40c977;
  --ok-bg: rgba(4, 184, 76, 0.15);
  --warn: #ff8549;
  --warn-bg: rgba(251, 106, 34, 0.16);
  --link-bg: rgba(124, 128, 255, 0.2);
  --info-bg: rgba(255, 255, 255, 0.08);
  --hover: rgba(255, 255, 255, 0.08);
  --active: rgba(255, 255, 255, 0.12);
  --btn-bg: #4f63f0;
  --btn-bg-hover: #3f52d6;
  --btn-text: #ffffff;
  --btn-grad: linear-gradient(135deg, #5d62f3, #4355e3);
  --brand-bed: radial-gradient(120% 130% at 16% 8%, #b9beff 0%, #6d6ff5 26%, #4f63f0 52%, #2c2a6e 100%);
  --seg-bg: #0d0d0d;
  --seg-thumb: #303030;
  --user-bubble: #303030;
  --bar: #6d7bf5;
  --backdrop: rgba(0, 0, 0, 0.5);
  --shadow-100: 0 1px 2px -1px rgba(0, 0, 0, 0.2);
  --shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.3), 0 4px 8px -2px rgba(0, 0, 0, 0.36);
  --radius: 12px;
  --r-control: 10px;
  --font: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "Noto Sans", Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f9f9f9;
  --surface: #ffffff;
  --surface-2: #f3f3f3;
  --surface-3: #ededed;
  --elevated: #ffffff;
  --border: rgba(13, 13, 13, 0.1);
  --border-subtle: rgba(13, 13, 13, 0.05);
  --border-strong: rgba(13, 13, 13, 0.16);
  --border-focus: rgba(13, 13, 13, 0.5);
  --text: #0d0d0d;
  --muted: #5d5d5d;
  --link: #4355e3;
  --focus: #4f63f0;
  --danger: #ba2623;
  --danger-bg: rgba(250, 66, 62, 0.08);
  --ok: #00692a;
  --ok-bg: rgba(4, 184, 76, 0.12);
  --warn: #923b0f;
  --warn-bg: rgba(251, 106, 34, 0.1);
  --link-bg: rgba(79, 99, 240, 0.1);
  --info-bg: rgba(13, 13, 13, 0.06);
  --hover: rgba(13, 13, 13, 0.06);
  --active: rgba(13, 13, 13, 0.1);
  --btn-bg: #4f63f0;
  --btn-bg-hover: #3f52d6;
  --btn-text: #ffffff;
  --bar: #4f63f0;
  --seg-bg: #ededed;
  --seg-thumb: #ffffff;
  --user-bubble: #f3f3f3;
  --backdrop: rgba(0, 0, 0, 0.3);
  --shadow-100: 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.12), 0 4px 8px -2px rgba(0, 0, 0, 0.1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
h1, h2, h3 { line-height: 1.3; margin: 0 0 0.5rem; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--link); text-decoration: none; }
a:not([class]):hover { text-decoration: underline; }
strong, b { font-weight: 600; }
img { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: 0.5; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--elevated); color: var(--text); padding: 10px 14px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); letter-spacing: 0.08em; }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.icon { flex: none; }
.noscript { padding: 24px; }
.boot { display: grid; place-items: center; min-height: 100dvh; color: var(--muted); }

/* logos: troca pela versão do tema */
.logo-for-light { display: none; }
:root[data-theme="light"] .logo-for-dark { display: none; }
:root[data-theme="light"] .logo-for-light { display: inline-block; }

/* ───────── botões e campos ───────── */
/* Botão padrão = contorno; primário = sólido neutro (quase preto no claro, quase branco no escuro), como no ChatGPT. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: var(--r-control); border: 1px solid var(--border-strong);
  background: transparent; color: var(--text); font-weight: 500; text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled) { background: var(--active); }
.btn-primary { background: var(--btn-bg); border-color: transparent; color: var(--btn-text); }
.btn-primary:hover:not(:disabled), .btn-primary:active:not(:disabled) { background: var(--btn-bg-hover); }
.btn-ghost { border-color: transparent; }
.btn-danger { background: var(--danger-solid); border-color: transparent; color: #fff; }
.btn-danger:hover:not(:disabled), .btn-danger:active:not(:disabled) { background: var(--danger-solid-hover); }
.btn-danger-ghost { border-color: transparent; color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-bg); }
.btn-small { min-height: 44px; padding: 0 12px; font-size: 0.875rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: none; color: var(--link); padding: 0 6px; font-weight: 400; text-decoration: none; }
.btn-link:hover:not(:disabled) { background: none; text-decoration: underline; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-control);
  border: none; background: transparent; color: var(--muted);
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.link { display: inline-flex; gap: 6px; align-items: center; }

.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-control); border: 1px solid var(--border-strong);
  background: transparent; color: var(--text); transition: border-color 0.15s;
}
.input::placeholder { color: var(--faint); opacity: 1; }
.input:hover:not(:disabled) { border-color: var(--border-focus); }
.input:focus-visible { outline: none; border-color: var(--border-focus); }
.select { appearance: auto; }
.select-small { width: auto; }
.input-code { font-family: var(--mono); font-size: 1.6rem; letter-spacing: 0.4em; text-align: center; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 500; font-size: 0.875rem; margin-bottom: 6px; }
.field-check { display: flex; align-items: center; gap: 10px; }
.field-check input { width: 22px; height: 22px; flex: none; accent-color: var(--btn-bg); }
.field-check label { margin: 0; font-weight: 400; font-size: 1rem; }
.help { color: var(--muted); font-size: 0.8125rem; margin: 6px 0 0; }
.form-error { color: var(--danger); background: var(--danger-bg); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 12px; font-size: 0.875rem; }
.form-error .btn { display: flex; width: fit-content; margin-top: 8px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }

/* selo: fundo suave + texto da cor, sem contorno */
.badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; background: var(--info-bg); color: var(--muted); }
.badge-ok { color: var(--ok); background: var(--ok-bg); }
.badge-muted { color: var(--muted); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-brand { color: var(--link); background: var(--link-bg); }

.notice { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--radius); margin: 0 0 12px; background: var(--info-bg); font-size: 0.875rem; }
.notice-warn { background: var(--warn-bg); }
.notice-error { background: var(--danger-bg); color: var(--danger); }

.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(76px + var(--safe-b)); z-index: 200; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; max-width: 480px; display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-radius: var(--radius); background: var(--elevated); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 0.875rem; animation: rise 0.2s ease-out; }
.toast-error { border-color: var(--danger); }
.toast-success { border-color: var(--ok); }
.toast-action { background: none; border: none; color: var(--link); font-weight: 600; min-height: 44px; padding: 0 8px; }

/* ───────── casca (menu) ───────── */
.shell { display: grid; grid-template-rows: minmax(0, 1fr) auto; height: 100dvh; }
.main { min-height: 0; outline: none; }
.shell > .main { overflow-y: auto; overscroll-behavior: contain; }
.shell > .main-chat { overflow: hidden; }
.nav { display: flex; order: 2; background: var(--bg); border-top: 1px solid var(--border); padding-bottom: var(--safe-b); }
.nav-brand { display: none; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; color: var(--muted); text-decoration: none; font-size: 0.6875rem; font-weight: 500; }
.nav-item.is-active { color: var(--text); }
.nav-ico { position: relative; display: inline-flex; }
.nav-badge { position: absolute; top: -6px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger-solid); color: #fff; font-size: 0.6875rem; font-weight: 600; line-height: 18px; text-align: center; }
.nav-badge[hidden] { display: none; }
body.kbd-open .nav { display: none; }

@media (min-width: 900px) {
  .shell { grid-template-rows: none; grid-template-columns: 260px minmax(0, 1fr); }
  .nav { order: 0; flex-direction: column; background: var(--sidebar); border-top: none; border-right: 1px solid var(--border-subtle); padding: 12px 8px; gap: 2px; }
  .nav-brand { display: block; padding: 6px 12px 16px; }
  .nav-item { flex: none; flex-direction: row; justify-content: flex-start; gap: 10px; min-height: 36px; padding: 0 12px; border-radius: 8px; font-size: 0.875rem; font-weight: 400; color: var(--text); }
  .nav-item:hover { background: var(--hover); }
  .nav-item.is-active { background: var(--info-bg); font-weight: 500; }
  body.kbd-open .nav { display: flex; }
  .toasts { bottom: 24px; }
}

/* ───────── páginas internas ───────── */
.page { max-width: 760px; margin: 0 auto; padding: calc(20px + var(--safe-t)) 16px 32px; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.panel h2 { margin-bottom: 10px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { min-height: 44px; padding: 0 12px; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); font-weight: 500; }
.tab.is-active { color: var(--text); border-bottom-color: var(--text); }
.cards { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.cards.grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.panel .card { background: transparent; }
.card-top { display: flex; gap: 12px; align-items: center; }
.card-title { display: flex; flex-direction: column; align-items: flex-start; flex: 1; min-width: 0; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.app-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: var(--r-control); background: var(--surface-2); font-size: 1.4rem; }
.desc { margin: 0; flex: 1; }
.conn-note { margin: 0; }
.conn-note.is-ok { color: var(--ok); }
.conn-note.is-error { color: var(--danger); }
.empty-card { text-align: center; padding: 32px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: thin; }
.chip { flex: none; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; font-weight: 500; font-size: 0.875rem; }
.chip:hover { background: var(--hover); }
.chip.is-active { background: var(--btn-bg); border-color: transparent; color: var(--btn-text); }
#catalog-grid { margin-top: 4px; }
.tools .input[type="search"] { margin-bottom: 8px; }

.kv { margin: 0; display: grid; grid-template-columns: fit-content(55%) minmax(0, 1fr); gap: 4px 12px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.kv-wide { font-size: 1rem; margin-bottom: 14px; }
.kv-more { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.kv-hidden { color: var(--warn); font-weight: 600; font-size: 0.8125rem; }
.kv-expand { min-height: 44px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.stat-value { font-size: 1.25rem; font-weight: 600; }
.plain-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.meter-wrap { margin: 8px 0 14px; }
.meter-wrap meter { display: block; width: 100%; height: 14px; }
.budget-form { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.policy-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.policy-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; align-items: flex-start; }
.policy-row .select { width: auto; flex: none; max-width: 48%; }
.risk { display: inline-flex; align-items: center; min-height: 22px; font-size: 0.75rem; font-weight: 600; padding: 0 7px; border-radius: 6px; background: var(--info-bg); }
.risk-ok { color: var(--ok); background: var(--ok-bg); }
.risk-warn { color: var(--warn); background: var(--warn-bg); }
.risk-danger { color: var(--danger); background: var(--danger-bg); }
.install-card { display: grid; gap: 10px; justify-items: start; }
.install-card.is-compact { margin-top: 18px; text-align: center; justify-items: center; }
.connect-result { display: grid; gap: 10px; background: var(--info-bg); padding: 12px; border-radius: var(--radius); margin-top: 8px; }
.connect-result .btn { justify-self: start; }

/* ───────── folhas (dialog) ───────── */
dialog.sheet { border: 1px solid var(--border); background: var(--elevated); color: var(--text); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: 88dvh; box-shadow: var(--shadow); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: rise 0.18s ease-out; }
dialog.sheet::backdrop { background: var(--backdrop); }
dialog.sheet-small { width: min(420px, calc(100vw - 24px)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 18px; border-bottom: 1px solid var(--border); }
.sheet-head h2 { margin: 0; font-size: 1.125rem; }
.sheet-body { padding: 16px 18px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--border); }
@media (max-width: 600px) {
  dialog.sheet { margin: auto 0 0; width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; max-height: 92dvh; }
}
.model-group { margin-bottom: 16px; }
.model-group h3 { font-size: 0.8125rem; font-weight: 500; color: var(--muted); }
.model-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 48px; padding: 8px 12px; margin-bottom: 6px; text-align: left; border: 1px solid var(--border); border-radius: var(--r-control); background: transparent; }
.model-row:hover { background: var(--hover); }
.model-row.is-selected { border-color: var(--text); background: var(--info-bg); }
.model-row.is-unavailable { opacity: 0.7; }
.model-main { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }

/* ───────── entrar ───────── */
.auth, .boot-error { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(24px + var(--safe-t)) 16px calc(24px + var(--safe-b)); background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: transparent; border: none; padding: 8px 4px; }
.auth-card h1 { font-size: 1.75rem; letter-spacing: -0.01em; }
.auth-card .btn-primary, .auth-card .input { border-radius: 999px; }
.auth-card .input { padding-left: 18px; padding-right: 18px; }
.auth-card .input-code { padding-left: 12px; padding-right: 12px; }
.auth-logo { margin-bottom: 22px; }
.auth-links { margin-top: 10px; }
.dev-code { margin-bottom: 14px; }

/* ───────── onboarding ───────── */
.onboarding { max-width: 720px; margin: 0 auto; padding: calc(18px + var(--safe-t)) 16px calc(24px + var(--safe-b)); min-height: 100dvh; display: flex; flex-direction: column; }
.onb-head { padding: 4px 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.onb-logout { color: var(--muted); }
.stepper { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 6px; }
.step { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--muted); min-width: 0; }
.step::after { content: ""; flex: 1; height: 1px; background: var(--border-strong); }
.step:last-child { flex: none; }
.step:last-child::after { display: none; }
.step-dot { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--border-strong); font-size: 0.8125rem; font-weight: 600; }
.step-label { display: none; font-size: 0.875rem; font-weight: 500; white-space: nowrap; }
.step.is-current { color: var(--text); }
.step.is-current .step-dot { border-color: var(--btn-bg); background: var(--btn-bg); color: var(--btn-text); }
.step.is-done .step-dot { border-color: var(--text); color: var(--text); }
.step.is-done::after { background: var(--text); }
.stepper-text { margin: 0 0 18px; }
.onb-content { flex: 1; padding-bottom: 12px; }
.onb-footer { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; padding: 16px 0 calc(8px + var(--safe-b)); margin-bottom: calc(-1 * var(--safe-b)); background: linear-gradient(to top, var(--bg) calc(100% - 12px), transparent); }
.onb-footer { flex-wrap: wrap; }
.onb-footer > .form-error { flex-basis: 100%; margin: 0; }
.pick-grid { display: grid; gap: 10px; grid-template-columns: 1fr; margin-top: 12px; }
.pick-card { display: block; position: relative; cursor: pointer; }
.pick-input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pick-body { display: flex; gap: 12px; align-items: flex-start; padding: 14px; min-height: 64px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: border-color 0.15s, background 0.15s; }
.pick-card:hover .pick-body { background: var(--hover); }
.pick-input:checked + .pick-body { border-color: var(--text); background: var(--info-bg); box-shadow: 0 0 0 1px var(--text) inset; }
.pick-body::after { content: ""; flex: none; width: 22px; height: 22px; margin-left: auto; border-radius: 50%; border: 1.5px solid var(--border-strong); }
.pick-input[type="checkbox"] + .pick-body::after { border-radius: 6px; }
.pick-input:checked + .pick-body::after { border-color: var(--btn-bg); background: var(--btn-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center / 14px no-repeat; }
.pick-input:focus-visible + .pick-body { outline: 2px solid var(--focus); outline-offset: 2px; }
.pick-input:focus-visible + .pick-body { outline: 2px solid var(--focus); outline-offset: 2px; }
.pick-ico { font-size: 1.5rem; line-height: 1.2; }
.pick-text { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
@media (min-width: 600px) {
  .pick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step-label { display: inline; }
  .stepper-text { display: none; }
  .stepper { margin-bottom: 24px; }
}

/* ───────── conversa ───────── */
.chat { display: flex; height: 100%; min-height: 0; position: relative; }
.chat-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat-head { display: flex; align-items: center; gap: 4px; padding: calc(6px + var(--safe-t)) 8px 6px; border-bottom: 1px solid var(--border-subtle); }
.chat-title { flex: 1; margin: 0; font-size: 1rem; font-weight: 500; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.messages { max-width: 760px; margin: 0 auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 18px; }

.conv-list { display: flex; flex-direction: column; background: var(--sidebar); border-right: 1px solid var(--border-subtle); position: fixed; top: 0; bottom: 0; left: 0; width: min(86vw, 320px); z-index: 60; transform: translateX(-102%); visibility: hidden; transition: transform 0.2s ease, visibility 0.2s; padding-top: var(--safe-t); }
.chat.drawer-open .conv-list { transform: none; visibility: visible; }
.scrim { position: fixed; inset: 0; background: var(--backdrop); z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.chat.drawer-open .scrim { opacity: 1; pointer-events: auto; }
.conv-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.conv-head h2 { flex: 1; margin: 0; font-size: 0.875rem; font-weight: 500; color: var(--muted); }
.conv-items { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.conv-row { display: flex; align-items: center; border-radius: 10px; }
.conv-row.is-current { background: var(--info-bg); }
.conv-row:hover { background: var(--hover); }
.conv-item { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; min-height: 44px; padding: 4px 10px; background: none; border: none; text-align: left; justify-content: center; font-size: 0.875rem; }
.conv-title { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.conv-archive { opacity: 0.7; }
.conv-empty { padding: 14px; list-style: none; }
@media (min-width: 900px) {
  .conv-list { position: static; transform: none; visibility: visible; width: 280px; flex: none; z-index: auto; padding-top: 0; }
  .scrim { display: none; }
  .only-narrow { display: none !important; }
}

.empty { text-align: center; margin: 8vh auto 0; max-width: 520px; }
.empty-mark { display: none; }
.empty h2 { font-size: 1.75rem; letter-spacing: -0.01em; }
.suggestions { display: grid; gap: 8px; margin-top: 18px; text-align: left; }
.suggestion { min-height: 44px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; text-align: left; font-size: 0.9375rem; }
.suggestion:hover { background: var(--hover); }

.msg { display: flex; gap: 10px; }
.msg-user { justify-content: flex-end; }
.bubble-user { max-width: 80%; padding: 10px 16px; border-radius: 18px; background: var(--user-bubble); white-space: pre-wrap; word-break: break-word; }
.avatar { display: none; }
.msg-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.bubble-assistant { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.bubble-assistant:empty { display: none; }
.turn-status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.9rem; min-height: 0; }
.turn-status:empty { display: none; }
.turn-status-warn { color: var(--warn); }
.turn-status-error { color: var(--danger); background: var(--danger-bg); padding: 10px 12px; border-radius: 10px; }
.turn-foot:empty { display: none; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }

/* Markdown renderizado */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 0.7em; }
.md h3, .md h4, .md h5, .md h6 { margin: 1em 0 0.4em; }
.md h3 { font-size: 1.15rem; }
.md h4 { font-size: 1.05rem; }
.md h5, .md h6 { font-size: 1rem; }
.md ul, .md ol { margin: 0 0 0.7em; padding-left: 1.4em; }
.md li { margin: 0.15em 0; }
.md code { font-family: var(--mono); font-size: 0.875em; background: var(--info-bg); padding: 2px 5px; border-radius: 6px; }
.md pre.code { margin: 0 0 0.8em; padding: 12px 14px; background: var(--sidebar); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.md pre.code code { background: none; padding: 0; font-size: 0.85rem; white-space: pre; }
.md blockquote { margin: 0 0 0.7em; padding: 2px 0 2px 14px; border-left: 2px solid var(--border-strong); color: var(--muted); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1em 0; }
.md .md-table { overflow-x: auto; margin: 0 0 0.8em; }
.md table { border-collapse: collapse; font-size: 0.9rem; min-width: 100%; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--info-bg); font-weight: 600; }

/* cartões de ferramenta */
.tool { border: 1px solid var(--border); border-radius: var(--radius); background: transparent; }
.tool > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 12px; cursor: pointer; list-style: none; }
.tool > summary::-webkit-details-marker { display: none; }
.tool > summary::after { content: "›"; margin-left: auto; font-size: 1.3rem; color: var(--muted); transition: transform 0.15s; }
.tool[open] > summary::after { transform: rotate(90deg); }
.tool-ico { display: inline-grid; color: var(--muted); }
.tool-name { font-weight: 500; }
.tool-state { font-size: 0.75rem; font-weight: 600; color: var(--muted); background: var(--info-bg); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.tool.is-running .tool-state { color: var(--muted); animation: pulse 1.4s infinite; }
.tool.is-ok .tool-state { color: var(--ok); background: var(--ok-bg); }
.tool.is-error .tool-state { color: var(--danger); background: var(--danger-bg); }
.tool.is-denied .tool-state { color: var(--warn); background: var(--warn-bg); }
.tool-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.tool-body { padding: 4px 12px 12px; border-top: 1px solid var(--border); }
.tool-sec { margin: 10px 0 4px; font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.tool-result { margin: 0; padding: 10px 12px; max-height: 260px; overflow: auto; background: var(--info-bg); border-radius: 8px; font-family: var(--mono); font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; }

/* aprovação */
.approval { border: 1px solid var(--border-strong); background: var(--warn-bg); border-radius: var(--radius); padding: 14px 16px; }
.approval-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.approval-args { background: var(--surface); border-radius: 10px; padding: 10px 12px; margin: 8px 0 12px; max-height: min(50vh, 360px); overflow: auto; }
.approval-meta-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 8px; }
.approval-link { color: var(--link); font-weight: 500; min-height: 44px; display: inline-flex; align-items: center; }
.approval-list { display: grid; gap: 14px; margin-bottom: 16px; }
.approvals-page .empty-state { text-align: center; padding: 40px 16px; }
.approvals-page .empty-state[hidden] { display: none; }
.badge-warn { color: var(--warn); background: var(--warn-bg); }
.approval-chip { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 999px; border: none; color: var(--warn); background: var(--warn-bg); font-size: 0.8125rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.approval-chip[hidden] { display: none; }
/* Abaixo do título de cada conversa: selos ("Aguardando sua aprovação", "Computador") e a data numa linha; o nome do projeto
   (conversa que veio do app do computador) na linha seguinte, cortado com reticências se não couber. */
.conv-time { display: flex; align-items: center; align-self: stretch; flex-wrap: wrap; gap: 2px 6px; min-width: 0; }
.conv-wait, .conv-origin, .conv-when { flex: none; }
.conv-project { flex: 0 0 100%; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.approval-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.approval-actions .btn { flex: 1; min-width: 120px; }
.approval-state { margin: 10px 0 0; font-size: 0.9rem; color: var(--muted); }
.approval-state:empty { display: none; }
.approval-state.is-error { color: var(--danger); }
.approval.is-approved { border-color: var(--ok); }
.approval.is-denied, .approval.is-expired { border-color: var(--border); background: var(--surface); }

/* composer */
.composer { padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); background: linear-gradient(to top, var(--bg) 80%, transparent); }
.composer > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.composer .notice { margin-bottom: 8px; }
.composer-box { display: flex; align-items: flex-end; gap: 8px; background: var(--elevated); border: 1px solid var(--border); border-radius: 28px; padding: 6px 6px 6px 18px; box-shadow: var(--shadow-100); }
.composer-box:focus-within { border-color: var(--border-strong); }
.composer-input { flex: 1; min-width: 0; resize: none; border: none; outline: none; background: transparent; padding: 10px 0; max-height: 168px; line-height: 1.4; font-size: 1rem; }
.composer-input::placeholder { color: var(--faint); }
.send-btn { width: 44px; height: 44px; flex: none; border-radius: 50%; border: none; display: grid; place-items: center; background: var(--btn-bg); color: var(--btn-text); }
.send-btn:hover:not(:disabled) { background: var(--btn-bg-hover); }
.send-stop { background: var(--btn-bg); color: var(--btn-text); }
.composer-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; flex-wrap: nowrap; }
.composer-tools .seg { flex: none; }
.composer-input { overflow-y: hidden; }
.composer-hint { margin: 4px 4px 0; font-size: 0.78rem; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-control); background: var(--seg-bg); }
.seg-btn { min-height: 44px; padding: 0 12px; border: none; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 600; font-size: 0.875rem; }
.seg-btn[aria-pressed="true"] { background: var(--seg-thumb); color: var(--text); box-shadow: 0 1px 4px -1px rgba(0, 0, 0, 0.2); }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; font-weight: 500; font-size: 0.875rem; max-width: 100%; }
.chip-btn:hover { background: var(--hover); }
.chip-btn.is-warn { border-color: var(--warn); }
.composer-tools > .chip-btn { flex: 0 1 auto; min-width: 0; }
.chip-btn > .chip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }

@media (max-width: 599px) {
  /* dica do modo: some da vista no celular (continua lida por leitores de tela via aria-describedby) */
  .composer-hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ───────── convite recebido (faixa no topo) ───────── */
.shell > .main-chat { display: flex; flex-direction: column; }
.main-chat > .chat { flex: 1; height: auto; min-height: 0; }
.invite-banner { display: flex; align-items: center; justify-content: space-between; flex-wrap: nowrap; gap: 8px 12px; padding: calc(4px + var(--safe-t)) 8px 4px 14px; background: var(--info-bg); border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.invite-banner-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-banner .btn { flex: none; }
.invite-banner[hidden] { display: none; }
.main-chat > .invite-banner { flex: none; }
.invite-card { gap: 6px; }

/* ───────── soluções ───────── */
.solutions .page-head p { margin-bottom: 0; }
.solutions-panel { min-height: 120px; }
.solutions .tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.solutions .tabs::-webkit-scrollbar { display: none; }
.solution-group { margin-bottom: 22px; }
.solution-group-title { font-size: 0.875rem; font-weight: 500; color: var(--muted); margin: 14px 0 10px; }
.solution-card .desc { flex: none; }
.solution-for { margin: 0; }
.solution-needs { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.need-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.solution-card .card-actions { margin-top: auto; }
.version-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.version-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--r-control); background: transparent; }
.version-info { display: flex; align-items: center; gap: 8px; }
.mono-small { font-family: var(--mono); font-size: 0.85rem; }
.empty-card h2 { margin-bottom: 6px; }
.empty-card .btn { margin-top: 6px; }

/* ───────── equipe e privacidade ───────── */
.member-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.member-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; }
.member-avatar { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); color: var(--text); font-weight: 600; font-size: 0.875rem; }
.member-info { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
.member-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.link-row { display: flex; flex-direction: column; gap: 2px; min-height: 56px; justify-content: center; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--text); text-decoration: none; }
.link-row:hover { background: var(--hover); }
.privacy-list { gap: 10px; margin-bottom: 14px; }
.privacy-list li { padding-left: 14px; border-left: 2px solid var(--border-strong); }
.org-switcher { margin: 0 0 14px; }
.conv-delete { opacity: 0.7; }

/* ───────── aprovação: resumo do servidor, pedido grande demais, outras pessoas ───────── */
.approval-summary { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 8px; padding: 8px 10px; border-left: 3px solid var(--warn); background: var(--surface); border-radius: 0 10px 10px 0; }
.approval-label { font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.approval-summary-text { word-break: break-word; }
.approval-reason { margin: 0 0 8px; }
.approval-truncated { margin: 0 0 8px; padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: 0.9rem; }
.approval-preview { max-height: 180px; }
.approval-viewall { margin: -4px 0 10px; }
.approval-full dd { max-height: none; }
.approvals-others { margin-top: 12px; }

/* ───────── computador com mouse: medidas compactas do ChatGPT na web (no toque, os alvos seguem com 44px) ───────── */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .btn { min-height: 36px; padding: 0 14px; font-size: 0.875rem; border-radius: 8px; }
  .btn-small { min-height: 32px; padding: 0 10px; }
  .auth-card .btn { min-height: 44px; font-size: 1rem; }
  .icon-btn { width: 36px; height: 36px; border-radius: 8px; }
  .input { min-height: 40px; padding: 8px 12px; font-size: 0.9375rem; border-radius: 8px; }
  .auth-card .input { min-height: 44px; font-size: 1rem; }
  .chip, .chip-btn { min-height: 36px; padding: 0 14px; }
  .tab { min-height: 40px; }
  .seg { border-radius: 8px; }
  .seg-btn { min-height: 32px; padding: 0 12px; border-radius: 6px; }
  .nav-brand .logo { height: 22px; width: auto; }
  .nav-item .icon { stroke-width: 1.75; color: var(--muted); }
  .nav-item.is-active .icon { color: var(--text); }
  .conv-item { min-height: 40px; }
  .conv-row .icon-btn { width: 32px; height: 32px; }
  .send-btn { width: 36px; height: 36px; }
  .composer-box { padding: 8px 8px 8px 18px; }
  .composer-input { padding: 6px 0; }
  .toast-action { min-height: 32px; }
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .btn, .input, .card, .panel, .tool, .approval { border: 1px solid CanvasText; }
}

/* ═════ Azul da marca X1 no produto (15/11/2026, escolha do Saymon: "nível 3, com gradiente") ═════
   A base continua branca e cinza. O azul entra onde a pessoa age e onde o produto fala de si; o gradiente
   assinatura (o mesmo da landing) aparece na tela de entrada e na saudação da conversa. */
/* botão principal e enviar: leve gradiente sobre o azul sólido (no hover fica o sólido mais escuro) */
.btn-primary, .send-btn, .chip.is-active { background-image: var(--btn-grad); }
.btn-primary:disabled, .send-btn:disabled { background-image: none; }
/* menu: item ativo na cor da marca */
.nav-item.is-active { color: var(--link); }
.tab.is-active { border-bottom-color: var(--btn-bg); }
@media (min-width: 900px) {
  .nav-item.is-active { background: var(--link-bg); color: var(--text); }
  .nav-item.is-active .icon { color: var(--link); }
}
/* tela de entrada: o cartão flutua sobre o gradiente da marca */
.auth { background: var(--brand-bed); }
.auth-card { background: var(--elevated); border-radius: 20px; padding: 28px 22px 22px; box-shadow: 0 40px 100px -30px rgba(12, 10, 60, 0.75); }
.auth > .install-card.is-compact { color: #ffffff; }
.auth > .install-card.is-compact .muted { color: rgba(255, 255, 255, 0.88); }
.auth > .install-card.is-compact .btn-primary { background: #ffffff; background-image: none; color: #0d0d0d; }
/* saudação da conversa vazia: cama de gradiente com o texto em branco; as sugestões ficam embaixo, no neutro */
.empty-hero { margin-top: 12px; border-radius: 24px; padding: 30px 20px; background: var(--brand-bed); color: #ffffff; position: relative; overflow: hidden; }
.empty-hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(80% 60% at 80% 100%, rgba(90, 80, 200, 0.5), transparent 60%); pointer-events: none; }
.empty-hero > * { position: relative; z-index: 1; }
.empty-hero h2 { color: #ffffff; margin: 0 0 6px; }
.empty-hero p { color: rgba(255, 255, 255, 0.88); margin: 0; }

/* ───────── voltar (subpáginas de Ajustes) ───────── */
.back-link { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: -8px 0 4px -6px; padding: 0 8px 0 4px; border-radius: var(--r-control); color: var(--muted); font-size: 0.875rem; text-decoration: none; }
.back-link .icon { transform: rotate(90deg); }
.back-link:hover { background: var(--hover); color: var(--text); }

/* ───────── conversa trazida do computador ───────── */
.conv-origin-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 16px; padding: 8px 12px; border-radius: var(--radius); background: var(--surface-2); }

/* ───────── Plano e uso ───────── */
.plan-now { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.plan-cards { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
.plan-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.plan-card.is-current { border-color: var(--btn-bg); box-shadow: 0 0 0 1px var(--btn-bg) inset; }
.plan-card-head h3 { margin: 0 0 2px; font-size: 1rem; font-weight: 600; }
.plan-price { margin: 0; }
.plan-price strong { display: block; font-size: 1.25rem; font-weight: 600; }
.plan-period { display: block; }
.plan-current > .btn { margin-top: 4px; }
.plan-feats { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.875rem; }
.plan-feats li { display: flex; gap: 8px; align-items: flex-start; }
.plan-feats .icon { margin-top: 2px; color: var(--link); }
.plan-cta { margin-top: auto; }
.plan-cta .btn { width: 100%; }
.plan-msg { margin-bottom: 16px; }
.plan-seats-line { margin-bottom: 8px; }
.plan-help { margin: 16px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.plan-help p { margin: 0; }
@media (min-width: 700px) { .plan-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
