/* ==========================================================================
   Compiladores (UFCG 2026.2) — Design System v3
   --------------------------------------------------------------------------
   Estrutura:
     0. Tokens globais (tipografia, espaçamento, raio, movimento, camadas)
     1. Temas de cor (Tokyo Night, Catppuccin, Gruvbox, Rosé Pine, Papel)
     2. Reset moderno & base
     3. Acessibilidade (skip-link, foco, sr-only, movimento reduzido)
     4. App shell & sidebar
     5. Barra superior (top nav) & menu de temas
     6. Pipeline bar (stepper de fases)
     7. Layout de leitura & sumário lateral (TOC)
     8. Tipografia de conteúdo
     9. Código, badges e transformações
    10. Diagramas Mermaid & KaTeX
    11. Tabelas
    12. Callouts pedagógicos
    13. Exercícios resolvidos
    14. Navegação entre aulas & conclusão
    15. Página inicial (hero, pipeline, módulos, passos, rodapé)
    16. Voltar ao topo
    17. Impressão
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. TOKENS GLOBAIS
   -------------------------------------------------------------------------- */
:root {
  --font-sans: "Inter", "Inter var", system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-body: 1.0625rem;
  --fs-lg: 1.1875rem;
  --fs-xl: 1.375rem;
  --fs-2xl: clamp(1.4rem, 1.2rem + 0.8vw, 1.65rem);
  --fs-3xl: clamp(1.85rem, 1.4rem + 1.9vw, 2.6rem);
  --fs-hero: clamp(2.4rem, 1.6rem + 3.6vw, 4rem);

  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;

  --sidebar-w: 280px;
  --header-h: 56px;
  --content-w: 50rem;
  --content-w-wide: 82rem;
  --home-w: 74rem;
  --toc-w: 14.5rem;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 120ms;
  --dur: 200ms;
  --dur-slow: 320ms;

  --z-content: 1;
  --z-header: 50;
  --z-popover: 70;
  --z-fab: 60;
  --z-backdrop: 90;
  --z-drawer: 100;
  --z-skip: 200;
}

/* --------------------------------------------------------------------------
   1. TEMAS DE COR
   Todos os valores são hexadecimais para que possam ser lidos pelo Mermaid.
   -------------------------------------------------------------------------- */

/* 1.1 Tokyo Night (padrão escuro) */
:root,
[data-theme="tokyo-night"] {
  color-scheme: dark;
  --bg: #1a1b26;
  --surface: #1f2133;
  --surface-2: #262a3f;
  --surface-sunken: #16161e;
  --overlay: rgba(26, 27, 38, 0.82);
  --text: #c8d0f5;
  --text-2: #a9b1d6;
  --text-3: #7f88b5;
  --accent: #7aa2f7;
  --accent-strong: #9ab8ff;
  --accent-soft: rgba(122, 162, 247, 0.13);
  --on-accent: #12131c;
  --border: #2a2e44;
  --border-strong: #3b4261;
  --code-text: #7dcfff;
  --intuition: #9ece6a;
  --formal: #bb9af7;
  --trap: #e0af68;
  --conflict: #f7768e;
  --shadow-color: 0 0% 0%;
  --shadow-strength: 0.45;
  --glow: rgba(122, 162, 247, 0.22);
}

/* 1.2 Catppuccin Mocha */
[data-theme="catppuccin"] {
  color-scheme: dark;
  --bg: #1e1e2e;
  --surface: #252536;
  --surface-2: #313244;
  --surface-sunken: #181825;
  --overlay: rgba(30, 30, 46, 0.82);
  --text: #cdd6f4;
  --text-2: #bac2de;
  --text-3: #9399b2;
  --accent: #cba6f7;
  --accent-strong: #ddc2ff;
  --accent-soft: rgba(203, 166, 247, 0.14);
  --on-accent: #1e1e2e;
  --border: #34354a;
  --border-strong: #45475a;
  --code-text: #89dceb;
  --intuition: #a6e3a1;
  --formal: #f5c2e7;
  --trap: #fab387;
  --conflict: #f38ba8;
  --shadow-color: 240 20% 4%;
  --shadow-strength: 0.5;
  --glow: rgba(203, 166, 247, 0.22);
}

/* 1.3 Gruvbox Dark */
[data-theme="gruvbox"] {
  color-scheme: dark;
  --bg: #282828;
  --surface: #2f2d2c;
  --surface-2: #3c3836;
  --surface-sunken: #1d2021;
  --overlay: rgba(40, 40, 40, 0.84);
  --text: #ebdbb2;
  --text-2: #d5c4a1;
  --text-3: #a89984;
  --accent: #fabd2f;
  --accent-strong: #ffd35c;
  --accent-soft: rgba(250, 189, 47, 0.13);
  --on-accent: #1d2021;
  --border: #3f3b38;
  --border-strong: #504945;
  --code-text: #8ec07c;
  --intuition: #b8bb26;
  --formal: #d3869b;
  --trap: #fe8019;
  --conflict: #fb4934;
  --shadow-color: 30 10% 4%;
  --shadow-strength: 0.5;
  --glow: rgba(250, 189, 47, 0.18);
}

/* 1.4 Rosé Pine */
[data-theme="rose-pine"] {
  color-scheme: dark;
  --bg: #191724;
  --surface: #1f1d2e;
  --surface-2: #26233a;
  --surface-sunken: #14121e;
  --overlay: rgba(25, 23, 36, 0.84);
  --text: #e0def4;
  --text-2: #c7c3e0;
  --text-3: #908caa;
  --accent: #ebbcba;
  --accent-strong: #f5d4d2;
  --accent-soft: rgba(235, 188, 186, 0.13);
  --on-accent: #191724;
  --border: #2a273f;
  --border-strong: #403d52;
  --code-text: #9ccfd8;
  --intuition: #9ccfd8;
  --formal: #c4a7e7;
  --trap: #f6c177;
  --conflict: #eb6f92;
  --shadow-color: 250 25% 3%;
  --shadow-strength: 0.55;
  --glow: rgba(235, 188, 186, 0.18);
}

