/* Sistema visual baseado em design/DESIGN.md (análise do Notion, awesome-design-md).
   Inter no lugar da Notion Sans (fonte proprietária; Inter é o fallback documentado). */
:root {
  --canvas: #ffffff;
  --surface: #f6f5f4;
  --surface-soft: #fafaf9;
  --hairline: #e5e3df;
  --hairline-strong: #c8c4be;
  --ink: #1a1a1a;
  --charcoal: #37352f;
  --slate: #5d5b54;
  --steel: #787671;
  --muted: #bbb8b1;
  --primary: #5645d4;
  --primary-pressed: #4534b3;
  --primary-tint: #e6e0f5;
  --link: #0075de;
  --navy: #0a1530;
  --navy-mid: #1a2a52;
  --certo: #1a8a34;
  --certo-fill: #1aae39;
  --certo-tint: #d9f3e1;
  --errado: #c4320a;
  --errado-fill: #e0452b;
  --errado-tint: #fde4dc;
  --marca: #f5d75e;
  --code-bg: #f6f5f4;
  --t-gray: #f0eeec; --t-yellow: #fef7d6; --t-lavender: #e6e0f5; --t-peach: #ffe8d4; --t-mint: #d9f3e1;
  --t-rose: #fde0ec; --t-sky: #dcecfa; --t-cream: #f8f5e8; --t-purple: #ece0fa;
  --tag-ink: #37352f;
  --sombra-1: rgba(15, 15, 15, 0.04) 0 1px 2px 0;
  --sombra-modal: rgba(15, 15, 15, 0.16) 0 16px 48px -8px;
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;
  --sans: "Inter", -apple-system, system-ui, "Segoe UI", Helvetica, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #191919; --surface: #202020; --surface-soft: #1d1d1d; --hairline: #2f2f2f; --hairline-strong: #474644;
    --ink: #ebebea; --charcoal: #d4d3cf; --slate: #a5a39c; --steel: #8d8b85; --muted: #5a5853;
    --primary: #8577f0; --primary-pressed: #6f60e6; --primary-tint: #2c2748; --link: #4ea4f0;
    --navy: #0a1530; --navy-mid: #1a2a52;
    --certo: #4cc76a; --certo-fill: #2fa64d; --certo-tint: #1b3022; --errado: #ff7a5c; --errado-fill: #e0452b; --errado-tint: #3a2019;
    --code-bg: #202020;
    --t-gray: #2a2a29; --t-yellow: #3a3420; --t-lavender: #2e2a44; --t-peach: #3d2c1f; --t-mint: #1f3428;
    --t-rose: #3c2330; --t-sky: #1e2f42; --t-cream: #33312a; --t-purple: #352a47; --tag-ink: #e3e2de;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --canvas: #191919; --surface: #202020; --surface-soft: #1d1d1d; --hairline: #2f2f2f; --hairline-strong: #474644;
  --ink: #ebebea; --charcoal: #d4d3cf; --slate: #a5a39c; --steel: #8d8b85; --muted: #5a5853;
  --primary: #8577f0; --primary-pressed: #6f60e6; --primary-tint: #2c2748; --link: #4ea4f0;
  --certo: #4cc76a; --certo-fill: #2fa64d; --certo-tint: #1b3022; --errado: #ff7a5c; --errado-fill: #e0452b; --errado-tint: #3a2019;
  --code-bg: #202020;
  --t-gray: #2a2a29; --t-yellow: #3a3420; --t-lavender: #2e2a44; --t-peach: #3d2c1f; --t-mint: #1f3428;
  --t-rose: #3c2330; --t-sky: #1e2f42; --t-cream: #33312a; --t-purple: #352a47; --tag-ink: #e3e2de;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 400 16px/1.55 var(--sans);
  font-feature-settings: "cv11", "ss01";
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm); }
img { max-width: 100%; height: auto; }
.vazio { color: var(--slate); }

.pagina { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }

