/* Cálculo Certeiro: folha de estilo única. Sem dependências externas. */

@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/archivo-latin.woff2") format("woff2");
}

:root {
  color-scheme: light dark;
  --cabo: #c8161d;          /* vermelho da marca */
  --cabo-escuro: #9c0f15;
  --sobre-cabo: #ffffff;
  --aco: #edf0f2;           /* fundo: aço escovado claro */
  --chapa: #ffffff;         /* superfícies */
  --tinta: #17212b;
  --tinta-suave: #51606d;
  --borda: #cbd3da;
  --marca-texto: #b3121a;   /* vermelho legível sobre fundo claro */
  --foco: #1463d6;
  --ok: #17703f;
  --raio: 14px;
  --fonte: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --largura: 68rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --cabo: #cf2630;
    --cabo-escuro: #e04550;
    --aco: #10161c;
    --chapa: #19222b;
    --tinta: #e8edf1;
    --tinta-suave: #a3b0bb;
    --borda: #2f3b46;
    --marca-texto: #ff8a90;
    --foco: #7fb2ff;
    --ok: #6fd39b;
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }

body {
  margin: 0;
  background: var(--aco);
  color: var(--tinta);
  font: 400 1.0625rem/1.55 var(--fonte);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { line-height: 1.12; letter-spacing: -0.02em; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2rem, 5.2vw, 3.1rem); font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; letter-spacing: 0; }
p { margin: 0 0 1em; max-width: 70ch; }
a { color: var(--marca-texto); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
small { color: var(--tinta-suave); font-weight: 400; }
code, pre, .mono { font-family: var(--mono); font-size: 0.92em; }
pre { margin: 0 0 1em; padding: 0.9rem 1rem; background: var(--aco); border: 1px solid var(--borda); border-radius: 10px; overflow-x: auto; }

:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; border-radius: 4px; }

