:root {
  --paper: #f4efe6;
  --paper-2: #fffaf3;
  --ink: #1d1914;
  --ink-soft: #514a41;
  --faint: #7a7166;
  --line: #e3d8c8;
  --forest: #1b4636;
  --forest-2: #2d6a4e;
  --clay: #b24b28;
  --gold: #8d6424;
  --blue: #1d4c74;
  --purple: #4a3f6b;
  --amber: #8a4b08;
  --olive: #55643f;
  --shadow: 0 16px 40px rgba(48, 32, 14, 0.08);
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Palatino, serif;
  --display: "Fraunces", "Iowan Old Style", serif;
  --child: "Nunito", "Segoe UI", sans-serif;
  --numero: #1b4636;
  --algebra: #8a4b08;
  --geometria: #1d4c74;
  --medidas: #8c3d2c;
  --estatistica: #4a3f6b;
  --infancia: #55643f;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.55;
}
a { color: var(--forest); }
a:hover { color: var(--clay); }
img, svg { max-width: 100%; }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--ink);
  color: white;
  padding: 0.5rem 0.8rem;
  z-index: 5;
}
.skip:focus { top: 0.6rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1.4rem;
  background: rgba(244, 239, 230, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--display);
  font-weight: 560;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.brand small {
  display: block;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  font-family: var(--sans);
  font-size: 0.95rem;
}
.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  padding: 0.15rem 0;
}
.nav a[aria-current="page"] {
  color: var(--ink);
  border-color: var(--clay);
}

.wrap { width: min(1120px, calc(100% - 2.4rem)); margin: 0 auto; }
.wrap-narrow { width: min(760px, calc(100% - 2.4rem)); margin: 0 auto; }

.hero { padding: 3.2rem 0 1.4rem; }
.eyebrow {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--clay);
  font-weight: 700;
  margin: 0 0 0.7rem;
}
h1 {
  font-family: var(--display);
  font-weight: 560;
  font-size: clamp(2.3rem, 5vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
}
.lede {
  font-size: 1.28rem;
  color: var(--ink-soft);
  max-width: 42rem;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 1.4rem 0 0.4rem; }
.button {
  display: inline-block;
  font-family: var(--sans);
  text-decoration: none;
  background: var(--forest);
  color: #f7f3ea;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  font-weight: 600;
}
.button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}
.button:hover { color: white; background: var(--clay); }
.button.secondary:hover { color: white; }

h2 {
  font-family: var(--display);
  font-weight: 560;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 2.4rem 0 0.7rem;
}
h3 {
  font-family: var(--sans);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  margin: 1.4rem 0 0.35rem;
}
.section { padding: 0.4rem 0 1.2rem; }
.note, .callout {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  padding: 0.9rem 1rem;
  border-radius: 0 12px 12px 0;
}
.callout.forest { border-left-color: var(--forest); }
.meta-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin: 1.4rem 0;
}
.stat {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
}
.stat b {
  display: block;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 560;
}
.stat span { font-family: var(--sans); color: var(--ink-soft); font-size: 0.92rem; }

.spine { list-style: none; padding: 0; margin: 1rem 0 0; }
.spine li {
  position: relative;
  padding: 0.55rem 0 0.55rem 1.4rem;
  border-left: 2px solid var(--forest-2);
}
.spine li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 0.85rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--forest);
}
.spine .cross { border-left-color: var(--blue); }
.spine .cross::before { background: var(--blue); }
.spine small { display: block; color: var(--faint); font-family: var(--sans); }

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.98rem;
  background: var(--paper-2);
}
th, td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
code, .code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.86em;
}

.footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.4rem 0 2.4rem;
  color: var(--faint);
  font-family: var(--sans);
  font-size: 0.92rem;
}

