:root {
  --ink: #1a2233;
  --muted: #5b6472;
  --paper: #ffffff;
  --bg: #f6f7f9;
  --primary: #1f4e79;
  --primary-dark: #163a5c;
  --accent: #2e75b6;
  --warm: #c97a2b;
  --warm-bg: #fff6ea;
  --warm-border: #f0cf9e;
  --border: #e3e6ea;
  --summary-bg: #eaf2fb;
  --radius: 10px;
  font-size: 17px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-head {
  background: var(--primary);
  padding: 0.9rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.site-head .brand {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  font-size: 1.05rem;
}
.site-head .brand:hover { text-decoration: none; opacity: 0.9; }

main.home, main.chapter {
  max-width: 780px;
  margin: 0 auto;
  padding: 2.4rem 1.4rem 5rem;
}

/* ---------- página inicial ---------- */
main.home h1 {
  color: var(--primary);
  font-size: 2.1rem;
  margin-bottom: 0.6rem;
}
.lede {
  color: var(--muted);
  max-width: 640px;
  margin-bottom: 2.4rem;
}
.lede a { color: var(--primary); font-weight: 600; }

section.part { margin-bottom: 2.2rem; }
section.part h2 {
  color: var(--primary);
  font-size: 1.05rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 0.9rem;
}
ol.chlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; }
ol.chlist li a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.9rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink);
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
ol.chlist li a:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateX(3px);
  box-shadow: 0 4px 14px rgba(31,78,121,0.10);
}
ol.chlist .n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.9rem; height: 1.9rem;
  border-radius: 50%;
  background: var(--summary-bg);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
  flex: none;
}

/* ---------- página de capítulo ---------- */
.crumb { color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.78rem; margin: 0 0 0.3rem; }
main.chapter h1 {
  color: var(--primary);
  font-size: 1.7rem;
  margin: 0 0 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.chnum {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem; height: 2.1rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.05rem;
  flex: none;
}
.resumo {
  background: var(--summary-bg);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.6rem;
}
.resumo h2 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
}
.resumo p { margin: 0; color: var(--ink); font-size: 0.95rem; }

nav.chapnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 1.4rem 0;
  font-size: 0.88rem;
}
nav.chapnav a { color: var(--muted); font-weight: 600; }
nav.chapnav a:hover { color: var(--primary); }

/* ---------- lista de exercícios ---------- */
ol.exlist.toplevel { list-style: none; margin: 0; padding: 0; counter-reset: none; }
ol.exlist.toplevel > li {
  position: relative;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
ol.exlist.toplevel > li::before {
  content: attr(value) ".";
  position: absolute;
  left: -2.1rem;
  top: 1rem;
  color: var(--primary);
  font-weight: 700;
  width: 1.8rem;
  text-align: right;
}
ol.exlist.toplevel { margin-left: 2.1rem; }
.ex-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.8rem; }
.ex-body { flex: 1 1 auto; }
.ex-body ol.exlist { list-style-type: lower-alpha; margin: 0.5rem 0 0.2rem; padding-left: 1.3rem; }
.ex-body ol.exlist li { margin-bottom: 0.3rem; }
.ex-body ul { margin: 0.5rem 0; padding-left: 1.3rem; }

.ans-badge {
  flex: none;
  display: inline-block;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: var(--warm-bg);
  border: 1px solid var(--warm-border);
  color: var(--warm);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.ans-badge:hover, .ans-badge:focus { background: var(--warm); color: #fff; outline: none; }
.ans-badge.sample { cursor: default; }

.ans-pop {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .28s ease, opacity .2s ease, margin .28s ease;
  background: var(--warm-bg);
  border: 1px solid var(--warm-border);
  border-radius: var(--radius);
  font-size: 0.93rem;
}
.ans-pop > * { padding: 0 0.9rem; }
.ans-pop::before {
  content: "Resposta";
  display: block;
  padding: 0.6rem 0.9rem 0.2rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warm);
  font-weight: 700;
}
li.has-answer.open .ans-pop {
  max-height: 3000px;
  opacity: 1;
  margin-top: 0.6rem;
}
.ans-pop p:last-child { padding-bottom: 0.8rem; }

/* ---------- elementos de conteúdo ---------- */
figure.mfpic { margin: 0.7rem 0; text-align: center; }
figure.mfpic img {
  max-width: 300px; width: 100%; height: auto;
  background: #fff; border-radius: 6px; padding: 4px;
}
img.fig-inline {
  max-width: 130px; vertical-align: middle;
  background: #fff; border-radius: 4px; padding: 2px;
}
img.photo { max-width: 100%; border-radius: 6px; margin: 0.6rem 0; }
.center { text-align: center; }

.tbl-wrap { overflow-x: auto; margin: 0.9rem 0; }
table.tbl { border-collapse: collapse; width: 100%; }
table.tbl td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.8rem;
  text-align: center;
  font-size: 0.92rem;
}
table.tbl tr:first-child td { background: var(--summary-bg); font-weight: 600; }

.fnref { color: var(--accent); cursor: help; position: relative; font-size: 0.75em; }
.fnref .fnpop {
  display: none;
  position: absolute;
  bottom: 1.4em;
  left: 0;
  z-index: 30;
  width: 260px;
  background: var(--ink);
  color: #fff;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.4;
}
.fnref:hover .fnpop, .fnref:focus .fnpop { display: block; }

.xref { font-weight: 600; }

a.brand:visited { color: #fff; }

@media (max-width: 560px) {
  :root { font-size: 16px; }
  main.home, main.chapter { padding: 1.6rem 1rem 4rem; }
  ol.exlist.toplevel { margin-left: 1.6rem; }
  ol.exlist.toplevel > li::before { left: -1.6rem; width: 1.3rem; }
  .ex-row { flex-direction: column; }
  .ans-badge { align-self: flex-start; }
}

