/* =========================================================================
   Paritian — folha de estilo unica.

   Ideia do desenho: uma bancada de trabalho. Papel quadriculado de
   engenharia no modo claro, papel azul de projecto no modo escuro.
   Regras finas em vez de sombras, tipografia editorial grande, e todos
   os numeros em monoespacado com algarismos de largura fixa, como num
   instrumento de medida.

   Sem frameworks e sem fontes externas: um unico pedido, funciona offline.
   ========================================================================= */

/* ---------------------------------------------------------------- tokens */
:root {
  /* papel */
  --paper:       #f3efe6;
  --paper-2:     #fbf9f4;
  --paper-3:     #ece7db;
  --ink:         #17191f;
  --ink-2:       #3c424e;
  --muted:       #71788a;
  --rule:        #ded7c7;
  --rule-2:      #c6bda8;

  /* sinal */
  --accent:      #d1490b;
  --accent-ink:  #ffffff;
  --accent-soft: #fbe6d8;
  --ok:          #1c7a45;
  --danger:      #b02318;

  /* grelha de fundo */
  --grid-line:   rgba(23, 25, 31, .055);
  --grid-major:  rgba(23, 25, 31, .085);

  /* curvas dos graficos: cinco cores que se distinguem uma da outra
     tambem para quem nao distingue vermelho de verde — por isso variam
     em claridade, e nao so em matiz */
  --chart-1:     #c2410c;
  --chart-2:     #1c7a45;
  --chart-3:     #1e4d8c;
  --chart-4:     #7c3aed;
  --chart-5:     #8a6d00;
  --chart-grid:  rgba(23, 25, 31, .09);
  --chart-axis:  #b3a894;

  --wrap:        1180px;
  --radius:      3px;
  --tick:        14px;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
          "Liberation Mono", "Courier New", monospace;
}

:root[data-theme="dark"] {
  /* papel de projecto */
  --paper:       #081826;
  --paper-2:     #0d2233;
  --paper-3:     #102b3f;
  --ink:         #e6eef6;
  --ink-2:       #b7c7d6;
  --muted:       #7d95aa;
  --rule:        #1b3c55;
  --rule-2:      #2b587a;

  --accent:      #ffb020;
  --accent-ink:  #16202b;
  --accent-soft: #14283a;
  --ok:          #56d69a;
  --danger:      #ff9a8f;

  --grid-line:   rgba(120, 200, 255, .055);
  --grid-major:  rgba(120, 200, 255, .1);

  --chart-1:     #ff9a4d;
  --chart-2:     #56d69a;
  --chart-3:     #6fb4ff;
  --chart-4:     #c49bff;
  --chart-5:     #ffd24d;
  --chart-grid:  rgba(120, 200, 255, .12);
  --chart-axis:  #2b587a;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  /* papel quadriculado: linha fina a cada 22px, linha forte a cada 110px */
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px);
  background-size: 22px 22px, 22px 22px, 110px 110px, 110px 110px;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; }

a { color: var(--ink); text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

::selection { background: var(--accent); color: var(--accent-ink); }

.wrap { width: min(100% - 2.4rem, var(--wrap)); margin-inline: auto; }
.wrap.narrow { width: min(100% - 2.4rem, 46rem); }

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

.skip {
  position: absolute; left: 1rem; top: -4rem;
  background: var(--ink); color: var(--paper); padding: .6rem 1rem;
  z-index: 100; transition: top .15s; font-weight: 600;
}
.skip:focus { top: .6rem; }

/* ---------------------------------------------------------------- texto */
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 800; line-height: 1.08; letter-spacing: -.035em; }
h1 { font-size: clamp(2.1rem, 1.3rem + 3.6vw, 4.1rem); }
h2 { font-size: clamp(1.45rem, 1.1rem + 1.5vw, 2.1rem); }
h3 { font-size: 1.05rem; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.15em; }