/* 1.5 Papel Universitário (claro) */
[data-theme="light"] {
  color-scheme: light;
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --surface-sunken: #f4f2ed;
  --overlay: rgba(250, 249, 246, 0.85);
  --text: #1c1917;
  --text-2: #44403c;
  --text-3: #6b6560;
  --accent: #3b5bdb;
  --accent-strong: #2c47b8;
  --accent-soft: rgba(59, 91, 219, 0.09);
  --on-accent: #ffffff;
  --border: #e8e4db;
  --border-strong: #d4cec2;
  --code-text: #a3245e;
  --intuition: #0f7a55;
  --formal: #6d28d9;
  --trap: #b45309;
  --conflict: #c0262d;
  --shadow-color: 30 15% 30%;
  --shadow-strength: 0.12;
  --glow: rgba(59, 91, 219, 0.14);
}

/* Sem preferência salva: respeita o sistema operacional */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #faf9f6;
    --surface: #ffffff;
    --surface-2: #f3f1ec;
    --surface-sunken: #f4f2ed;
    --overlay: rgba(250, 249, 246, 0.85);
    --text: #1c1917;
    --text-2: #44403c;
    --text-3: #6b6560;
    --accent: #3b5bdb;
    --accent-strong: #2c47b8;
    --accent-soft: rgba(59, 91, 219, 0.09);
    --on-accent: #ffffff;
    --border: #e8e4db;
    --border-strong: #d4cec2;
    --code-text: #a3245e;
    --intuition: #0f7a55;
    --formal: #6d28d9;
    --trap: #b45309;
    --conflict: #c0262d;
    --shadow-color: 30 15% 30%;
    --shadow-strength: 0.12;
    --glow: rgba(59, 91, 219, 0.14);
  }
}

/* Sombras derivadas do tema */
:root {
  --shadow-sm: 0 1px 2px hsl(var(--shadow-color) / calc(var(--shadow-strength) * 0.6));
  --shadow-md: 0 2px 4px hsl(var(--shadow-color) / calc(var(--shadow-strength) * 0.4)),
               0 8px 24px -6px hsl(var(--shadow-color) / var(--shadow-strength));
  --shadow-lg: 0 4px 8px hsl(var(--shadow-color) / calc(var(--shadow-strength) * 0.4)),
               0 24px 48px -12px hsl(var(--shadow-color) / calc(var(--shadow-strength) * 1.3));
}

/* --------------------------------------------------------------------------
   2. RESET MODERNO & BASE
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1.25rem);
  hanging-punctuation: first last;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01", "ss03";
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
svg,
video,
canvas {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

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

/* Barras de rolagem discretas */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  border-radius: var(--radius-full);
  background-clip: padding-box;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* --------------------------------------------------------------------------
   3. ACESSIBILIDADE
   -------------------------------------------------------------------------- */
.skip-link {
  position: fixed;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: var(--z-skip);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform var(--dur) var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

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

:focus:not(:focus-visible) {
  outline: none;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.72em;
  font-weight: 500;
  padding: 0.12em 0.45em;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface);
  color: var(--text-2);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   4. APP SHELL & SIDEBAR
   -------------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  transition: grid-template-columns var(--dur-slow) var(--ease-in-out);
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .sidebar {
  transform: translateX(-100%);
  visibility: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-3) var(--sp-4);
  background: var(--surface-sunken);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  z-index: var(--z-drawer);
  transition: transform var(--dur-slow) var(--ease-in-out), visibility var(--dur-slow);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.sidebar-header-titles {
  min-width: 0;
  flex: 1;
}

/* Marca (novo cabeçalho) */
.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
  color: var(--text);
  min-width: 0;
  border-radius: var(--radius-sm);
}

.brand-mark {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--formal));
  color: var(--on-accent);
  box-shadow: 0 4px 14px -4px var(--glow);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.brand-title {
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
}

/* Cabeçalho legado (páginas antigas) */
.sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0;
  padding: 0;
  border: 0;
}

.sidebar-subtitle {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
}

.sidebar-close-btn {
  flex-shrink: 0;
  display: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  transition: background var(--dur-fast), color var(--dur-fast);
}

.sidebar-close-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.sidebar-close-btn svg {
  width: 18px;
  height: 18px;
}

/* Busca */
.sidebar-search-box {
  position: relative;
  padding: 0 var(--sp-1);
}

