/* InVoxZero — visual v2 (26-08, manhã).
   O MASTER não gostou do v1 ("caixas escuras com bordas") e apontou o grafismo
   do trabalho do Cursor como referência. A linguagem daqui vem daí:
   - tipografia em vez de caixas: o email é texto sobre o fundo, sem moldura;
   - o ASSUNTO é o herói, grande; o remetente é uma etiqueta pequena por cima;
   - botões cheios e luminosos (primário claro com texto escuro), cantos 20px+;
   - três peles — Meia-noite, Titânio, Papel — comutáveis à vista.
   Regras de condução mantêm-se: nada abaixo de 17px, alvos >= 80px, contraste alto. */

:root, html[data-tema="meia-noite"] {
  --bg: #070709;
  --fg: #f4f4f5;
  --muted: #a1a1aa;
  --line: #27272a;
  --card: #121214;
  --accent: #7dd3fc;
  --btn: #38bdf8;
  --btn-fg: #041018;
  --flag: #f59e0b;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
}

html[data-tema="titanio"] {
  --bg: #161618;
  --fg: #f5f5f7;
  --muted: #a8a29e;
  --line: #3f3f46;
  --card: #232326;
  --accent: #e7e5e4;
  --btn: #f5f5f7;
  --btn-fg: #111113;
  --flag: #c4a574;
  --ok: #86efac;
  --warn: #e7d5a3;
  --err: #fca5a5;
}

html[data-tema="papel"] {
  --bg: #f3eee4;
  --fg: #1c1612;
  --muted: #6b6258;
  --line: #d6cfc3;
  --card: #fffaf2;
  --accent: #7a1f33;
  --btn: #1c1612;
  --btn-fg: #f3eee4;
  --flag: #b45309;
  --ok: #166534;
  --warn: #92400e;
  --err: #b91c1c;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 400 17px/1.5 ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, system-ui, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}

.oculto { display: none !important; }

.ecra {
  min-height: 100dvh;
  max-width: 520px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}

/* ── Ecrãs de arranque / fim ── */

#ecra-pin, #ecra-inicio, #ecra-fim { align-items: center; justify-content: center; gap: 18px; text-align: center; }

.marca { font-size: 46px; font-weight: 650; letter-spacing: -0.03em; }
.marca span { color: var(--accent); }
.sub { color: var(--muted); font-size: 19px; max-width: 32ch; line-height: 1.4; }
.nota { color: var(--muted); font-size: 14.5px; max-width: 36ch; }
.erro { color: var(--err); font-size: 16px; min-height: 20px; }

#pin {
  width: 230px; padding: 18px; text-align: center; font-size: 30px; letter-spacing: 0.3em;
  background: var(--card); border: 0; border-radius: 20px;
  color: var(--fg); -webkit-user-select: text; user-select: text;
}

.primario {
  background: var(--btn); color: var(--btn-fg); border: 0; border-radius: 24px;
  padding: 22px 48px; font-size: 22px; font-weight: 650; font-family: inherit;
}
.primario.grande { padding: 28px 0; width: 100%; font-size: 26px; border-radius: 28px; }
.primario:disabled { background: var(--card); color: var(--muted); }
.primario:active { transform: scale(.98); }

/* ── Condução ── */

#ecra-fila { justify-content: space-between; gap: 12px; }

