/*
 * Jarvis — direção "Coluna" (2026-09-25).
 *
 * Um arquivo só: substitui hud.css + hud-v2.css, que se sobrescreviam.
 * Referência: app Goose (kolkovsky.dev). O que veio de lá e por quê:
 *   - cinza quente em claro e escuro, sem cor de identidade no chrome;
 *   - UMA cor (laranja) reservada para "agora": o dia de hoje, a previsão, a
 *     voz ouvindo. Todo o resto é contexto em cinza (Brain: "cinza para
 *     contexto, uma cor para destaque");
 *   - número em mono com os centavos apagados: lê-se o real antes do centavo;
 *   - blocos de raio único (18px) sobre o fundo, sem borda nem sombra.
 * Tema segue o sistema (prefers-color-scheme). Movimento tem variante
 * reduzida equivalente, não só "animation: none".
 */

:root {
  color-scheme: light dark;

  --bg: #eeeeeb;
  --surface: #ffffff;
  --surface-2: #f4f4f1;
  --line: #e4e4e0;
  --text: #161615;
  --muted: #6b6b66;
  --faint: #83837e;
  --accent: #e85d0c;
  --accent-text: #b8480a;
  --accent-soft: rgba(232, 93, 12, 0.13);
  --ok: #1d8f5a;
  --warn: #a8650f;
  --danger: #cf3326;
  --scrim: rgba(22, 22, 21, 0.32);
  --core-idle: #161615;
  --core-think: #83837e;
  --bar: #d6d6d1;

  --r: 18px;
  --r-sm: 12px;
  --pill: 999px;
  --col: 720px;
  --gap: 10px;

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);
  --t-fast: 160ms;
  --t: 240ms;
  --t-slow: 380ms;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --surface: #1c1c1b;
    --surface-2: #262624;
    --line: #2c2c2a;
    --text: #efefec;
    --muted: #9a9a94;
    --faint: #6e6e69;
    --accent: #ff6b1a;
    --accent-text: #ff8a47;
    --accent-soft: rgba(255, 107, 26, 0.16);
    --ok: #3ccf8e;
    --warn: #f2b23a;
    --danger: #ff5a4f;
    --scrim: rgba(0, 0, 0, 0.55);
    --core-idle: #efefec;
    --core-think: #9a9a94;
    --bar: #3d3d3a;
  }
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

body.app-open { height: 100dvh; overflow: hidden; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  border-radius: 6px;
}

.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;
}

/* Número: mono, algarismos de mesma largura, centavo em cinza. */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; white-space: nowrap; }
/* Centavo apagado, mas em --muted (≥5,3:1): em lista o número é texto pequeno. */
.num .c { color: var(--muted); }
.num.in { color: var(--ok); }
.num.in .c { color: inherit; opacity: 0.7; }

.muted { color: var(--muted); }
.na { color: var(--muted); font-family: var(--mono); }

/* ---------- Controles ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: none; border-radius: var(--pill);
  background: var(--surface-2); color: var(--text);
  font-size: 15px; font-weight: 500;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--text); color: var(--bg); }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.ghost {
  min-height: 44px; padding: 0 14px;
  background: none; border: none; border-radius: var(--pill);
  color: var(--muted); font-size: 14px;
}
.ghost:hover { color: var(--text); }

.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border: none; border-radius: var(--pill);
  background: var(--surface); color: var(--text);
  transition: transform var(--t-fast) var(--ease);
}
.icon-btn:active:not(:disabled) { transform: scale(0.94); }
.icon-btn svg { width: 19px; height: 19px; }

.chip {
  min-height: 40px; padding: 0 16px;
  border: none; border-radius: var(--pill);
  background: var(--surface); color: var(--text);
  font-size: 14px;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.chip:active { transform: scale(0.96); }

input[type="password"], input[type="text"], input[type="search"] {
  width: 100%; min-height: 48px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font-size: 16px; /* 16px: o iOS não dá zoom no foco */
}
input::placeholder, textarea::placeholder { color: var(--muted); }

/* ---------- Login ---------- */

