:root {
  --purple: #673ab7;
  --purple-dark: #512da8;
  --purple-soft: #ede7f6;
  --green-bg: #e6f4ea;
  --green-text: #1e7e34;
  --green-border: #34a853;
  --red-bg: #fce8e6;
  --red-text: #c5221f;
  --red-border: #ea4335;
  --gray-text: #5f6368;
  --gray-border: #dadce0;
  --page-bg: #f0eef7;
  --card-bg: #ffffff;
}

* { box-sizing: border-box; }

/* Visível apenas para leitores de tela. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--page-bg);
  color: #202124;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--purple);
  color: #fff;
}

.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 4px;
}

.site-nav a {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 20px;
}

.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }

.site-nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
  font-weight: 600;
}

.score-pill {
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
}

/* Home */
.home {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 20px;
  text-align: center;
}

.home h1 { font-size: 1.6rem; margin-bottom: 8px; }
.subtitle { color: var(--gray-text); margin-bottom: 36px; }

.modules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.module-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 32px 20px;
  text-decoration: none;
  color: #202124;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
  border-top: 6px solid var(--gray-border);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.module-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(60, 64, 67, 0.2);
}

.module-card.html { border-top-color: #e34c26; }
.module-card.css { border-top-color: #264de4; }
.module-card.js { border-top-color: #f0db4f; }

.module-icon { font-size: 2.2rem; margin-bottom: 8px; }
.module-card h2 { margin: 4px 0; }
.module-card p { color: var(--gray-text); margin: 0 0 12px; font-size: 0.9rem; }
.module-count {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--purple-dark);
  background: #ede7f6;
  padding: 4px 10px;
  border-radius: 20px;
}

.level-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.level-link {
  display: block;
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--purple-dark);
  background: #f6f3fb;
  border: 1px solid #e3daf5;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.level-link:hover { background: #ede7f6; }

/* Níveis com fases (home) */
.nivel-grupo { margin-bottom: 14px; }

.nivel-cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.nivel-nome {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--purple-dark);
}

.nivel-contador {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gray-text);
}

.nivel-contador.done { color: var(--green-text); }

.fase-linha {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fase-pill {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--purple-dark);
  background: #f6f3fb;
  border: 1px solid #e3daf5;
  transition: background 0.15s ease, transform 0.15s ease;
}

.fase-pill:hover {
  background: var(--purple-soft);
  transform: translateY(-2px);
}

.fase-pill.started {
  border-color: var(--purple);
  border-style: dashed;
}

.fase-pill.done {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green-text);
}

/* Fase trancada: não é link, não reage ao mouse. */
.fase-pill.locked,
.fase-tab.locked {
  background: #f1f1f1;
  border-color: var(--gray-border);
  border-style: dashed;
  color: var(--gray-text);
  cursor: not-allowed;
  font-size: 0.8rem;
  transform: none;
}

.fase-pill.locked:hover,
.fase-tab.locked:hover {
  background: #f1f1f1;
  transform: none;
}

/* Abas de fase (quiz) */
.fase-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: -8px 0 20px;
}

.fase-rotulo {
  font-size: 0.78rem;
  color: var(--gray-text);
  margin-right: 2px;
}

.fase-tab {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--purple-dark);
  background: #fff;
  border: 1px solid #e3daf5;
}

.fase-tab:hover { background: #f6f3fb; }

.fase-tab.active {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}

.fase-tab.done:not(.active) {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green-text);
}

/* Card do Teste Prático (home) */
.pratica-card {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 24px;
  padding: 22px 24px;
  background: var(--card-bg);
  border-radius: 12px;
  border-left: 6px solid var(--purple);
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
  text-decoration: none;
  color: #202124;
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pratica-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(60, 64, 67, 0.2);
}

.pratica-icone { font-size: 2.2rem; flex-shrink: 0; }
.pratica-texto { flex: 1; }
.pratica-texto h2 { margin: 0 0 2px; font-size: 1.15rem; color: var(--purple-dark); }
.pratica-texto p { margin: 0; font-size: 0.9rem; color: var(--gray-text); }
.pratica-seta { font-size: 1.4rem; color: var(--purple); flex-shrink: 0; }

