/* ============================================================================
   Manual Rabi — Design System v2.1 (2026-09-19)
   v2.0: Inter + JetBrains Mono, dark mode, escala perfect-fourth, WCAG AA.
   v2.1: refresh visual — topbar em vidro (blur), sombras suaves em camadas,
   raios maiores, tabelas com zebra + hover, cards com lift refinado,
   scrollbar e seleção estilizadas. Sem mudanças estruturais.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ----------------------------------------------------------------------------
   1. RESET + BASE
   ---------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
body { font-family: var(--font-sans); font-size: var(--fs-base); line-height: 1.6; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
img, svg, video { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* Focus visible (acessibilidade) */
*:focus { outline: none; }
*:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); }

/* Skip-to-content link (acessibilidade) */
.skip-link { position: absolute; top: -40px; left: var(--sp-4); background: var(--primary); color: #fff; padding: var(--sp-2) var(--sp-4); border-radius: var(--r-md); font-weight: 600; z-index: 1000; transition: top var(--t-base); }
.skip-link:focus { top: var(--sp-4); text-decoration: none; }

/* ----------------------------------------------------------------------------
   2. VARIÁVEIS — LIGHT THEME (default)
   ---------------------------------------------------------------------------- */

:root {
  /* Fontes */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Paleta light */
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #e4e4e7;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #71717a;
  --primary: #0070f3;
  --primary-lt: #e6f0ff;
  --primary-dk: #0052cc;
  --primary-text: #ffffff;
  --accent: #10b981;
  --accent-lt: #d1fae5;
  --warn: #f59e0b;
  --warn-lt: #fef3c7;
  --danger: #ef4444;
  --danger-lt: #fee2e2;
  --info: #3b82f6;
  --info-lt: #dbeafe;

  /* Escala tipográfica (perfect fourth ratio 1.333) */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.333rem;
  --fs-2xl: 1.777rem;
  --fs-3xl: 2.369rem;
  --fs-4xl: 3.157rem;

  /* Espaçamento (escala 4px) */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.25rem;
  --sp-6: 1.5rem;
  --sp-8: 2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Raios */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 24px;
  --r-full: 9999px;

  /* Sombras (v2.1: mais suaves, com leve tom frio) */
  --shadow-xs: 0 1px 2px rgba(16,24,40,.04);
  --shadow-sm: 0 1px 3px rgba(16,24,40,.07), 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 6px 16px -4px rgba(16,24,40,.10), 0 2px 6px -2px rgba(16,24,40,.05);
  --shadow-lg: 0 14px 32px -8px rgba(16,24,40,.14), 0 4px 10px -4px rgba(16,24,40,.06);
  --shadow-xl: 0 24px 48px -12px rgba(16,24,40,.18), 0 8px 16px -8px rgba(16,24,40,.08);

  /* Transições */
  --t-fast: 150ms ease;
  --t-base: 200ms ease;
  --t-slow: 300ms ease;

  /* Layout */
  --sidebar-w: 280px;
  --topbar-h: 64px;
  --content-max: 880px;

  /* ALIASES para variáveis antigas (não quebrar páginas existentes) */
  --color-primary: var(--primary);
  --color-primary-lt: var(--primary-lt);
  --color-primary-dk: var(--primary-dk);
  --color-text: var(--text);
  --color-text-muted: var(--text-2);
  --color-surface: var(--surface);
  --color-border: var(--border);
  --color-accent: var(--accent);
  --color-warn: var(--warn);
  --color-danger: var(--danger);
  --radius: var(--r-md);
  --transition: var(--t-base);
}

/* ----------------------------------------------------------------------------
   3. VARIÁVEIS — DARK THEME
   ---------------------------------------------------------------------------- */

[data-theme="dark"] {
  --bg: #09090b;
  --surface: #18181b;
  --surface-2: #27272a;
  --surface-3: #3f3f46;
  --border: #27272a;
  --border-strong: #3f3f46;
  --text: #fafafa;
  --text-2: #d4d4d8;
  --text-3: #a1a1aa;
  --primary: #3b9eff;
  --primary-lt: rgba(59,158,255,.15);
  --primary-dk: #1e88e5;
  --accent: #34d399;
  --accent-lt: rgba(52,211,153,.15);
  --warn: #fbbf24;
  --warn-lt: rgba(251,191,36,.15);
  --danger: #f87171;
  --danger-lt: rgba(248,113,113,.15);
  --info: #60a5fa;
  --info-lt: rgba(96,165,250,.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.5), 0 2px 4px -2px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.4);
}

