:root {
  --bg: #07060d;
  --bg-2: #0f0c1e;
  --ink: #ece8ff;
  --muted: #9d95c9;
  --soft: #c9c3ec;
  --accent: #ff7ab6;
  --accent-2: #7af3e0;
  --accent-3: #ffd166;
  --line: rgba(255, 255, 255, 0.09);
  --card: rgba(255, 255, 255, 0.035);
  --radius: 22px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 800px at 15% -10%, #2a1450 0%, transparent 60%),
              radial-gradient(900px 700px at 100% 30%, #0c3340 0%, transparent 55%),
              var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 0.5em;
}
h1 { font-size: clamp(2.6rem, 8vw, 5.5rem); line-height: 0.98; }
h2 { font-size: clamp(1.7rem, 4vw, 2.6rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: var(--accent-2); }
em { font-style: italic; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ---------- cabeçalho ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(7, 6, 13, 0.82);
  border-bottom: 1px solid var(--line);
}
.top .wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 12px;
  padding-bottom: 12px;
}
.brand {
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  padding: 6px 10px;
  border-radius: 999px;
  transition: color .2s, background .2s;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); background: rgba(255, 255, 255, 0.07); }

.search { display: flex; gap: 6px; }
.search input {
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  width: 190px;
  max-width: 44vw;
}
.search input::placeholder { color: var(--muted); }

/* ---------- tipografia da página ---------- */
.hero { padding-top: 84px; padding-bottom: 24px; }
.eyebrow {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent-2);
  margin-bottom: 1.1em;
}
.lead {
  font-size: clamp(1.02rem, 2.2vw, 1.2rem);
  color: var(--muted);
  max-width: 44em;
}
.page-head { padding-top: 64px; padding-bottom: 8px; }
.page-head .lead { margin-bottom: 0; }
.crumbs { font-size: 0.85rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }

section.block { padding-top: 56px; }

.article { max-width: 70ch; }
.article p, .article li { color: var(--soft); }
.article h2 { margin-top: 1.6em; font-size: clamp(1.4rem, 3vw, 1.9rem); }
.article ul, .article ol { padding-left: 1.2em; }
.article li { margin-bottom: 0.4em; }

.note { color: var(--muted); font-size: 0.92rem; }

/* ---------- painéis e grades ---------- */
.two {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 28px;
}
@media (min-width: 900px) {
  .two { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .two.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-width: 0;
}
.panel p { color: var(--muted); }
.panel h3 { color: var(--ink); }

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  background: #000;
  touch-action: none;
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px -20px rgba(122, 243, 224, 0.15);
}
canvas.cross { cursor: crosshair; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}
button, select {
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
button:hover, select:hover { border-color: var(--accent); background: rgba(255, 255, 255, 0.1); }
button.primary { background: var(--accent); color: #12040c; border-color: var(--accent); font-weight: 500; }
button.primary:hover { background: #ff96c6; }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}
select option { background: var(--bg-2); color: var(--ink); }

label.ctl {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--muted);
}
input[type="range"] {
  accent-color: var(--accent);
  width: 180px;
  max-width: 100%;
}
input[type="number"], input[type="text"] {
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  width: 140px;
  max-width: 100%;
}

.readout {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  color: var(--accent-2);
  margin-top: 14px;
  word-break: break-word;
}
.big {
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2.2rem, 6vw, 3.1rem);
  line-height: 1;
  margin: 6px 0 16px;
  color: var(--ink);
}
.stat-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; }
.stat-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}
.stat-list b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- cartões de navegação ---------- */
.cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  margin-top: 28px;
}
.card-link {
  display: block;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 122, 182, 0.08), rgba(122, 243, 224, 0.04));
  color: var(--ink);
  text-decoration: none;
  transition: transform .2s, border-color .2s;
}
.card-link:hover { transform: translateY(-3px); border-color: var(--accent); }
.card-link small {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.7rem;
}
.card-link strong {
  display: block;
  font-family: Fraunces, Georgia, serif;
  font-weight: 400;
  font-size: 1.2rem;
  margin: 4px 0 6px;
}
.card-link span { color: var(--muted); font-size: 0.92rem; }