.sidebar-search {
  width: 100%;
  height: 36px;
  padding: 0 2.6rem 0 2.1rem;
  font-size: var(--fs-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.sidebar-search::placeholder {
  color: var(--text-3);
}

.sidebar-search:hover {
  border-color: var(--border-strong);
}

.sidebar-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sidebar-search::-webkit-search-cancel-button {
  display: none;
}

.sidebar-search-icon {
  position: absolute;
  left: calc(var(--sp-1) + 0.7rem);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.sidebar-search-icon svg {
  width: 15px;
  height: 15px;
}

.sidebar-search-kbd {
  position: absolute;
  right: calc(var(--sp-1) + 0.55rem);
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Grupos de navegação */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.nav-group[hidden] {
  display: none;
}

.nav-group-label {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 var(--sp-3);
  margin: var(--sp-1) 0 var(--sp-1);
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
}

.nav-list li {
  margin: 0;
}

.nav-list a,
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 36px;
  padding: 0.4rem var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.35;
  text-decoration: none;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.nav-list a:hover,
.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-list a.active,
.nav-link.active,
.nav-list a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-list a.active::before,
.nav-list a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-num {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  min-width: 1.75rem;
  height: 1.35rem;
  padding: 0 0.3rem;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all var(--dur-fast);
}

.nav-list a.active .nav-num,
.nav-list a[aria-current="page"] .nav-num {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.nav-list a.completed .nav-num {
  color: var(--intuition);
  border-color: color-mix(in srgb, var(--intuition) 45%, transparent);
  background: color-mix(in srgb, var(--intuition) 10%, transparent);
}

.nav-text {
  flex: 1;
  min-width: 0;
}

.nav-list a.completed::after,
.nav-link.completed::after {
  content: "";
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  background: var(--intuition);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}

.nav-empty-message {
  font-size: var(--fs-sm);
  color: var(--text-3);
  text-align: center;
  padding: var(--sp-4) var(--sp-2);
}

/* Rodapé da sidebar: progresso */
.sidebar-footer {
  margin-top: auto;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.sidebar-progress-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-bottom: var(--sp-2);
}

.sidebar-progress-label strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
}

.progress-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: var(--progress, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--intuition));
  transition: width var(--dur-slow) var(--ease-out);
}

/* Drawer mobile */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 900px) {
  .app-shell,
  .app-shell.sidebar-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar,
  .app-shell.sidebar-collapsed .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, 300px);
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: var(--shadow-lg);
  }

  .app-shell.sidebar-mobile-open .sidebar {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar-close-btn {
    display: grid;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: var(--z-backdrop);
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) ease;
  }

  .app-shell.sidebar-mobile-open ~ .sidebar-backdrop,
  body.sidebar-mobile-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.sidebar-mobile-open {
    overflow: hidden;
  }
}

/* --------------------------------------------------------------------------
   5. BARRA SUPERIOR & MENU DE TEMAS
   -------------------------------------------------------------------------- */
.content-area,
.content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.top-nav-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  height: var(--header-h);
  padding: 0 var(--sp-5);
  background: var(--overlay);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

@media (max-width: 640px) {
  .top-nav-header {
    padding: 0 var(--sp-3);
    gap: var(--sp-2);
  }
}

.top-nav-left,
.top-nav-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.top-nav-right {
  flex-shrink: 0;
}

.nav-action-btn,
.theme-dropdown-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 36px;
  min-width: 36px;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}

.nav-action-btn:hover,
.theme-dropdown-btn:hover,
.theme-dropdown-btn[aria-expanded="true"] {
  background: var(--surface-2);
  color: var(--text);
}

.nav-action-btn[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-action-btn svg,
.theme-dropdown-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.theme-dropdown-btn {
  padding: 0 var(--sp-3);
  border-color: var(--border);
}

.theme-dropdown-btn .chevron {
  width: 14px;
  height: 14px;
  opacity: 0.7;
  transition: transform var(--dur) var(--ease-out);
}

.theme-dropdown-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

@media (max-width: 560px) {
  #theme-current-name,
  .theme-dropdown-btn .chevron {
    display: none;
  }

  .theme-dropdown-btn {
    padding: 0 var(--sp-2);
  }
}

.top-breadcrumb-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.breadcrumb-root {
  color: var(--text-3);
  text-decoration: none;
  transition: color var(--dur-fast);
}

a.breadcrumb-root:hover {
  color: var(--text);
}

.breadcrumb-sep {
  color: var(--border-strong);
}

.breadcrumb-current {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 767px) {
  .breadcrumb-root,
  .breadcrumb-sep {
    display: none;
  }
}

.wide-mode-toggle {
  display: none;
}

@media (min-width: 1100px) {
  .wide-mode-toggle {
    display: inline-flex;
  }
}

.theme-dropdown-container {
  position: relative;
}

.theme-dropdown-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-popover);
  width: 288px;
  padding: var(--sp-2);
  display: none;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform-origin: top right;
}

.theme-dropdown-popover.open {
  display: flex;
  animation: popIn var(--dur) var(--ease-out);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
  }
}

.theme-popover-header {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: var(--sp-2) var(--sp-3) var(--sp-2);
}

.theme-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background var(--dur-fast);
}

.theme-option-row:hover,
.theme-option-row:focus-visible {
  background: var(--surface-2);
}

.theme-option-row:focus-visible {
  outline-offset: -2px;
}

.theme-option-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.theme-palette-dots {
  display: flex;
  flex-shrink: 0;
}

.theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
}

.theme-dot + .theme-dot {
  margin-left: -4px;
}