/* Auto dark mode (se usuário não setou nada) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09090b;
    --surface: #18181b;
    --surface-2: #27272a;
    --surface-3: #3f3f46;
    --border: #27272a;
    --border-strong: #3f3f46;
    --text: #fafafa;
    --text-2: #d4d4d8;
    --text-3: #a1a1aa;
    --primary: #3b9eff;
    --primary-lt: rgba(59,158,255,.15);
    --primary-dk: #1e88e5;
    --primary-text: #ffffff;
    --accent: #34d399;
    --accent-lt: rgba(52,211,153,.15);
    --warn: #fbbf24;
    --warn-lt: rgba(251,191,36,.15);
    --danger: #f87171;
    --danger-lt: rgba(248,113,113,.15);
    --info: #60a5fa;
    --info-lt: rgba(96,165,250,.15);
  }
}

/* ----------------------------------------------------------------------------
   4. TOPBAR
   ---------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  backdrop-filter: saturate(1.6) blur(12px);
  box-shadow: var(--shadow-xs);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-4);
  gap: var(--sp-4);
  backdrop-filter: saturate(180%) blur(12px);
}
.topbar .menu-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  display: none;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
}
.topbar .menu-toggle:hover { background: var(--surface-2); }
.topbar .logo {
  font-weight: 800;
  font-size: var(--fs-lg);
  color: var(--primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.topbar .logo span {
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-left: var(--sp-2);
}
.topbar .search-bar {
  flex: 1;
  max-width: 560px;
  position: relative;
}
.topbar .search-bar input {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-4) 0 var(--sp-10);
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  color: var(--text);
  transition: border var(--t-fast), background var(--t-fast);
}
.topbar .search-bar input::placeholder { color: var(--text-3); }
.topbar .search-bar input:focus { border-color: var(--primary); background: var(--surface); outline: none; }
.topbar .search-icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  font-size: 1rem;
}
.topbar .search-shortcut {
  position: absolute;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  pointer-events: none;
  font-family: var(--font-mono);
}

.topbar .topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}
.theme-toggle, .icon-btn {
  background: none;
  border: 1px solid var(--border);
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.theme-toggle:hover, .icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { width: 18px; height: 18px; }
[data-theme="dark"] .theme-toggle .icon-sun, html:not([data-theme]) .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
html:not([data-theme="dark"]) .theme-toggle .icon-moon { display: none; }
html:not([data-theme="dark"]) .theme-toggle .icon-sun { display: block; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .theme-toggle .icon-moon { display: block; }
  html:not([data-theme]) .theme-toggle .icon-sun { display: none; }
}

.version-badge {
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  padding: 4px var(--sp-2);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  white-space: nowrap;
}

/* Resultados de busca */
#search-results {
  position: absolute;
  top: calc(100% + var(--sp-2));
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  max-height: 480px;
  overflow-y: auto;
  display: none;
  z-index: 200;
}
#search-results.active { display: block; }
#search-results .result-item {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background var(--t-fast);
}
#search-results .result-item:last-child { border-bottom: none; }
#search-results .result-item:hover, #search-results .result-item.active { background: var(--surface-2); text-decoration: none; }
#search-results .result-item .result-title { font-weight: 600; font-size: var(--fs-sm); margin-bottom: 2px; }
#search-results .result-item .result-section { font-size: var(--fs-xs); color: var(--text-3); }
#search-results .result-item mark { background: var(--primary-lt); color: var(--primary-dk); padding: 0 2px; border-radius: 2px; }
[data-theme="dark"] #search-results .result-item mark { color: var(--primary); }
#search-results .empty { padding: var(--sp-6); text-align: center; color: var(--text-3); font-size: var(--fs-sm); }

/* ----------------------------------------------------------------------------
   5. SIDEBAR
   ---------------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: var(--sp-6) var(--sp-4);
  z-index: 90;
  transition: transform var(--t-base);
}
.sidebar-section { margin-bottom: var(--sp-6); }
.sidebar-section-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 0 var(--sp-3) var(--sp-2);
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--t-fast);
}
.sidebar a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar a.active { background: var(--primary-lt); color: var(--primary); font-weight: 600; }
.sidebar a .icon, .sidebar a svg { width: 18px; height: 18px; flex-shrink: 0; color: currentColor; opacity: .8; }
.sidebar a.active .icon, .sidebar a.active svg { opacity: 1; }

#sidebar-overlay { transition: opacity var(--t-base); }

/* ----------------------------------------------------------------------------
   6. MAIN CONTENT
   ---------------------------------------------------------------------------- */