.btn.hidden { display: none; }

/* Progresso do módulo */
.module-progress {
  font-size: 0.78rem;
  color: var(--gray-text);
  margin: 10px 0 0;
  font-weight: 600;
}

.module-progress.complete { color: var(--green-text); }
.module-progress.hidden { display: none; }

/* Apagar progresso */
.reset-wrap {
  margin-top: 32px;
}

.reset-wrap.hidden { display: none; }

.reset-btn {
  background: none;
  border: 1px solid var(--gray-border);
  color: var(--gray-text);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
}

.reset-btn:hover {
  border-color: var(--red-border);
  color: var(--red-text);
  background: var(--red-bg);
}

/* Recorde no topo do quiz e no resultado */
.quiz-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.best-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gray-text);
  background: #fff;
  border: 1px solid var(--gray-border);
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.best-badge.done {
  color: var(--green-text);
  background: var(--green-bg);
  border-color: var(--green-border);
}

.best-badge.hidden { display: none; }

/* Mais específico que ".result-banner p", para não precisar de !important. */
.result-banner .best-text {
  font-size: 0.9rem;
  color: var(--gray-text);
  margin: -8px 0 16px;
}

.result-banner .best-text.hidden { display: none; }

.level-link.disabled {
  color: var(--gray-text);
  background: #f1f1f1;
  border-color: var(--gray-border);
  pointer-events: none;
}

/* Level tabs on quiz page */
.level-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.level-tab {
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--purple-dark);
  background: #fff;
  border: 1px solid #e3daf5;
  padding: 8px 14px;
  border-radius: 20px;
}

.level-tab:hover { background: #f6f3fb; }

.level-tab.active {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}

.level-tab.disabled {
  pointer-events: none;
  opacity: 0.5;
}

.empty-state {
  text-align: center;
  color: var(--gray-text);
  padding: 40px 0;
}

/* Aprender */
.learn-main {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 20px 60px;
  text-align: center;
}

.learn-title { font-size: 1.6rem; margin-bottom: 8px; color: var(--purple-dark); }

.learn-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 32px;
  text-align: left;
}

.term-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
  padding: 24px 20px 20px;
}

/* Resumo / índice */
.summary {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
  padding: 20px;
  margin-top: 28px;
  text-align: left;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.summary-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-text);
  margin: 0;
  font-weight: 700;
}

/* Interruptor deslizante: a bolinha corre da esquerda para a direita */
.switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch-texto {
  font-size: 0.82rem;
  color: var(--gray-text);
  font-weight: 600;
}

.switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-trilho {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #cfd3d9;
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s ease;
}

.switch-bolinha {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.switch-input:checked ~ .switch-trilho { background: var(--purple); }
.switch-input:checked ~ .switch-trilho .switch-bolinha { transform: translateX(20px); }

.switch-input:checked ~ .switch-texto,
.switch-wrap:hover .switch-texto { color: var(--purple-dark); }

.switch-input:focus-visible ~ .switch-trilho {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

/* Destaque sutil enquanto o modo concreto está ligado */
body.modo-real .term-figure { background: #fbfaff; border-radius: 10px; }

.summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 6px;
  counter-reset: none;
}

.summary-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: #202124;
  font-size: 0.92rem;
  transition: background 0.15s ease;
}

.summary-link:hover { background: var(--purple-soft); }

.summary-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--purple-soft);
  color: var(--purple-dark);
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.summary-icon { font-size: 1rem; }
.summary-text { flex: 1; }

html { scroll-behavior: smooth; }
.term-card { scroll-margin-top: 20px; }

.term-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 8px;
}

.example-btn {
  flex-shrink: 0;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.example-btn:hover { background: var(--purple-dark); }

.term-icon { font-size: 1.9rem; flex-shrink: 0; line-height: 1.2; }

.term-info { flex: 1; }

.term-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--purple-dark);
}

.term-short { font-size: 0.95rem; color: var(--gray-text); margin: 0; }

.term-figure { margin: 0; }

.diagram-box {
  overflow-x: auto;
  padding: 8px 0 0;
}

.diagram-box svg {
  display: block;
  margin: 0 auto;
  width: 100%;
  min-width: 480px;
  height: auto;
  color: #202124;
}