.theme-option-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.theme-option-name {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.theme-option-desc {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.theme-badge {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-3);
}

.theme-check-icon {
  color: var(--accent);
  opacity: 0;
}

.theme-check-icon svg {
  width: 16px;
  height: 16px;
}

.theme-option-row[aria-checked="true"] .theme-check-icon,
.theme-option-row.active .theme-check-icon {
  opacity: 1;
}

/* Barra de progresso de leitura */
#reading-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(var(--read, 0));
  background: linear-gradient(90deg, var(--accent), var(--formal));
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   6. PIPELINE BAR (stepper de fases nas aulas)
   -------------------------------------------------------------------------- */
.pipeline-bar {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: calc(var(--content-w) + 2 * var(--sp-6));
  margin: var(--sp-6) auto 0;
  padding: 0 var(--sp-6);
  overflow-x: auto;
  scrollbar-width: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
  mask-image: linear-gradient(90deg, #000 92%, transparent);
}

.pipeline-bar::-webkit-scrollbar {
  display: none;
}

.page-layout.is-wide ~ .pipeline-bar,
.content-area.is-wide .pipeline-bar {
  max-width: calc(var(--content-w-wide) + 2 * var(--sp-6));
}

@media (min-width: 900px) {
  .pipeline-bar {
    -webkit-mask-image: none;
    mask-image: none;
  }
}

.pipe-step,
.pipeline-step {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  color: var(--text-3);
  white-space: nowrap;
  font-weight: 500;
}

.pipe-step::before,
.pipeline-step::before {
  content: "";
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
}

.pipe-step:not(:last-child)::after,
.pipeline-step:not(:last-child)::after {
  content: "";
  flex: 1;
  min-width: 1.25rem;
  height: 1px;
  margin: 0 var(--sp-2);
  background: var(--border);
}

.pipe-step.step-active,
.pipeline-step.current {
  color: var(--accent);
  font-weight: 600;
}

.pipe-step.step-active::before,
.pipeline-step.current::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.pipe-step.step-active:has(+ .step-active)::after {
  background: var(--accent);
  opacity: 0.55;
}

/* --------------------------------------------------------------------------
   7. LAYOUT DE LEITURA & SUMÁRIO LATERAL
   -------------------------------------------------------------------------- */
.lesson-container {
  width: 100%;
  max-width: calc(var(--content-w) + 2 * var(--sp-6));
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-6) var(--sp-8);
  transition: max-width var(--dur-slow) var(--ease-in-out);
}

.lesson-container.wide-mode {
  max-width: calc(var(--content-w-wide) + 2 * var(--sp-6));
}

@media (max-width: 640px) {
  .lesson-container {
    padding: var(--sp-5) var(--sp-4) var(--sp-7);
  }

  .pipeline-bar {
    padding: 0 var(--sp-4);
    margin-top: var(--sp-5);
  }
}

/* Layout de leitura limpo sem barra lateral fixa */
.page-layout {
  display: block;
  width: 100%;
}

.page-layout > .lesson-container {
  min-width: 0;
}

/* O sumário fixo à direita foi removido do fluxo normal */
.page-toc {
  display: none !important;
}

/* --------------------------------------------------------------------------
   7.1 TOGGLE DE SUMÁRIO NA TOP-NAV (TOC DROPDOWN POPOVER)
   -------------------------------------------------------------------------- */
.toc-dropdown-container {
  position: relative;
}

.toc-dropdown-btn {
  gap: var(--sp-2);
}

.toc-dropdown-btn .chevron {
  width: 14px;
  height: 14px;
  opacity: 0.7;
  transition: transform var(--dur) var(--ease-out);
}

.toc-dropdown-btn[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

.toc-dropdown-btn[aria-expanded="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

@media (max-width: 640px) {
  .toc-btn-label,
  .toc-dropdown-btn .chevron {
    display: none;
  }
}

.toc-dropdown-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-popover);
  width: min(90vw, 360px);
  max-height: calc(85vh - var(--header-h));
  display: none;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform-origin: top right;
  overflow: hidden;
}

.toc-dropdown-popover.open {
  display: flex;
  animation: popIn var(--dur) var(--ease-out);
}

.toc-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toc-popover-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.toc-menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--sp-2);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.toc-menu-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 0.55rem var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-sm);
  line-height: 1.4;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}

.toc-menu-item:hover,
.toc-menu-item:focus-visible {
  background: var(--surface-2);
  color: var(--text);
}

.toc-menu-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.toc-item-num {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  min-width: 1.6rem;
  height: 1.3rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-3);
  background: var(--bg);
  border: 1px solid var(--border);
  margin-top: 1px;
}

.toc-menu-item.is-active .toc-item-num {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.toc-item-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* --------------------------------------------------------------------------
   8. TIPOGRAFIA DE CONTEÚDO
   -------------------------------------------------------------------------- */
.lesson-container h1 {
  font-size: var(--fs-3xl);
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: var(--sp-5);
  text-wrap: balance;
}

.lesson-container h1 .slide-badge {
  vertical-align: 0.45em;
  margin-left: var(--sp-2);
}

.lesson-container h2 {
  position: relative;
  font-size: var(--fs-2xl);
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: var(--sp-8) 0 var(--sp-4);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  text-wrap: balance;
}

.lesson-container section:first-of-type > h2:first-child {
  margin-top: var(--sp-7);
}

.lesson-container h2 .slide-badge {
  margin-left: var(--sp-2);
  vertical-align: 0.2em;
}

.lesson-container h3 {
  font-size: var(--fs-lg);
  line-height: 1.4;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: var(--sp-6) 0 var(--sp-3);
}

.lesson-container h4 {
  font-size: var(--fs-md);
  font-weight: 650;
  color: var(--text);
  margin: var(--sp-5) 0 var(--sp-2);
}

.heading-anchor {
  margin-left: var(--sp-2);
  color: var(--text-3);
  font-weight: 500;
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--dur-fast), color var(--dur-fast);
}

h2:hover .heading-anchor,
h3:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
}

.heading-anchor:hover {
  color: var(--accent);
}

.lesson-container p {
  font-size: var(--fs-body);
  line-height: 1.75;
  color: var(--text);
  margin-bottom: var(--sp-4);
  text-wrap: pretty;
}

.lesson-container ul,
.lesson-container ol {
  font-size: var(--fs-body);
  line-height: 1.7;
  margin: 0 0 var(--sp-4) var(--sp-5);
  color: var(--text);
}

.lesson-container li {
  margin-bottom: var(--sp-2);
  padding-left: var(--sp-1);
}

.lesson-container li::marker {
  color: var(--text-3);
}

.lesson-container strong {
  font-weight: 650;
  color: var(--text);
}

.lesson-container em {
  color: var(--text);
}

.lesson-container hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: var(--sp-7) 0;
}

.lesson-container a:not([class]),
.home a.inline-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--dur-fast), color var(--dur-fast);
}

.lesson-container a:not([class]):hover,
.home a.inline-link:hover {
  color: var(--accent-strong);
  text-decoration-color: currentColor;
}

/* --------------------------------------------------------------------------
   9. CÓDIGO, BADGES E TRANSFORMAÇÕES
   -------------------------------------------------------------------------- */
