:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #eeece6;
  --text: #1c1b19;
  --text-muted: #6b675f;
  --border: #ddd8ce;
  --accent: #2f5d50;
  --accent-soft: #e3ede9;
  --good: #2f5d50;
  --good-soft: #e3ede9;
  --warn: #9c6b1f;
  --warn-soft: #f4e9d6;
  --bad: #9c3b3b;
  --bad-soft: #f6e2e2;
  --neutral: #4a5a72;
  --neutral-soft: #e6eaf1;
  --radius: 10px;
  --font: -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --surface: #1e2023;
    --surface-2: #26282c;
    --text: #ecebe8;
    --text-muted: #a3a099;
    --border: #34363b;
    --accent: #7fb8a4;
    --accent-soft: #223330;
    --good: #7fb8a4;
    --good-soft: #1e2f2a;
    --warn: #d9ac5c;
    --warn-soft: #332a18;
    --bad: #e08585;
    --bad-soft: #362222;
    --neutral: #93a7c6;
    --neutral-soft: #232a35;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

header.top {
  margin-bottom: 32px;
}

header.top .eyebrow {
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

header.top h1 {
  font-size: 30px;
  margin: 6px 0 8px;
  letter-spacing: -0.01em;
}

header.top p.lead {
  color: var(--text-muted);
  font-size: 15.5px;
  max-width: 640px;
  margin: 0;
}

a.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 18px;
}
a.back:hover { color: var(--accent); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 24px 0 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card .num {
  font-size: 22px;
  font-weight: 700;
}
.stat-card .label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
}

.summary-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 28px;
  font-size: 15px;
}
.summary-box h2 { margin: 0 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent); }
.summary-box p { margin: 0; }

/* ---- Bloco "Como funciona" (collapsible) ---- */
details.method-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  overflow: hidden;
}
details.method-box > summary {
  cursor: pointer;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
details.method-box > summary::before {
  content: "▶";
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--accent);
}
details.method-box[open] > summary::before { transform: rotate(90deg); }
details.method-box > summary:hover { color: var(--text); }

.method-body {
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}
.method-intro {
  font-size: 14px;
  color: var(--text-muted);
  margin: 16px 0 18px;
  max-width: 720px;
}
.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.mcard {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border);
}
.mcard-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 6px;
}
.mcard-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.search-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.search-row input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.search-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

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

.item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.item .row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.item h3 { margin: 0; font-size: 17px; }
.item .date { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.item p.desc { margin: 8px 0 10px; color: var(--text-muted); font-size: 14px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--neutral);
  font-weight: 600;
  white-space: nowrap;
}
.badge.tema { background: var(--accent-soft); color: var(--accent); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 14px;
}

/* ---- Detail page (conteúdo renderizado a partir de markdown puro) ---- */

.meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* Prose: qualquer heading/parágrafo/lista/tabela vindo do markdown.js */
#content h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin: 34px 0 14px;
}
#content h3 { font-size: 17px; margin: 20px 0 8px; }
#content p { font-size: 14.5px; margin: 0 0 12px; }
#content ul, #content ol { padding-left: 20px; font-size: 14.5px; margin: 0 0 14px; }
#content li { margin-bottom: 6px; }
#content code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}
#content a { color: var(--accent); }
#content hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
#content blockquote {
  margin: 0 0 14px;
  padding: 8px 16px;
  border-left: 3px solid var(--border);
  color: var(--text-muted);
  font-size: 14px;
}

/* Tabela de forças motrizes (qualquer <table> vindo do markdown) */
#content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 10px 0 18px;
}
#content table th, #content table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
#content table th { color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
#content td.ic { color: var(--bad); font-weight: 700; }
#content td.tp { color: var(--neutral); font-weight: 700; }

/* Grid 2x2 dos cenários, montado automaticamente pelo enhanceScenarios() */
.quadrant-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 10px 0 24px;
}
.quadrant-grid.grid-8 { grid-template-columns: repeat(4, 1fr); }

.q-card {
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--border);
}
.q-card.q1 { background: var(--good-soft); border-color: var(--good); }
.q-card.q2 { background: var(--warn-soft); border-color: var(--warn); }
.q-card.q3 { background: var(--neutral-soft); border-color: var(--neutral); }
.q-card.q4 { background: var(--bad-soft); border-color: var(--bad); }

.q-card h3 { margin: 0 0 6px; font-size: 18px; }

details.narrative { margin-top: 6px; }
details.narrative summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  opacity: 0.85;
}
details.narrative[open] summary { margin-bottom: 8px; }
details.narrative ol, details.narrative ul { font-size: 13.5px; padding-left: 18px; margin: 0; }
details.narrative li { margin-bottom: 8px; }
details.narrative p { font-size: 13.5px; margin: 0 0 8px; }

.toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}
button.toggle-btn {
  font-family: var(--font);
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
button.toggle-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Convergência entre matrizes ---- */
.convergence-box {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 28px 0;
}
.convergence-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 10px;
}
.convergence-box p, .convergence-box li { font-size: 14px; }

/* ---- Futurismo (sinais fracos & wildcards) ---- */
.futurism-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--warn);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 28px 0 0;
}
.futurism-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--warn);
  margin-bottom: 14px;
}
.futurism-box p, .futurism-box li { font-size: 14px; }
#content td.wildcard    { color: var(--bad);     font-weight: 700; }
#content td.sinal-fraco { color: var(--warn);    font-weight: 700; }
#content td.sinal-forte { color: var(--good);    font-weight: 700; }
#content tr.row-wildcard    { background: var(--bad-soft); }
#content tr.row-sinal       { background: var(--warn-soft); }
#content tr.row-sinal-forte { background: var(--good-soft); }
#content td.prob-num { white-space: nowrap; min-width: 90px; vertical-align: middle; }
.prob-bar {
  display: inline-block;
  width: 48px;
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  vertical-align: middle;
  margin-right: 6px;
  overflow: hidden;
}
.prob-fill {
  display: block;
  height: 100%;
  border-radius: 99px;
}
#content td.prob-baixa .prob-fill { background: var(--text-muted); }
#content td.prob-media .prob-fill { background: var(--warn); }
#content td.prob-alta  .prob-fill { background: var(--bad); }
.prob-val { font-size: 12px; font-weight: 700; vertical-align: middle; }
#content td.prob-baixa .prob-val { color: var(--text-muted); }
#content td.prob-media .prob-val { color: var(--warn); }
#content td.prob-alta  .prob-val { color: var(--bad); }

footer.page-footer {
  margin-top: 50px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .quadrant-grid, .quadrant-grid.grid-8 { grid-template-columns: 1fr; }
}