h1, h2, h3 { font-weight: 600; margin: 0; color: var(--ink); }
h1 { font-size: 36px; line-height: 1.1; letter-spacing: -1px; }
h2 { font-size: 22px; line-height: 1.3; letter-spacing: -0.2px; }
h3 { font-size: 18px; line-height: 1.4; }
@media (min-width: 768px) { h1 { font-size: 48px; letter-spacing: -1.2px; } }

/* Botões: retângulos de 8px (não pílulas); roxo só na ação principal */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: var(--r-md); border: 1px solid var(--primary);
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 500; line-height: 1.3; text-decoration: none;
}
.btn:active { background: var(--primary-pressed); }
.btn.sec { background: transparent; color: var(--ink); border-color: var(--hairline-strong); }
.btn.sec:active { background: var(--surface); }
.btn.fantasma { border-color: transparent; background: transparent; color: var(--slate); padding: 8px 12px; border-radius: var(--r-sm); }
.btn:disabled { background: var(--hairline); border-color: var(--hairline); color: var(--muted); cursor: default; }
.btn.sec:disabled { background: transparent; }
.btn-linha { display: flex; gap: 10px; flex-wrap: wrap; }

/* Faixa azul-marinho com pontos coloridos (entrada e início) */
.faixa {
  position: relative; overflow: hidden; background: var(--navy); color: #fff;
  padding: 16px 16px 40px;
}
.pontos { display: flex; gap: 10px; align-items: center; margin-top: 24px; }
.pontos i { display: block; border-radius: 50%; }
.pontos i:nth-child(1) { width: 14px; height: 14px; background: #f5d75e; }
.pontos i:nth-child(2) { width: 10px; height: 10px; background: #ff64c8; }
.pontos i:nth-child(3) { width: 12px; height: 12px; background: #2a9d99; }
.pontos i:nth-child(4) { width: 8px; height: 8px; background: #7b3ff2; }
.pontos i:nth-child(5) { width: 10px; height: 10px; background: #dd5b00; }
.faixa .dentro { position: relative; max-width: 720px; margin: 0 auto; }
.faixa h1 { color: #fff; }
.faixa .marca { color: #fff; }
.faixa .btn.fantasma { color: #a4a097; }
.faixa p { color: #c9c6bf; }
.faixa p b { color: #fff; font-weight: 600; }

/* Entrada */
.entrada { min-height: 100dvh; display: flex; flex-direction: column; background: var(--canvas); }
.entrada .faixa { padding-top: 28px; padding-bottom: 56px; }
.entrada .faixa h1 { margin: 28px 0 12px; max-width: 14ch; }
.entrada .faixa p { max-width: 46ch; margin: 0; font-size: 17px; }
.entrada-caixa {
  position: relative; width: calc(100% - 32px); max-width: 420px; margin: -28px auto 32px;
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--sombra-modal);
}
.entrada-caixa label { display: block; font-size: 14px; font-weight: 500; color: var(--charcoal); margin-bottom: 6px; }
.campo { display: block; width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--hairline-strong); background: var(--canvas); font-size: 16px; }
.campo:focus { border: 2px solid var(--primary); padding: 0 13px; outline: none; }
.erro { color: var(--errado); min-height: 22px; margin: 8px 0; font-size: 14px; font-weight: 500; }
.entrada-caixa .btn { width: 100%; }

/* Cartão-resposta */
.cartao-mini { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; max-width: 300px; }
.cartao-mini i { aspect-ratio: 1; border-radius: 50%; border: 1.5px solid var(--hairline-strong); display: block; }
.cartao-mini i.r { background: var(--primary); border-color: var(--primary); }
.cartao-mini i.c { background: var(--certo-fill); border-color: var(--certo-fill); }
.cartao-mini i.e { background: var(--errado-fill); border-color: var(--errado-fill); }
.cartao-mini i.a { border-style: dashed; border-color: var(--muted); }

/* Topo */
.topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.marca { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; color: var(--ink); }
.marca svg { width: 28px; height: 28px; }

.saudacao { margin: 28px 0 8px; }
.contagem { margin: 0; font-size: 17px; }

.secao { margin: 40px 0 14px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.secao p { margin: 0; color: var(--steel); font-size: 14px; }
.inicio .pagina { padding-top: 0; }

.lista-sim { display: grid; gap: 12px; }
@media (min-width: 640px) { .lista-sim { grid-template-columns: 1fr 1fr; } }
.sim {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: start;
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg);
  padding: 20px; text-decoration: none; color: inherit;
}
.sim:hover { box-shadow: var(--sombra-1); border-color: var(--hairline-strong); }
.sim h3 { font-size: 18px; }
.sim .meta { color: var(--slate); font-size: 14px; }
.sim .nota { grid-row: 1 / span 2; grid-column: 2; text-align: right; }
.sim .nota b { display: block; font-size: 28px; line-height: 1; font-weight: 600; letter-spacing: -0.5px; }
.sim .nota b.ok { color: var(--certo); }
.sim .nota b.nao { color: var(--errado); }
.sim .nota span { font-size: 12px; color: var(--steel); font-weight: 500; }
.sim .cartao-mini { grid-column: 1 / -1; margin-top: 12px; max-width: none; }
.sim.misto { background: var(--t-yellow); border-color: transparent; }

.topicos { border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 4px 20px; }
.topico { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 14px 0; border-bottom: 1px solid var(--hairline); align-items: center; }
.topico:last-child { border-bottom: 0; }
.topico .barra { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.topico .barra span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.topico small { color: var(--slate); font-size: 14px; font-variant-numeric: tabular-nums; }

.rodape { margin-top: 40px; color: var(--steel); font-size: 13px; line-height: 1.5; }

/* Etiquetas de tópico: cores pastel, como as propriedades de banco do Notion */
.selo { display: inline-block; font-size: 13px; font-weight: 600; line-height: 1.4; padding: 2px 8px; border-radius: var(--r-sm); color: var(--tag-ink); background: var(--t-gray); }
.selo.t-fundamentos { background: var(--t-sky); }
.selo.t-linguagens { background: var(--t-yellow); }
.selo.t-complexidade { background: var(--t-lavender); }
.selo.t-estruturas { background: var(--t-peach); }
.selo.t-arvores { background: var(--t-mint); }
.selo.t-hash { background: var(--t-rose); }
.selo.t-busca { background: var(--t-cream); }
.selo.t-ordenacao { background: var(--t-purple); }
.selo.t-grafos { background: var(--t-gray); }
.selo.anulada { background: var(--errado-tint); color: var(--errado); }

/* Início do simulado */
.voltar { display: inline-flex; align-items: center; gap: 6px; color: var(--slate); text-decoration: none; min-height: 44px; font-size: 15px; }
.intro h1 { margin: 8px 0 8px; }
.intro .meta { color: var(--slate); margin: 0 0 32px; }
.modos { display: grid; gap: 12px; margin: 14px 0 24px; }
@media (min-width: 640px) { .modos { grid-template-columns: 1fr 1fr; } }
.modo { display: block; text-align: left; width: 100%; background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 20px; }
.modo[aria-pressed="true"] { background: var(--surface); border: 2px solid var(--primary); padding: 19px; }
.modo b { font-size: 17px; font-weight: 600; display: block; margin-bottom: 4px; }
.modo span { color: var(--slate); font-size: 14px; }
.historico { margin-top: 40px; }
.historico h2 { margin-bottom: 8px; }
.historico table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.historico td, .historico th { text-align: left; padding: 10px 4px; border-bottom: 1px solid var(--hairline); }
.historico th { color: var(--steel); font-weight: 500; }

/* Prova */
.barra-prova {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--hairline);
}
.barra-prova .dentro { max-width: 720px; margin: 0 auto; padding: 6px 16px; display: flex; align-items: center; gap: 8px; }
.barra-prova .titulo { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-prova .btn { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.relogio { font-variant-numeric: tabular-nums; color: var(--slate); font-size: 14px; }
.progresso-fino { height: 2px; background: var(--hairline); }
.progresso-fino span { display: block; height: 100%; background: var(--primary); transition: width .3s; }

.questao { padding-top: 20px; }
.q-cab { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.q-num { font-weight: 600; font-size: 22px; letter-spacing: -0.3px; }
.q-num small { font-size: 15px; color: var(--steel); font-weight: 400; }
.marcar { margin-left: auto; min-height: 36px; padding: 6px 12px; border-radius: var(--r-md); border: 1px solid var(--hairline-strong); background: var(--canvas); font-size: 14px; font-weight: 500; }
.marcar[aria-pressed="true"] { border-color: transparent; background: var(--marca); color: #37352f; }
.origem { color: var(--steel); font-size: 14px; margin: -6px 0 12px; }

.md { overflow-wrap: anywhere; color: var(--ink); }
.md p { margin: 0 0 12px; }
.md img { display: block; margin: 14px auto; background: #fff; border-radius: var(--r-md); padding: 6px; border: 1px solid var(--hairline); }
.md pre { background: var(--code-bg); border-radius: var(--r-md); padding: 14px 16px; overflow-x: auto; margin: 0 0 14px; }
.md code { font-family: var(--mono); font-size: 13.5px; font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.md :not(pre) > code { background: var(--code-bg); color: #eb5757; padding: 1px 5px; border-radius: 4px; }
.md table { border-collapse: collapse; margin: 0 0 14px; display: block; overflow-x: auto; }
.md td, .md th { border: 1px solid var(--hairline); padding: 6px 10px; font-family: var(--mono); font-size: 13.5px; }
.md th { background: var(--surface); font-weight: 600; }
.md ul, .md ol { padding-left: 22px; margin: 0 0 12px; }
.md > :last-child { margin-bottom: 0; }

.alternativas { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 8px; }
.alt {
  width: 100%; display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start; text-align: left;
  background: var(--canvas); border: 1px solid var(--hairline); border-radius: var(--r-lg); padding: 12px 14px;
}
.alt .bolha {
  width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--hairline-strong); display: grid; place-items: center;
  font-weight: 600; font-size: 14px; color: var(--slate);
}
.alt .md { padding-top: 4px; min-width: 0; }
.alt .md pre { margin-bottom: 0; }
.alt:not(:disabled):not(.escolhida):hover { background: var(--surface-soft); border-color: var(--hairline-strong); }
.alt.escolhida { border: 2px solid var(--primary); padding: 11px 13px; background: var(--surface-soft); }
.alt.escolhida .bolha { background: var(--primary); border-color: var(--primary); color: #fff; }
.alt.certa { border: 2px solid var(--certo-fill); padding: 11px 13px; background: var(--certo-tint); }
.alt.certa .bolha { background: var(--certo-fill); border-color: var(--certo-fill); color: #fff; }
.alt.errada { border: 2px solid var(--errado-fill); padding: 11px 13px; background: var(--errado-tint); }
.alt.errada .bolha { background: var(--errado-fill); border-color: var(--errado-fill); color: #fff; }
.alt:disabled { cursor: default; color: inherit; }

.explica { margin-top: 16px; padding: 16px 18px; border-radius: var(--r-lg); background: var(--surface); }
.explica h3 { margin-bottom: 6px; font-size: 15px; }
.explica .md { font-size: 15px; }
.explica .diverg { margin: 10px 0 0; color: var(--slate); font-size: 14px; }
.veredito { font-weight: 600; margin: 16px 0 0; }
.veredito.c { color: var(--certo); }
.veredito.e { color: var(--errado); }

.nav-prova {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--canvas); border-top: 1px solid var(--hairline);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.nav-prova .dentro { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; align-items: center; }
.nav-prova .btn { flex: 1; padding: 10px 12px; }
.nav-prova .btn.cartao-btn { flex: 0 0 auto; }

/* Folha do cartão-resposta */
dialog.folha { border: 0; padding: 0; width: min(560px, 100vw); max-height: 88dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; margin: auto auto 0; background: var(--canvas); color: var(--ink); box-shadow: var(--sombra-modal); }
@media (min-width: 640px) { dialog.folha { border-radius: var(--r-xl); margin: auto; } }
dialog.folha::backdrop { background: rgb(15 15 15 / .45); }
.folha-dentro { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.folha-cab { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.grade { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.grade button {
  aspect-ratio: 1; border-radius: 50%; border: 1.5px solid var(--hairline-strong); background: transparent; font-weight: 600;
  position: relative; font-size: 15px; min-width: 44px; color: var(--charcoal);
}
.grade button.r { background: var(--primary); border-color: var(--primary); color: #fff; }
.grade button.c { background: var(--certo-fill); border-color: var(--certo-fill); color: #fff; }
.grade button.e { background: var(--errado-fill); border-color: var(--errado-fill); color: #fff; }
.grade button.a { border-style: dashed; }
.grade button.atual { outline: 2px solid var(--ink); outline-offset: 3px; }
.grade button.m::after { content: ""; position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--marca); border: 2px solid var(--canvas); }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--slate); font-size: 13px; margin: 16px 0 18px; }
.legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 1.5px solid var(--hairline-strong); }
.legenda i.r { background: var(--primary); border-color: var(--primary); }
.legenda i.m { background: var(--marca); border-color: var(--marca); }
.legenda i.a { border-style: dashed; }

/* Resultado */
.resultado h1 { margin: 8px 0 4px; }
.placar { display: flex; align-items: flex-end; gap: 20px; margin: 24px 0 16px; flex-wrap: wrap; }
.placar .grande { font-weight: 600; font-size: 80px; line-height: .95; letter-spacing: -2px; }
.placar .grande.ok { color: var(--certo); }
.placar .grande.nao { color: var(--errado); }
.placar p { margin: 0; color: var(--slate); font-size: 15px; }
.placar p b { color: var(--ink); font-weight: 600; }
.revisao { margin-top: 20px; border: 1px solid var(--hairline); border-radius: var(--r-lg); overflow: hidden; }
.rev { border-bottom: 1px solid var(--hairline); }
.rev:last-child { border-bottom: 0; }
.rev[open] { background: var(--surface-soft); }
.rev summary { list-style: none; cursor: pointer; padding: 12px 16px; display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; min-height: 52px; }
.rev summary::-webkit-details-marker { display: none; }
.rev summary .pt { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: var(--slate); border: 1.5px solid var(--hairline-strong); }
.rev summary .pt.c { background: var(--certo-fill); border-color: var(--certo-fill); color: #fff; }
.rev summary .pt.e { background: var(--errado-fill); border-color: var(--errado-fill); color: #fff; }
.rev summary .pt.a { border-style: dashed; }
.rev summary .res { color: var(--slate); font-size: 14px; white-space: nowrap; }
.rev summary .tit { min-width: 0; overflow: hidden; }
.rev .corpo { padding: 4px 16px 18px; }
.revisao > .vazio { padding: 16px; margin: 0; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 28px; }
.filtros button { min-height: 36px; padding: 6px 14px; border-radius: 9999px; border: 1px solid var(--hairline); background: transparent; color: var(--steel); font-size: 14px; font-weight: 500; }
.filtros button[aria-pressed="true"] { background: var(--ink); color: var(--canvas); border-color: var(--ink); }

#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--canvas); padding: 10px 16px; border-radius: var(--r-md); font-size: 14px; transition: .2s; pointer-events: none; z-index: 20; max-width: calc(100vw - 32px); box-shadow: var(--sombra-modal); }
#toast.on { opacity: 1; transform: translateX(-50%); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.rev summary .tit .selo { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