.main-content {
  margin-left: var(--sidebar-w);
  padding: var(--sp-8) var(--sp-6);
  max-width: calc(var(--sidebar-w) + var(--content-max) + var(--sp-12));
}
.main-content > * { max-width: var(--content-max); }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--text-3); opacity: .5; }
.breadcrumb span:last-child { color: var(--text); font-weight: 500; }

.page-title { font-size: var(--fs-3xl); font-weight: 800; letter-spacing: -0.025em; color: var(--text); margin-bottom: var(--sp-3); line-height: 1.15; }
.page-subtitle { font-size: var(--fs-lg); color: var(--text-2); margin-bottom: var(--sp-8); line-height: 1.5; }

/* TOC */
.toc {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-8);
}
.toc-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: var(--sp-3); }
.toc ol, .toc ul { list-style: none; padding-left: 0; }
.toc li { margin: 4px 0; }
.toc a { font-size: var(--fs-sm); color: var(--text-2); display: block; padding: 4px 0; }
.toc a:hover { color: var(--primary); text-decoration: none; }
.toc a.toc-h3 { padding-left: var(--sp-4); font-size: var(--fs-sm); color: var(--text-3); }
.toc a.active { color: var(--primary); font-weight: 600; }

/* ----------------------------------------------------------------------------
   7. TIPOGRAFIA DE CONTEÚDO
   ---------------------------------------------------------------------------- */

.main-content h1, .main-content h2, .main-content h3, .main-content h4 {
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin-top: var(--sp-10);
  margin-bottom: var(--sp-4);
  scroll-margin-top: calc(var(--topbar-h) + var(--sp-4));
  position: relative;
}
.main-content h2 { font-size: var(--fs-2xl); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); }
.main-content h3 { font-size: var(--fs-xl); }
.main-content h4 { font-size: var(--fs-lg); }
.main-content > h2:first-of-type { margin-top: 0; }
.main-content p { margin-bottom: var(--sp-4); color: var(--text); }
.main-content ul, .main-content ol { margin-left: var(--sp-6); margin-bottom: var(--sp-4); }
.main-content li { margin-bottom: var(--sp-2); }
.main-content strong { font-weight: 600; color: var(--text); }
.main-content em { font-style: italic; }
.main-content hr { border: none; border-top: 1px solid var(--border); margin: var(--sp-8) 0; }

/* Copy-link em títulos */
.main-content h2 .anchor-link, .main-content h3 .anchor-link {
  position: absolute;
  left: -28px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: var(--text-3);
  font-weight: normal;
  transition: opacity var(--t-fast);
  text-decoration: none;
  font-size: 1rem;
}
.main-content h2:hover .anchor-link, .main-content h3:hover .anchor-link { opacity: 1; }
.main-content .anchor-link:hover { color: var(--primary); }

/* Código */
.main-content code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  color: var(--primary-dk);
  border: 1px solid var(--border);
}
[data-theme="dark"] .main-content code:not(pre code) { color: var(--primary); }
.main-content pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin: var(--sp-4) 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.5;
}
.main-content pre code { background: none; padding: 0; border: none; color: var(--text); font-size: inherit; }

/* Tabelas */
.main-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-4) 0;
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.main-content th, .main-content td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.main-content th { background: var(--surface-2); font-weight: 600; color: var(--text); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; }
.main-content tr:last-child td { border-bottom: none; }
.main-content tr:nth-child(even) td { background: var(--surface-2); }
.main-content tr:hover td { background: var(--primary-lt); }

/* Blockquote */
.main-content blockquote {
  border-left: 4px solid var(--primary);
  background: var(--surface-2);
  padding: var(--sp-4) var(--sp-5);
  margin: var(--sp-4) 0;
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--text-2);
  font-style: italic;
}

/* Details/Summary (interativo nativo) */
.main-content details {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  margin: var(--sp-3) 0;
  transition: border var(--t-fast);
}
.main-content details[open] { border-color: var(--primary); }
.main-content details summary { cursor: pointer; font-weight: 600; color: var(--text); user-select: none; padding: var(--sp-1) 0; }
.main-content details summary:hover { color: var(--primary); }
.main-content details > *:not(summary) { margin-top: var(--sp-3); }

/* ----------------------------------------------------------------------------
   8. COMPONENTES
   ---------------------------------------------------------------------------- */