.diagram-box svg text { fill: currentColor; }
.diagram-box svg text.s2 { fill: var(--gray-text); }

/* ================= Teste Prático ================= */
.pratica-app { min-height: 100vh; }

.pratica-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 10px;
}

.desafio-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gray-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.desafio-select {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--gray-border);
  background: #fff;
  color: #202124;
}

.desafio-select:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

.ghost-btn {
  background: none;
  border: 1px solid var(--gray-border);
  color: var(--gray-text);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.ghost-btn:hover { border-color: var(--purple); color: var(--purple-dark); }

.desafio-info {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 12px;
}

.desafio-objetivo {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  background: var(--purple-soft);
  border-left: 4px solid var(--purple);
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
}

.desafio-dicas {
  margin-top: 8px;
  font-size: 0.87rem;
  color: var(--gray-text);
}

.desafio-dicas summary {
  cursor: pointer;
  color: var(--purple-dark);
  font-weight: 600;
}

.desafio-dicas ul { margin: 8px 0 0; padding-left: 22px; }
.desafio-dicas li { margin-bottom: 4px; }

/* Tela dividida: código à esquerda, resultado à direita */
.split {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 460px;
}

.split-code,
.split-preview {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
  min-height: 0;
}

.code-tabs {
  display: flex;
  background: #252526;
  flex-shrink: 0;
}

.code-tab {
  background: #2d2d2d;
  border: none;
  border-right: 1px solid #1e1e1e;
  color: #969696;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 0.82rem;
  padding: 10px 18px;
  cursor: pointer;
}

.code-tab:hover { color: #ddd; }

.code-tab.active {
  background: #1e1e1e;
  color: #fff;
  border-top: 2px solid #a78bfa;
}

.editor-area {
  flex: 1;
  width: 100%;
  border: none;
  resize: none;
  background: #1e1e1e;
  color: #d4d4d4;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.86rem;
  line-height: 1.6;
  padding: 14px 16px;
  tab-size: 2;
}

.editor-area:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: -2px;
}

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--purple);
  color: #fff;
  font-size: 0.8rem;
  padding: 9px 14px;
  flex-shrink: 0;
}

.preview-hint { opacity: 0.75; font-size: 0.74rem; }

.preview-frame {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
  min-height: 300px;
}

/* Resultado da verificação */
.check-result {
  max-width: 1280px;
  width: 100%;
  margin: 16px auto 0;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.check-result.hidden { display: none; }
.check-result.sucesso { background: var(--green-bg); border-left: 4px solid var(--green-border); }
.check-result.parcial { background: #fdf1da; border-left: 4px solid #d99a00; }
.check-result.erro { background: var(--red-bg); border-left: 4px solid var(--red-border); }

.check-titulo { margin: 0 0 8px; font-weight: 700; }
.check-lista { margin: 0; padding-left: 4px; list-style: none; }
.check-lista li { margin-bottom: 4px; }
.check-lista li.ok { color: var(--green-text); }
.check-lista li.falhou { color: var(--gray-text); }

/* No celular a divisão vira de cima para baixo */
@media (max-width: 860px) {
  .split {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .editor-area { min-height: 260px; }
  .preview-frame { min-height: 240px; }
}

/* Editor simulado (VS Code) */
body.modal-open { overflow: hidden; }

.editor-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.editor-modal.hidden { display: none; }

.editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 30, 0.6);
}

.editor-window {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: min(76vh, 620px);
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  font-family: "Consolas", "Courier New", monospace;
}

.editor-titlebar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #323233;
  padding: 10px 14px;
  flex-shrink: 0;
}