.lead { font-size: clamp(1rem, .95rem + .35vw, 1.15rem); color: var(--ink-2); max-width: 58ch; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* etiqueta tecnica: monoespacado, maiusculas, muito espacado */
.kicker, .eyebrow, .card-cat, .ad-label, thead th, .stat-label, .step-no {
  font-family: var(--mono);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 600;
}
.eyebrow { color: var(--accent); margin: 0 0 .7rem; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.kicker { color: var(--muted); }

code { font-family: var(--mono); font-size: .92em; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- cabecalho */
.site-head {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}
@supports not (backdrop-filter: blur(1px)) { .site-head { background: var(--paper); } }

.head-inner { display: flex; align-items: center; gap: 1rem; min-height: 58px; }

.brand {
  display: inline-flex; align-items: center; gap: .55rem;
  color: var(--ink); text-decoration: none;
  font-weight: 800; letter-spacing: -.045em; font-size: 1.06rem;
}
.brand-mark { color: var(--ink); flex: none; }
.brand-bar { fill: var(--accent); }
.brand-name::after {
  content: ""; display: inline-block; width: 6px; height: 6px;
  background: var(--accent); margin-left: .35rem; vertical-align: .08em;
}

.head-nav { margin-left: auto; }
.head-nav ul { display: flex; gap: .1rem; list-style: none; margin: 0; padding: 0; }
.head-nav a {
  display: block; padding: .4rem .7rem; color: var(--ink-2);
  text-decoration: none; font-size: .9rem; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.head-nav a:hover { color: var(--ink); border-bottom-color: var(--rule-2); }
.head-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.head-tools { display: flex; align-items: center; gap: .35rem; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid var(--rule-2); border-radius: var(--radius);
  background: var(--paper-2); color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.theme-switch { display: flex; border: 1px solid var(--rule-2); border-radius: var(--radius); overflow: hidden; }
.theme-switch button {
  width: 30px; height: 32px; border: 0; background: var(--paper-2);
  color: var(--muted); cursor: pointer; font-size: .9rem; line-height: 1;
}
.theme-switch button + button { border-left: 1px solid var(--rule); }
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.lang-pick { position: relative; }
.lang-pick summary {
  list-style: none; cursor: pointer; display: grid; place-items: center;
  width: 38px; height: 34px; border: 1px solid var(--rule-2); border-radius: var(--radius);
  font-family: var(--mono); font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  color: var(--muted); background: var(--paper-2);
}
.lang-pick summary::-webkit-details-marker { display: none; }
.lang-pick[open] summary { border-color: var(--accent); color: var(--accent); }
.lang-pick ul {
  position: absolute; right: 0; top: calc(100% + .4rem); min-width: 10rem;
  background: var(--paper-2); border: 1px solid var(--rule-2);
  list-style: none; margin: 0; padding: .25rem; z-index: 50;
  box-shadow: 6px 6px 0 var(--grid-major);
}
.lang-pick a { display: block; padding: .4rem .6rem; color: var(--ink); text-decoration: none; font-size: .9rem; }
.lang-pick a:hover { background: var(--paper-3); }
.lang-pick a[aria-current="true"] { color: var(--accent); font-weight: 700; }

@media (max-width: 680px) { .head-nav { display: none; } }

/* ---------------------------------------------------------------- pesquisa no topo */
.searchbar { border-bottom: 1px solid var(--rule); background: var(--paper-2); padding: .8rem 0 1rem; }
.searchbar input {
  width: 100%; padding: .75rem .9rem; font: inherit; font-size: 1rem;
  border: 1px solid var(--rule-2); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
}
.searchbar input:focus { border-color: var(--accent); }
.search-results { margin-top: .5rem; max-height: 60vh; overflow-y: auto; }
.search-results:empty { display: none; }
.search-results a {
  display: block; padding: .55rem .7rem; color: var(--ink); text-decoration: none;
  border-bottom: 1px solid var(--rule);
}
.search-results a:hover, .search-results a.is-active { background: var(--paper-3); }
.search-results strong { display: block; font-size: .95rem; font-weight: 700; }
.search-results small { color: var(--muted); font-size: .8rem; }
.search-results mark { background: var(--accent-soft); color: inherit; }

/* ================================================================ PALCO (homepage) */
.stage {
  position: relative;
  padding: clamp(2.6rem, 7vw, 5.4rem) 0 clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}
.stage::before,
.stage::after {
  content: ""; position: absolute; pointer-events: none;
  border: 1px solid var(--rule-2); width: var(--tick); height: var(--tick);
}
.stage::before { top: 1.1rem; left: 1.1rem; border-right: 0; border-bottom: 0; }
.stage::after { bottom: 1.1rem; right: 1.1rem; border-left: 0; border-top: 0; }

.stage-inner { text-align: center; }
.stage h1 { max-width: 16ch; margin-inline: auto; }
.stage h1 em { font-style: normal; color: var(--accent); }
.stage .lead { margin-inline: auto; text-align: center; }

.stat-strip {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem 1.6rem;
  margin: 0 0 1.6rem; padding: 0; list-style: none;
}
.stat-strip li { display: flex; align-items: baseline; gap: .4rem; }
.stat-strip b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .95rem; }
.stat-label { color: var(--muted); }

/* caixa de pesquisa grande */
.hero-search { position: relative; max-width: 42rem; margin: 2rem auto 1rem; text-align: left; }
.hero-search form { display: flex; border: 2px solid var(--ink); background: var(--paper-2); }
.hero-search input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: clamp(1rem, .95rem + .4vw, 1.15rem);
  padding: 1rem 1.1rem;
}
.hero-search input::placeholder { color: var(--muted); }
.hero-search input:focus { outline: 0; }
.hero-search button {
  border: 0; border-left: 2px solid var(--ink); background: var(--ink); color: var(--paper);
  font: inherit; font-weight: 700; padding: 0 1.3rem; cursor: pointer;
  display: grid; place-items: center;
}
.hero-search button:hover { background: var(--accent); color: var(--accent-ink); }
.hero-search:focus-within form { border-color: var(--accent); }
.hero-search:focus-within button { background: var(--accent); border-left-color: var(--accent); color: var(--accent-ink); }

/* resposta imediata a uma conversao escrita na caixa */
.hero-answer {
  margin-top: -1px; border: 2px solid var(--accent); background: var(--accent-soft);
  padding: .9rem 1.1rem; display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: .6rem;
}
.hero-answer .q { font-family: var(--mono); font-size: .85rem; color: var(--ink-2); }
.hero-answer .a {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(1.3rem, 1rem + 1.6vw, 1.9rem); font-weight: 700; color: var(--ink);
}
.hero-answer a { font-size: .82rem; color: var(--ink-2); }

.hero-hits { border: 1px solid var(--rule-2); border-top: 0; background: var(--paper-2); }
.hero-hits:empty { display: none; }
.hero-hits a {
  display: flex; align-items: baseline; gap: .7rem; padding: .6rem .9rem;
  text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--rule);
}
.hero-hits a:last-child { border-bottom: 0; }
.hero-hits a:hover { background: var(--paper-3); }
.hero-hits b { font-weight: 700; font-size: .95rem; }
.hero-hits span { font-family: var(--mono); font-size: .68rem; text-transform: uppercase;
                  letter-spacing: .14em; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* sugestoes clicaveis */
.try {
  display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem;
  list-style: none; margin: 0; padding: 0;
}
.try li button {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .02em;
  padding: .35rem .7rem; border: 1px dashed var(--rule-2); background: transparent;
  color: var(--ink-2); cursor: pointer; border-radius: var(--radius);
}
.try li button:hover { border-style: solid; border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- seccoes */
.band { padding: clamp(2.4rem, 6vw, 4rem) 0; border-bottom: 1px solid var(--rule); }
.band:last-of-type { border-bottom: 0; }
.band-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1rem;
  padding-bottom: .6rem; margin-bottom: 1.6rem; border-bottom: 2px solid var(--ink);
}
.band-head h2 { margin: 0; }
.band-head p { margin: 0; color: var(--muted); font-size: .92rem; max-width: 46ch; }
.band-head .more { margin-left: auto; }

.more {
  font-family: var(--mono); font-size: .75rem; text-transform: uppercase;
  letter-spacing: .14em; font-weight: 700; color: var(--accent); text-decoration: none;
  white-space: nowrap;
}
.more:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- indice numerado */
.index-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.index-list li { border-bottom: 1px solid var(--rule); }
.index-list a {
  display: grid; align-items: baseline; gap: .2rem .9rem;
  grid-template-columns: 2.6rem 1fr; padding: .75rem .3rem;
  text-decoration: none; color: var(--ink);
}
@media (min-width: 50rem) {
  .index-list a { grid-template-columns: 3rem minmax(0, 20rem) 1fr auto; padding: .7rem .4rem; }
}
.index-list a:hover { background: var(--paper-2); }
.index-list a:hover .idx-name { color: var(--accent); }
.idx-no { font-family: var(--mono); font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.idx-name { font-weight: 700; letter-spacing: -.015em; }
.idx-desc { color: var(--muted); font-size: .88rem; overflow: hidden;
            display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.idx-cat { font-family: var(--mono); font-size: .66rem; text-transform: uppercase;
           letter-spacing: .14em; color: var(--muted); white-space: nowrap; }
@media (max-width: 50rem) { .idx-desc, .idx-cat { grid-column: 2; } .idx-cat { order: 3; } }

/* ---------------------------------------------------------------- folha de categorias */
.sheet {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 0;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr));
  border-top: 1px solid var(--rule); border-left: 1px solid var(--rule);
}
.sheet li { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.sheet a {
  display: flex; flex-direction: column; gap: .3rem; height: 100%;
  padding: 1.1rem 1.1rem 1.2rem; text-decoration: none; color: var(--ink);
  position: relative; background: transparent;
}
.sheet a:hover { background: var(--paper-2); }
.sheet a:hover .sheet-icon { color: var(--accent); transform: translateY(-2px); }
.sheet-icon { font-size: 1.9rem; line-height: 1; color: var(--ink-2); transition: .15s; }
.sheet-name { font-weight: 700; letter-spacing: -.02em; }
.sheet-count {
  position: absolute; top: .9rem; right: 1rem;
  font-family: var(--mono); font-size: .7rem; color: var(--muted); font-variant-numeric: tabular-nums;
}
.sheet-desc { color: var(--muted); font-size: .82rem; line-height: 1.45; margin-top: .2rem; }

/* ---------------------------------------------------------------- cartoes (listas) */
.cards {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 0;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.5rem), 1fr));
  border-top: 1px solid var(--rule); border-left: 1px solid var(--rule);
}
.card { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.card a {
  display: grid; height: 100%;
  grid-template-columns: 2.1rem 1fr auto;
  grid-template-areas: "icon cat go" "icon title title" "icon desc desc";
  gap: .18rem .7rem; align-content: start;
  padding: 1.05rem 1.05rem 1.15rem; text-decoration: none; color: var(--ink);
  position: relative; transition: background .14s ease;
}
/* a barra de acento cresce da esquerda em vez de aparecer de repente, para
   o cartao nao saltar nem mudar de tamanho ao passar o rato */
.card a::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform .14s ease;
}
.card a:hover, .card a:focus-visible { background: var(--paper-2); }
.card a:hover::before, .card a:focus-visible::before { transform: scaleX(1); }
.card a:hover .card-title, .card a:focus-visible .card-title { color: var(--accent); }
.card a:hover .card-icon, .card a:focus-visible .card-icon { color: var(--accent); }
.card a:hover .card-go, .card a:focus-visible .card-go { opacity: 1; transform: none; }
.card-icon {
  grid-area: icon; font-size: 1.45rem; line-height: 1.1; color: var(--ink-2);
  transition: color .14s ease;
}
.card-cat {
  grid-area: cat; color: var(--muted);
  font-family: var(--mono); font-size: .64rem;
  text-transform: uppercase; letter-spacing: .14em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* dentro de uma categoria, o nome dela esta no titulo da pagina: repeti-lo
   em cada cartao so enche a lista de ruido. O icone fica, porque ajuda a
   reconhecer a familia de relance. */
.cards-same-cat .card-cat { display: none; }
.cards-same-cat .card a { grid-template-areas: "icon title go" "icon desc desc"; }
.card-title {
  grid-area: title; font-weight: 700; font-size: 1rem; line-height: 1.25;
  letter-spacing: -.02em; margin-top: .15rem;
}
.card-desc { grid-area: desc; font-size: .85rem; color: var(--muted); line-height: 1.5; margin-top: .15rem; }
.card-go {
  grid-area: go; color: var(--accent); font-size: .95rem; line-height: 1;
  opacity: 0; transform: translateX(-.25rem); transition: opacity .14s ease, transform .14s ease;
}
@media (prefers-reduced-motion: reduce) {
  .card a, .card a::before, .card-go, .card-icon { transition: none; }
}

.pill-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.pill-list a {
  display: inline-block; padding: .4rem .8rem; border: 1px solid var(--rule-2);
  color: var(--ink); text-decoration: none; font-size: .87rem; border-radius: var(--radius);
}
.pill-list a:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------------------------------------------------------- passos */
.steps {
  list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  border-top: 1px solid var(--rule); border-left: 1px solid var(--rule);
}
.steps li {
  counter-increment: s; padding: 1.3rem 1.2rem;
  border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.steps li::before {
  content: counter(s, decimal-leading-zero);
  display: block; font-family: var(--mono); font-size: .72rem; letter-spacing: .2em;
  color: var(--accent); margin-bottom: .7rem;
}
.steps h3 { margin-bottom: .3rem; }
.steps p { margin: 0; color: var(--muted); font-size: .89rem; }

/* ---------------------------------------------------------------- paginas internas */
.page-head { padding: clamp(1.6rem, 4vw, 3rem) 0 1rem; }
.page-head h1 { max-width: 22ch; }
.crumbs { padding-top: 1.1rem; }
.crumbs ol {
  display: flex; flex-wrap: wrap; gap: .3rem; list-style: none; margin: 0; padding: 0;
  font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; color: var(--muted);
  text-transform: uppercase;
}
.crumbs li + li::before { content: "/"; margin-right: .3rem; opacity: .5; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

/* ---------------------------------------------------------------- botoes */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .7rem 1.2rem; min-height: 44px;
  border: 2px solid var(--ink); border-radius: var(--radius);
  font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--ink); color: var(--paper);
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule-2); }
.btn-ghost:hover { background: transparent; border-color: var(--accent); color: var(--accent); }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .4rem .8rem; min-height: 36px;
  border: 1px solid var(--rule-2); border-radius: var(--radius);
  background: var(--paper-2); color: var(--ink-2); font: inherit; font-size: .85rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- instrumento (calculadora) */
.tool-layout {
  display: grid; gap: clamp(1.6rem, 4vw, 2.8rem);
  grid-template-columns: minmax(0, 1fr); padding-bottom: 2.5rem;
}
@media (min-width: 64rem) {
  .tool-layout { grid-template-columns: minmax(0, 1fr) 18.5rem; align-items: start; }
  .tool-aside { position: sticky; top: 4.8rem; }
}
.tool-head { padding: 1rem 0 .2rem; }
.tool-bar { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1.1rem; }

.calc-card {
  background: var(--paper-2); border: 2px solid var(--ink);
  margin: 1.4rem 0 1.8rem; position: relative;
}
.calc-card::before {
  content: ""; position: absolute; inset: 5px; border: 1px solid var(--rule);
  pointer-events: none;
}
.calc { padding: clamp(1.1rem, 3vw, 1.7rem); position: relative; }
.fields { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr)); }