/* Callouts (5 tipos) */
.callout {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  border-left: 4px solid;
  margin: var(--sp-4) 0;
  background: var(--surface-2);
  align-items: flex-start;
}
.callout-title { font-weight: 700; margin-bottom: var(--sp-1); display: flex; align-items: center; gap: var(--sp-2); }
.callout-body { flex: 1; }
.callout-body p:last-child { margin-bottom: 0; }
.callout-info { background: var(--info-lt); border-left-color: var(--info); }
.callout-info .callout-title { color: var(--info); }
.callout-tip, .callout-success { background: var(--accent-lt); border-left-color: var(--accent); }
.callout-tip .callout-title, .callout-success .callout-title { color: var(--accent); }
.callout-warn, .callout-warning { background: var(--warn-lt); border-left-color: var(--warn); }
.callout-warn .callout-title, .callout-warning .callout-title { color: var(--warn); }
.callout-danger, .callout-error { background: var(--danger-lt); border-left-color: var(--danger); }
.callout-danger .callout-title, .callout-error .callout-title { color: var(--danger); }
.callout-note { background: var(--surface-2); border-left-color: var(--text-3); }
.callout-note .callout-title { color: var(--text-2); }

/* Cards */
.card, .card-module {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-5);
  transition: all var(--t-base);
  display: block;
  color: var(--text);
}
.card-module:hover {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  text-decoration: none;
}
.card, .card-module { border-radius: var(--r-lg); }
.card-icon { font-size: 1.75rem; margin-bottom: var(--sp-3); display: block; }
.card-title { font-size: var(--fs-lg); font-weight: 700; color: var(--text); margin-bottom: var(--sp-2); }
.card-desc { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.5; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

/* Steps */
.steps {
  list-style: none;
  margin: var(--sp-4) 0;
  padding-left: 0;
  counter-reset: step;
}
.steps > li {
  position: relative;
  padding-left: 52px;
  padding-bottom: var(--sp-6);
  border-left: 2px solid var(--border);
  margin-left: 18px;
  counter-increment: step;
}
.steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: -19px;
  top: 0;
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
  font-size: var(--fs-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 4px var(--bg);
}
.step-title { font-weight: 700; font-size: var(--fs-lg); margin-bottom: var(--sp-2); color: var(--text); }
.step-content { padding-top: 6px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.badge-primary { background: var(--primary-lt); color: var(--primary-dk); border-color: transparent; }
[data-theme="dark"] .badge-primary { color: var(--primary); }
.badge-success { background: var(--accent-lt); color: var(--accent); border-color: transparent; }
.badge-warn { background: var(--warn-lt); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-lt); color: var(--danger); border-color: transparent; }

/* Botoes */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: var(--fs-sm);
  border: 1px solid transparent;
  transition: all var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-dk); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-white { background: #fff; color: var(--primary); }
.btn-white:hover { background: #f5f5f5; box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); }
.btn-outline:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.7); }
.btn-sm { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-xs); }
.btn-lg { padding: var(--sp-4) var(--sp-6); font-size: var(--fs-base); }

/* Screenshots (preservar layout antigo) */
.screenshot-wrap, figure.screenshot {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  margin: var(--sp-4) 0;
  text-align: center;
}
.screenshot-wrap img, figure.screenshot img {
  max-width: 100%;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
}
.screenshot-caption, figure.screenshot figcaption {
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-2);
  text-align: left;
}
figure.screenshot figcaption ol { margin-top: var(--sp-2); }

/* Footer */
.footer {
  margin-top: var(--sp-16);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-3);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.footer a { color: var(--text-2); }
.footer a:hover { color: var(--primary); }

/* Back-to-top */
.back-to-top {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  width: 44px; height: 44px;
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  border-radius: var(--r-full);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: all var(--t-fast);
  z-index: 50;
}
.back-to-top.visible { display: flex; }
.back-to-top:hover { background: var(--primary-dk); transform: translateY(-2px); }

/* ----------------------------------------------------------------------------
   9. RESPONSIVO (mobile-first overrides para tablet/desktop)
   ---------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-xl); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; max-width: 100%; }
  .topbar .menu-toggle { display: flex; }
  .version-badge { display: none; }
}
@media (max-width: 640px) {
  .topbar { gap: var(--sp-2); padding: 0 var(--sp-3); }
  .topbar .logo span { display: none; }
  .topbar .search-shortcut { display: none; }
  .main-content { padding: var(--sp-6) var(--sp-4); }
  .page-title { font-size: var(--fs-2xl); }
  .page-subtitle { font-size: var(--fs-base); }
  .card-grid { grid-template-columns: 1fr; }
  .main-content h2 { font-size: var(--fs-xl); }
  .main-content h3 { font-size: var(--fs-lg); }
  .steps > li { padding-left: 44px; margin-left: 16px; }
  .steps > li::before { width: 32px; height: 32px; left: -17px; font-size: var(--fs-xs); }
  .footer { flex-direction: column; align-items: flex-start; }
}

/* ----------------------------------------------------------------------------
   10. PRINT
   ---------------------------------------------------------------------------- */