.window-dots { display: flex; gap: 7px; }
.window-dots .dot { width: 12px; height: 12px; border-radius: 50%; display: block; }
.window-dots .red { background: #ff5f57; }
.window-dots .yellow { background: #febc2e; }
.window-dots .green { background: #28c840; }

.editor-title {
  flex: 1;
  text-align: center;
  color: #ccc;
  font-size: 0.82rem;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

.editor-close {
  background: none;
  border: none;
  color: #ccc;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.editor-close:hover { color: #fff; }

.lang-tabs {
  display: flex;
  gap: 2px;
  background: #252526;
  padding: 8px 12px 0;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
  overflow-x: auto;
}

.lang-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #9aa0a6;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 0.85rem;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.lang-tab:hover { color: #ddd; }

.lang-tab.active {
  color: #fff;
  border-bottom-color: #a78bfa;
  font-weight: 600;
}

.editor-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.editor-sidebar {
  width: 190px;
  flex-shrink: 0;
  background: #252526;
  border-right: 1px solid #333;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8a8a8a;
  margin: 0 0 8px;
  padding: 0 14px;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

.file-list { list-style: none; margin: 0; padding: 0; }

.file-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: #ccc;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 0.82rem;
  padding: 6px 14px;
  cursor: pointer;
  text-align: left;
}

.file-item:hover { background: #2a2d2e; }
.file-item.active { background: #37373d; color: #fff; }

.file-dot {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: #a78bfa;
  flex-shrink: 0;
}

.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.editor-tabs {
  display: flex;
  background: #252526;
  border-bottom: 1px solid #333;
  overflow-x: auto;
  flex-shrink: 0;
}

.editor-tab {
  background: #2d2d2d;
  border: none;
  border-right: 1px solid #1e1e1e;
  color: #969696;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 0.8rem;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.editor-tab.active {
  background: #1e1e1e;
  color: #fff;
  border-top: 1px solid #a78bfa;
}

.code-area {
  flex: 1;
  overflow: auto;
  padding: 14px 0;
  font-size: 0.83rem;
  line-height: 1.65;
  background: #1e1e1e;
}

.code-line { display: flex; white-space: pre; }
.code-line:hover { background: #2a2a2a; }

.ln {
  width: 44px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 16px;
  color: #5a5a5a;
  user-select: none;
}

.lc { color: #d4d4d4; padding-right: 20px; }

.tok-keyword { color: #c586c0; }
.tok-string { color: #ce9178; }
.tok-comment { color: #6a9955; font-style: italic; }
.tok-number { color: #b5cea8; }

.editor-status {
  display: flex;
  justify-content: space-between;
  background: #6b3fa0;
  color: #fff;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 0.74rem;
  padding: 5px 14px;
  flex-shrink: 0;
}

.term-figure figcaption {
  font-size: 0.85rem;
  color: var(--gray-text);
  text-align: center;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-border);
}

/* Quiz */
.quiz-main {
  flex: 1;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.quiz-title {
  color: var(--purple-dark);
  font-size: 1.3rem;
  margin: 8px 0 20px;
}

.question-list { display: flex; flex-direction: column; gap: 16px; }

.q-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
}

.q-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
}

.q-icon {
  font-weight: bold;
  width: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.q-icon.correct { color: var(--green-border); }
.q-icon.incorrect { color: var(--red-border); }

.q-text { flex: 1; margin: 0; font-size: 1.02rem; line-height: 1.4; }

.q-badge {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--gray-text);
}

.card-correct .q-badge { color: var(--green-text); }
.card-incorrect .q-badge { color: var(--red-text); }

.options { display: flex; flex-direction: column; gap: 2px; }

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
}

.option:hover { background: #f8f7fb; }

.option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-circle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #80868b;
  flex-shrink: 0;
  position: relative;
}

/* Foco visível no teclado: o input real tem 0x0 e opacity 0, então o
   indicador precisa aparecer no círculo desenhado ao lado dele. */
.option input:focus-visible + .radio-circle {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

.option:has(input:focus-visible) { background: var(--purple-soft); }

.option input:checked + .radio-circle { border-color: var(--purple); }
.option input:checked + .radio-circle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #202124;
}

.option-text { flex: 1; font-size: 0.95rem; }

.mark { font-weight: bold; width: 18px; text-align: center; }

.option.correct {
  background: var(--green-bg);
}
.option.correct .mark { color: var(--green-text); }

.option.incorrect {
  background: var(--red-bg);
}
.option.incorrect .mark { color: var(--red-text); }

input:disabled ~ .option-text,
.option input:disabled + .radio-circle {
  opacity: 1;
}

.correct-answer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--gray-border);
}

.correct-answer.hidden { display: none; }

.correct-label {
  font-size: 0.85rem;
  color: var(--gray-text);
  margin: 0 0 8px;
}

.correct-option {
  cursor: default;
  background: transparent;
}
.correct-option input:checked + .radio-circle {
  border-color: #202124;
}

/* Explicação "Por quê?" */
.explicacao {
  margin-top: 14px;
  background: var(--purple-soft);
  border-left: 4px solid var(--purple);
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
}

.explicacao.hidden { display: none; }

.explicacao-label {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--purple-dark);
}

.explicacao-texto {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #202124;
}

/* Code question */
.code-wrap { margin-top: 4px; }

.code-input {
  width: 100%;
  min-height: 90px;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.9rem;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--gray-border);
  resize: vertical;
  background: #fafafa;
  color: #202124;
}

.code-input:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 2px;
  border-color: var(--purple);
}

.code-input:disabled {
  background: #f5f5f5;
  color: #444;
}

.code-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

.code-feedback { font-size: 0.85rem; }
.code-feedback.ok { color: var(--green-text); }
.code-feedback.bad { color: var(--red-text); }
.code-feedback.warn { color: #b45309; }

.code-wrap.code-correct .code-input {
  border-color: var(--green-border);
  background: var(--green-bg);
}

.code-wrap.code-incorrect .code-input {
  border-color: var(--red-border);
  background: var(--red-bg);
}

.solution-code {
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.85rem;
  background: #f6f3fb;
  padding: 10px 12px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* Result banner */
.result-banner {
  margin-top: 24px;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
}

.result-banner.hidden { display: none; }

.result-banner p { font-size: 1.05rem; margin: 0 0 16px; }

.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.btn-primary {
  background: var(--purple);
  color: #fff;
}
.btn-primary:hover { background: var(--purple-dark); }

.btn-secondary {
  background: #fff;
  color: var(--purple);
  border: 1px solid var(--purple);
}
.btn-secondary:hover { background: #f3edfb; }

/* Siglas com tooltip */
.acronym {
  text-decoration: none;
  border-bottom: 1px dotted var(--purple);
  cursor: help;
  padding-bottom: 1px;
}

.acronym:hover,
.acronym:focus-visible {
  background: var(--purple-soft);
  border-radius: 3px;
}

.acronym:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}

.acronym-tip {
  position: fixed;
  z-index: 200;
  max-width: 290px;
  background: #23252b;
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.82rem;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  pointer-events: none;
  text-align: left;
}

.acronym-tip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.acronym-tip::after {
  content: "";
  position: absolute;
  left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: #23252b;
  bottom: -12px;
}

.acronym-tip.below::after {
  bottom: auto;
  top: -12px;
  border-top-color: transparent;
  border-bottom-color: #23252b;
}

.tip-sigla {
  display: block;
  font-weight: 700;
  color: #c4a7f7;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.tip-full {
  display: block;
  font-weight: 600;
  margin-top: 2px;
}

.tip-pt {
  display: block;
  margin-top: 6px;
  color: #b9bec9;
  font-size: 0.78rem;
}

.footer {
  text-align: center;
  color: var(--gray-text);
  font-size: 0.8rem;
  padding: 20px;
}

.license-note {
  font-size: 0.75rem;
  margin: 4px 0 0;
}

.license-note a {
  color: var(--purple-dark);
  text-decoration: none;
}

.license-note a:hover { text-decoration: underline; }

.author {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.author-photo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--gray-border);
}

.author-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.author-name {
  font-size: 0.85rem;
  color: #202124;
  font-weight: 600;
}

.author-links {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.author-links a {
  color: var(--purple-dark);
  text-decoration: none;
}

.author-links a:hover { text-decoration: underline; }

.author-sep { color: var(--gray-border); }

@media (max-width: 480px) {
  .q-header { flex-wrap: wrap; }
}

@media (max-width: 620px) {
  .editor-modal { padding: 0; }

  .editor-window {
    height: 100%;
    max-width: none;
    border-radius: 0;
  }

  .editor-sidebar { display: none; }

  .term-header { flex-wrap: wrap; }
  .example-btn { width: 100%; margin-top: 4px; }
}