#login {
  margin: auto; width: min(360px, calc(100vw - 32px));
  padding: 32px 0; display: flex; flex-direction: column; gap: 12px;
}
.login-mark { width: 44px; height: 44px; color: var(--text); margin-bottom: 8px; }
#login h1 { margin: 0; font-size: 34px; font-weight: 600; letter-spacing: -0.03em; }
.login-intro { margin: 0 0 12px; color: var(--muted); font-size: 16px; }
#login .field { margin-bottom: 10px; }
.erro {
  min-height: 20px; color: var(--danger); font-size: 14px;
  opacity: 0; transition: opacity var(--t) var(--ease);
}
.erro.show { opacity: 1; }
.login-foot { color: var(--muted); font-size: 13px; }

/* ---------- Cabeçalho ---------- */

#topbar {
  display: none; flex-shrink: 0;
  padding: calc(14px + var(--safe-t)) 16px 10px;
}
#topbar .inner {
  width: 100%; max-width: var(--col); margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
}
.wordmark { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; display: flex; align-items: center; gap: 8px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status-dot.off { background: var(--danger); }
#topbar .wordmark { flex: 1; }
#topbar .acoes { display: flex; gap: 6px; justify-content: flex-end; }

/* Navegação: segmento em pílula no desktop, barra flutuante no celular. */
#tabbar {
  display: none; gap: 2px; padding: 4px;
  background: var(--surface); border-radius: var(--pill);
}
#tabbar.on { display: flex; }
.tab {
  min-height: 36px; padding: 0 14px;
  border: none; border-radius: var(--pill); background: none;
  color: var(--muted); font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t) var(--ease), color var(--t) var(--ease);
}
.tab svg { width: 18px; height: 18px; display: none; }
.tab.active { background: var(--text); color: var(--bg); font-weight: 500; }

/* ---------- Vistas ---------- */

#views { flex: 1; min-height: 0; display: none; position: relative; }
.view {
  position: absolute; inset: 0;
  overflow-y: auto; overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}