/* Map */
.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1rem;
  align-items: start;
  padding-bottom: 3rem;
}
.board-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper-2);
  max-height: calc(100vh - 8rem);
  position: relative;
}
.board { position: relative; min-width: 1180px; }
.edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.edge { fill: none; stroke: rgba(27, 70, 54, 0.35); stroke-width: 1.4; }
.edge.apoia { stroke-dasharray: 4 4; stroke: rgba(141, 100, 36, 0.7); }
.edge.hot { stroke: var(--clay); stroke-width: 2.3; }
.edge.hot.apoia { stroke: var(--gold); }
.thread-row { display: grid; grid-template-columns: 7.4rem repeat(11, minmax(7.6rem, 1fr)); }
.yearhead, .cell, .rowlabel {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0.35rem;
}
.yearhead {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: center;
  position: sticky;
  top: 0;
  background: #fbf7f0;
  z-index: 2;
}
.yearhead.corner { left: 0; z-index: 3; }
.rowlabel {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  position: sticky;
  left: 0;
  background: #fbf7f0;
  z-index: 1;
  display: flex;
  align-items: center;
}
.node {
  display: block;
  width: 100%;
  text-align: left;
  margin: 0.25rem 0;
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: white;
  color: var(--ink);
  font-family: var(--sans);
  cursor: pointer;
}
.node .node-pt { display: block; font-size: 0.78rem; font-weight: 700; line-height: 1.25; }
.node .node-en { display: block; font-size: 0.68rem; color: var(--faint); line-height: 1.25; }
.node[data-fio="numero"] { border-color: var(--numero); }
.node[data-fio="algebra"] { border-color: var(--algebra); }
.node[data-fio="geometria"] { border-color: var(--geometria); }
.node[data-fio="medidas"] { border-color: var(--medidas); }
.node[data-fio="estatistica"] { border-color: var(--estatistica); }
.node[data-fio="infancia"] { border-color: var(--infancia); }
.node.has-book { background: #f3fae8; }
.node.active { outline: 2px solid var(--clay); background: #fff4ec; }
.node.dim { opacity: 0.28; }
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  align-items: center;
  font-family: var(--sans);
  margin: 0.6rem 0 0.8rem;
}
.filters label { font-size: 0.92rem; }
.filters input[type="search"] {
  font: inherit;
  padding: 0.4rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  min-width: 14rem;
}
.panel {
  position: sticky;
  top: 4.4rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  max-height: calc(100vh - 5.5rem);
  overflow: auto;
  font-family: var(--sans);
}
.panel h2 { margin-top: 0; font-size: 1.45rem; }
.panel .porque { font-size: 0.92rem; color: var(--ink-soft); }
.panel .skill {
  border-top: 1px solid var(--line);
  padding: 0.55rem 0;
  font-size: 0.9rem;
}
.tag {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  margin-right: 0.25rem;
}
.browser { margin: 1.5rem 0 3rem; }
.browser select, .browser button.ghost {
  font: inherit;
  font-family: var(--sans);
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
}
.skill-list { display: grid; gap: 0.45rem; margin-top: 0.8rem; }
.skill-row {
  width: 100%;
  text-align: left;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  font-family: var(--sans);
  color: var(--ink);
  cursor: pointer;
}
.skill-row b { font-family: ui-monospace, Menlo, monospace; font-size: 0.82rem; }

/* Books */
body.book { background: #efe7d8; }
.sheet {
  width: min(820px, calc(100% - 1.4rem));
  margin: 1.2rem auto 3rem;
  background: var(--paper-2);
  border: 1px solid #e5d9c6;
  box-shadow: var(--shadow);
  padding: clamp(1.2rem, 4vw, 3rem);
}
body.student .sheet { font-family: var(--child); font-size: 1.28rem; line-height: 1.45; }
body.teacher .sheet { font-family: var(--serif); }
.book-kicker {
  font-family: var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--clay);
  font-weight: 700;
}
.lesson { margin: 2.2rem 0; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.lesson h2 { margin-top: 0.2rem; }
.skill-pill {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--forest);
}
.gloss {
  display: none;
  background: #f6f1e6;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  margin: 0.8rem 0;
  color: #3e4658;
  font-family: var(--serif);
  font-size: 1.02rem;
}
body.show-en .gloss { display: block; }
.guarde, .activity, .talk {
  background: #f8f4ea;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin: 1rem 0;
}
.guarde strong { color: var(--forest); }
.cards { display: grid; gap: 0.55rem; }
.choice, .item, .pair-btn, .line-btn {
  font: inherit;
  text-align: left;
  background: white;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  color: var(--ink);
}
.choice.good, .item.counted, .pair-btn.used, .line-btn.picked {
  border-color: var(--forest-2);
  background: #eef6ef;
}
.choice.bad { border-color: var(--clay); background: #fff1ea; }
.pair-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.feedback { font-family: var(--child); min-height: 1.4em; }
.count-stage { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.bread {
  width: 3.1rem;
  height: 2.4rem;
  border-radius: 40% 40% 46% 46%;
  border: 2px solid #c4883a;
  background: #f3c27a;
  cursor: pointer;
}
.bread.counted { background: #e7a04a; box-shadow: inset 0 0 0 3px #fff6e4; }
.people { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.person, .cup {
  width: 4.2rem;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.85rem;
}
.face, .cup-body {
  height: 3.2rem;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: white;
}
.line-row { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.line-btn { min-width: 2.4rem; text-align: center; padding: 0.45rem 0.2rem; font-weight: 800; }
.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.6rem;
}
.toggle {
  font-family: var(--sans);
  border: 1px solid var(--ink);
  background: transparent;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}
.rubric td:first-child { font-weight: 700; white-space: nowrap; }
.cast { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin: 1rem 0; }
.cast figure {
  margin: 0;
  background: #f8f4ea;
  border-radius: 12px;
  padding: 0.6rem;
  text-align: center;
  font-family: var(--sans);
}
.cast svg { width: 72px; height: 72px; }
figcaption { font-size: 0.9rem; }
#cesta-a { display: flex; flex-wrap: wrap; gap: 0.85rem; align-content: flex-start; min-height: 7rem; }
#cesta-b { display: flex; flex-wrap: wrap; gap: 0.2rem; align-content: flex-start; max-width: 12rem; }
.basket-label { font-family: var(--sans); font-size: 0.95rem; margin: 0 0 0.4rem; }
.scene-svg { margin: 0.6rem 0 1rem; }
.stack { display: flex; flex-direction: column; gap: 0.7rem; align-items: stretch; }
.stack label { font-family: var(--sans); }
.stack input[type="text"], .stack input[type="password"], textarea.ata {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  font: inherit;
  padding: 0.6rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
}
textarea.ata { min-height: 22rem; font-family: var(--sans); font-size: 0.95rem; line-height: 1.45; }
#ado-anos { overflow-x: auto; }
.estado {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
.estado.gap { color: var(--clay); }
.estado.evidenced { color: var(--forest); }
.estado.bloqueado, .estado.conflito { color: var(--gold); }
.estado.unseen { color: var(--faint); }

.graph-tools { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0.6rem 0 1rem; }
.graph-tools input[type="search"] { flex: 1 1 16rem; font: inherit; padding: 0.55rem 0.7rem; border-radius: 10px; border: 1px solid var(--line); background: var(--paper-2); color: var(--ink); }
.graph-modes { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.graph-modes button, #graph-fit { font-family: var(--sans); }
.graph-modes button[aria-pressed="true"] { background: var(--forest); color: white; border-color: var(--forest); }
.graph-layout { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 1rem; align-items: start; }
.graph-scroll { height: 72vh; min-height: 28rem; overflow: hidden; background: var(--paper-2); border: 1px solid var(--line); border-radius: 16px; touch-action: none; }
#graph { width: 100%; height: 100%; display: block; }
.skill-hit { cursor: pointer; }
.skill-hit text { font-family: var(--sans); font-size: 11px; fill: var(--ink); pointer-events: none; }
.skill-edge { fill: none; stroke: #8a7b68; stroke-width: 1.4; }
.skill-edge.hot { stroke: var(--ink); stroke-width: 2.2; }
.skill-node.dim { opacity: 0.28; }
.skill-edge.dim { opacity: 0.12; }

@media (max-width: 980px) {
  .map-layout, .graph-layout { grid-template-columns: 1fr; }
  .graph-scroll { height: 62vh; }
  .panel { position: relative; top: 0; max-height: none; }
  .meta-row, .cast { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .meta-row, .cast, .pair-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
}
@media print {
  .topbar, .toggle, .gloss, .footer, .skip { display: none !important; }
  body.show-en .gloss { display: none !important; }
  .sheet { box-shadow: none; border: none; width: auto; margin: 0; }
  body { background: white; }
}