pre,
code,
samp {
  font-family: var(--font-mono);
  font-feature-settings: "calt" 1, "zero" 1;
}

code {
  font-size: 0.86em;
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--code-text);
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
}

pre:not(.mermaid) {
  position: relative;
  margin: 0 0 var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  font-size: 0.86rem;
  line-height: 1.65;
  background: var(--surface-sunken);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  tab-size: 2;
}

pre:not(.mermaid) code {
  font-size: inherit;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  overflow-wrap: normal;
}

.copy-code-btn {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 28px;
  padding: 0 var(--sp-2);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}

.copy-code-btn svg {
  width: 13px;
  height: 13px;
}

pre:hover .copy-code-btn,
.copy-code-btn:focus-visible,
.copy-code-btn.copied {
  opacity: 1;
}

@media (hover: none) {
  .copy-code-btn {
    opacity: 1;
  }
}

.copy-code-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.copy-code-btn.copied {
  color: var(--intuition);
  border-color: color-mix(in srgb, var(--intuition) 50%, transparent);
}

.slide-badge,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0;
  white-space: nowrap;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  vertical-align: middle;
}

/* Grade de transformação lado a lado */
.transformation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: var(--sp-3);
  margin: var(--sp-5) 0 var(--sp-6);
}

.transformation-grid:not(:has(.transform-arrow)) {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.transform-box,
.transform-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.transform-box pre,
.transform-pane pre {
  margin-bottom: 0;
  flex-grow: 1;
}

.transform-box > p:last-child,
.transform-pane > p:last-child {
  margin-bottom: 0;
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--text-2);
}

.transform-title,
.transform-header {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: var(--sp-3);
}

.transform-arrow {
  display: grid;
  place-items: center;
  width: 36px;
  font-size: 1.25rem;
  color: var(--accent);
}

@media (max-width: 800px) {
  .transformation-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .transform-arrow {
    width: auto;
    transform: rotate(90deg);
  }
}

/* --------------------------------------------------------------------------
   10. DIAGRAMAS MERMAID & KATEX
   -------------------------------------------------------------------------- */
.diagram-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  margin: var(--sp-5) 0 var(--sp-6);
  padding: var(--sp-5) var(--sp-4);
  background-color: var(--surface);
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

pre.mermaid,
.diagram-wrapper pre.mermaid {
  display: flex;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  font-family: var(--font-sans);
  color: transparent; /* esconde o código-fonte antes da renderização */
  min-height: 2rem;
}

pre.mermaid[data-processed="true"] {
  color: inherit;
}

pre.mermaid svg {
  max-width: 100%;
  height: auto;
}

.transform-box pre.mermaid {
  padding: var(--sp-3) 0;
}

.katex {
  font-size: 1.06em;
}

.katex-display {
  margin: var(--sp-4) 0;
  padding: var(--sp-1) 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* --------------------------------------------------------------------------
   11. TABELAS
   -------------------------------------------------------------------------- */
.table-wrapper {
  width: 100%;
  margin: var(--sp-5) 0 var(--sp-6);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.compiler-table {
  width: 100%;
  margin: var(--sp-5) 0 var(--sp-6);
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-variant-numeric: tabular-nums;
}

.table-wrapper > .compiler-table {
  margin: 0;
  border: 0;
  border-radius: 0;
}

.compiler-table caption {
  caption-side: top;
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.compiler-table th,
.compiler-table td {
  padding: 0.6rem 0.9rem;
  text-align: left;
  vertical-align: top;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.compiler-table th + th,
.compiler-table td + td {
  border-left: 1px solid var(--border);
}

.compiler-table tbody tr:last-child td {
  border-bottom: 0;
}

.compiler-table th {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
  background: var(--surface-2);
  white-space: nowrap;
}

.compiler-table thead th:first-child {
  border-top-left-radius: calc(var(--radius-md) - 1px);
}

.compiler-table thead th:last-child {
  border-top-right-radius: calc(var(--radius-md) - 1px);
}

.compiler-table tbody tr {
  transition: background var(--dur-fast);
}

.compiler-table tbody tr:hover {
  background: var(--accent-soft);
}

.compiler-table code {
  font-size: 0.95em;
}

.compiler-table.is-prose {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}

/* --------------------------------------------------------------------------
   12. CALLOUTS PEDAGÓGICOS
   -------------------------------------------------------------------------- */
.callout {
  --c: var(--accent);
  position: relative;
  margin: var(--sp-5) 0 var(--sp-6);
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid color-mix(in srgb, var(--c) 28%, var(--border));
  border-left: 3px solid var(--c);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--c) 6%, var(--surface));
}

.callout-intuition {
  --c: var(--intuition);
}

.callout-formal {
  --c: var(--formal);
}

.callout-trap {
  --c: var(--trap);
}

.callout-conflict {
  --c: var(--conflict);
}

.callout-title {
  display: block;
  margin-bottom: var(--sp-2);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c);
}

.callout > :last-child,
.callout p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   13. EXERCÍCIOS RESOLVIDOS
   -------------------------------------------------------------------------- */
.exercise-card {
  margin: var(--sp-6) 0;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.exercise-header,
.exercise-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  margin: calc(-1 * var(--sp-5)) calc(-1 * var(--sp-5)) var(--sp-4);
  padding: var(--sp-3) var(--sp-5);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.exercise-Injector {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--text);
  line-height: 1.45;
}

.exercise-header .slide-badge {
  white-space: normal;
}

details.hint-toggle,
details.solution-toggle {
  --c: var(--accent);
  margin-top: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  overflow: hidden;
}

details.hint-toggle {
  --c: var(--trap);
}

details.solution-toggle {
  --c: var(--intuition);
}

details.hint-toggle > summary,
details.solution-toggle > summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background var(--dur-fast);
}