.so-leitor { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pular { position: absolute; left: 1rem; top: -4rem; z-index: 10; padding: 0.6rem 1rem; background: var(--chapa); border-radius: 8px; }
.pular:focus { top: 1rem; }

.largura { width: min(100% - 2rem, var(--largura)); margin-inline: auto; }

/* Topo */
.topo { padding: 1rem 0; }
.topo .largura { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.logo { min-height: 2.75rem; display: inline-flex; align-items: center; gap: 0.6rem; color: var(--tinta); text-decoration: none; font-weight: 800; font-size: 1.2rem; letter-spacing: -0.02em; }
.logo svg { width: 2rem; height: 2rem; flex: none; }
.topo nav { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: 0.95rem; }
.topo nav a { color: var(--tinta); text-decoration: none; font-weight: 600; padding: 0.7rem 0; white-space: nowrap; }
/* No celular, o menu vira uma única linha que desliza para o lado, para a ferramenta aparecer logo. */
@media (max-width: 60rem) {
  .topo { padding-bottom: 0.25rem; }
  .topo .largura { gap: 0.25rem 1rem; }
  .topo nav { flex-wrap: nowrap; width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .topo nav::-webkit-scrollbar { display: none; }
}
.topo nav a:hover { text-decoration: underline; text-decoration-thickness: 2px; }

/* Bloco vermelho da página inicial, com a busca dentro */
.cabo {
  position: relative;
  margin-top: 0.5rem;
  padding: clamp(1.75rem, 5vw, 3.25rem) clamp(1.5rem, 6vw, 4.5rem);
  background: var(--cabo);
  color: var(--sobre-cabo);
  border-radius: clamp(28px, 6vw, 64px);
}
.cabo-figura { position: absolute; right: clamp(3rem, 7vw, 6.5rem); top: 50%; width: min(15rem, 24%); height: auto; transform: translateY(-50%); }
@media (max-width: 52rem) { .cabo-figura { display: none; } }
.cabo h1 { max-width: 16ch; }
.cabo p { margin: 0.9rem 0 1.5rem; font-size: 1.15rem; max-width: 46ch; }
.busca { display: block; max-width: 34rem; }
.busca input {
  width: 100%;
  padding: 0.95rem 1.4rem;
  font: 500 1.1rem var(--fonte);
  color: #17212b;
  background: #fff;
  border: 0;
  border-radius: 999px;
}
.busca input:focus-visible { outline-color: #fff; outline-offset: 3px; }

/* Índice de ferramentas */
.categoria { margin-top: 2.75rem; }
.categoria > h2 { padding-bottom: 0.7rem; border-bottom: 3px solid var(--tinta); }
.indice { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); column-gap: 2rem; }
.indice li { border-bottom: 1px solid var(--borda); }
.indice a { display: block; padding: 0.85rem 0; color: var(--tinta); text-decoration: none; }
.indice strong { display: block; font-weight: 700; font-size: 1.08rem; }
.indice span { display: block; color: var(--tinta-suave); font-size: 0.95rem; line-height: 1.4; }
.indice a:hover strong, .indice a:focus-visible strong { color: var(--marca-texto); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.18em; }
.vazio { margin-top: 2rem; font-size: 1.1rem; }

/* Página de ferramenta */
.trilha { margin: 0.5rem 0 1.25rem; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; font-size: 0.92rem; color: var(--tinta-suave); }
.trilha li + li::before { content: "/"; margin-right: 0.4rem; }
.trilha a { color: inherit; display: inline-block; padding: 0.6rem 0; }
.trilha li { display: flex; align-items: center; }
.lide { margin: 0.8rem 0 1.5rem; font-size: 1.15rem; color: var(--tinta-suave); max-width: 60ch; }

.chapa {
  background: var(--chapa);
  border: 1px solid var(--borda);
  border-top: 5px solid var(--cabo);
  border-radius: var(--raio);
  padding: clamp(1.1rem, 3.5vw, 2rem);
}
.chapa > :last-child { margin-bottom: 0; }

.texto { margin-top: 2.75rem; max-width: 46rem; }
.texto h2 { margin: 2.25rem 0 0.8rem; }
.texto ul, .texto ol { padding-left: 1.2rem; margin: 0 0 1em; max-width: 68ch; }
.texto li { margin-bottom: 0.35em; }
.faq details { border-bottom: 1px solid var(--borda); }
.faq summary { padding: 0.9rem 0; font-weight: 700; cursor: pointer; }
.faq details p { margin-bottom: 1rem; }
.relacionadas { margin-top: 2.75rem; }

/* Formulários */
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: 1rem 1.25rem; margin-bottom: 1.25rem; }
.campo { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.98rem; }
.campo small { font-size: 0.85rem; }
.campo-largo { grid-column: 1 / -1; }

input, select, textarea, button { font: inherit; color: inherit; }
input:not([type="checkbox"], [type="radio"], [type="range"]), select, textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--chapa);
  border: 1.5px solid var(--tinta-suave);
  border-radius: 10px;
  font-weight: 500;
  font-size: max(1rem, 16px); /* abaixo de 16px o iPhone dá zoom ao tocar no campo */
}
textarea { min-height: 11rem; resize: vertical; font-family: var(--mono); line-height: 1.5; }
textarea.prosa { font-family: var(--fonte); font-size: 1.0625rem; }
input::placeholder, textarea::placeholder { color: var(--tinta-suave); opacity: 0.75; }
.marcar { display: flex; align-items: center; gap: 0.55rem; font-weight: 500; min-height: 2.75rem; }
.marcar input { width: 1.2rem; height: 1.2rem; accent-color: var(--cabo); flex: none; }
fieldset { border: 0; padding: 0; margin: 0 0 1.25rem; }
legend { padding: 0; font-weight: 700; margin-bottom: 0.5rem; }
.opcoes { display: flex; flex-wrap: wrap; gap: 0.6rem 1.4rem; }

.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.6rem;
  background: var(--cabo);
  color: var(--sobre-cabo);
  border: 2px solid var(--cabo);
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.botao:hover { background: var(--cabo-escuro); border-color: var(--cabo-escuro); }
.botao:disabled { opacity: 0.55; cursor: progress; }
.botao-2 { background: transparent; color: var(--tinta); border-color: var(--tinta); }
.botao-2:hover { background: var(--tinta); color: var(--chapa); border-color: var(--tinta); }
.acoes { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0; }