/* ---------- crivo ---------- */
.sieve {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 4px;
  margin-top: 18px;
}
.cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  transition: background .2s, color .2s, opacity .2s;
}
.cell.comp { opacity: 0.22; text-decoration: line-through; }
.cell.cur { background: var(--accent); color: #12040c; border-color: var(--accent); font-weight: 600; }
.cell.prime { background: rgba(122, 243, 224, 0.18); border-color: var(--accent-2); }

/* ---------- barras ---------- */
.bars {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  height: 260px;
  margin-top: 12px;
}
.bar-col {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
}
.bar {
  width: 100%;
  min-height: 2px;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(to top, var(--accent), var(--accent-3));
  transition: height .2s;
}
.theory {
  position: absolute;
  left: -3px;
  right: -3px;
  border-top: 2px dashed var(--accent-2);
  transition: bottom .2s;
}
.bar-label { font-size: 0.78rem; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---------- busca ---------- */
.search-box { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.search-box input[type="search"] {
  flex: 1 1 280px;
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 14px 22px;
}
.search-box input[type="search"]:focus { border-color: var(--accent); outline: none; }
.results { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 14px; }
.result {
  padding: 18px 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--card);
}
.result a { font-family: Fraunces, Georgia, serif; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.result a:hover { color: var(--accent); }
.result small { display: block; color: var(--accent-2); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem; margin-bottom: 4px; }
.result p { color: var(--muted); font-size: 0.93rem; margin: 6px 0 0; }

/* ---------- rodapé ---------- */
footer.site-foot {
  margin-top: 64px;
  padding: 36px 16px 56px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

@media (max-width: 560px) {
  .nav a { padding: 6px 7px; font-size: 0.8rem; }
  .search input { width: 140px; }
  .panel { padding: 16px; }
  input[type="range"] { width: 100%; }
  label.ctl { width: 100%; }
  .bars { height: 200px; gap: 3px; }
  .hero { padding-top: 72px; }
}

[hidden] { display: none !important; }

/* ---------- artigos ---------- */
.article strong { color: var(--ink); font-weight: 600; }
.article code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.07);
  padding: 1px 6px;
  border-radius: 6px;
}
.article h3 { font-size: 1.2rem; margin-top: 1.4em; }
.article pre {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--soft);
}
.article pre code { background: none; padding: 0; }

/* ---------- diagramas (widgets) ---------- */
.arch {
  margin: 32px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  max-width: 70ch;
  color: var(--ink);
  min-width: 0;
}
.arch svg { width: 100%; height: auto; display: block; color: var(--accent-2); }
.arch .edge { fill: none; stroke: rgba(255, 255, 255, 0.22); stroke-width: 2; transition: stroke .3s, stroke-width .3s; }
.arch .edge.on { stroke: var(--accent-3); stroke-width: 3.5; }
.arch rect { fill: rgba(255, 255, 255, 0.05); stroke: var(--line); stroke-width: 1.5; transition: fill .3s, stroke .3s; }
.arch .node.on rect { fill: rgba(255, 122, 182, 0.18); stroke: var(--accent); }
.arch text { fill: var(--ink); font-family: Inter, system-ui, sans-serif; font-size: 17px; font-weight: 500; text-anchor: middle; }
.arch text.sub { fill: var(--muted); font-size: 12px; font-weight: 400; }
.arch-log { margin: 14px 0 0; padding-left: 1.4em; color: var(--soft); font-size: 0.95rem; min-height: 3em; }
.arch-log li { margin-bottom: 4px; }

.quiz { max-width: 70ch; margin-top: 56px; }
.quiz h2 { font-size: 1.5rem; }
.quiz-q {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 18px;
  margin: 0 0 14px;
  background: var(--card);
  min-width: 0;
}
.quiz-q legend { padding: 0 6px; color: var(--ink); font-weight: 500; }
.quiz-q label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
  color: var(--soft);
  cursor: pointer;
}
.quiz-q label.is-ok { color: var(--accent-2); }
.quiz-q label.is-bad { color: var(--accent); text-decoration: line-through; }
.quiz-result { color: var(--accent-3); font-size: 0.95rem; }

.related { margin-top: 56px; }
.related h2 { font-size: 1.5rem; }

.result mark {
  background: rgba(255, 209, 102, 0.22);
  color: var(--ink);
  border-radius: 4px;
  padding: 0 3px;
}

.useful {
  margin-top: 56px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  max-width: 70ch;
}
.useful-q { font-family: Fraunces, Georgia, serif; font-size: 1.15rem; color: var(--ink); margin-bottom: 12px; }
.useful-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.useful-count { color: var(--muted); font-size: 0.92rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