/* Trocar de aba anima só o destino (Brain, Motion §regras de produto). */
.view.entrando { animation: entrar var(--t) var(--ease) both; }
@keyframes entrar { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.view-inner {
  width: 100%; max-width: var(--col); margin: 0 auto;
  padding: 12px 16px calc(40px + var(--safe-b));
  display: flex; flex-direction: column; gap: var(--gap);
}
.carregando { color: var(--muted); padding: 48px 0; text-align: center; font-size: 14px; }

/* ---------- Blocos ---------- */

.bloco {
  background: var(--surface); border-radius: var(--r);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.bloco-titulo {
  display: flex; align-items: baseline; gap: 12px;
  margin: 0 0 6px; font-size: 16px; font-weight: 600; letter-spacing: -0.01em;
}
.bloco-titulo .extra { margin-left: auto; font-size: 13px; font-weight: 400; color: var(--muted); }
.bloco .nota { color: var(--muted); font-size: 13px; line-height: 1.5; }
.grade { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.grade.dois { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile { background: var(--surface); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tile .rot { font-size: 13px; color: var(--muted); }
.tile .rot.agora { color: var(--accent-text); }
.tile .num { font-size: 22px; }

.hero { padding: 18px 4px 8px; display: flex; flex-direction: column; gap: 6px; }
.hero .rot { font-size: 15px; color: var(--muted); }
.hero .num { font-size: clamp(44px, 10vw, 64px); line-height: 1; letter-spacing: -0.045em; }
.hero .sub { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }

.aviso {
  display: flex; align-items: center; gap: 12px;
  background: var(--accent-soft); border-radius: var(--r-sm);
  padding: 12px 14px; font-size: 14px;
}
.aviso .ghost { margin-left: auto; color: var(--accent-text); font-weight: 500; min-height: 36px; }

/* Linha de lista: rótulo à esquerda, valor à direita. */
.linha {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 8px 0;
  border-top: 1px solid var(--line);
}
.bloco-titulo + .linha, .linha:first-child { border-top: none; }
.linha .grow { flex: 1; min-width: 0; }
.linha .t { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha .num { font-size: 15px; }
button.linha {
  width: 100%; background: none; border: none; border-top: 1px solid var(--line);
  text-align: left; padding: 8px 0; color: inherit; border-radius: 0;
}
button.linha:first-of-type { border-top: none; }
button.linha:active { background: var(--surface-2); }

.selo {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); white-space: nowrap;
}
.selo::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.selo.ok { color: var(--ok); }
.selo.warn { color: var(--warn); }
.selo.bad { color: var(--danger); }

.vazio { color: var(--muted); font-size: 14px; padding: 6px 0; }

/* Barra fina: trilho em linha, preenchimento em cinza; só "agora" é laranja. */
.trilho { height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.trilho i { display: block; height: 100%; border-radius: 2px; background: var(--faint); }
.trilho i.agora { background: var(--accent); }
.trilho i.warn { background: var(--warn); }
.trilho i.bad { background: var(--danger); }

/* ---------- Finanças ---------- */

.grupo { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.grupo:first-of-type { border-top: none; }
.grupo-cabeca {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; padding: 0; text-align: left; min-height: 32px;
}
.grupo-cabeca .nome { flex: 1; font-size: 15px; }
.grupo-cabeca .qtd { color: var(--muted); }
.grupo-cabeca .pct { width: 44px; text-align: right; font-size: 13px; color: var(--muted); }
.grupo-cabeca .chev { width: 16px; height: 16px; color: var(--faint); transition: transform var(--t) var(--ease); }
.grupo-cabeca[aria-expanded="true"] .chev { transform: rotate(90deg); }
.grupo-itens { display: none; padding: 2px 0 2px 14px; flex-direction: column; gap: 6px; }
.grupo-itens.on { display: flex; }
.grupo-itens .sub { display: flex; gap: 10px; font-size: 14px; color: var(--muted); }
.grupo-itens .sub span:first-child { flex: 1; }

.grafico { width: 100%; height: auto; display: block; overflow: visible; }
.grafico line, .grafico polyline, .grafico polygon { vector-effect: non-scaling-stroke; }
.grafico .eixo { stroke: var(--line); }
.grafico .grade-l { stroke: var(--line); stroke-dasharray: 2 4; }
.grafico .ritmo { stroke: var(--faint); stroke-dasharray: 4 5; fill: none; }
.grafico .media { stroke: var(--muted); stroke-dasharray: 1 4; fill: none; }
.grafico .gasto { stroke: var(--accent); stroke-width: 2; fill: none; stroke-linejoin: round; }
.grafico .area { fill: var(--accent-soft); }
.grafico .hoje { fill: var(--accent); }
.grafico text { fill: var(--muted); font: 11px var(--mono); }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.legenda i { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: 6px; }
.legenda i.ritmo { border-top: 1.5px dashed var(--faint); }
.legenda i.media { border-top: 1.5px dotted var(--muted); }

.colunas { display: flex; align-items: flex-end; gap: 8px; height: 132px; }
.coluna { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.coluna .poco { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-height: 0; }
.coluna .barra { width: 100%; max-width: 44px; border-radius: 8px 8px 4px 4px; background: var(--bar); }
.coluna .barra.agora { background: var(--accent); }
.coluna .barra.parcial { background: repeating-linear-gradient(135deg, var(--bar) 0 3px, transparent 3px 7px); }
.coluna .m { font: 11px var(--mono); color: var(--muted); }
.coluna .v { font: 11px var(--mono); color: var(--muted); }

/* ---------- Conversa ---------- */

#view-chat .view-inner { min-height: 100%; padding-bottom: 16px; }
#nucleo-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 12px 0 4px;
  transition: padding var(--t-slow) var(--ease);
}
#nucleo {
  width: min(260px, 62vw); height: min(260px, 62vw); display: block;
  transition: width var(--t-slow) var(--ease), height var(--t-slow) var(--ease);
}
#nucleo-estado { font-size: 14px; color: var(--muted); min-height: 20px; text-align: center; }
#nucleo-estado b { color: var(--accent-text); font-weight: 500; }
#voz-toggle { min-width: 180px; }
#voz-toggle.on { background: var(--accent); color: #fff; }
/* Com conversa na tela, o núcleo recua e cede espaço ao texto. */
.conversando #nucleo { width: 92px; height: 92px; }
.conversando #nucleo-wrap { flex-direction: row; justify-content: center; padding: 0; gap: 14px; }
.conversando #voz-toggle { min-width: 0; }

.contexto { text-align: center; padding: 20px 0 4px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.contexto h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.contexto p { margin: 0; color: var(--muted); font-size: 14px; }
.conversando .contexto { display: none; }

.quick-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 14px 0 4px; }
.conversando .quick-actions { display: none; }

.feed-shell { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
#feed { display: flex; flex-direction: column; gap: 14px; padding: 8px 0; }
.log { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.log .ts { font: 11px var(--mono); color: var(--muted); }
.log .msg { font-size: 16px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.log.user { align-items: flex-end; }
.log.user .msg { background: var(--surface); padding: 10px 14px; border-radius: var(--r) var(--r) 6px var(--r); max-width: 85%; }
.log.user .ts { display: none; }
.log.sys { align-items: center; }
.log.sys .ts { display: none; }
.log.sys .msg { font-size: 13px; color: var(--muted); text-align: center; }
.log.err .msg { color: var(--danger); }
.msg.parcial { color: var(--muted); }
.cursor::after {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 4px;
  border-radius: 50%; background: var(--accent); vertical-align: middle;
  animation: pulso 1s var(--ease) infinite;
}
@keyframes pulso { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

.feed-end {
  position: sticky; bottom: 8px; align-self: center;
  min-height: 36px; padding: 0 14px; border: none; border-radius: var(--pill);
  background: var(--text); color: var(--bg); font-size: 13px;
}

#composer {
  display: none; flex-shrink: 0;
  padding: 8px 16px calc(10px + var(--safe-b));
}
#composer form {
  max-width: var(--col); margin: 0 auto;
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--surface); border-radius: 26px; padding: 6px 6px 6px 18px;
}
#input {
  flex: 1; min-height: 44px; max-height: 132px; padding: 11px 0;
  border: none; background: transparent; resize: none; outline: none;
  font-size: 16px; line-height: 1.4;
}
#composer .icon-btn { background: var(--surface-2); }
#composer .send { background: var(--text); color: var(--bg); }
#composer .mic.on { background: var(--accent); color: #fff; }

/* ---------- Brain ---------- */

.fato { padding: 10px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.grupo-cat + .fato { border-top: none; }
.fato .topo { display: flex; gap: 10px; align-items: flex-start; }
.fato .frase { flex: 1; font-size: 15px; line-height: 1.45; }
.fato .obj { font-weight: 500; }
.fato .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 12px; color: var(--muted); }
.fato .conf { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); }
.fato .conf .trilho { width: 48px; }
.fato .conf.baixa { color: var(--warn); }
.fato.esquecido { opacity: 0.4; }
.fato .esquecer { min-height: 36px; font-size: 13px; }
.grupo-cat {
  display: flex; align-items: baseline; gap: 8px;
  padding: 16px 0 4px; font-size: 13px; color: var(--muted);
  text-transform: capitalize;
}
.grupo-cat:first-of-type { padding-top: 0; }
.grupo-cat .qtd { font-family: var(--mono); }

.cat-chips { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.cat-chip { display: grid; grid-template-columns: minmax(0, 1fr) 90px 36px; gap: 12px; align-items: center; font-size: 14px; }
.cat-chip-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-chip-n { text-align: right; font-family: var(--mono); color: var(--muted); font-size: 13px; }

.grafo-wrap { position: relative; margin: 4px -8px 0; }
#grafo-canvas { display: block; width: 100%; touch-action: pan-y; }
.grafo-tooltip {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--text); color: var(--bg);
  font-size: 12px; padding: 5px 10px; border-radius: var(--pill);
  pointer-events: none; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Folhas (dialog) ---------- */

dialog.folha {
  border: none; padding: 0; margin: auto;
  width: min(520px, calc(100vw - 24px)); max-height: min(86dvh, 720px);
  border-radius: 24px; background: var(--bg); color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
dialog.folha[open] { display: flex; flex-direction: column; animation: folha-in var(--t-slow) var(--ease-sheet); }
dialog.folha::backdrop { background: var(--scrim); animation: fundo-in var(--t) var(--ease); }
@keyframes folha-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes fundo-in { from { opacity: 0; } to { opacity: 1; } }
.folha-cabeca {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 16px 8px 22px; flex-shrink: 0;
}
.folha-cabeca h2 { margin: 0; flex: 1; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.folha-cabeca .icon-btn { background: var(--surface-2); width: 36px; height: 36px; }
.folha-corpo { padding: 4px 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: var(--gap); }
.folha-corpo .bloco { padding: 14px 16px; }
.folha-corpo .passos { margin: 0; padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.drag-alvo {
  display: flex; align-items: center; justify-content: center; min-height: 48px;
  border-radius: var(--pill); background: var(--text); color: var(--bg);
  font-weight: 500; text-decoration: none; cursor: grab;
}
.conversa-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 8px 4px; border: none; border-top: 1px solid var(--line);
  background: none; text-align: left;
}
.conversa-item:first-child { border-top: none; }
.conversa-item .t { flex: 1; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversa-item .s { font: 12px var(--mono); color: var(--muted); }

.cat-busca { position: sticky; top: 0; }
.cat-opcoes { display: flex; flex-direction: column; }
.cat-opcoes .grupo-nome { font-size: 12px; color: var(--muted); padding: 14px 4px 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.cat-opcao {
  display: flex; align-items: center; min-height: 44px; padding: 0 4px; width: 100%;
  border: none; border-top: 1px solid var(--line); background: none; text-align: left; font-size: 15px;
}
.cat-opcao.atual { font-weight: 600; }
.cat-opcao.atual::after { content: "atual"; margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- Telefone ---------- */

@media (max-width: 767px) {
  #topbar { padding: calc(10px + var(--safe-t)) 16px 6px; }
  .wordmark { font-size: 28px; letter-spacing: -0.03em; }
  .wordmark .status-dot { margin-top: 6px; }

  /* A navegação desce para a base e flutua acima do gesto do iPhone. */
  #tabbar {
    position: fixed; z-index: 30; left: 12px; right: 12px;
    bottom: calc(10px + var(--safe-b));
    justify-content: space-between; padding: 5px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  }
  .tab { flex: 1; flex-direction: column; gap: 2px; min-height: 50px; padding: 0 4px; font-size: 11px; justify-content: center; }
  .tab svg { display: block; }

  .view-inner { padding-bottom: calc(96px + var(--safe-b)); }
  #view-chat .view-inner { padding-bottom: 12px; }
  #composer { padding-bottom: calc(84px + var(--safe-b)); }

  .grade { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* O SVG encolhe junto com a tela; o texto dele não pode encolher junto. */
  .grafico text { font-size: 22px; }
  .grade > .tile:nth-child(3):last-child { grid-column: 1 / -1; }
  .grade.dois.empilha { grid-template-columns: minmax(0, 1fr); }
  .bloco { padding: 16px; }

  /* Folha vira folha de verdade: sobe da base. */
  dialog.folha {
    margin: auto 0 0; width: 100%; max-width: 100%;
    max-height: 90dvh; border-radius: 24px 24px 0 0;
    padding-bottom: var(--safe-b);
  }
  dialog.folha[open] { animation: folha-sobe var(--t-slow) var(--ease-sheet); }
  @keyframes folha-sobe { from { transform: translateY(100%); } to { transform: none; } }
  .folha-cabeca::before {
    content: ""; position: absolute; left: 50%; top: 7px; transform: translateX(-50%);
    width: 36px; height: 5px; border-radius: 3px; background: var(--line);
  }
  .folha-cabeca { position: relative; padding-top: 22px; }
}

@media (min-width: 768px) {
  /* Marca, navegação ao centro, ações à direita. */
  #topbar .inner { max-width: 960px; display: grid; grid-template-columns: 1fr auto 1fr; }
}

/* ---------- Movimento reduzido ---------- */

@media (prefers-reduced-motion: reduce) {
  /* Equivalente: o estado final aparece, só sem deslocamento. */
  .view.entrando { animation: esmaecer var(--t-fast) linear both; }
  @keyframes esmaecer { from { opacity: 0; } to { opacity: 1; } }
  dialog.folha[open], dialog.folha::backdrop { animation: esmaecer var(--t-fast) linear both; }
  #nucleo, #nucleo-wrap, .grupo-cabeca .chev, .tab, .btn, .chip, .icon-btn { transition: none; }
  .cursor::after { animation: none; opacity: 1; }
}

/* A folha de categoria não muda de altura enquanto a busca filtra. */
#painel-categoria[open] { height: min(80dvh, 640px); }
.tile .valor-texto { font-size: 22px; letter-spacing: -0.02em; }