details > summary::-webkit-details-marker {
  display: none;
}

details.hint-toggle > summary::after,
details.solution-toggle > summary::after {
  content: "";
  margin-left: auto;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform var(--dur) var(--ease-out);
}

details[open] > summary::after {
  transform: rotate(180deg);
}

details.hint-toggle > summary:hover,
details.solution-toggle > summary:hover {
  background: color-mix(in srgb, var(--c) 7%, transparent);
}

details[open].hint-toggle > summary,
details[open].solution-toggle > summary {
  border-bottom: 1px solid var(--border);
}

details.hint-toggle > :not(summary),
details.solution-toggle > :not(summary) {
  margin-left: var(--sp-4);
  margin-right: var(--sp-4);
}

details.hint-toggle > :not(summary):first-of-type,
details.solution-toggle > :not(summary):first-of-type {
  margin-top: var(--sp-4);
}

details.hint-toggle > :last-child:not(summary),
details.solution-toggle > :last-child:not(summary) {
  margin-bottom: var(--sp-4);
}

.solution-content,
.solution-body {
  margin-top: var(--sp-4);
}

.solution-content > :last-child,
.solution-body > :last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   14. NAVEGAÇÃO ENTRE AULAS & CONCLUSÃO
   -------------------------------------------------------------------------- */
.lesson-nav,
.lesson-footer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-6);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--border);
}

.lesson-nav > span:empty {
  display: none;
}

.lesson-nav .nav-btn {
  min-height: 64px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  line-height: 1.45;
  white-space: normal;
}

.lesson-nav .nav-btn:last-child:not(:first-child),
.lesson-nav span:empty + .nav-btn {
  justify-content: flex-end;
  text-align: right;
}

.nav-btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}

.nav-btn:hover,
.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-btn:active,
.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 6px 20px -8px var(--glow);
}

.btn-primary:hover {
  color: var(--on-accent);
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-ghost {
  background: transparent;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-lg {
  min-height: 46px;
  padding: 0 var(--sp-5);
  font-size: var(--fs-md);
  border-radius: var(--radius-md);
}

/* Cartão "marcar como concluída" */
.lesson-complete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: var(--sp-7);
  padding: var(--sp-4) var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.lesson-complete-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lesson-complete-text strong {
  font-size: var(--fs-md);
}

.lesson-complete-text span {
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.lesson-complete.is-done {
  border-color: color-mix(in srgb, var(--intuition) 40%, var(--border));
  background: color-mix(in srgb, var(--intuition) 6%, var(--surface));
}

.btn-complete[aria-pressed="true"] {
  color: var(--intuition);
  border-color: color-mix(in srgb, var(--intuition) 50%, transparent);
  background: color-mix(in srgb, var(--intuition) 10%, transparent);
}

/* Toast acessível */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--sp-5);
  z-index: var(--z-popover);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  transform: translate(-50%, 150%);
  opacity: 0;
  transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur);
  pointer-events: none;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* --------------------------------------------------------------------------
   15. PÁGINA INICIAL
   -------------------------------------------------------------------------- */
.home {
  width: 100%;
  max-width: calc(var(--home-w) + 2 * var(--sp-6));
  margin: 0 auto;
  padding: 0 var(--sp-6) var(--sp-7);
}

@media (max-width: 640px) {
  .home {
    padding: 0 var(--sp-4) var(--sp-6);
  }
}

.home-section {
  padding-top: var(--sp-8);
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3) var(--sp-5);
  margin-bottom: var(--sp-5);
}

.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}

.section-title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
  text-wrap: balance;
}

.section-lead {
  max-width: 44rem;
  margin-top: var(--sp-2);
  color: var(--text-2);
  font-size: var(--fs-md);
  line-height: 1.65;
  text-wrap: pretty;
}

/* 15.1 Hero */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: center;
  gap: var(--sp-7);
  padding: var(--sp-8) 0 var(--sp-6);
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -2rem -30% auto auto;
  width: 60%;
  height: 120%;
  z-index: -1;
  background: radial-gradient(closest-side, var(--glow), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}

@media (max-width: 1040px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--sp-6);
    padding-top: var(--sp-7);
  }
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  padding: 0.3rem 0.75rem 0.3rem 0.4rem;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
}

.hero-eyebrow .pill {
  padding: 0.1rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: var(--radius-full);
}

.hero-title {
  font-size: var(--fs-hero);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.04em;
  color: var(--text);
}

.hero-title .grad {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.48em;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.025em;
  background: linear-gradient(90deg, var(--accent), var(--formal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-wrap: balance;
}

.hero-lead {
  max-width: 38rem;
  margin-top: var(--sp-5);
  font-size: var(--fs-lg);
  line-height: 1.65;
  color: var(--text-2);
  text-wrap: pretty;
}

.hero-lead strong {
  color: var(--text);
  font-weight: 600;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-top: var(--sp-7);
  padding: 0;
  list-style: none;
}

@media (max-width: 560px) {
  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.hero-stats li {
  display: flex;
  flex-direction: column;
  padding-left: var(--sp-3);
  border-left: 2px solid var(--border);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* Demonstração do pipeline no hero */
.hero-demo {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.demo-titlebar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-3);
}

.demo-dots {
  display: flex;
  gap: 6px;
  margin-right: var(--sp-2);
}

.demo-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}

.demo-dots span:nth-child(1) { background: var(--conflict); }
.demo-dots span:nth-child(2) { background: var(--trap); }
.demo-dots span:nth-child(3) { background: var(--intuition); }

.demo-body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-5);
}

.demo-stage {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.demo-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.demo-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c, var(--accent));
}

.demo-code {
  margin: 0;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  white-space: pre;
}

.demo-code .k { color: var(--formal); }
.demo-code .n { color: var(--trap); }
.demo-code .o { color: var(--text-3); }
.demo-code .v { color: var(--code-text); }