@media print {
  .topbar, .sidebar, .back-to-top, .toc, #sidebar-overlay { display: none !important; }
  .main-content { margin: 0; max-width: 100%; padding: 0; }
  body { background: white; color: black; }
  a { color: black; text-decoration: underline; }
  .card, .card-module { break-inside: avoid; }
  .callout { break-inside: avoid; }
  pre, table { break-inside: avoid; }
  h1, h2, h3, h4 { page-break-after: avoid; }
}

/* ----------------------------------------------------------------------------
   v2.1 — REFRESH VISUAL (2026-09-19)
   Toques modernos aditivos; nenhum seletor existente foi removido.
   ---------------------------------------------------------------------------- */

/* Tabelas: zebra suave + hover de linha */
.main-content tbody tr:nth-child(even),
.main-content table tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.main-content table tr:hover td { background: color-mix(in srgb, var(--primary-lt) 40%, transparent); }
.main-content table th { letter-spacing: .01em; }
.table-wrap { border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }

/* Links: sublinhado moderno */
.main-content a { text-underline-offset: 3px; text-decoration-thickness: 1.5px; }

/* Seleção de texto com a cor da marca */
::selection { background: color-mix(in srgb, var(--primary) 22%, transparent); }

/* Scrollbar discreta (WebKit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: var(--r-full); border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Títulos: leve aperto tipográfico moderno */
.main-content h1 { letter-spacing: -0.025em; }
.main-content h2 { letter-spacing: -0.015em; }

/* Alerts/callouts inline (muito usados nas páginas): raio maior */
.main-content .alert, .main-content div[style*="border-left"] { border-radius: var(--r-md) !important; }

/* Imagens de diagrama e figuras: moldura suave */
.main-content figure { margin: var(--sp-6) 0; }
.main-content figure img { background: #fff; border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-3); box-shadow: var(--shadow-sm); }
.main-content figcaption { font-size: var(--fs-sm); color: var(--text-3); text-align: center; margin-top: var(--sp-2); }

/* Botão voltar-ao-topo e chips ganham sombra suave */
.back-to-top { box-shadow: var(--shadow-md); }

/* Dark mode: zebra e molduras coerentes */
[data-theme="dark"] .main-content figure img { background: var(--surface); }

/* ----------------------------------------------------------------------------
   v2.2 — TOQUES VISÍVEIS (2026-09-20)
   ---------------------------------------------------------------------------- */

/* Faixa de gradiente da marca no topo do site */
.topbar { border-top: 3px solid transparent; border-image: linear-gradient(90deg, var(--primary), var(--accent)) 1; }

/* Navegação do topo: links em "pílula" com hover */
.topbar-nav a { padding: 6px 12px; border-radius: var(--r-full); transition: background var(--t-fast), color var(--t-fast); }
.topbar-nav a:hover { background: var(--primary-lt); color: var(--primary-dk); text-decoration: none; }

/* H1 com gradiente sutil da marca */
.main-content h1 {
  background: linear-gradient(90deg, var(--text) 55%, var(--primary));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Divisor suave após h2 */
.main-content h2 { border-bottom: 1px solid var(--border); padding-bottom: var(--sp-2); }

/* Cabeçalho de tabela com fundo da marca bem suave */
.main-content table th { background: color-mix(in srgb, var(--primary-lt) 60%, var(--surface)); }

/* ----------------------------------------------------------------------------
   v2.3 — ACABAMENTO GERAL + ÁREA DA API (2026-09-24)
   Aditivo: não altera a estrutura das páginas.
   ---------------------------------------------------------------------------- */

/* Âncoras não ficam escondidas atrás do topo fixo */
.main-content h2, .main-content h3, .main-content h4, .main-content [id] { scroll-margin-top: calc(var(--topbar-h) + 16px); }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Barra de progresso de leitura (criada pelo main.js) */
.reading-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 200;
  background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 80ms linear; pointer-events: none; }

/* Sidebar: item ativo e hover em pílula */
.sidebar nav a { border-radius: var(--r-md); transition: background var(--t-fast), color var(--t-fast); }
.sidebar nav a:hover { background: var(--primary-lt); color: var(--primary-dk); text-decoration: none; }
.sidebar nav a.active { background: var(--primary-lt); color: var(--primary-dk); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary); }
[data-theme="dark"] .sidebar nav a.active, [data-theme="dark"] .sidebar nav a:hover { color: var(--primary); }
.sidebar-section-title { letter-spacing: .06em; }