.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label {
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase;
  letter-spacing: .14em; font-weight: 600; color: var(--muted);
}
.opt-tag { letter-spacing: .06em; text-transform: none; color: var(--rule-2); }
.control { display: flex; align-items: stretch; }
.field input, .field select, .field textarea {
  width: 100%; min-width: 0; padding: .6rem .75rem; min-height: 46px;
  font-family: var(--mono); font-size: 1.05rem; font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule-2); border-radius: 0;
}
.field select { font-family: var(--sans); font-size: .95rem; }
.field textarea { font-size: .95rem; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); outline: 0; box-shadow: inset 0 -2px 0 var(--accent);
}
.field .unit {
  display: grid; place-items: center; padding: 0 .7rem; margin-left: -1px;
  background: var(--paper-3); border: 1px solid var(--rule-2);
  font-family: var(--mono); font-size: .8rem; color: var(--muted); white-space: nowrap;
}
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field-error { margin: 0; font-size: .78rem; color: var(--danger); }

.field-inline { flex-direction: row; align-items: center; gap: .5rem; margin-left: auto; }
.field-inline label { white-space: nowrap; }
.field-inline select { min-height: 38px; padding: .3rem .45rem; width: auto; }

.conv-grid { display: grid; gap: .9rem; grid-template-columns: 1fr; align-items: end; }
@media (min-width: 48rem) {
  .conv-grid { grid-template-columns: minmax(7rem, .9fr) minmax(0, 1.25fr) auto minmax(0, 1.25fr); }
}
.conv-swap { display: flex; justify-content: center; padding-bottom: .35rem; }