.token-stream {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tok {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--tc, var(--text));
  background: color-mix(in srgb, var(--tc, var(--text)) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--tc, var(--text)) 30%, transparent);
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: translateY(4px);
  animation: tokIn 420ms var(--ease-out) forwards;
  animation-delay: calc(var(--i, 0) * 70ms + 200ms);
}

.tok-id { --tc: var(--code-text); }
.tok-op { --tc: var(--formal); }
.tok-num { --tc: var(--trap); }

@keyframes tokIn {
  to {
    opacity: 1;
    transform: none;
  }
}

.demo-arrow {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding-left: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.demo-arrow svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

/* 15.2 Mapa do pipeline */
.pipeline-map {
  display: grid;
  grid-template-columns: 4fr 3fr;
  gap: var(--sp-4);
}

@media (max-width: 1100px) {
  .pipeline-map {
    grid-template-columns: minmax(0, 1fr);
  }
}

.pipeline-region {
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.region-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-3);
  margin-bottom: var(--sp-4);
  padding: 0 var(--sp-1);
}

.region-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
}

.region-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.stage-list {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: var(--sp-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 760px) {
  .stage-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .stage-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-3) var(--sp-4);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--dur), transform var(--dur) var(--ease-out);
}

.stage.is-covered {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 5%, var(--bg));
}

a.stage {
  text-decoration: none;
  color: inherit;
}

a.stage:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.stage-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-3);
  background: var(--surface-2);
}

.stage.is-covered .stage-num {
  color: var(--on-accent);
  background: var(--accent);
}

.stage-cover {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text-3);
}

.stage.is-covered .stage-cover {
  color: var(--accent);
}

.stage-name {
  font-size: var(--fs-sm);
  font-weight: 650;
  line-height: 1.35;
  color: var(--text);
}

.stage-out {
  margin-top: auto;
  padding: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--text-2);
  background: var(--surface-sunken);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
}

.stage-out-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 2px;
}

.symtab {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: color-mix(in srgb, var(--formal) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--formal) 30%, var(--border));
  border-radius: var(--radius-lg);
}

.symtab-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--formal);
  background: color-mix(in srgb, var(--formal) 14%, transparent);
}

.symtab-icon svg {
  width: 20px;
  height: 20px;
}

.symtab-text {
  font-size: var(--fs-sm);
  color: var(--text-2);
  line-height: 1.55;
}

.symtab-text strong {
  color: var(--text);
}

/* 15.3 Módulos */
.module-groups {
  display: flex;
  flex-direction: column;
  gap: var(--sp-7);
}

.module-group-head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.module-group-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.module-group-meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-3);
  white-space: nowrap;
}

.module-group-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: var(--sp-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.module-grid > li {
  display: flex;
  margin: 0;
}

.module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur) var(--ease-out), background var(--dur);
}

.module-card:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.module-card:focus-visible {
  outline-offset: 3px;
  border-radius: var(--radius-lg);
}

.module-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

.module-num {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--border-strong);
  transition: color var(--dur);
}

.module-card:hover .module-num {
  color: var(--accent);
}

.module-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 22px;
  padding: 0 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.module-status:empty {
  display: none;
}

.module-status.is-done {
  color: var(--intuition);
  background: color-mix(in srgb, var(--intuition) 12%, transparent);
}

.module-status.is-current {
  color: var(--accent);
  background: var(--accent-soft);
}

.module-status svg {
  width: 12px;
  height: 12px;
}

.module-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-3);
}

.module-card h3,
.module-title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--text);
  text-wrap: balance;
}

.module-card p,
.module-desc {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-2);
}

.module-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.module-topics li {
  margin: 0;
  padding: 0.12rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-2);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.module-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-3);
  margin-top: auto;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
}

.module-meta span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.module-meta svg {
  width: 13px;
  height: 13px;
}

.module-cta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--accent);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--dur), transform var(--dur) var(--ease-out);
}

.module-card:hover .module-cta,
.module-card:focus-visible .module-cta {
  opacity: 1;
  transform: none;
}

@media (hover: none) {
  .module-cta {
    opacity: 1;
    transform: none;
  }
}

.module-card.is-featured {
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--trap) 14%, transparent), transparent 55%),
    var(--surface);
  border-color: color-mix(in srgb, var(--trap) 35%, var(--border));
}

.module-card.is-featured .module-num {
  color: var(--trap);
}

/* 15.4 Como estudar */
.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-4);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

@media (max-width: 860px) {
  .steps {
    grid-template-columns: minmax(0, 1fr);
  }
}

.step {
  position: relative;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  counter-increment: step;
}

.step::before {
  content: counter(step, decimal-leading-zero);
  display: block;
  margin-bottom: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
}

.step h3 {
  font-size: var(--fs-md);
  font-weight: 650;
  margin-bottom: var(--sp-2);
  color: var(--text);
}

.step p {
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-2);
}

/* 15.5 Rodapé */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-top: var(--sp-8);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--text-3);
}

.site-footer p {
  max-width: 40rem;
}

.site-footer cite {
  color: var(--text-2);
}

.shortcut-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.shortcut-list li {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}

/* Animação de entrada suave */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    animation: reveal 600ms var(--ease-out) both;
    animation-delay: var(--d, 0ms);
  }

  @keyframes reveal {
    from {
      opacity: 0;
      transform: translateY(10px);
    }
  }
}

/* --------------------------------------------------------------------------
   16. VOLTAR AO TOPO
   -------------------------------------------------------------------------- */
#back-to-top {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: var(--z-fab);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity var(--dur), transform var(--dur) var(--ease-out), visibility var(--dur), color var(--dur-fast), border-color var(--dur-fast);
}

#back-to-top svg {
  width: 18px;
  height: 18px;
}

