/* Termos, Privacidade e Privacidade da extensão (AFT-370, redesenho linha 20).
   Páginas estáticas fora do React (public/*.html). Cores = tokens do painel
   (styles/theme-light.css e theme.css), copiados aqui. Tema: o salvo pelo painel
   (`lenda-theme`, aplicado pelo legal.js em <html data-theme>) ou, sem ele, o do
   sistema. O texto dos documentos fica no HTML e não muda por causa deste arquivo. */

:root {
  --bg-page: #ffffff;
  --bg-surface: #ffffff;
  --surface-2: #e6ebfd;
  --field: #ffffff;
  --text-primary: #232229;
  --text-secondary: #52525b;
  --text-muted: #6e6e79;
  --border: #dde3fa;
  --border-strong: #c8d1f4;
  --card-border: #e2e7fb;
  --accent: #3e5bf3;
  --accent-wash: #e9edfe;
  --accent-wash-border: #c8d1f4;
  --badge-text: #2b44d4;
  --bg-hover: #e6ebfd;
  --topo: rgba(255, 255, 255, 0.72);
  --gradient-page:
    radial-gradient(1000px 560px at 8% -8%, rgba(62, 91, 243, 0.13), transparent 60%),
    radial-gradient(900px 520px at 100% 4%, rgba(202, 15, 253, 0.075), transparent 60%),
    radial-gradient(900px 600px at 60% 112%, rgba(7, 186, 253, 0.1), transparent 60%),
    #ffffff;
  --font-content: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

/* Escuro: pelo sistema (sem escolha salva) ou pela escolha salva no painel. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-page: #090d1b;
    --bg-surface: rgba(18, 26, 47, 0.9);
    --surface-2: #18223a;
    --field: #1b2640;
    --text-primary: #eef2fb;
    --text-secondary: #a1adc7;
    --text-muted: #7a86a3;
    --border: #202b45;
    --border-strong: #2c3a58;
    --card-border: #202b45;
    --accent: #5a7bff;
    --accent-wash: color-mix(in srgb, #5a7bff 18%, #121a2f);
    --accent-wash-border: color-mix(in srgb, #5a7bff 40%, #121a2f);
    --badge-text: #a9baff;
    --bg-hover: #18223a;
    --topo: rgba(9, 13, 27, 0.72);
    --gradient-page:
      radial-gradient(1000px 560px at 6% -10%, rgba(62, 91, 243, 0.26), transparent 60%),
      radial-gradient(900px 520px at 100% 0%, rgba(117, 65, 252, 0.18), transparent 60%),
      radial-gradient(900px 600px at 55% 115%, rgba(7, 186, 253, 0.1), transparent 60%),
      #090d1b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg-page: #090d1b;
  --bg-surface: rgba(18, 26, 47, 0.9);
  --surface-2: #18223a;
  --field: #1b2640;
  --text-primary: #eef2fb;
  --text-secondary: #a1adc7;
  --text-muted: #7a86a3;
  --border: #202b45;
  --border-strong: #2c3a58;
  --card-border: #202b45;
  --accent: #5a7bff;
  --accent-wash: color-mix(in srgb, #5a7bff 18%, #121a2f);
  --accent-wash-border: color-mix(in srgb, #5a7bff 40%, #121a2f);
  --badge-text: #a9baff;
  --bg-hover: #18223a;
  --topo: rgba(9, 13, 27, 0.72);
  --gradient-page:
    radial-gradient(1000px 560px at 6% -10%, rgba(62, 91, 243, 0.26), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(117, 65, 252, 0.18), transparent 60%),
    radial-gradient(900px 600px at 55% 115%, rgba(7, 186, 253, 0.1), transparent 60%),
    #090d1b;
  color-scheme: dark;
}

/* Peças que trocam com o tema: logo e ícone do botão. */
.so-escuro { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .so-claro { display: none; }
  :root:not([data-theme="light"]) .so-escuro { display: inline; }
}
:root[data-theme="dark"] .so-claro { display: none; }
:root[data-theme="dark"] .so-escuro { display: inline; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--gradient-page);
  background-attachment: fixed;
  color: var(--text-primary);
  font: 16px/1.5 var(--font-content);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* ---------- topo da página fora do painel ---------- */
.topo {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--topo);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.topo .marca { display: inline-flex; align-items: center; min-height: 44px; }
.topo .marca img { height: 26px; width: auto; } /* sem `display` aqui: quem decide é .so-claro/.so-escuro */
.topo .dir { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.btn-painel {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--field);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
.btn-painel:hover { background: var(--bg-hover); }
.btn-tema {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
}
.btn-tema[hidden] { display: none; }
.btn-tema:hover { background: var(--bg-hover); color: var(--text-primary); }
.so-cel { display: none; }

/* ---------- página: sumário + documento ---------- */
.pagina {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}
.sumario { font-size: 13.5px; }
.sumario ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sumario a {
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1.35;
}
.sumario a:hover { background: var(--bg-hover); color: var(--text-primary); }
.sumario a[aria-current="true"] { background: var(--accent-wash); color: var(--badge-text); font-weight: 600; }
.sumario-pc { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; }
.sumario-pc .rot {
  display: block;
  margin: 0 0 8px 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sumario-cel { display: none; }

/* ---------- documento (o texto vem do HTML, sem mudança) ---------- */
main {
  min-width: 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
}
main h1 { margin: 0; font-size: 34px; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
main h1 + p.mudo { margin-top: 8px; }
main .mudo { color: var(--text-muted); font-size: 14px; line-height: 1.55; }
main nav.docs { margin: 6px 0 0; color: var(--text-secondary); font-size: 14px; }
main nav.docs a { text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
/* o espaço entre os links já vem do HTML; o "·" é só visual e viaja junto com o link */
main nav.docs a + a::before { content: "·"; display: inline-block; margin: 0 6px 0 0; color: var(--text-muted); text-decoration: none; }
main p { margin: 10px 0; }
main p a, main li a { text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
main ul { margin: 10px 0; padding-left: 22px; }
main li { margin: 4px 0; }
main h2 { margin: 40px 0 8px; font-size: 21px; font-weight: 700; line-height: 1.3; scroll-margin-top: 84px; }
main h2 a.ancora { color: inherit; text-decoration: none; }
main h2 a.ancora::after { content: "#"; margin-left: 8px; color: var(--text-muted); font-weight: 400; opacity: 0.6; }
main h2 a.ancora:hover::after { opacity: 1; color: var(--accent); }
main .caixa {
  margin: 20px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--accent-wash);
  border: 1px solid var(--accent-wash-border);
  font-size: 15px;
  line-height: 1.6;
}
main .caixa p { margin: 0; }
main .caixa p + p { margin-top: 4px; }

main table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.55; margin: 14px 0; }
main th {
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
  padding: 8px;
  vertical-align: bottom;
}
main td { border-bottom: 1px solid var(--border); padding: 10px 8px; vertical-align: top; }

/* ---------- rodapé ---------- */
.rodape {
  border-top: 1px solid var(--border);
  padding: 20px 24px 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.rodape p { margin: 0; }
.rodape a { color: var(--text-secondary); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- meio: sumário recolhido acima do documento ---------- */
@media (max-width: 899px) {
  .pagina { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 24px 20px 40px; }
  .sumario-pc { display: none; }
  .sumario-cel {
    display: block;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-surface);
  }
  .sumario-cel summary {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 14px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    list-style: none;
  }
  .sumario-cel summary::-webkit-details-marker { display: none; }
  .sumario-cel[open] summary svg { transform: rotate(180deg); }
  .sumario-cel ol { padding: 0 6px 10px; }
  .sumario-cel a { padding: 0 10px; min-height: 44px; display: flex; align-items: center; }
  main h2 { scroll-margin-top: 76px; }
}

/* ---------- celular ---------- */
@media (max-width: 669px) {
  .topo { padding: 8px 8px 8px 16px; min-height: 60px; }
  .topo .marca img { height: 24px; }
  .so-pc { display: none; }
  .so-cel { display: inline; }
  .btn-painel { height: 44px; padding: 0 16px; font-size: 14px; }
  .btn-tema { width: 44px; height: 44px; }
  .pagina { padding: 16px 16px 32px; }
  main h1 { font-size: 26px; }
  main h2 { font-size: 20px; margin-top: 32px; }
  main h2 a.ancora::after { display: none; }

  /* tabelas viram cartões: o rótulo vem do data-r de cada célula */
  main table, main tbody, main tr, main td { display: block; }
  main thead { display: none; }
  main tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 12px;
    margin-bottom: 10px;
    background: var(--bg-surface);
  }
  main td { border: 0; padding: 6px 0; }
  main td::before { content: attr(data-r); display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); }

  .rodape a { display: inline-block; padding: 12px 4px; min-height: 44px; }
}

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

@media print {
  .topo, .sumario, .rodape { display: none !important; }
  body { background: #ffffff; color: #000000; display: block; }
  .pagina { display: block; max-width: none; padding: 0; }
  main h2 a.ancora::after { display: none; }
  main a { color: inherit; }
}