/* Resultados */
.saida { margin-top: 1.75rem; padding-top: 1.5rem; border-top: 1px solid var(--borda); }
.saida > :last-child { margin-bottom: 0; }
.destaque { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 1.5rem; }
.destaque-rotulo { font-weight: 600; color: var(--tinta-suave); }
.destaque-valor { font-size: clamp(2.1rem, 7vw, 3.2rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; overflow-wrap: anywhere; }
.destaque-nota { color: var(--tinta-suave); }
.grupo { margin-bottom: 1.5rem; }
.grupo h3 { margin-bottom: 0.4rem; }
.linhas { margin: 0; }
.linha { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--borda); }
.linha dt { font-weight: 500; }
.linha dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.linha-menos dd { color: var(--marca-texto); white-space: nowrap; }
.linha-total { border-bottom: 0; border-top: 2px solid var(--tinta); margin-top: -1px; }
.linha-total dt, .linha-total dd { font-weight: 800; font-size: 1.1rem; }
.nota { font-size: 0.92rem; color: var(--tinta-suave); }
.aviso { padding: 0.8rem 1rem; border-radius: 10px; border: 1.5px solid var(--borda); font-weight: 600; }
.aviso-erro { border-color: var(--marca-texto); color: var(--marca-texto); }
.aviso-ok { border-color: var(--ok); color: var(--ok); }

.tabela-rolagem { overflow-x: auto; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { padding: 0.5rem 0.75rem; text-align: right; border-bottom: 1px solid var(--borda); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th { font-weight: 700; border-bottom: 2px solid var(--tinta); }
.tabela-texto td, .tabela-texto th { text-align: left; white-space: normal; overflow-wrap: anywhere; }

/* Qual é o meu IP */
.ip-rotulo { margin: 0; font-weight: 600; color: var(--tinta-suave); }
.ip-valor { margin: 0.1rem 0 0; font-size: clamp(1.7rem, 7.5vw, 3.6rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; max-width: none; }

/* Medidores e mídia */
.medidor { height: 1.4rem; background: var(--aco); border: 1px solid var(--borda); border-radius: 999px; overflow: hidden; }
.medidor div { height: 100%; width: 0; background: var(--ok); }
.palco { display: block; width: 100%; max-height: 70vh; background: #000; border-radius: 10px; aspect-ratio: 16 / 9; object-fit: contain; }
.espelhado { transform: scaleX(-1); }
audio { width: 100%; margin-top: 0.75rem; }
canvas.qr { display: block; width: min(100%, 20rem); height: auto; image-rendering: pixelated; background: #fff; border: 1px solid var(--borda); border-radius: 10px; }

/* Teste de teclado */
.teclado { display: grid; gap: 0.3rem; overflow-x: auto; padding-bottom: 0.25rem; }
.fila { display: flex; gap: 0.3rem; min-width: 46rem; }
.tecla {
  flex: 1 1 0;
  min-width: 0;
  height: 2.7rem;
  display: grid;
  place-items: center;
  background: var(--aco);
  border: 1.5px solid var(--borda);
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}
/* A primeira cor vale para navegadores antigos, sem color-mix. */
.tecla[data-testada] { background: var(--chapa); background: color-mix(in srgb, var(--ok) 22%, var(--chapa)); border-color: var(--ok); border-width: 2.5px; }
.tecla[data-ativa] { background: var(--cabo); border-color: var(--cabo); color: var(--sobre-cabo); }
.vao { flex: 0.5 1 0; }

/* Contadores */
.contagens { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: 0.75rem; margin: 1.25rem 0; padding: 0; list-style: none; }
.contagens li { padding: 0.8rem 0.9rem; border: 1px solid var(--borda); border-radius: 10px; }
.contagens strong { display: block; font-size: 1.7rem; font-weight: 800; line-height: 1.1; }
.contagens span { font-size: 0.9rem; color: var(--tinta-suave); }

/* Rodapé */
.rodape { margin-top: 4rem; padding: 2rem 0 2.5rem; border-top: 3px solid var(--tinta); font-size: 0.95rem; }
.rodape .largura { display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; }
.rodape p { margin: 0; color: var(--tinta-suave); }
.rodape nav { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; }
.rodape a { color: var(--tinta); display: inline-block; padding: 0.7rem 0; }

.espaco { margin-top: 1.25rem; }

[hidden] { display: none !important; }

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

@media print {
  .topo nav, .rodape, .relacionadas, .botao, .acoes { display: none; }
  body { background: #fff; }
}