#back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

#back-to-top:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 640px) {
  #back-to-top {
    right: var(--sp-4);
    bottom: var(--sp-4);
  }
}

/* --------------------------------------------------------------------------
   16.2 SIMULADOR DE PROVA & CADERNO DE RESPOSTAS
   -------------------------------------------------------------------------- */
.exam-hero {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: var(--sp-6);
  margin-bottom: var(--sp-6);
  position: relative;
  overflow: hidden;
}

.exam-hero::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, var(--glow), transparent 70%);
  pointer-events: none;
}

.exam-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.exam-badge-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.exam-score-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  background: color-mix(in srgb, var(--intuition) 15%, var(--surface-2));
  color: var(--intuition);
  border: 1px solid color-mix(in srgb, var(--intuition) 35%, transparent);
  border-radius: var(--radius-full);
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.exam-title {
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  margin: var(--sp-2) 0 var(--sp-3);
}

.exam-desc {
  font-size: var(--fs-sm);
  color: var(--text-2);
  max-width: 65ch;
  line-height: 1.6;
  margin-bottom: var(--sp-4);
}

.exam-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.exam-meta-item {
  font-size: var(--fs-xs);
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Barra de Abas / Seleção de Questões */
.exam-tabs-wrapper {
  position: sticky;
  top: var(--header-h);
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--sp-3) 0;
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
}

.exam-tabs {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: 2px;
}

.exam-tabs::-webkit-scrollbar {
  display: none;
}

.exam-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur) var(--ease-out);
}

.exam-tab-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.exam-tab-btn.is-active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  box-shadow: 0 2px 8px var(--glow);
}

.exam-tab-btn .tab-pts {
  display: inline-block;
  font-size: 0.7rem;
  opacity: 0.85;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: var(--radius-full);
}

/* Card de Questão da Prova */
.exam-question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-7);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur);
}

.exam-question-card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
}

.exam-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
}

.exam-question-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.exam-q-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 800;
}

.exam-q-score {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: var(--radius-full);
  padding: 3px 10px;
}

.exam-prompt {
  font-size: var(--fs-body);
  line-height: 1.7;
  color: var(--text);
  margin-bottom: var(--sp-4);
}

.exam-prompt code {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  background: var(--surface-sunken);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Área de Rascunho / Resposta do Estudante */
.scratchpad-container {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  margin: var(--sp-5) 0 var(--sp-4);
}

.scratchpad-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}

.scratchpad-title {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-2);
}

.scratchpad-status {
  font-size: var(--fs-xs);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.scratchpad-status.is-saved {
  color: var(--intuition);
}

.scratchpad-textarea {
  width: 100%;
  min-height: 130px;
  max-height: 500px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text);
  line-height: 1.6;
  outline: none;
  transition: border-color var(--dur), box-shadow var(--dur);
}

.scratchpad-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}

.scratchpad-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

.scratchpad-btn-group {
  display: flex;
  gap: var(--sp-2);
}

.scratchpad-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--dur);
}

.scratchpad-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

/* Quiz Interativo V/F (Questão 05.b) */
.vf-quiz-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: var(--sp-4) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.vf-quiz-table th {
  background: var(--surface-2);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.vf-quiz-table td {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.vf-quiz-table tr:last-child td {
  border-bottom: none;
}

.vf-choice-cell {
  width: 130px;
  white-space: nowrap;
  text-align: center;
}

.vf-options {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
}

.vf-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-xs);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--dur);
}

.vf-label:hover {
  background: var(--surface-2);
}

.vf-label input[type="radio"] {
  accent-color: var(--accent);
  margin: 0;
}

.vf-status-icon {
  display: inline-block;
  margin-left: var(--sp-2);
  font-weight: 800;
}

.vf-row.is-correct {
  background: color-mix(in srgb, var(--intuition) 8%, transparent);
}

.vf-row.is-wrong {
  background: color-mix(in srgb, var(--conflict) 8%, transparent);
}

.vf-score-result {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  display: none;
}

.vf-score-result.is-visible {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* Galeria de Prova Original Escaneada */
.exam-gallery-toggle {
  margin: var(--sp-5) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.exam-gallery-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  font-weight: 650;
  font-size: var(--fs-sm);
  color: var(--text);
  background: var(--surface-2);
}

.exam-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--sp-4);
  padding: var(--sp-4);
}

.exam-scan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-sunken);
  display: flex;
  flex-direction: column;
}

.exam-scan-card img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
  object-position: top;
  cursor: zoom-in;
  transition: transform var(--dur);
}

.exam-scan-card img:hover {
  transform: scale(1.02);
}

.exam-scan-caption {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
}

/* Controles de Navegação Entre Questões */
.question-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px dashed var(--border);
}

/* --------------------------------------------------------------------------
   17. IMPRESSÃO
   -------------------------------------------------------------------------- */
@media print {
  :root,
  [data-theme] {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --surface-sunken: #f7f7f8;
    --text: #000000;
    --text-2: #27272a;
    --text-3: #52525b;
    --accent: #1d4ed8;
    --border: #d4d4d8;
    --border-strong: #a1a1aa;
    --code-text: #9f1239;
  }

  .sidebar,
  .sidebar-backdrop,
  .top-nav-header,
  .pipeline-bar,
  .page-toc,
  .lesson-nav,
  .lesson-complete,
  #back-to-top,
  .copy-code-btn,
  .heading-anchor,
  .skip-link,
  .toast {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .lesson-container,
  .home {
    max-width: none;
    padding: 0;
  }

  .page-layout {
    display: block;
  }

  .exercise-card,
  .callout,
  pre,
  .diagram-wrapper,
  .compiler-table,
  .module-card {
    break-inside: avoid;
    box-shadow: none;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  .diagram-wrapper {
    background-image: none;
  }
}