/* Selo de versão do topo com cara de "chip" */
.version-badge { background: linear-gradient(90deg, var(--primary-lt), var(--accent-lt)); color: var(--primary-dk);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); border-radius: var(--r-full);
  padding: 3px 10px; font-weight: 600; white-space: nowrap; }
[data-theme="dark"] .version-badge { color: var(--primary); }

/* Primeiro parágrafo da página como "lead" */
.main-content h1 + p { font-size: var(--fs-lg); color: var(--text-2); line-height: 1.6; }

/* Callouts inline (div com borda lateral) ganham profundidade discreta */
.main-content div[style*="border-left"] { box-shadow: var(--shadow-xs); }

/* Tabelas largas não estouram a tela no celular */
@media (max-width: 760px) {
  .main-content table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
.table-wrap { overflow-x: auto; }

/* Blocos de código: estilo de terminal + botão Copiar (main.js) */
.main-content pre { position: relative; background: #0f172a; color: #e2e8f0; border: 1px solid #1e293b;
  border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); overflow-x: auto; box-shadow: var(--shadow-sm);
  font-size: .86rem; line-height: 1.6; }
.main-content pre code { color: inherit; }
.copy-btn { position: absolute; top: 8px; right: 8px; font: 600 .72rem var(--font-sans); color: #cbd5e1;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); border-radius: var(--r-sm);
  padding: 3px 9px; cursor: pointer; opacity: .75; transition: opacity var(--t-fast), background var(--t-fast); }
.copy-btn:hover, .copy-btn:focus-visible { opacity: 1; background: rgba(255,255,255,.16); }
.copy-btn.copied { color: #34d399; border-color: #34d399; }

/* Área da API externa: métodos HTTP, caminhos, permissões e cartões de rota */
.http-method { display: inline-block; min-width: 3.9em; text-align: center; font: 700 .72rem var(--font-mono);
  letter-spacing: .03em; padding: 2px 7px; border-radius: var(--r-sm); color: #fff; vertical-align: middle; }
.m-get { background: #2563eb; } .m-post { background: #059669; } .m-put { background: #d97706; }
.m-patch { background: #7c3aed; } .m-delete { background: #dc2626; }
.main-content code.http-path { font-family: var(--font-mono); font-weight: 600; background: var(--surface-2);
  color: var(--text); border: 1px solid var(--border); }
.main-content code.perm { background: var(--accent-lt); color: #047857; border: none; }
[data-theme="dark"] .main-content code.perm { color: var(--accent); }
.endpoint { border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5);
  margin: var(--sp-4) 0; background: var(--surface); box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t-base), border-color var(--t-base); }
.endpoint:hover { box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }

/* Cards: realce do ícone ao passar o mouse */
.card-module:hover .card-icon { transform: scale(1.08); }
.card-icon { transition: transform var(--t-base); }

/* Impressão: sem barra de progresso nem botões de copiar; código legível */
@media print {
  .reading-progress, .copy-btn { display: none !important; }
  .main-content pre { background: #fff; color: #000; border: 1px solid #999; box-shadow: none; }
}

/* v2.3 — Topo unificado nas páginas de layout simples (sem barra lateral):
   logo + busca + navegação + selo de versão */
.topbar-nav { display: flex; align-items: center; gap: 2px; white-space: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: auto; font-size: var(--fs-sm); }
.topbar-nav::-webkit-scrollbar { display: none; }
.topbar .search-bar + .topbar-nav { margin-left: 0; }
@media (max-width: 1024px) { .topbar:has(.topbar-nav) .search-bar { max-width: 280px; } }
@media (max-width: 640px) { .topbar:has(.topbar-nav) .search-bar { display: none; } }

/* v2.4 (23/10/2026): palavras longas (endereços, códigos) quebram em vez de criar rolagem lateral no celular */
.main-content p, .main-content li, .main-content td, .main-content dd { overflow-wrap: anywhere; }
.main-content p code, .main-content li code { word-break: break-all; }
