:root {
  --bg: #f6f3ec;
  --surface: #ffffff;
  --surface-2: #f0ece3;
  --ink: #1b2230;
  --muted: #5d6573;
  --line: #e2dccf;
  --accent: #2f6fe0;
  --accent-ink: #ffffff;
  --ok: #1f9d55;
  --shadow: 0 1px 2px rgba(27, 34, 48, .06), 0 6px 20px rgba(27, 34, 48, .07);
  --radius: 16px;
  --fig-sky: #eef3f8;
  --fig-mat: #a9cdb0;
  --fig-mat-line: #78a582;
  --fig-label: #44614b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161d;
    --surface: #1b212b;
    --surface-2: #232b37;
    --ink: #eef1f6;
    --muted: #a3acba;
    --line: #2e3744;
    --accent: #5b93ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --fig-sky: #26303d;
    --fig-mat: #3f6a4b;
    --fig-mat-line: #548461;
    --fig-label: #b9d6bf;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161d; --surface: #1b212b; --surface-2: #232b37; --ink: #eef1f6; --muted: #a3acba;
  --line: #2e3744; --accent: #5b93ff; --fig-sky: #26303d; --fig-mat: #3f6a4b; --fig-mat-line: #548461;
  --fig-label: #b9d6bf; color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.01em; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 .4rem; }
section { padding: 48px 0 8px; }
.section-lead { color: var(--muted); max-width: 70ch; margin: 0 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- topo ---------- */
.hero {
  background: linear-gradient(135deg, #14213d 0%, #1d3b8f 55%, #2f6fe0 100%);
  color: #fff;
  padding: 56px 0 40px;
  position: relative;
  overflow: hidden;
}
.hero::after { /* faixa preta com a ponteira vermelha */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 10px;
  background: linear-gradient(90deg, #111 0 78%, #e53935 78% 90%, #111 90%);
}
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; opacity: .8; margin: 0 0 8px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); margin: 0 0 12px; }
.lead { max-width: 62ch; font-size: 1.08rem; opacity: .92; margin: 0 0 20px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: .9rem; opacity: .95; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 2px solid #1b2230; }
.dot.azul { background: #2f6fe0; border-color: #fff; }
.dot.branco { background: #f4f1ea; }
.dot.alvo { background: transparent; border: 3px solid #ff6b66; }
.dot.seta { background: #f2a20c; border-color: #f2a20c; border-radius: 3px; height: 4px; width: 18px; }
.jump { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.jump a {
  color: #fff; text-decoration: none; padding: 8px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .25); font-weight: 600;
}
.jump a:hover { background: rgba(255, 255, 255, .25); }

/* ---------- pontuação ---------- */
.score-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.score {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; cursor: pointer; text-align: left; padding: 0;
  font: inherit; color: inherit; display: flex; flex-direction: column; transition: transform .15s;
}
.score:hover { transform: translateY(-3px); }
.score .fig svg { display: block; width: 100%; height: auto; }
.score .s-body { padding: 10px 14px 14px; position: relative; }
.score .pts {
  position: absolute; right: 12px; top: -22px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 1.35rem;
  display: grid; place-items: center; border: 3px solid var(--surface);
}
.score h3 { margin: 0 0 4px; font-size: 1.02rem; padding-right: 40px; }
.score p { margin: 0; font-size: .86rem; color: var(--muted); }

.ladder { margin: 28px 0 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.ladder h3 { margin: 0 0 12px; font-size: 1.05rem; }
.ladder ol { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; counter-reset: s; }
.ladder li {
  flex: 1 1 140px; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; position: relative;
  counter-increment: s; display: flex; flex-direction: column;
}
.ladder li::before { content: counter(s); font-size: .75rem; font-weight: 800; color: var(--accent); }
.ladder li b { font-size: .92rem; }
.ladder li span { font-size: .82rem; color: var(--muted); }

.rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 20px 0; }
.rule { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 12px 14px; }
.rule b { display: block; margin-bottom: 2px; }
.rule span { color: var(--muted); font-size: .92rem; }

.glossary { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.glossary summary { cursor: pointer; font-weight: 700; }
.glossary dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 4px; }
.glossary dt { font-weight: 700; }
.glossary dd { margin: 0; color: var(--muted); }
@media (max-width: 560px) { .glossary dl { grid-template-columns: 1fr; } .glossary dd { margin-bottom: 8px; } }

/* ---------- filtros ---------- */
.tech-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.progress { font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.progress .bar { width: 140px; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress .bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }
.filters { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 10px 0; display: flex; flex-direction: column; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex: none; }
.search input { border: 0; background: transparent; color: var(--ink); font: inherit; padding: 12px 0; width: 100%; outline: none; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 7px 14px; font: inherit; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.count { color: var(--muted); font-size: .9rem; margin: 6px 0 12px; }

/* ---------- grade ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column; cursor: pointer; text-align: left; padding: 0;
  font: inherit; color: inherit; position: relative; transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(27, 34, 48, .14); }
.card:focus-visible, .score:focus-visible, .chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card .fig { border-bottom: 1px solid var(--line); }
.card .fig svg { display: block; width: 100%; height: auto; }
.card .c-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { margin: 0; font-size: 1.08rem; }
.card .aka { font-size: .8rem; color: var(--muted); margin-top: -4px; }
.card .resumo { font-size: .9rem; color: var(--muted); margin: 0; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.tag { font-size: .74rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink); }
.tag.cat { color: #fff; }
.tag.pts { background: #fff3cd; color: #7a5600; }
.learned-badge {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%; background: var(--ok);
  color: #fff; display: grid; place-items: center; font-weight: 800; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.empty { grid-column: 1 / -1; text-align: center; padding: 40px 0; color: var(--muted); }

.fig-target { transform-box: fill-box; transform-origin: center; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.7); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fig-target { animation: none; } html { scroll-behavior: auto; } }

/* ---------- detalhe ---------- */
dialog {
  border: 0; padding: 0; border-radius: 20px; width: min(860px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(10, 14, 22, .6); backdrop-filter: blur(3px); }
.d-inner { display: flex; flex-direction: column; }
.d-fig { position: relative; background: linear-gradient(var(--fig-sky) 82.67%, var(--fig-mat-line) 82.67%, var(--fig-mat-line) calc(82.67% + 1px), var(--fig-mat) calc(82.67% + 1px)); }
.d-fig.top { background: var(--fig-mat); }
.d-fig svg { display: block; width: 100%; height: auto; max-height: 46vh; }
.d-close {
  position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 1.4rem; cursor: pointer; line-height: 1;
}
.d-nav { position: absolute; bottom: 10px; right: 10px; display: flex; gap: 6px; }
.d-nav button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 1.1rem; cursor: pointer; }
.d-body { padding: 18px 22px 24px; }
.d-body h2 { margin: 0; }
.d-body .aka { color: var(--muted); margin: 2px 0 10px; }
.d-body h4 { margin: 20px 0 8px; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.d-body ol.steps { counter-reset: st; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.d-body ol.steps li { counter-increment: st; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.d-body ol.steps li::before {
  content: counter(st); width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: .85rem;
}
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .cols { grid-template-columns: 1fr; } }
.box { border-radius: 12px; padding: 12px 14px; }
.box ul { margin: 0; padding-left: 18px; }
.box.tip { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.box.err { background: color-mix(in srgb, #e53935 10%, var(--surface)); }
.box b { display: block; margin-bottom: 4px; }
.rel { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.rel button {
  flex: none; width: 150px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface);
  color: var(--ink); cursor: pointer; padding: 0; text-align: left; font: inherit;
}
.rel button svg { display: block; width: 100%; height: auto; }
.rel button span { display: block; padding: 6px 8px; font-size: .84rem; font-weight: 600; }
.d-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 10px;
  padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.done { background: var(--ok); color: #fff; border-color: var(--ok); }

/* ---------- quiz ---------- */
.quiz { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: grid; grid-template-columns: 1.2fr 1fr; }
@media (max-width: 720px) { .quiz { grid-template-columns: 1fr; } }
.quiz .q-fig svg { display: block; width: 100%; height: auto; }
.quiz .q-side { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.quiz .q-score { font-size: .9rem; color: var(--muted); }
.quiz .q-opts { display: grid; gap: 8px; }
.quiz .q-opts button { text-align: left; }
.quiz .q-opts button.right { background: var(--ok); color: #fff; border-color: var(--ok); }
.quiz .q-opts button.wrong { background: #e53935; color: #fff; border-color: #e53935; }
.quiz .q-msg { min-height: 1.5em; font-weight: 600; }

.foot { color: var(--muted); font-size: .88rem; padding-top: 40px; padding-bottom: 40px; }