.topo { display: flex; flex-direction: column; gap: 10px; }
.progresso { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.barra { height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
.linha-topo { display: flex; justify-content: space-between; align-items: center; }
.contador { color: var(--muted); font-size: 14.5px; font-variant-numeric: tabular-nums; }

/* as três peles, sempre à mão */
.peles { display: flex; gap: 8px; }
.pele {
  flex: 1; min-height: 38px; border: 0; border-radius: 12px;
  background: var(--card); color: var(--muted); font: 600 12.5px/1 inherit;
}
.pele.escolhida { background: var(--btn); color: var(--btn-fg); }

/* O iPhone já mostra o indicador de microfone na barra dele — o nosso saiu (MASTER, 26-08). */
.escuta { display: none; }
.escuta .ponto { width: 12px; height: 12px; border-radius: 50%; background: var(--err); }
.escuta.activa .ponto { background: var(--ok); animation: pulsar 1.6s ease-in-out infinite; }
.escuta.ouviu .ponto { background: var(--flag); }
.escuta.morto .ponto { background: var(--err); }
.escuta.espera .ponto { background: var(--accent); animation: respirar 2.4s ease-in-out infinite; }
/* a gravar ditado: laranja a pulsar, como o indicador do iPhone */
.escuta.gravando .ponto { background: #ff9500; animation: pulsar .9s ease-in-out infinite; }
@keyframes pulsar { 0%,100% { opacity: 1 } 50% { opacity: .25 } }
@keyframes respirar { 0%,100% { transform: scale(1); opacity: 1 } 50% { transform: scale(1.6); opacity: .5 } }

/* O email é tipografia sobre o fundo — sem caixa, sem borda.
   Hierarquia: remetente pequeno em cima, ASSUNTO grande, resumo a ler-se. */
.cartao {
  flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 10px;
  overflow-y: auto; overscroll-behavior: contain; padding: 8px 2px;
}

.etiqueta {
  align-self: flex-start; font-size: 12px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
}
.etiqueta.p5 { color: var(--err); }
.etiqueta.p4 { color: var(--flag); }
.etiqueta.auto { color: var(--muted); opacity: .7; }

.quem {
  font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}
.assunto { font-size: 30px; font-weight: 650; line-height: 1.12; letter-spacing: -0.02em; color: var(--fg); text-wrap: balance; }
.resumo { font-size: 21px; line-height: 1.42; color: var(--fg); }
.prazo { color: var(--flag); font-size: 18px; font-weight: 650; }

.transcricao {
  margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 17px; line-height: 1.55; white-space: pre-wrap;
  -webkit-user-select: text; user-select: text;
}

.ondas { display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 24px; }
.ondas i { width: 4px; height: 4px; background: var(--line); border-radius: 2px; transition: height .1s; }
.ondas.viva i { background: var(--accent); }

/* Ações: o Responder é o primário cheio; Arquivar e Saltar em cartão. */
.accoes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
/* Enquanto lê só há 3 botões — mais ecrã para o email. Um swipe para cima
   revela a segunda fila (MASTER, 26-08, 3ª volta). */
body[data-modo="ler"]:not(.extras-visiveis) .accao.extra { display: none; }
.accao {
  min-height: 88px; border: 0; border-radius: 20px; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--card); color: var(--fg);
}
.accoes.fase1 { gap: 8px; }
.accoes.fase1 .accao { min-height: 44px; border-radius: 14px; }
.accoes.fase1 .accao b { font-size: 16px; }
.accao b { font-size: 18px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.accao:active { transform: scale(.97); }
.accao.responder { background: var(--btn); color: var(--btn-fg); }
.accao.responder small { color: var(--btn-fg); opacity: .65; }

.accao.pausada, .mini.pausada { background: var(--flag); color: #1c1200; }
.accao.pausada b { color: #1c1200; }

.rodape { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.mini {
  background: var(--card); border: 0; color: var(--muted);
  border-radius: 999px; padding: 12px 18px; font: 500 15px/1 inherit;
}
.mini.activa { color: var(--accent); }

/* ── Tosta ── */
.tosta {
  position: fixed; left: 14px; right: 14px; bottom: max(14px, env(safe-area-inset-bottom));
  background: var(--card); border-radius: 20px;
  padding: 17px 20px; display: flex; align-items: center; justify-content: space-between;
  gap: 14px; font-size: 17px; box-shadow: 0 12px 40px rgba(0,0,0,.45); z-index: 50;
}
html[data-tema="papel"] .tosta { box-shadow: 0 10px 30px rgba(60,45,25,.25); }
.tosta.aviso { color: var(--warn); }
.tosta.mau { color: var(--err); }
.tosta-btn {
  background: var(--btn); color: var(--btn-fg); border: 0; border-radius: 999px;
  padding: 12px 22px; font: 650 16px/1 inherit; white-space: nowrap;
}

/* ── Definições ── */
#ecra-definicoes { gap: 18px; }
.cabeca { display: flex; align-items: center; gap: 14px; }
.titulo { font-size: 26px; font-weight: 650; }
.ligacao { background: none; border: 0; color: var(--accent); font: inherit; font-size: 17px; text-decoration: underline; }
.lista { display: flex; flex-direction: column; gap: 22px; overflow-y: auto; }
.campo { display: flex; flex-direction: column; gap: 9px; }
.campo label { font-size: 17px; font-weight: 650; }
.campo label small { display: block; font-weight: 400; color: var(--muted); font-size: 15px; margin-top: 3px; }
.par { display: flex; gap: 9px; }
.campo input, .campo select {
  flex: 1; min-width: 0; padding: 16px; font-size: 16px; font-family: ui-monospace, Menlo, monospace;
  background: var(--card); border: 0; border-radius: 16px; color: var(--fg);
  -webkit-user-select: text; user-select: text;
}
.campo select { font-family: inherit; }
.campo textarea {
  padding: 14px; font-size: 16px; font-family: inherit; line-height: 1.5;
  background: var(--card); border: 0; border-radius: 16px;
  color: var(--fg); resize: vertical; min-height: 96px;
  -webkit-user-select: text; user-select: text;
}
.estado-chave { font-size: 15px; color: var(--muted); min-height: 18px; }
.estado-chave.boa { color: var(--ok); }
.estado-chave.ma { color: var(--err); }
.risca { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.opcoes { display: flex; gap: 9px; }
.opcao {
  flex: 1; min-height: 56px; background: var(--card); color: var(--muted);
  border: 0; border-radius: 16px; font: 600 15.5px/1.2 inherit;
}
.opcao.escolhida { background: var(--btn); color: var(--btn-fg); }

.fases { display: flex; flex-direction: column; gap: 8px; }
.fase {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 0; border-radius: 16px;
  padding: 12px 14px; min-height: 58px;
}
.fase.desligada { opacity: .45; }
.fase .num {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--btn); color: var(--btn-fg); font-size: 14px; font-weight: 700;
}
.fase.desligada .num { background: var(--line); color: var(--muted); }
.fase .rotulo { flex: 1; font-size: 16.5px; border: 0; background: none; color: var(--fg); text-align: left; font-family: inherit; }
.fase .seta {
  width: 42px; height: 42px; border-radius: 12px; border: 0;
  background: var(--bg); color: var(--muted); font-size: 18px; font-family: inherit;
}
.fase .seta:disabled { opacity: .25; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── Overlay de espera: os comandos possíveis, por cima de tudo, translúcido ── */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; justify-content: center; gap: 12px;
  padding: 20px 18px max(20px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--bg) 12%, transparent) 0%,
    color-mix(in srgb, var(--bg) 78%, transparent) 55%);
  backdrop-filter: blur(1.5px); -webkit-backdrop-filter: blur(1.5px);
}
.overlay-grelha {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
/* todos os mosaicos do overlay são iguais (MASTER, 26-08) */
.ov {
  min-height: 112px; gap: 6px; border: 0; border-radius: 20px; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: var(--card); color: var(--fg);
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
html[data-tema="papel"] .ov { box-shadow: 0 6px 18px rgba(60,45,25,.2); }
.ov b { font-size: 22px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.ov:active { transform: scale(.97); }
.ov-pri { background: color-mix(in srgb, var(--btn) 82%, transparent); color: var(--btn-fg); }
.ov-pri small { color: var(--btn-fg); opacity: .65; }
.overlay-aux { display: flex; gap: 8px; justify-content: center; }

.topo-dir { display: flex; align-items: center; gap: 12px; }
.engrenagem {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: none; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.engrenagem:active { color: var(--fg); transform: scale(.94); }
.engrenagem:active { transform: scale(.94); }

.compor {
  position: fixed; left: 14px; right: 14px; bottom: max(14px, env(safe-area-inset-bottom));
  background: var(--card); border-radius: 20px; padding: 12px;
  display: flex; flex-direction: column; gap: 10px; z-index: 45;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}
.compor textarea {
  width: 100%; border: 0; border-radius: 14px; padding: 12px;
  background: var(--bg); color: var(--fg); font: 400 17px/1.5 inherit;
  resize: none; -webkit-user-select: text; user-select: text;
}
.compor-linha { display: flex; gap: 8px; align-items: center; }
.compor-linha .tosta-btn { margin-left: auto; font-size: 17px; padding: 14px 26px; }
.reply-acoes { display: none; }

.seccao {
  font-size: 15px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-top: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.ignorado { min-height: 50px; padding: 8px 8px 8px 16px; }
.ignorado .rotulo { font-family: ui-monospace, Menlo, monospace; font-size: 14.5px; }

.primario.gigante {
  font-size: 64px; padding: 48px 0; border-radius: 36px; width: 100%;
}

.zona-ouvido { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 46px; }
/* A legenda corre para o lado, como o rodapé de um telejornal. */
.ouvido-txt {
  font-size: 20px; font-weight: 500; color: var(--fg); min-height: 26px;
  width: 100%; max-width: 100%; overflow: hidden; white-space: nowrap; text-align: left;
}
.ouvido-txt .fita, .ouvido-espelho .fita {
  display: inline-block; white-space: nowrap;
  animation: fita 9s linear infinite;
}
@keyframes fita { from { transform: translateX(100vw) } to { transform: translateX(-100%) } }
.ouvido-txt.comando { color: var(--accent); font-weight: 650; }
/* pontinhos enquanto capta; reticências enquanto transcreve */
.ouvido-txt.captando::after { content: "● ● ●"; color: var(--accent); animation: pulsar 1s ease-in-out infinite; }
.ouvido-txt.pensando::after { content: "a perceber…"; color: var(--muted); }

/* Os dois botões do início: gémeos em tamanho — só a cor os distingue. */
.botoes-inicio { display: flex; flex-direction: column; gap: 12px; width: 230px; }
.botoes-inicio .primario { width: 100%; padding: 18px 0; font-size: 19px; border-radius: 20px; }
.primario.secundario { background: var(--card); color: var(--fg); }
/* Arranque automático: ecrã negro só com o nome */
.arranque-negro #resumo-inicio, .arranque-negro #btn-comecar, .arranque-negro #btn-defs { display: none; }


/* Modo inspetor: os botões mostram o nome em vez de executar. */
body.inspecao button { outline: 2px dashed var(--flag); outline-offset: -2px; }
.selo-inspecao {
  position: fixed; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: var(--flag); color: #1c1200; font: 700 13px/1 inherit;
  padding: 8px 14px; border-radius: 999px; z-index: 90;
}

.mini.voltar { padding: 14px 22px; font-size: 17px; font-weight: 650; color: var(--fg); }

/* A letra dos botões é a do próprio iPhone (SF Pro) — caixa normal, sem
   espaçamento: o look Apple limpo, em vez de MAIÚSCULAS a gritar. */
.accao b, .ov b {
  font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
  letter-spacing: 0; text-transform: capitalize; font-weight: 600;
}
.accao b { font-size: 22px; }
.ov b { font-size: 24px; }
.contador { font-size: 16px; font-weight: 600; color: var(--fg); }

/* A espera do arranque: um anel a rodar e uma frase com vida. */
.espera-inicial { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.anel {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent);
  animation: rodar 0.9s linear infinite;
}
@keyframes rodar { to { transform: rotate(360deg) } }
body.a-preparar #btn-comecar, body.a-preparar #btn-defs, body.a-preparar .botoes-inicio { display: none; }
/* No arranque direto só há o nome e um convite discreto a pulsar. */
.toque-arranque { display: none; }
body.arranque-negro .toque-arranque {
  display: block; color: var(--muted); font-size: 16px;
  animation: pulsar 2.2s ease-in-out infinite;
}

/* legenda viva também dentro do overlay, em rodapé */
.ouvido-espelho {
  min-height: 28px; text-align: left; color: var(--fg); font-size: 20px; font-weight: 500;
  overflow: hidden; white-space: nowrap; width: 100%;
}
.ouvido-espelho:empty { display: none; }

/* bandeira marcada: o mosaico fica assinalado e pronto para a próxima ação */
.ov.feita, .accao.feita { background: var(--flag); color: #1c1200; }
.ov.feita b, .accao.feita b { color: #1c1200; }