.calc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1.3rem; }
.calc-error { margin: .8rem 0 0; color: var(--danger); font-size: .88rem; }

/* mostrador */
.results {
  background: var(--ink); color: var(--paper);
  padding: clamp(1rem, 3vw, 1.4rem); display: grid; gap: .3rem;
}
:root[data-theme="dark"] .results { background: #04101b; }
.result {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .1rem .8rem;
  padding: .5rem .2rem; border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.result:last-child { border-bottom: 0; }
.result--primary { padding: .8rem .2rem 1rem; border-bottom: 1px solid rgba(255, 255, 255, .25); }
.result-label {
  grid-column: 1; font-family: var(--mono); font-size: .66rem; text-transform: uppercase;
  letter-spacing: .16em; color: rgba(255, 255, 255, .55);
}
.result--primary .result-label { color: var(--accent); }
.result-body { grid-column: 1; display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap; min-width: 0; }
.result-value {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 1.15rem; font-weight: 600; word-break: break-word; color: #fff;
}
:root[data-theme="dark"] .result-value { color: var(--ink); }
.result--primary .result-value {
  font-size: clamp(1.9rem, 1.3rem + 2.6vw, 2.9rem); font-weight: 700; letter-spacing: -.03em;
}
.result-unit { font-family: var(--mono); font-size: .85rem; color: rgba(255, 255, 255, .6); }
/* Um resultado que e uma grelha — um calendario, uma tabela alinhada — so se
   le se os espacos ficarem onde estao e o corpo for pequeno. O tamanho
   gigante do resultado principal desfaz a grelha em qualquer ecra estreito. */
.result--grid .result-value {
  display: block;
  white-space: pre;
  overflow-x: auto;
  font-size: .95rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.55;
  word-break: normal;
  tab-size: 2;
}
.result--grid.result--primary .result-value { font-size: 1.05rem; font-weight: 600; }
@media (max-width: 30rem) { .result--grid .result-value { font-size: .85rem; } }
.copy-btn {
  grid-row: 1 / span 2; grid-column: 2; align-self: center;
  border: 1px solid rgba(255, 255, 255, .25); background: transparent; color: rgba(255, 255, 255, .7);
  border-radius: var(--radius); padding: .3rem .65rem; min-height: 34px;
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .1em;
  cursor: pointer; white-space: nowrap;
}
.copy-btn:hover { color: #fff; border-color: var(--accent); }
.copy-btn.is-done { color: var(--ok); border-color: var(--ok); }
.result-sentence {
  margin: .5rem 0 0; font-family: var(--mono); font-size: .85rem;
  color: rgba(255, 255, 255, .6);
}
.result-sentence strong { color: #fff; }
:root[data-theme="dark"] .result-unit,
:root[data-theme="dark"] .result-label,
:root[data-theme="dark"] .result-sentence { color: var(--muted); }
:root[data-theme="dark"] .result-sentence strong { color: var(--ink); }
:root[data-theme="dark"] .copy-btn { color: var(--muted); border-color: var(--rule); }
:root[data-theme="dark"] .copy-btn:hover { color: var(--accent); border-color: var(--accent); }

.notice {
  padding: .8rem 1rem; border: 1px solid var(--rule-2); border-left: 3px solid var(--accent);
  background: var(--paper-2); font-size: .9rem;
}

/* ---------------------------------------------------------------- prosa */
.prose { max-width: 66ch; }
.prose h2 {
  margin-top: 2.4rem; padding-bottom: .4rem; border-bottom: 1px solid var(--rule);
  font-size: clamp(1.2rem, 1.05rem + .6vw, 1.5rem);
}
.prose h3 { margin-top: 1.7rem; }
.prose .formula {
  font-family: var(--mono); font-size: 1rem; padding: 1rem 1.1rem;
  background: var(--paper-2); border: 1px solid var(--rule-2);
  border-left: 3px solid var(--accent);
  overflow-x: auto; white-space: pre-wrap; line-height: 1.7;
}
.notes { list-style: none; padding: 0; display: grid; gap: .5rem; }
.notes li {
  padding: .7rem .9rem .7rem 1.6rem; background: var(--paper-2);
  border: 1px solid var(--rule); font-size: .9rem; color: var(--ink-2); position: relative;
}
.notes li::before {
  content: "!"; position: absolute; left: .65rem; top: .7rem;
  font-family: var(--mono); font-weight: 700; color: var(--accent);
}
.faq { border: 1px solid var(--rule); background: var(--paper-2); margin-bottom: .5rem; }
.faq summary { padding: .8rem 1rem; cursor: pointer; font-weight: 700; font-size: .95rem; }
.faq[open] summary { border-bottom: 1px solid var(--rule); color: var(--accent); }
.faq p { padding: .8rem 1rem; margin: 0; color: var(--ink-2); font-size: .92rem; }

.example-grid {
  display: grid; gap: .9rem; align-items: center; grid-template-columns: 1fr;
  padding: 1.1rem; background: var(--paper-2); border: 1px solid var(--rule-2);
}
@media (min-width: 42rem) { .example-grid { grid-template-columns: 1fr auto 1fr; } }
.example-grid ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.example-grid li {
  display: flex; justify-content: space-between; gap: .8rem; font-size: .88rem;
  border-bottom: 1px dotted var(--rule-2); padding-bottom: .25rem;
}
.example-grid li span { color: var(--muted); }
.example-grid li b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.example-out li b { color: var(--accent); }
.example-arrow { text-align: center; color: var(--accent); font-size: 1.4rem; }
.example { font-family: var(--mono); font-size: 1.05rem; }


/* ---------------------------------------------------------------- grafico
   O grafico nao substitui o resultado: mostra o que lhe acontece se o campo
   varrido for outro. Por isso vive por baixo dos resultados, e nao por cima.
   O desenho vem do mesmo motor em Python e em JavaScript, e as cores sao
   variaveis CSS — muda o tema, muda o grafico, sem uma linha de codigo. */
.chart-box {
  margin: 1.1rem 0 0;
  padding: 1rem 1rem .75rem;
  border: 1px solid var(--rule);
  background: var(--paper-2);
}
.chart-box figcaption {
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .55rem;
}
.chart-hint {
  margin: .5rem 0 0;
  font-size: .82rem;
  color: var(--muted);
}
.chart {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--sans);
  overflow: visible;
}
.chart-grid  { stroke: var(--chart-grid); }
.chart-axis  { stroke: var(--chart-axis); }
.chart-zero  { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart-now   { stroke: var(--ink); stroke-dasharray: 4 4; opacity: .5; }
.chart-line  {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart-dot    { stroke: var(--paper-2); stroke-width: 2; }
.chart-tick   { fill: var(--muted); font-size: 12px; }
.chart-tick-y { text-anchor: end; }
.chart-tick-x { text-anchor: middle; }
.chart-axis-name { fill: var(--muted); font-size: 12.5px; text-anchor: middle; }
.chart-legend    { fill: var(--ink-2); font-size: 13px; }

/* num ecra estreito o desenho fica pequeno de mais para se ler; deixa-se
   arrastar de lado em vez de encolher ate nao servir para nada */
@media (max-width: 560px) {
  .chart-box { overflow-x: auto; }
  .chart { min-width: 440px; }
}


/* ------------------------------------------------- extras do conversor
   Casas decimais, algarismos significativos e notacao cientifica ficam na
   mesma linha dos botoes, pequenos, porque sao afinacoes e nao a conta. */
.field-check {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.field-check input { margin: 0; }
.field-check label { margin: 0; }

details.batch {
  margin: 1.4rem 0;
  border: 1px solid var(--rule);
  padding: .8rem 1rem;
  background: var(--paper-2);
}
details.batch summary {
  cursor: pointer;
  font-weight: 600;
}
details.batch > p { margin: .6rem 0 .8rem; font-size: .88rem; }
.batch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}
.batch-grid textarea {
  width: 100%;
  font: 13px/1.5 var(--mono);
  padding: .5rem;
  border: 1px solid var(--rule-2);
  background: var(--paper);
  color: var(--ink);
  resize: vertical;
}
.batch-grid textarea[readonly] { background: var(--paper-3); }
@media (max-width: 560px) {
  .batch-grid { grid-template-columns: 1fr; }
}


/* ---------------------------------------------------------------- desenho
   A figura e desenhada a escala a partir dos numeros de quem la esta: um
   triangulo de catetos 3 e 4 parece mesmo um 3-4-5. Vive por cima do grafico
   porque responde a uma pergunta anterior — "que forma e esta?" — e so
   depois vem o "e se fosse outro valor?". */
.diagram-box {
  margin: 1.1rem 0 0;
  padding: 1rem 1rem .8rem;
  border: 1px solid var(--rule);
  background: var(--paper-2);
}
.diagram-box figcaption {
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .4rem;
}
.diagram {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  margin: 0 auto;
  font-family: var(--sans);
  color: var(--ink-2);
}
.dg-shape  { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2;
             stroke-linejoin: round; }
.dg-ghost  { fill: none; stroke: var(--rule-2); stroke-width: 1.2; stroke-dasharray: 4 3; }
.dg-dim    { fill: none; stroke: var(--ink-2); stroke-width: 1.2; }
.dg-ext    { stroke: var(--rule-2); stroke-width: 1; }
.dg-aux    { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 5 4; }
.dg-angle  { fill: none; stroke: var(--ink-2); stroke-width: 1.4; }
.dg-right  { fill: none; stroke: var(--ink-2); stroke-width: 1.4; }
.dg-centre { fill: var(--ink-2); stroke: none; }
.dg-label       { fill: var(--ink); font-size: 14px; font-weight: 600; }
.dg-angle-label { fill: var(--ink-2); font-size: 13px; }
.dg-note        { fill: var(--muted); font-size: 12px; font-style: italic; }

@media (max-width: 560px) {
  .diagram-box { overflow-x: auto; }
  .diagram { min-width: 380px; }
}

.table-wrap { overflow-x: auto; margin: 0 0 1.4rem; border: 1px solid var(--rule); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
caption { text-align: left; color: var(--muted); font-size: .85rem; padding: .6rem .7rem 0; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--rule); }
thead th { color: var(--muted); background: var(--paper-2); }
tbody th { font-weight: 600; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--paper-2); }
table.vars .is-out th code { color: var(--accent); }
table.conv td { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- relacionadas */
.related { border: 1px solid var(--rule-2); background: var(--paper-2); }
.related h2 {
  font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .16em;
  margin: 0; padding: .8rem 1rem; border-bottom: 1px solid var(--rule); color: var(--muted);
}
.related ul { list-style: none; margin: 0; padding: 0; }
.related li { border-bottom: 1px solid var(--rule); }
.related li:last-child { border-bottom: 0; }
.related a { display: block; padding: .7rem 1rem; text-decoration: none; color: var(--ink); }
.related a:hover { background: var(--paper-3); }
.related a span { display: block; font-weight: 700; font-size: .9rem; letter-spacing: -.01em; }
.related a small {
  display: -webkit-box; color: var(--muted); font-size: .78rem; line-height: 1.4;
  overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.related > p { margin: 0; padding: .7rem 1rem; border-top: 1px solid var(--rule); }

/* ---------------------------------------------------------------- publicidade */
.ad-slot {
  display: grid; place-items: center; position: relative;
  margin: clamp(1.6rem, 4vw, 2.4rem) auto;
  width: min(100% - 2.4rem, var(--wrap));
  min-height: 92px; padding: .6rem;
  border: 1px dashed var(--rule-2);
}
.ad-label { color: var(--muted); }
.ad-slot.is-live { border-style: solid; padding: 0; }
.ad-slot.is-live .ad-label {
  position: absolute; top: -.55rem; left: .6rem; background: var(--paper); padding: 0 .3rem;
}
.ad-slot.is-hidden { display: none; }
/* so aparece na pre-visualizacao local, para se ver onde os anuncios vao
   ficar antes de haver conta. Num site publicado estas caixas nao existem. */
.ad-slot.is-preview { border-color: var(--accent); background: var(--paper-2); }
.ad-slot.is-preview .ad-label { color: var(--accent); font-family: var(--mono); font-size: .7rem;
  text-transform: uppercase; letter-spacing: .14em; }
/* Enquanto nao ha anuncios, a caixa leva ferramentas em vez de ficar vazia.
   Nao se parece com um anuncio nem finge ser um: e uma lista de links do
   proprio site, com a moldura suave do resto da pagina. */
.ad-slot.is-suggest, .ad-slot:has(.ad-fill) {
  border-style: solid; border-color: var(--rule); background: var(--paper-2);
  place-items: stretch; padding: 1rem 1.1rem; border-radius: 10px;
}
.ad-slot.is-suggest > .ad-label, .ad-slot:has(.ad-fill) > .ad-label { display: none; }
.ad-slot.is-live .ad-fill { display: none; }
.ad-sug-head {
  margin: 0 0 .6rem; color: var(--muted); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .14em; font-weight: 600;
}
.ad-sug {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .4rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.ad-sug a {
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .6rem; border-radius: 8px;
  text-decoration: none; color: var(--ink);
  border: 1px solid transparent;
}
.ad-sug a:hover, .ad-sug a:focus-visible {
  background: var(--paper); border-color: var(--rule-2); color: var(--accent);
}
.ad-sug-icon { font-size: 1.05rem; line-height: 1; flex: 0 0 auto; opacity: .75; }
.ad-sug-name { font-size: .92rem; line-height: 1.3; }
.ad-sug-all {
  display: inline-block; margin-top: .7rem;
  font-size: .82rem; color: var(--muted); text-decoration: none;
}
.ad-sug-all:hover, .ad-sug-all:focus-visible { color: var(--accent); }
.prose .ad-slot { width: 100%; margin-inline: 0; }

/* ---------------------------------------------------------------- rodape */
.site-foot {
  margin-top: clamp(2rem, 6vw, 4rem);
  border-top: 2px solid var(--ink);
  background: var(--paper-2);
  padding: clamp(2rem, 5vw, 3rem) 0 1.4rem;
}
.foot-grid { display: grid; gap: 1.8rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); }
.foot-about { max-width: 28rem; }
.foot-col h2 {
  font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .18em;
  color: var(--muted); margin-bottom: .8rem;
}
.foot-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.foot-col a { color: var(--ink-2); text-decoration: none; font-size: .88rem; }
.foot-col a:hover { color: var(--accent); }
.foot-col span { color: var(--muted); font-size: .8rem; }
.foot-base { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.foot-base p { margin: 0; }
.site-foot .brand-name { font-weight: 800; letter-spacing: -.04em; font-size: 1.05rem; }

/* ---------------------------------------------------------------- cookies */
.cookie-bar {
  position: fixed; inset: auto 0 0 0; z-index: 60;
  background: var(--paper-2); border-top: 2px solid var(--ink);
  padding: 1rem 0 max(1rem, env(safe-area-inset-bottom));
}
.cookie-inner { display: grid; gap: .9rem; }
@media (min-width: 54rem) { .cookie-inner { grid-template-columns: 1fr auto; align-items: center; } }
.cookie-bar h2 { font-size: .98rem; margin-bottom: .25rem; }
.cookie-bar p { margin: 0; font-size: .86rem; color: var(--muted); max-width: 70ch; }
.cookie-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.cookie-prefs { display: grid; gap: .55rem; margin: .9rem 0 0; }
.cookie-prefs label { display: flex; gap: .55rem; align-items: start; font-size: .86rem; }
.cookie-prefs input { margin-top: .25rem; }
.cookie-prefs b { display: block; }
.cookie-prefs span { color: var(--muted); }

/* ---------------------------------------------------------------- misc */
.contact-box { padding: 1rem 1.1rem; background: var(--paper-2); border: 1px solid var(--rule-2); }
.search-page input {
  width: 100%; padding: .9rem 1rem; font: inherit; font-size: 1.05rem;
  border: 2px solid var(--ink); background: var(--paper-2); color: var(--ink);
}
.search-page input:focus { border-color: var(--accent); outline: 0; }
.lang-pick-page { display: grid; place-items: center; min-height: 100vh; text-align: center; }
.lang-pick-page .pill-list { justify-content: center; }

@media print {
  .site-head, .site-foot, .ad-slot, .tool-bar, .calc-actions, .related, .cookie-bar { display: none !important; }
  body { background: #fff; color: #000; }
  .results { background: #fff; color: #000; border: 2px solid #000; }
  .result-value, .result-unit, .result-label { color: #000 !important; }
}

/* ---- codigos QR e de barras -------------------------------------------
   O motor devolve a matriz como texto; a pagina desenha-a em SVG. O texto
   fica escondido mas continua no documento, para o botao de copiar e para
   quem use um leitor de ecra. */
.code-render {
  display: block;
  margin: 0 0 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--rule);
  overflow-x: auto;
  text-align: center;
}
.code-render svg { display: inline-block; max-width: 100%; height: auto; }
.result-value.is-code-source {
  font-size: 11px;
  line-height: 1.15;
  letter-spacing: .5px;
  max-height: 4.5em;
  overflow: auto;
  opacity: .45;
  word-break: break-all;
}
.laps {
  margin: 12px 0 0;
  padding: 0 0 0 28px;
  font-variant-numeric: tabular-nums;
  max-height: 220px;
  overflow: auto;
}
.laps li { padding: 2px 0; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.swatch {
  width: 100%;
  min-height: 44px;
  padding: 4px;
  border: 1px solid var(--rule);
  background: none;
  cursor: pointer;
}

/* ---- ferramentas que abrem um ficheiro ---------------------------------
   A imagem nunca sai do computador: e lida, redesenhada numa tela e
   guardada outra vez, tudo na mesma pagina. */
.file-pick {
  margin: 0 0 20px;
  border: 2px dashed var(--rule);
  background: var(--surface, #fafbfc);
  text-align: center;
  transition: border-color .15s, background .15s;
}
.file-pick.is-over { border-color: var(--accent); background: #fff; }
.file-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.file-label {
  display: block;
  padding: 26px 16px 10px;
  cursor: pointer;
  font-weight: 600;
}
.file-input:focus-visible + .file-label { outline: 2px solid var(--accent); outline-offset: 2px; }
.file-icon { display: block; font-size: 22px; margin-bottom: 6px; opacity: .6; }
.file-text { word-break: break-all; }
.file-note { margin: 0; padding: 0 16px 18px; font-size: 13px; color: var(--muted); }
.file-result { margin-top: 20px; text-align: center; }
.file-preview {
  display: block;
  max-width: 100%;
  max-height: 420px;
  margin: 0 auto 14px;
  border: 1px solid var(--rule);
  background: #fff;
}
.preview-frame {
  display: block;
  width: 100%;
  height: 420px;
  margin: 0 0 12px;
  border: 1px solid var(--rule);
  background: #fff;
}
@media print {
  .code-render { border: 0; padding: 0; }
  .result-value.is-code-source, [data-code-download] { display: none !important; }
  .file-pick { display: none !important; }
}
