﻿/* ------ tipografia base, paleta Folhetim de rua ------
 * Unifica com a capa: papel-impressão oitocentista (1852, Correio
 * Mercantil), tinta sépia escura da litografia, carmim de folhetim,
 * verde urbano, ouro queimado e anil. A sidebar fria contrasta com o
 * papel de leitura sem virar tema escuro. */
:root {
  --bg: #f7f0e2;             /* papel de leitura */
  --bg-card: #ebe0bc;        /* sidebar dourada sutil */
  --surface: #fff8eb;        /* card / superfície elevada */
  --surface-2: #efe3ce;
  --surface-3: #dac8aa;
  --fg: #211a15;             /* tinta sépia-escura */
  --fg-soft: #48372c;
  --muted: #716454;
  --rule: #b8a98a;           /* filete oxidado */
  --rule-strong: #8f7a5b;
  --accent: #8f3027;         /* carmim de folhetim */
  --accent-2: #2f6b45;       /* verde urbano/mata */
  --accent-3: #8a6105;       /* ouro queimado */
  --accent-4: #1f5d75;       /* anil */
  --link: #1f5d75;           /* azul para hyperlinks */
  --danger: #7c2f2f;
  --glow: 0 0 22px rgba(143, 48, 39, 0.15);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Cores por tipo: paleta Folhetim de rua, com distinção alta sobre papel claro. */
  --type-pessoa: #1f5d75;      /* anil — figura humana */
  --type-lugar: #2f6b45;       /* verde — território */
  --type-evento: #8f3027;      /* carmim — fato narrado */
  --type-conceito: #8a6105;    /* ouro queimado — abstração */
  --type-organizacao: #67466e; /* roxo terra — instituição */
  --type-data: #5f6358;        /* cinza-verde — marca temporal */
  --type-obra: #8c4b1f;        /* cobre — outro texto */
  --type-doenca: #7c2f2f;      /* marrom-vermelho — corpo */
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); font-family: var(--sans); font-size: 16px; line-height: 1.55; }
body {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

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

code { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; background: #efe3ce; padding: 0 0.25em; border-radius: 3px; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.tag { display: inline-block; padding: 1px 6px; border: 1px solid var(--rule); border-radius: 3px; font-size: 0.75em; color: var(--muted); }

/* ------ sidebar ------ */
#sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--rule);
  padding: 1.2em 1em 1em 1.2em;
  font-family: var(--sans);
  font-size: 0.92em;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
#sidebar header { border-bottom: 1px solid var(--rule); padding-bottom: 0.6em; margin-bottom: 0.8em; }
#sidebar h1 { font-family: var(--serif); font-size: 1.25em; margin: 0 0 0.2em 0; line-height: 1.15; }
#sidebar h1 a { color: var(--fg); }
#sidebar h2 { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 1.2em 0 0.4em 0; }
#sidebar section { margin-bottom: 1em; }
#sidebar label { display: block; font-size: 0.85em; color: var(--muted); margin-bottom: 0.4em; }
#sidebar select, #sidebar input {
  width: 100%; padding: 0.35em 0.4em; border: 1px solid var(--rule); border-radius: 3px;
  background: var(--surface); color: var(--fg); font-size: 0.92em; font-family: var(--sans);
}
.sidebar-button {
  width: 100%;
  padding: 0.42em 0.55em;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: #fff8eb;
  font-family: var(--sans);
  cursor: pointer;
}
.sidebar-button:hover { filter: brightness(0.96); }
/* ------ seletor de obras na sidebar (P2) ------ */
.sidebar-obras { margin-bottom: 1em; }
.obras-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.45em; }
.obras-list-loading { padding: 0.4em 0.55em; }
.obras-list-item {
  border: 1px solid var(--rule);
  border-radius: var(--lica-radius, 4px);
  background: var(--bg-card);
  overflow: hidden;
  position: relative;
}
.obras-list-item .obra-link,
.obras-list-item .obra-current {
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  align-items: stretch;
  gap: 0.65em;
  padding: 0.55em 0.65em;
  text-decoration: none;
  color: var(--fg);
  min-height: 4.6em;
}
.obras-list-item .obra-link:hover {
  background: rgba(143, 48, 39, 0.08);
  text-decoration: none;
  color: var(--fg);
}
.obras-list-item.is-current {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(143, 48, 39, 0.11), rgba(255, 248, 235, 0.72));
}
.obras-list-item.is-current .obra-titulo { color: var(--accent); }
.obra-mark {
  display: block;
  width: 4px;
  min-height: 100%;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--obra-cor, var(--accent));
  box-shadow: 0 0 16px color-mix(in srgb, var(--obra-cor, var(--accent)) 38%, transparent);
}
.obra-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.obra-titulo {
  font-family: var(--lica-serif, var(--serif));
  font-size: 0.92em;
  font-weight: 600;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.obra-autor {
  font-family: var(--lica-sans, var(--sans));
  font-size: 0.74em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.obra-ano {
  font-family: var(--lica-sans, var(--sans));
  font-size: 0.68em;
  color: var(--muted);
  letter-spacing: 0.03em;
}
.obra-stats {
  margin-top: 0.25em;
  font-family: var(--lica-sans, var(--sans));
  font-size: 0.66em;
  color: var(--fg-soft);
  letter-spacing: 0.02em;
}

#caps-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.3em; }
#caps-list li a {
  display: block; text-align: center; padding: 0.25em 0; font-size: 0.78em;
  border: 1px solid var(--rule); border-radius: 3px; background: var(--surface);
  font-family: var(--sans); color: var(--fg);
}
#caps-list li a:hover { background: var(--accent); color: #fff8eb; text-decoration: none; }
#sidebar footer { margin-top: 1.5em; padding-top: 0.8em; border-top: 1px solid var(--rule); }

/* ------ main ------ */
#content { flex: 1; min-width: 0; padding: 2em 2.5em; max-width: 980px; }
#view h1 { font-size: 2em; margin-top: 0; }
#view h2 { font-size: 1.35em; border-bottom: 1px solid var(--rule); padding-bottom: 0.15em; margin-top: 1.6em; }
#view h3 { font-size: 1.05em; color: var(--muted); margin-top: 1.2em; }
#view p { max-width: 70ch; }
#view .breadcrumb { font-family: var(--sans); font-size: 0.85em; color: var(--muted); margin-bottom: 0.4em; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4em; }

/* ------ home ------ */
.home-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6em; margin: 1.2em 0; }
.stat { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px; padding: 0.6em; text-align: center; }
.stat .n { font-size: 1.6em; font-weight: bold; }
.stat .label { font-size: 0.78em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.theses-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1em; margin: 1em 0; }
.thesis-card { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px; padding: 0.9em 1em; color: var(--fg); display: block; }
.thesis-card h3 { margin-top: 0; color: var(--accent); }
.thesis-card:hover { text-decoration: none; border-color: var(--accent); }

/* ------ Regimes narrativos (home): faixa cronológica com os lemas
 * (verbo/subst./adj.) sobre-representados em cada capítulo. ------ */
.regimes-narrativos { margin: 1.6em 0 1.4em; }
.regimes-narrativos > h2 { margin-bottom: 0.2em; }
.regimes-list { list-style: none; padding: 0; margin: 0.8em 0 0; display: grid; gap: 0; }
.regime-row {
  display: grid;
  grid-template-columns: 8em 1fr;
  gap: 0.7em;
  align-items: baseline;
  padding: 0.4em 0;
  border-bottom: 1px solid var(--rule);
}
.regime-row:last-child { border-bottom: 0; }
.regime-cap {
  font-family: var(--sans);
  font-weight: 600;
  color: var(--fg);
  font-size: 0.9em;
}
.regime-cap:hover { color: var(--accent); text-decoration: none; }
.regime-lemmas { display: flex; flex-wrap: wrap; gap: 0.4em; }
.regime-lemma {
  display: inline-flex;
  align-items: center;
  gap: 0.32em;
  padding: 0.12em 0.55em 0.12em 0.4em;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--bg-card);
  font-family: var(--serif);
  font-size: 0.94em;
  color: var(--fg);
  text-decoration: none;
  line-height: 1.4;
}
.regime-lemma:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  text-decoration: none;
}
.regime-pos-pill {
  font-family: var(--sans);
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.05em 0.32em;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 2px;
  letter-spacing: 0.04em;
}
.regime-lemma:hover .regime-pos-pill {
  color: white;
  background: rgba(255, 255, 255, 0.22);
}
.regime-empty { font-style: italic; }

@media (max-width: 640px) {
  .regime-row { grid-template-columns: 1fr; gap: 0.2em; }
}

/* ------ perfil ------ */
.perfil-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 1.6em; margin-top: 1em; }
.perfil-grid > section { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px; padding: 1em; }
.perfil-grid > section h3 { margin-top: 0; }
#ego-controls, .graph-controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.7em;
  background: white; border: 1px solid var(--rule); border-bottom: none;
  border-top-left-radius: 3px; border-top-right-radius: 3px;
  padding: 0.5em 0.7em;
  font-family: var(--sans); font-size: 0.82em;
}
.legend { display: flex; flex-wrap: wrap; gap: 0.5em 0.9em; align-items: center; flex: 1; min-width: 0; }
.legend-item { display: inline-flex; align-items: center; gap: 0.3em; cursor: pointer; user-select: none; color: var(--fg); }
.legend-item input[type="checkbox"] { margin: 0; }
.legend-item .swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; }

/* Filtro por nó individual dentro dos controles do grafo */
.node-filter-wrap {
  flex: 0 0 100%;
  margin: 0.35em 0 0;
  font-family: var(--sans);
  font-size: 0.82em;
}
.node-filter-summary {
  cursor: pointer;
  color: var(--muted);
  padding: 0.2em 0;
  user-select: none;
}
.node-filter-summary:hover { color: var(--fg); }
.node-filter-wrap[open] .node-filter-summary { color: var(--fg); font-weight: 600; }
.node-filter-actions {
  display: flex;
  gap: 0.35em;
  flex-wrap: wrap;
  align-items: center;
  margin: 0.35em 0 0.45em;
}
.node-filter-actions .np-btn {
  font-family: var(--sans); font-size: 0.78em;
  padding: 0.14em 0.55em;
  border: 1px solid var(--rule);
  background: var(--bg-card);
  color: var(--fg);
  border-radius: 3px; cursor: pointer;
}
.node-filter-actions .np-btn:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.node-filter-hint { margin-left: auto; font-size: 0.78em; color: var(--muted); }
.node-filter {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.18em 0.6em;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.4em 0.55em;
  background: var(--bg-card);
}
.node-filter-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  cursor: pointer;
  user-select: none;
  color: var(--fg);
  font-size: 0.85em;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-filter-item:hover { color: var(--accent); }

/* Notas de leitura — convenções da obra (verbete + perfil) */
.verbete-leitura .leitura-card {
  border-left: 3px solid var(--accent-3);
  background: rgba(138, 97, 5, 0.06);
  padding: 0.6em 0.9em;
  margin: 0.5em 0;
  border-radius: 0 3px 3px 0;
}
.verbete-leitura h3 {
  margin: 0 0 0.3em;
  font-size: 0.95em;
  color: var(--accent-3);
}
.verbete-leitura code {
  background: rgba(138, 97, 5, 0.10);
  padding: 0 0.3em;
  border-radius: 2px;
  font-size: 0.9em;
}
.perfil-nota-leitura {
  border-left: 3px solid var(--accent-3);
  background: rgba(138, 97, 5, 0.06);
  padding: 0.55em 0.85em;
  margin: 0.6em 0 1em;
  font-size: 0.92em;
  border-radius: 0 3px 3px 0;
  line-height: 1.5;
}
.perfil-nota-leitura strong { color: var(--accent-3); }
.node-filter-item input[type="checkbox"] { margin: 0; }
.node-filter-item .type-pill {
  font-size: 0.65em;
  padding: 1px 4px;
  text-transform: uppercase;
}
.node-filter-id {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ego-actions { display: flex; gap: 0.3em; }
.ego-actions button {
  font-family: var(--sans); font-size: 0.78em;
  padding: 0.18em 0.55em;
  border: 1px solid var(--rule); background: white; color: var(--fg);
  border-radius: 3px; cursor: pointer;
}
.ego-actions button:hover { background: var(--bg); }
.ego-actions button[aria-pressed="false"] { color: var(--muted); background: var(--bg); }
#ego-network {
  height: 420px; width: 100%; max-width: 100%; background: white;
  border: 1px solid var(--rule); border-top: none;
  border-bottom-left-radius: 3px; border-bottom-right-radius: 3px;
  overflow: hidden;
  position: relative;
  contain: layout paint;
}
.graph-wrapper { display: flex; flex-direction: column; width: 100%; max-width: 100%; min-width: 0; }
#ego-wrapper:not(.graph-expanded) #ego-network,
#rare-wrapper:not(.graph-expanded) #rare-graph { flex: 0 0 auto; }
body.graph-expanded-open { overflow: hidden; }
body.graph-expanded-open::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 12, 0.74);
  backdrop-filter: blur(4px);
  z-index: 1400;
  pointer-events: none;
}
.graph-wrapper.graph-expanded {
  position: fixed;
  inset: 24px;
  z-index: 1500;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: 0.75em;
  gap: 0;
  width: auto;
  max-width: none;
  border: 1px solid rgba(143, 48, 39, 0.42);
  border-radius: 8px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.62);
}
.graph-wrapper.graph-expanded .graph-controls,
.graph-wrapper.graph-expanded #ego-controls,
.graph-wrapper.graph-expanded #rare-graph-controls {
  border-radius: 6px 6px 0 0;
  flex: 0 0 auto;
}
.graph-wrapper.graph-expanded .graph-canvas,
.graph-wrapper.graph-expanded #ego-network,
.graph-wrapper.graph-expanded #rare-graph {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
  border-radius: 0 0 6px 6px;
}
#presence-spark { height: 80px; width: 100%; }
.verbos-list { font-family: var(--sans); font-size: 0.88em; }
.verbos-list ol { padding-left: 1.5em; margin: 0; }
.char-neighbors {
  list-style: none;
  padding: 0;
  margin: 0 0 0.4em 0;
  font-family: var(--sans);
  font-size: 0.85em;
  display: grid;
  gap: 0.32em;
}
.char-neighbors li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 0.5em;
  padding: 0.18em 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.char-neighbors li:last-child { border-bottom: none; }
.char-neighbors .char-neighbor-name {
  color: var(--fg);
  font-weight: 600;
}
.char-neighbors .char-neighbor-name:hover {
  color: var(--accent);
  text-decoration: none;
}
.char-neighbors .type-pill {
  font-size: 0.62em;
  padding: 1px 5px;
  align-self: center;
  justify-self: start;
  margin-left: 0.35em;
}
.char-neighbors .muted {
  grid-column: 1 / -1;
  font-size: 0.78em;
  font-variant-numeric: tabular-nums;
}

/* ------ antagonismos (co-ocorrência negativa) ------ */
.antag-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5em;
}
.antag-list li {
  background: rgba(255, 248, 235, 0.62);
  border: 1px solid rgba(143, 48, 39, 0.22);
  border-left: 3px solid var(--accent-2);
  border-radius: 7px;
  padding: 0.7em 0.9em;
  display: grid;
  gap: 0.35em;
}
.antag-pair {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4em;
  font-family: var(--sans);
  font-size: 0.98em;
}
.antag-name {
  font-weight: 700;
  color: var(--fg);
}
.antag-name:hover {
  color: var(--accent);
  text-decoration: none;
}
.antag-sep {
  color: var(--muted);
  font-weight: 700;
  padding: 0 0.2em;
}
.antag-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 1em;
  font-variant-numeric: tabular-nums;
}
.antag-actions {
  display: flex;
  gap: 0.4em;
  flex-wrap: wrap;
}
.antag-actions .back-link {
  font-size: 0.78em;
}

/* ------ verbete (documento por entidade) ------ */
.verbete {
  max-width: 72ch;
  font-family: var(--serif);
  line-height: 1.65;
}
.verbete h1 {
  font-family: var(--sans);
  font-size: clamp(1.7rem, 2.4vw, 2.4rem);
  line-height: 1.1;
  margin: 0.2em 0 0.1em;
}
.verbete .verbete-section {
  margin: 1.6em 0;
  padding-bottom: 1.2em;
  border-bottom: 1px solid var(--rule);
}
.verbete .verbete-section:last-child {
  border-bottom: none;
}
.verbete .verbete-section h2 {
  font-family: var(--sans);
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0 0 0.6em 0;
  border-bottom: none;
  padding-bottom: 0;
}
.verbete .verbete-section h3 {
  font-family: var(--sans);
  font-size: 0.92em;
  color: var(--muted);
  margin: 1.1em 0 0.3em 0;
}
.verbete .verbete-section h4 {
  font-family: var(--sans);
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 0.3em 0;
}
.verbete p { max-width: 72ch; margin: 0.4em 0 0.6em; }
.verbete-twocol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1em;
}
.verbete-twocol ul {
  margin: 0;
  padding-left: 1.4em;
  font-family: var(--sans);
  font-size: 0.92em;
}
.verbete ul.inline-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 0.7em;
  font-family: var(--sans);
  font-size: 0.92em;
}
.verbete ul.inline-list li {
  background: rgba(255, 248, 235, 0.72);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.18em 0.55em;
}
.verbete-ext-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7em;
}
.verbete-ext-card {
  background: rgba(255, 248, 235, 0.62);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 0.7em 0.9em;
  font-family: var(--sans);
  font-size: 0.88em;
}
.verbete-ext-card.has-match {
  border-color: rgba(143, 48, 39, 0.42);
  background: rgba(143, 48, 39, 0.06);
}
.verbete-ext-card.no-match {
  border-style: dashed;
  border-color: var(--rule);
  opacity: 0.85;
}
.verbete-ext-card h4 {
  margin: 0 0 0.3em 0;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg);
}
.verbete-ext-card.has-match h4 {
  color: var(--accent);
}
.verbete-ext-card p {
  margin: 0.18em 0;
  font-family: var(--sans);
}
.external-meta-note {
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 0.65em 0.85em;
  margin: 0.6em 0 0.9em;
  background: rgba(255, 248, 235, 0.62);
  font-family: var(--sans);
  font-size: 0.9em;
}
.external-meta-note p {
  margin: 0.25em 0 0;
}
.external-meta-note.status-reviewed {
  border-color: rgba(143, 48, 39, 0.42);
  background: rgba(143, 48, 39, 0.06);
}
.external-meta-note.status-candidate {
  border-color: rgba(138, 97, 5, 0.42);
  background: rgba(138, 97, 5, 0.06);
}
.external-meta-note.status-rejected {
  border-color: rgba(255, 107, 107, 0.42);
  background: rgba(255, 107, 107, 0.06);
}
.external-metrics {
  margin: 1em 0;
}
.external-summary {
  margin-top: 1.2em;
}
.external-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.external-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-family: var(--sans);
  font-size: 0.9em;
}
.external-table th,
.external-table td {
  padding: 0.65em 0.75em;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
  text-align: left;
}
.external-table th {
  color: var(--muted);
  font-size: 0.76em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255, 248, 235, 0.62);
}
.external-table tr:last-child td {
  border-bottom: 0;
}
.external-status,
.external-ref-pill {
  display: inline-flex;
  align-items: center;
  min-height: 1.8em;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.12em 0.58em;
  margin: 0 0.25em 0.25em 0;
  background: rgba(255, 248, 235, 0.62);
  white-space: nowrap;
}
.external-status.status-reviewed {
  border-color: rgba(143, 48, 39, 0.45);
  color: var(--accent);
}
.external-status.status-candidate {
  border-color: rgba(138, 97, 5, 0.45);
  color: var(--accent-3);
}
.external-status.status-rejected {
  border-color: rgba(255, 107, 107, 0.45);
  color: var(--danger);
}
.external-ref-pill {
  color: var(--link);
  text-decoration: none;
}
.external-row.status-rejected {
  opacity: 0.82;
}
.verbete-notes ul {
  font-family: var(--sans);
  font-size: 0.88em;
  padding-left: 1.4em;
  color: var(--fg);
}
.verbete-notes li {
  margin: 0.4em 0;
}
.verbete-notes code {
  font-size: 0.85em;
}
.verbete-notes h3 {
  font-family: var(--sans);
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 1.1em 0 0.3em 0;
}

/* ------ verbete da obra (variante na home) ------ */
.obra-verbete-wrap {
  margin: 1.4em 0 1.6em;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: rgba(255, 248, 235, 0.50);
  overflow: hidden;
}
.obra-verbete-wrap > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85em 1em;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5em 0.7em;
  font-family: var(--sans);
}
.obra-verbete-wrap > summary::-webkit-details-marker { display: none; }
.obra-verbete-wrap > summary::before {
  content: '▸';
  color: var(--accent);
  font-size: 0.85em;
  transition: transform 120ms ease;
}
.obra-verbete-wrap[open] > summary::before {
  transform: rotate(90deg);
  display: inline-block;
}
.obra-verbete-wrap > summary:hover {
  background: rgba(143, 48, 39, 0.04);
}
.obra-verbete-summary-title {
  font-weight: 700;
  color: var(--fg);
  font-size: 0.98em;
}
.obra-verbete-summary-meta {
  font-style: italic;
}
.obra-verbete {
  padding: 0.2em 1.1em 1em;
  border-top: 1px solid var(--rule);
  margin-top: 0;
}
.obra-verbete-subtitle {
  margin-top: 0.6em;
  font-size: 0.94em;
}
.obra-quote {
  margin: 0.5em 0;
  padding: 0.45em 1em;
  border-left: 3px solid var(--accent);
  background: rgba(143, 48, 39, 0.05);
  font-family: var(--serif);
  font-size: 1.02em;
  color: var(--fg);
}
.obra-verbete .verbete-section:first-of-type {
  margin-top: 1.1em;
}

/* ------ callouts de agência e centralidade ------ */
.agencia-callouts,
.central-callouts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8em;
  margin-top: 0.9em;
}
.agencia-callouts > div,
.central-callouts > div {
  background: rgba(255, 248, 235, 0.62);
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 0.6em 0.8em;
  font-family: var(--sans);
  font-size: 0.88em;
}
.agencia-callouts h4,
.central-callouts h4 {
  margin: 0 0 0.4em 0;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.agencia-callouts ol,
.central-callouts ol {
  margin: 0;
  padding-left: 1.3em;
}
.agencia-callouts li,
.central-callouts li {
  margin: 0.18em 0;
}
.trecho { font-family: var(--serif); border-left: 3px solid var(--accent); padding: 0.4em 0.8em; margin: 0.6em 0; background: white; }
.trecho .relation { font-family: var(--sans); font-size: 0.78em; color: var(--muted); margin-bottom: 0.3em; }
.trecho .relation .label-text { color: var(--accent); font-style: italic; }
.trecho .cap { display: inline-block; background: var(--accent); color: white; padding: 0 0.4em; border-radius: 2px; font-size: 0.72em; margin-right: 0.5em; vertical-align: middle; }
.trecho .evidence-link {
  display: block;
  color: var(--fg);
  text-decoration: none;
  border-radius: 3px;
  padding: 0.18em 0.25em;
  margin: 0 -0.25em;
}
.trecho .evidence-link:hover {
  background: rgba(143, 48, 39, 0.08);
  text-decoration: none;
}
.open-original {
  display: inline-block;
  margin-left: 0.55em;
  font-family: var(--sans);
  font-size: 0.72em;
  color: var(--accent);
  white-space: nowrap;
}
.reader-focus-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.7em 1em;
  background: rgba(138, 97, 5, 0.10);
  border: 1px solid rgba(138, 97, 5, 0.36);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 0.65em 0.85em;
  margin: 0.8em 0;
  font-family: var(--sans);
  font-size: 0.9em;
}
.reader-focus-note .reader-focus-text { flex: 1; min-width: 0; }
.reader-focus-note em { color: var(--accent); }
.text-link {
  margin-left: 0.35em;
  font-size: 0.82em;
  color: var(--accent);
}
.chapter-edge-active {
  background: rgba(138, 97, 5, 0.10);
  border-left: 3px solid var(--accent);
  margin-left: -0.45em;
  padding: 0.18em 0.35em 0.18em 0.45em;
  border-radius: 3px;
}
.chapter-edge-active .text-link {
  font-weight: 700;
  color: var(--link);
}

/* ------ botão "voltar" ------ */
.back-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.78em;
  border: 1px solid var(--rule);
  background: white;
  color: var(--fg);
  padding: 0.18em 0.6em;
  border-radius: 3px;
  cursor: pointer;
  margin-right: 0.5em;
  vertical-align: middle;
}
.back-link:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
.back-link.strong {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-size: 0.85em;
  padding: 0.32em 0.85em;
  margin-right: 0;
  margin-left: auto;
  flex-shrink: 0;
}
.back-link.strong:hover { filter: brightness(0.95); background: var(--accent); color: white; }

/* tipo-pill (perfil header) */
.type-pill { display: inline-block; padding: 1px 8px; border-radius: 3px; color: white; font-family: var(--sans); font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.05em; }
.type-pill.pessoa     { background: var(--type-pessoa); }
.type-pill.lugar      { background: var(--type-lugar); }
.type-pill.evento     { background: var(--type-evento); }
.type-pill.conceito   { background: var(--type-conceito); }
.type-pill.organização { background: var(--type-organizacao); }
.type-pill.data       { background: var(--type-data); }
.type-pill.obra       { background: var(--type-obra); }
.type-pill.doença     { background: var(--type-doenca); }

/* ------ leitura (capítulo) ------ */
.chapter-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.8em; margin: 0.8em 0 1em; }
.summary-card { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px; padding: 0.6em 0.85em; font-family: var(--sans); font-size: 0.85em; }
.summary-card h4 { margin: 0 0 0.4em 0; font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.summary-card ol { margin: 0; padding-left: 1.3em; }
.summary-card li { margin: 0.15em 0; }
.summary-card .count { color: var(--muted); font-variant-numeric: tabular-nums; }
/* ------ nuvem de palavras TF-IDF (capítulo, personagem) ------ */
.word-cloud-section { margin: 1.4em 0 1em; }
.word-cloud-section h3 {
  margin: 0 0 0.6em 0;
  font-family: var(--sans);
  font-size: 0.95em;
  color: var(--fg);
}
.word-cloud {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35em 0.7em;
  padding: 1.1em 1.3em;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  line-height: 1.25;
}
.word-cloud-item {
  font-family: var(--serif);
  color: var(--fg);
  text-decoration: none;
  cursor: pointer;
  transition: color 120ms, transform 120ms;
  letter-spacing: -0.01em;
  display: inline-block;
}
.word-cloud-item:hover {
  color: var(--accent);
  transform: translateY(-1px);
  text-decoration: none;
}
.word-cloud-section > p.muted {
  margin-top: 0.5em;
}

/* Concordância de entorno: mesma estrutura visual da TF-IDF, mas com
 * borda do verde-mata pra distinguir as duas leituras lexicais lado a
 * lado. Hover usa o anil (link) pra reforçar a leitura como "porta de
 * entrada para o texto". */
.word-cloud.concordancia {
  background: var(--surface, var(--bg-card));
  border-left: 3px solid var(--accent-2, var(--accent));
}
.concordancia .word-cloud-item:hover,
.concordancia-grid .word-cloud-item:hover {
  color: var(--accent-4, var(--accent));
}

/* Versão sintática (UDPipe): 3 blocos lado a lado (verbo / substantivo /
 * adjetivo). Em mobile colapsa em coluna única. */
.concordancia-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.7em;
  margin-top: 0.4em;
}
.concordancia-bloco {
  background: var(--surface, var(--bg-card));
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent-2, var(--accent));
  border-radius: var(--lica-radius, 4px);
  padding: 0.45em 0.7em 0.7em;
  min-width: 0;
}
.concordancia-bloco h4 {
  margin: 0 0 0.45em;
  font-family: var(--sans);
  font-size: 0.74em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.word-cloud.concordancia-mini {
  background: transparent;
  border: 0;
  padding: 0;
  gap: 0.3em 0.55em;
  line-height: 1.3;
}
@media (max-width: 760px) {
  .concordancia-grid { grid-template-columns: 1fr; }
}

/* Lentes de capítulo: aplica a lógica dos perfis de entidade dentro do
 * recorte local do capítulo, mantendo tudo ancorado em evidência textual. */
.chapter-lenses {
  margin: 1.4em 0 1em;
}
.chapter-lenses > h2 {
  margin-bottom: 0.2em;
}
.chapter-lens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.85em;
  margin-top: 0.75em;
}
.chapter-lens-card {
  background: var(--surface, var(--bg-card));
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0.8em 0.9em;
  font-family: var(--sans);
  min-width: 0;
  display: grid;
  gap: 0.65em;
}
.chapter-lens-card header {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  min-width: 0;
}
.chapter-lens-card h3 {
  margin: 0;
  font-size: 1em;
  min-width: 0;
}
.chapter-lens-card h3 a {
  color: var(--fg);
}
.chapter-lens-card h3 a:hover {
  color: var(--accent);
  text-decoration: none;
}
.chapter-lens-card p {
  margin: 0;
}
.chapter-lens-row {
  display: grid;
  gap: 0.15em;
  font-size: 0.86em;
  line-height: 1.35;
}
.chapter-lens-row strong,
.chapter-lens-syntax h4 {
  color: var(--muted);
  font-size: 0.74em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.chapter-lens-row em {
  color: var(--muted);
  font-style: normal;
  font-size: 0.88em;
}
.chapter-lens-syntax {
  display: grid;
  gap: 0.55em;
}
.chapter-lens-syntax h4 {
  margin: 0 0 0.25em;
  font-weight: 600;
}
.chapter-lens-syntax .word-cloud.concordancia-mini {
  border-left: 3px solid var(--accent-2);
  padding-left: 0.6em;
}
.chapter-lens-evidence {
  display: block;
  border-left: 3px solid var(--accent);
  padding: 0.45em 0.65em;
  background: rgba(143, 48, 39, 0.07);
  color: var(--fg);
  font-family: var(--serif);
  line-height: 1.45;
  border-radius: 0 6px 6px 0;
  text-decoration: none;
}
.chapter-lens-evidence:hover {
  background: rgba(143, 48, 39, 0.11);
  text-decoration: none;
}

.chapter-nav { display: flex; justify-content: space-between; gap: 1em; margin-top: 1.6em; padding-top: 1em; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: 0.88em; }
.chapter-nav a { display: inline-block; padding: 0.4em 0.9em; border: 1px solid var(--rule); border-radius: 3px; background: var(--bg-card); color: var(--fg); }
.chapter-nav a:hover { background: var(--accent); color: white; border-color: var(--accent); text-decoration: none; }
.chapter-nav .empty { visibility: hidden; }
.leitura-grid { display: grid; grid-template-columns: 3fr 8px 2fr; gap: 0 0.7em; margin-top: 1em; align-items: stretch; }
.grid-resizer { background: var(--rule); cursor: col-resize; border-radius: 2px; align-self: stretch; transition: background 120ms; }
.grid-resizer:hover, .grid-resizer:focus-visible { background: var(--accent); outline: none; }
.leitura-text { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px; padding: 1.2em 1.4em; max-height: 75vh; overflow-y: auto; font-family: var(--serif); line-height: 1.7; }
.leitura-text p { margin: 0.6em 0; }
.leitura-text mark { background: rgba(143, 48, 39, 0.26); padding: 0 1px; border-radius: 2px; cursor: pointer; }
.leitura-text mark:hover { background: rgba(143, 48, 39, 0.38); }
.evidence-focus {
  background: rgba(138, 97, 5, 0.20);
  box-shadow: 0 0 0 3px rgba(138, 97, 5, 0.20), inset 0 -0.16em 0 rgba(143, 48, 39, 0.42);
  border-radius: 3px;
  padding: 0.05em 0.12em;
  scroll-margin-block: 32vh;
}
.evidence-focus mark { background: rgba(143, 48, 39, 0.28); color: var(--fg); }
.evidence-focus-pulse {
  animation: evidencePulse 1.35s ease-out 1;
}
@keyframes evidencePulse {
  0% { box-shadow: 0 0 0 0 rgba(143, 48, 39, 0.45), inset 0 -0.12em 0 rgba(143, 48, 39, 0.28); }
  65% { box-shadow: 0 0 0 9px rgba(143, 48, 39, 0), inset 0 -0.12em 0 rgba(143, 48, 39, 0.28); }
  100% { box-shadow: 0 0 0 3px rgba(138, 97, 5, 0.22), inset 0 -0.12em 0 rgba(143, 48, 39, 0.28); }
}
.leitura-side { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px; padding: 1em; max-height: 75vh; overflow-y: auto; }
.leitura-side h3 { margin-top: 0.6em; font-size: 0.9em; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.fam-block { font-family: var(--sans); font-size: 0.85em; margin-bottom: 0.6em; }
.fam-block .fam-name { font-weight: bold; color: var(--accent); }
.fam-block ul { padding-left: 1.2em; margin: 0.2em 0; }
.fam-rest { margin: 0.2em 0 0.4em; }
.fam-rest > summary {
  cursor: pointer;
  font-size: 0.85em;
  color: var(--muted);
  padding: 0.15em 0.2em;
  list-style: none;
  user-select: none;
}
.fam-rest > summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 140ms;
}
.fam-rest[open] > summary::before { content: '▾ '; }
.fam-rest > summary:hover { color: var(--accent); }
.fam-rest > ul { margin-top: 0.2em; }

/* ------ Toolbar do bloco de leitura: tela cheia + TTS (lateral, vertical) ------ */
.leitura-text {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.6em;
}
.leitura-text-body {
  flex: 1 1 auto;
  min-width: 0;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.leitura-text-body p:first-of-type { margin-top: 0; }
.leitura-toolbar {
  flex: 0 0 auto;
  order: 2;
  position: sticky;
  top: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  padding: 0.1em 0;
  z-index: 4;
}
.leitura-toolbar-btn {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 3px;
  width: 2em;
  height: 2em;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.95em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  transition: background-color 140ms, color 140ms, border-color 140ms;
  padding: 0;
  line-height: 1;
}
.leitura-toolbar-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.leitura-toolbar-btn[aria-pressed="true"] {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ------ Tela cheia: overlay do shell, NÃO Fullscreen API nativa ------ */
.leitura-text--fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  margin: 0;
  padding: 2.4em 1.4em 3em;
  background: var(--bg-card);
  z-index: 1000;
  border-radius: 0;
  border: none;
  overflow-y: auto;
  justify-content: center;
  gap: 1.5em;
}
.leitura-text--fullscreen .leitura-text-body {
  flex: 0 1 760px;
  max-width: 760px;
  width: 100%;
  font-size: 1.06em;
  line-height: 1.85;
}
.leitura-text--fullscreen .leitura-toolbar {
  top: 1em;
}
/* Trava o scroll do body enquanto há fullscreen na DOM. Ligado a :has()
 * de propósito: se a view do capítulo for destruída por navegação (clique
 * numa palavra-entidade enquanto o áudio toca, por exemplo), o lock some
 * automaticamente, sem depender de JS chamar exitFullscreen(). */
body:has(.leitura-text--fullscreen) { overflow: hidden; }

/* ------ TTS: destaque da palavra em leitura ------ */
.tts-word { transition: background-color 140ms, box-shadow 140ms; }
.tts-current {
  background: rgba(143, 48, 39, 0.30);
  box-shadow: 0 0 0 2px rgba(143, 48, 39, 0.30);
  border-radius: 2px;
}

/* ------ busca ------ */
.busca-result { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 3px; padding: 0.5em 0.8em; margin: 0.5em 0; }
.busca-result .meta { font-family: var(--sans); font-size: 0.8em; color: var(--muted); }
.busca-result .trecho-snippet { margin-top: 0.3em; }
.search-evidence-link {
  display: block;
  color: var(--fg);
  text-decoration: none;
  border-radius: 3px;
  padding: 0.15em 0.25em;
  margin-left: -0.25em;
}
.search-evidence-link:hover {
  background: rgba(143, 48, 39, 0.08);
  text-decoration: none;
}
.busca-empty { color: var(--muted); font-style: italic; }

/* ------ comparação e teses ------ */
.compare-controls, .thesis-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7em 1em;
  align-items: end;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.8em;
  margin: 0.9em 0 1.1em;
  font-family: var(--sans);
  font-size: 0.88em;
}
.thesis-controls.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.thesis-controls.scatter-controls { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.compare-controls label, .thesis-controls label { color: var(--muted); display: grid; gap: 0.25em; }
.compare-controls select, .thesis-controls select, .thesis-controls textarea, .thesis-controls input[type="search"] {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: white;
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.95em;
  padding: 0.36em 0.45em;
}
.thesis-controls textarea {
  min-height: 8.5em;
  resize: vertical;
  line-height: 1.35;
}
.compare-controls button {
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--accent);
  color: white;
  font-family: var(--sans);
  padding: 0.42em 0.7em;
  cursor: pointer;
}
.compare-header {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1em;
  margin: 1em 0;
}
.compare-header > div, .analysis-card {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1em;
}
.analysis-card { margin: 1em 0; }
.analysis-card h2 { margin-top: 0; }
.plot-box { min-height: 320px; }

/* scatterplots: moldura para sobrepor os botões de zoom */
.plot-frame { position: relative; }
.plot-frame.is-pan-enabled .plot-box,
.plot-frame.is-pan-enabled .plot-box .draglayer,
.plot-frame.is-pan-enabled .plot-box .draglayer *,
.plot-frame.is-pan-enabled .plot-box .nsewdrag {
  cursor: grab !important;
}
.plot-frame.is-pan-enabled.is-panning .plot-box,
.plot-frame.is-pan-enabled.is-panning .plot-box .draglayer,
.plot-frame.is-pan-enabled.is-panning .plot-box .draglayer *,
.plot-frame.is-pan-enabled.is-panning .plot-box .nsewdrag {
  cursor: grabbing !important;
}
.plot-zoom {
  position: absolute;
  top: 5px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 4;
}
.plot-zoom button {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: var(--sans);
  font-size: 1.05em;
  line-height: 1;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(33, 26, 21, 0.2);
}
.plot-zoom button:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
}
.plot-zoom button:active { transform: translateY(1px); }

/* legenda-checkbox dos scatterplots (mesmo padrão da legenda do grafo de ego) */
.scatter-legend { margin: 0.4em 0 0.7em; }
.scatter-legend:empty { display: none; }
.scatter-legend .legend {
  font-family: var(--sans);
  font-size: 0.84em;
  gap: 0.45em 0.95em;
}
.scatter-legend .legend-item .swatch {
  width: 13px;
  height: 13px;
  border-radius: 3px;
}
.scatter-legend .legend-item.legend-off { opacity: 0.4; }
.scatter-legend .legend-item.legend-off .swatch {
  box-shadow: inset 0 0 0 3px var(--bg);
}
.scatter-node-filter {
  margin: 0.65em 0 0.85em;
}
.scatter-node-filter .node-filter {
  max-height: 220px;
}
.mini-venn { max-width: 560px; margin: 0.2em auto 0.8em; }
.mini-venn svg { width: 100%; height: auto; display: block; }
.venn-region { cursor: pointer; }
.venn-region circle {
  fill: #f4dfc5;
  stroke: var(--accent);
  stroke-width: 2;
  opacity: 0.82;
}
.venn-region:nth-child(2) circle { fill: #dfead2; }
.venn-region:nth-child(3) circle { fill: #d8e7f0; }
.venn-region:hover circle { stroke-width: 4; }
.venn-region text {
  font-family: var(--sans);
  fill: var(--fg);
  pointer-events: none;
}
.venn-region text:first-of-type { font-weight: 700; font-size: 28px; }
.venn-region text:last-of-type { font-size: 13px; fill: var(--muted); }
.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6em;
  margin-bottom: 0.9em;
}
.metric {
  background: white;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.65em;
  font-family: var(--sans);
}
.metric span { display: block; font-size: 1.45em; font-weight: 700; color: var(--accent); line-height: 1.1; }
.metric small { display: block; color: var(--muted); line-height: 1.25; margin-top: 0.25em; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 0.9em;
  background: white;
}
.data-table th, .data-table td {
  border: 1px solid var(--rule);
  padding: 0.42em 0.55em;
  text-align: left;
  vertical-align: top;
}
.data-table th { background: rgba(143, 48, 39, 0.08); color: var(--muted); font-size: 0.82em; text-transform: uppercase; letter-spacing: 0.04em; }
.data-table.compact { max-width: 360px; margin-top: 0.8em; }
.verb-table td { width: 50%; }
#t4-graph,
#rare-graph {
  height: 620px;
  width: 100%;
  background: white;
  border: 1px solid var(--rule);
  border-top: none;
  border-bottom-left-radius: 3px;
  border-bottom-right-radius: 3px;
  overflow: hidden;
  position: relative;
  contain: layout paint;
}

/* ------ navegação extra na sidebar ------ */
.nav-list { list-style: none; padding: 0; margin: 0; }
.nav-list li { margin: 0.25em 0; }
.nav-list li a { font-family: var(--sans); font-size: 0.88em; color: var(--fg); display: block; padding: 0.25em 0.4em; border: 1px solid transparent; border-radius: 3px; }
.nav-list li a:hover { background: var(--bg); border-color: var(--rule); text-decoration: none; }

/* ------ linha do tempo ------ */
.linha-controls {
  display: flex; flex-wrap: wrap; gap: 0.6em 1.2em; align-items: center;
  font-family: var(--sans); font-size: 0.88em;
  background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px;
  padding: 0.6em 0.9em; margin: 0.8em 0;
}
.linha-controls select { padding: 0.2em 0.4em; border: 1px solid var(--rule); background: white; border-radius: 3px; font-family: var(--sans); }
.linha-toggle { margin-left: auto; display: inline-flex; border: 1px solid var(--rule); border-radius: 3px; overflow: hidden; }
.linha-toggle a { padding: 0.25em 0.7em; font-size: 0.85em; color: var(--muted); background: white; border-right: 1px solid var(--rule); }
.linha-toggle a:last-child { border-right: none; }
.linha-toggle a[aria-selected="true"] { background: var(--accent); color: white; }
.linha-toggle a:hover { text-decoration: none; }
#linha-plot { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px; padding: 0.4em; min-height: 380px; }
#linha-drill { margin-top: 1em; }
#linha-drill h3 { font-size: 1em; }

/* ------ mapa ------ */
.mapa-controls {
  display: flex; flex-direction: column; gap: 0.5em;
  font-family: var(--sans); font-size: 0.88em;
  background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px;
  padding: 0.5em 0.7em; margin: 0.8em 0;
}
/* P3: grupos colapsáveis (Filtros / Tempo / Estilo) */
.mapa-controls-group {
  border: 1px solid var(--rule);
  border-radius: var(--lica-radius, 4px);
  background: rgba(255, 248, 235, 0.55);
  padding: 0;
}
.mapa-controls-group > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.45em 0.7em;
  font-family: var(--sans);
  font-size: 0.78em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.4em;
}
.mapa-controls-group > summary::-webkit-details-marker { display: none; }
.mapa-controls-group > summary::before {
  content: '▸';
  display: inline-block;
  font-size: 0.85em;
  color: var(--accent);
  transition: transform 120ms ease;
}
.mapa-controls-group[open] > summary::before { transform: rotate(90deg); }
.mapa-controls-group[open] > summary { color: var(--fg); border-bottom: 1px solid var(--rule); }
.mapa-controls-group > .mapa-controls-grid { padding: 0.7em; }
.mapa-control-checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 0.45em !important;
}
.mapa-controls label.grow { flex: 1; min-width: 240px; display: flex; gap: 0.5em; align-items: center; }
.mapa-controls input[type="range"] { flex: 1; }
.mapa-controls output { font-family: var(--sans); font-weight: bold; color: var(--accent); min-width: 5em; text-align: center; }
.mapa-controls-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(150px, 0.8fr) minmax(160px, 0.9fr);
  gap: 0.7em 0.9em;
}
.mapa-controls-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.28em;
}
.mapa-controls-grid label.grow {
  grid-column: 1 / span 2;
  min-width: 0;
}
.mapa-controls-grid input[type="search"],
.mapa-controls-grid input[type="text"],
.mapa-controls-grid select {
  width: 100%;
  padding: 0.32em 0.42em;
  border: 1px solid var(--rule);
  border-radius: var(--lica-radius-sm, 3px);
  background: var(--bg-card);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.92em;
}
.mapa-controls-grid input[type="text"]:focus,
.mapa-controls-grid input[type="search"]:focus,
.mapa-controls-grid select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(143, 48, 39, 0.25);
}
.mapa-mode {
  display: inline-flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0;
  margin: 0;
  overflow: hidden;
}
.mapa-mode label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35em;
  padding: 0.38em 0.65em;
  border-right: 1px solid var(--rule);
  cursor: pointer;
}
.mapa-mode label:last-child { border-right: 0; }
.mapa-mode input { accent-color: var(--accent); }
.mapa-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 1em; }
#leaflet-map { height: 600px; border: 1px solid var(--rule); border-radius: 4px; background: white; }
#mapa-side { background: var(--bg-card); border: 1px solid var(--rule); border-radius: 4px; padding: 1em; max-height: 600px; overflow-y: auto; }
#mapa-side h3 { font-size: 1em; margin-top: 0.6em; }
#mapa-side h3:first-child { margin-top: 0; }
.mapa-stats {
  font-family: var(--sans);
  font-size: 0.9em;
  margin-bottom: 0.65em;
  color: var(--muted);
}
.mapa-stats strong { color: var(--accent); }
.mapa-results {
  list-style: none;
  padding: 0;
  margin: 0 0 1em;
  display: grid;
  gap: 0.32em;
  max-height: 260px;
  overflow-y: auto;
}
.mapa-results li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55em;
  align-items: start;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.46em 0.55em;
  cursor: pointer;
  font-family: var(--sans);
  background: rgba(255, 248, 235, 0.62);
}
.mapa-results li:hover,
.mapa-results li.active {
  border-color: rgba(143, 48, 39, 0.45);
  background: rgba(143, 48, 39, 0.07);
}
.mapa-results .count-badge {
  min-width: 2em;
  border: 1px solid rgba(143, 48, 39, 0.32);
  border-radius: 999px;
  padding: 0.05em 0.45em;
  color: var(--accent);
  text-align: center;
  font-size: 0.82em;
}
.mapa-results .place-name {
  color: var(--fg);
  font-weight: 650;
}
.mapa-results .place-meta {
  color: var(--muted);
  font-size: 0.82em;
}
#mapa-detail {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.85em;
  margin-bottom: 0.75em;
}
.mapa-detail-card {
  font-family: var(--sans);
}
.mapa-detail-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 1.65em;
  border: 1px solid rgba(143, 48, 39, 0.34);
  border-radius: 999px;
  padding: 0.06em 0.6em;
  color: var(--accent);
  background: rgba(143, 48, 39, 0.07);
  font-size: 0.76em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mapa-detail-card > h3 {
  margin-top: 0.45em;
}
.mapa-detail-card .trecho {
  margin: 0.62em 0;
}
.mapa-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 0.7em;
  margin: 0.3em 0 0.5em;
  font-family: var(--sans);
  font-size: 0.84em;
}
.mapa-detail-link {
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 0.2em 0.65em;
  border-radius: 4px;
  background: rgba(143, 48, 39, 0.06);
}
.mapa-detail-link:hover {
  background: var(--accent);
  color: var(--bg);
  text-decoration: none;
}
.mapa-detail-link-soft {
  border-color: var(--rule);
  color: var(--muted);
  background: transparent;
}
.mapa-detail-link-soft:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(143, 48, 39, 0.04);
}
.mapa-explain-note {
  border: 1px solid rgba(138, 97, 5, 0.34);
  border-radius: 7px;
  padding: 0.55em 0.7em;
  background: rgba(138, 97, 5, 0.07);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 0.88em;
  line-height: 1.45;
}
.mapa-all-passages {
  margin-top: 0.75em;
  border: 1px solid var(--rule);
  border-radius: 7px;
  padding: 0.55em 0.7em;
  background: rgba(255, 248, 235, 0.62);
}
.mapa-all-passages summary {
  cursor: pointer;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.9em;
}
.mapa-all-passages[open] summary {
  margin-bottom: 0.55em;
}
.map-popup h3 {
  margin: 0 0 0.2em;
  font-family: var(--sans);
}
.map-popup p {
  margin: 0.25em 0;
}
.map-popup .popup-meta {
  color: #66757f;
  font-size: 0.86em;
}
.map-popup .popup-desc {
  margin-top: 0.45em;
  font-family: Georgia, serif;
  font-size: 0.92em;
  line-height: 1.35;
}
.map-mobile-sheet {
  display: none;
}

/* ------ halo do ponto selecionado no mapa ------ */
.mapa-halo-wrap {
  pointer-events: none;
  position: relative;
}
.mapa-halo-ring {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 248, 235, 0.70), 0 0 18px 4px rgba(143, 48, 39, 0.42);
  background: rgba(143, 48, 39, 0.06);
}
.mapa-halo-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: mapa-halo-pulse 1.8s ease-out infinite;
}
.mapa-halo-pulse-2 { animation-delay: 0.9s; }
@keyframes mapa-halo-pulse {
  0%   { transform: scale(0.5); opacity: 0.9; }
  100% { transform: scale(2.4); opacity: 0;   }
}

/* ------ play/pause + reset no slider do mapa ------ */
.mapa-play-controls {
  display: inline-flex;
  gap: 0.3em;
  margin-left: 0.4em;
}
.mapa-play-btn {
  font-family: var(--sans);
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.18em 0.55em;
  font-size: 0.92em;
  cursor: pointer;
  line-height: 1;
}
.mapa-play-btn:hover { border-color: var(--accent); color: var(--accent); }
.mapa-play-btn.playing { border-color: var(--accent); color: var(--accent); background: rgba(143, 48, 39, 0.08); }

/* ------ capítulo-chart (distribuição de estreias) ------ */
.mapa-cap-chart-wrap {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.25em;
  margin-top: -0.3em;
}
.mapa-cap-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
  gap: 2px;
  align-items: end;
  height: 64px;
  padding: 0.2em 0.1em 0.1em;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg-card);
}
.mapa-cap-bar {
  position: relative;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 2px;
  align-items: end;
  font-family: var(--sans);
  color: var(--muted);
  min-width: 0;
}
.mapa-cap-bar:hover .mapa-cap-bar-fill { background: var(--accent); }
.mapa-cap-bar.active .mapa-cap-bar-fill { background: var(--accent); }
.mapa-cap-bar.active .mapa-cap-bar-label,
.mapa-cap-bar.active .mapa-cap-bar-count { color: var(--accent); }
.mapa-cap-bar.current .mapa-cap-bar-fill { background: var(--accent-2); }
.mapa-cap-bar.current .mapa-cap-bar-label,
.mapa-cap-bar.current .mapa-cap-bar-count { color: var(--accent-2); font-weight: 700; }
.mapa-cap-bar-fill {
  width: 100%;
  background: var(--rule-strong);
  border-radius: 2px 2px 0 0;
  transition: background 120ms;
  min-height: 2px;
}
.mapa-cap-bar-label {
  font-size: 0.62em;
  line-height: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mapa-cap-bar-count {
  font-size: 0.6em;
  line-height: 1;
  text-align: center;
  min-height: 0.7em;
}
.mapa-cap-chart-help {
  font-family: var(--sans);
  font-size: 0.75em;
  color: var(--muted);
  margin: 0;
}

/* ------ slideshow no popup do mapa ------ */
.map-popup .slideshow { margin-top: 0.45em; }
.map-popup .slide-meta {
  font-family: var(--sans);
  font-size: 0.82em;
  margin-bottom: 0.25em;
}
.map-popup .slide-meta strong { color: #2a3942; }
.map-popup .slide-text {
  font-family: Georgia, serif;
  font-size: 0.92em;
  line-height: 1.4;
}
.map-popup .slideshow-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5em;
  margin-top: 0.55em;
  padding-top: 0.45em;
  border-top: 1px solid #d8e0e2;
  font-family: var(--sans);
}
.map-popup .ss-prev,
.map-popup .ss-next {
  background: #f1f4f5;
  border: 1px solid #cfd7da;
  border-radius: 3px;
  padding: 0.15em 0.55em;
  font-size: 1.1em;
  cursor: pointer;
  line-height: 1;
  color: #2a3942;
}
.map-popup .ss-prev:hover,
.map-popup .ss-next:hover { background: var(--accent); border-color: var(--accent); color: white; }
.map-popup .ss-counter {
  font-size: 0.82em;
  color: #66757f;
  font-variant-numeric: tabular-nums;
}

/* ------ citation-box flutuante (canto do mapa) ------ */
.mapa-map-wrap { position: relative; }
.citation-box {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(360px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 14px 38px rgba(33, 26, 21, 0.22);
  display: none;
  flex-direction: column;
  z-index: 1100;
  font-family: var(--sans);
  overflow: hidden;
}
.citation-box.open { display: flex; }
/* P3: citation-box agora é <dialog>. UA stylesheet aplica
 * `inset: 0; margin: auto` que centralizaria a caixa na viewport —
 * sobrescrevemos com posicionamento explícito ancorado ao canto do
 * .mapa-map-wrap (que é position:relative). */
dialog.citation-box {
  position: absolute;
  inset: 12px 12px auto auto;   /* top right bottom left */
  margin: 0;
  padding: 0;
  color: var(--fg);
  max-width: min(360px, calc(100% - 24px));
  max-height: calc(100% - 24px);
}
dialog.citation-box[open] { display: flex; }
dialog.citation-box::backdrop { background: transparent; }
.citation-box-header {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.55em 0.7em;
  border-bottom: 1px solid var(--rule);
  background: rgba(143, 48, 39, 0.05);
}
.citation-box-title {
  margin: 0;
  font-size: 0.98em;
  color: var(--fg);
  flex: 1;
  font-family: var(--serif);
}
.citation-box-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.4em;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25em;
}
.citation-box-close:hover { color: var(--accent); }
.citation-box-meta {
  padding: 0.35em 0.7em 0.1em;
  font-size: 0.82em;
  color: var(--muted);
}
.citation-box-body {
  padding: 0.5em 0.7em 0.7em;
  overflow-y: auto;
  font-size: 0.92em;
  color: var(--fg);
  flex: 1;
}
.citation-box-body .slide,
.citation-box-body .popup-work { margin-bottom: 0.65em; padding-bottom: 0.55em; border-bottom: 1px dashed var(--rule); }
.citation-box-body .slide:last-child,
.citation-box-body .popup-work:last-child { border-bottom: 0; margin-bottom: 0; }
.citation-box-body .slide-text,
.citation-box-body .popup-work-text {
  font-family: var(--serif);
  font-size: 1em;
  line-height: 1.45;
}
.citation-box-body .slide-meta,
.citation-box-body .popup-work-title {
  color: var(--muted);
  margin-bottom: 0.2em;
  font-size: 0.84em;
}
@media (max-width: 768px) {
  .citation-box { display: none !important; }
}

/* ------ copy-link nos trechos ------ */
.trecho .relation { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3em; }
.copy-link {
  margin-left: auto;
  font-family: var(--sans); font-size: 0.7em;
  background: transparent; color: var(--muted); border: 1px solid var(--rule);
  padding: 0.1em 0.45em; border-radius: 3px; cursor: pointer; line-height: 1.5;
}
.copy-link:hover { color: var(--accent); border-color: var(--accent); background: var(--bg-card); }

/* ------ tooltip de grafo (Cytoscape) ------ */
.cy-tooltip {
  position: fixed; z-index: 10000; pointer-events: none;
  background: var(--fg); color: var(--bg);
  padding: 0.45em 0.7em; border-radius: 4px;
  font-family: var(--sans); font-size: 0.78em; line-height: 1.4;
  max-width: 320px; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  opacity: 0; transform: translateY(4px); transition: opacity 90ms, transform 90ms;
}
.cy-tooltip.visible { opacity: 0.96; transform: translateY(0); }
.cy-tooltip b { color: white; }
.cy-tooltip .cy-tooltip-quote { display: block; margin-top: 0.3em; font-family: var(--serif); font-style: italic; opacity: 0.92; }

/* ------ toast ------ */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--fg); color: var(--bg);
  padding: 0.55em 1.15em; border-radius: 4px;
  font-family: var(--sans); font-size: 0.86em;
  opacity: 0; transition: opacity 180ms, transform 180ms;
  pointer-events: none; z-index: 11000;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--accent); color: white; }

/* ------ sidebar selected indicator ------ */
#sidebar select.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* ------ responsivo (mínimo) ------ */
@media (max-width: 980px) {
  body { flex-direction: column; }
  #sidebar { width: 100%; height: auto; position: relative; }
  #caps-list { grid-template-columns: repeat(8, 1fr); }
  .perfil-grid, .leitura-grid, .theses-grid, .home-stats, .mapa-grid, .chapter-summary { grid-template-columns: 1fr; }
  .mapa-controls-grid { grid-template-columns: 1fr; }
  .mapa-controls-grid label.grow { grid-column: auto; }
  .compare-controls, .thesis-controls, .thesis-controls.three, .compare-header, .metric-row { grid-template-columns: 1fr; }
  .linha-toggle { margin-left: 0; }
  .leitura-grid { grid-template-columns: 1fr; }
  .grid-resizer { display: none; }
}

@media (max-width: 768px) {
  #leaflet-map {
    height: 58dvh;
    min-height: 360px;
  }
  #mapa-side {
    max-height: none;
  }
  .mapa-results {
    max-height: 220px;
  }
  .leaflet-popup {
    max-width: calc(100vw - 24px) !important;
  }
  .leaflet-popup-content-wrapper {
    max-height: 54dvh;
    overflow: hidden;
  }
  .leaflet-popup-content {
    width: calc(100vw - 72px) !important;
    max-height: 48dvh;
    overflow-y: auto;
    overflow-wrap: anywhere;
    margin: 14px;
  }
  .map-mobile-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12000;
    display: flex;
    flex-direction: column;
    max-height: 68dvh;
    background: #fff8eb;
    color: var(--fg);
    border-top: 1px solid rgba(143, 48, 39, 0.36);
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -14px 38px rgba(33, 26, 21, 0.22);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform 180ms ease, visibility 180ms ease;
  }
  .map-mobile-sheet.is-open {
    transform: translateY(0);
    visibility: visible;
  }
  .map-mobile-sheet__bar {
    width: 42px;
    height: 4px;
    margin: 9px auto 2px;
    border-radius: 999px;
    background: rgba(33, 26, 21, 0.26);
    flex: 0 0 auto;
  }
  .map-mobile-sheet__close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(143, 48, 39, 0.26);
    border-radius: 50%;
    background: #efe3ce;
    color: var(--fg);
    font: 700 22px/1 var(--sans);
    cursor: pointer;
    padding: 0;
  }
  .map-mobile-sheet__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 13px 16px 22px;
  }
  .map-mobile-sheet .mapa-detail-card > h3 {
    padding-right: 38px;
    font-size: 1.18em;
  }
  .map-mobile-sheet .trecho {
    margin: 0.72em 0;
  }
  .map-mobile-sheet .evidence-link {
    line-height: 1.55;
    overflow-wrap: anywhere;
  }
  .map-mobile-sheet .mapa-all-passages {
    margin-bottom: 1em;
  }
  .map-mobile-sheet-open .leaflet-control-container .leaflet-bottom {
    bottom: 58px;
  }
}

/* ------ modernizacao: interface de exploracao ------ */
a { color: var(--link); }
a:hover { color: var(--accent); text-decoration: none; }

code {
  background: rgba(143, 48, 39, 0.10);
  color: var(--accent);
  border: 1px solid rgba(143, 48, 39, 0.18);
  border-radius: 4px;
}

.tag {
  border-color: rgba(143, 48, 39, 0.38);
  background: rgba(143, 48, 39, 0.09);
  color: var(--accent);
  border-radius: 4px;
  letter-spacing: 0.04em;
}

#sidebar {
  background: linear-gradient(180deg, #ebe0bc 0%, #dcd0a8 100%);
  border-right: 1px solid #b8a98a;
  box-shadow: 8px 0 28px rgba(33, 26, 21, 0.10);
  backdrop-filter: none;
}
#sidebar header { border-bottom-color: rgba(143, 48, 39, 0.24); }
#sidebar h1 { font-family: var(--sans); font-size: 1.2em; letter-spacing: 0; }
#sidebar h1 a { color: var(--fg); }
#sidebar h2 { color: var(--accent); letter-spacing: 0.11em; }

#sidebar select,
#sidebar input,
.compare-controls select,
.thesis-controls select,
.thesis-controls input[type="search"],
.thesis-controls textarea,
.linha-controls select {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--rule-strong);
  border-radius: 6px;
  outline: none;
}
#sidebar select:focus,
#sidebar input:focus,
.compare-controls select:focus,
.thesis-controls select:focus,
.thesis-controls input[type="search"]:focus,
.thesis-controls textarea:focus,
.linha-controls select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(143, 48, 39, 0.18);
}

.sidebar-button,
.compare-controls button,
.back-link.strong {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff8eb;
  font-weight: 700;
  border-radius: 6px;
  box-shadow: var(--glow);
}
.sidebar-button:hover,
.compare-controls button:hover,
.back-link.strong:hover {
  filter: none;
  transform: translateY(-1px);
}

#caps-list li a,
.nav-list li a,
.chapter-nav a,
.back-link,
.ego-actions button {
  background: var(--surface);
  color: var(--fg);
  border-color: var(--rule);
  border-radius: 6px;
}
#caps-list li a:hover,
.nav-list li a:hover,
.chapter-nav a:hover,
.back-link:hover,
.ego-actions button:hover {
  background: rgba(143, 48, 39, 0.10);
  border-color: var(--accent);
  color: var(--accent);
}

#content {
  max-width: 1180px;
  padding: 2.4em 3em;
}
#view h1 {
  font-family: var(--sans);
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 1.02;
  margin-bottom: 0.35em;
}
#view h2 {
  border-bottom-color: rgba(143, 48, 39, 0.22);
  color: var(--fg);
}
#view h3 { color: var(--accent); }
#view p { max-width: 76ch; }
#view .breadcrumb { color: var(--muted); }

.home-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9em;
}
.stat,
.thesis-card,
.perfil-grid > section,
.summary-card,
.leitura-text,
.leitura-side,
.busca-result,
.compare-controls,
.thesis-controls,
.compare-header > div,
.analysis-card,
.metric,
#mapa-side {
  background: linear-gradient(180deg, #fff8eb 0%, #efe3ce 100%);
  border: 1px solid rgba(143, 122, 91, 0.50);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(33, 26, 21, 0.11);
}
.stat .n,
.metric span {
  color: var(--accent);
  text-shadow: 0 0 18px rgba(143, 48, 39, 0.16);
}
.stat .label,
.summary-card h4,
.data-table th { color: var(--muted); }
.thesis-card { transition: transform 140ms, border-color 140ms, box-shadow 140ms; }
.thesis-card h3 { color: var(--accent); }
.thesis-card:hover {
  transform: translateY(-2px);
  border-color: rgba(143, 48, 39, 0.55);
  box-shadow: 0 16px 42px rgba(33, 26, 21, 0.16), var(--glow);
}

#ego-controls,
.graph-controls,
.linha-controls,
.mapa-controls {
  background: #efe3ce;
  border-color: rgba(143, 122, 91, 0.60);
  color: var(--fg);
  border-radius: 8px 8px 0 0;
}
.legend-item {
  gap: 0.45em;
  padding: 0.22em 0.5em;
  border: 1px solid rgba(143, 122, 91, 0.42);
  background: rgba(255, 248, 235, 0.72);
  border-radius: 6px;
}
.legend-item input[type="checkbox"] { accent-color: var(--accent); }
.legend-item .swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}
.ego-actions button[aria-pressed="false"] {
  color: var(--muted);
  background: rgba(255, 248, 235, 0.62);
}

#ego-network,
#t4-graph,
#rare-graph,
#linha-plot,
#leaflet-map {
  background:
    linear-gradient(rgba(31, 93, 117, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(143, 48, 39, 0.055) 1px, transparent 1px),
    #fffaf1;
  background-size: 28px 28px;
  border-color: rgba(143, 122, 91, 0.50);
}
#ego-network,
#t4-graph,
#rare-graph {
  border-radius: 0 0 8px 8px;
  box-shadow: inset 0 0 52px rgba(143, 48, 39, 0.07);
}
.graph-wrapper.graph-expanded {
  background: #fff8eb;
  border-color: rgba(143, 48, 39, 0.44);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(33, 26, 21, 0.28), 0 0 0 1px rgba(143, 48, 39, 0.16);
}

.trecho {
  background: rgba(255, 248, 235, 0.82);
  border-left-color: var(--accent-2);
  border-radius: 0 8px 8px 0;
}
.trecho .cap {
  background: var(--accent-2);
  color: #fff8eb;
  border-radius: 4px;
  font-weight: 700;
}
.trecho .relation .label-text,
.open-original,
.text-link,
.fam-block .fam-name { color: var(--accent); }
.trecho .evidence-link:hover,
.search-evidence-link:hover { background: rgba(143, 48, 39, 0.08); }

.reader-focus-note,
.chapter-edge-active {
  background: rgba(138, 97, 5, 0.10);
  border-color: rgba(138, 97, 5, 0.36);
  border-left-color: var(--accent-3);
}
.leitura-text mark {
  background: rgba(143, 48, 39, 0.20);
  color: var(--fg);
  box-shadow: inset 0 -0.14em 0 rgba(143, 48, 39, 0.24);
}
.leitura-text mark:hover { background: rgba(143, 48, 39, 0.30); }
.evidence-focus {
  background: rgba(138, 97, 5, 0.20);
  box-shadow: 0 0 0 3px rgba(138, 97, 5, 0.20), inset 0 -0.16em 0 rgba(143, 48, 39, 0.36);
}

.venn-region circle {
  fill: rgba(143, 48, 39, 0.16);
  stroke: var(--accent);
}
.venn-region:nth-child(2) circle { fill: rgba(47, 107, 69, 0.15); stroke: var(--accent-2); }
.venn-region:nth-child(3) circle { fill: rgba(138, 97, 5, 0.15); stroke: var(--accent-3); }
.venn-region text { fill: var(--fg); }
.venn-region text:last-of-type { fill: var(--muted); }

.data-table {
  background: rgba(255, 248, 235, 0.78);
  color: var(--fg);
}
.data-table th,
.data-table td { border-color: var(--rule); }
.data-table th { background: rgba(143, 48, 39, 0.08); }

.linha-toggle {
  border-color: var(--rule);
  border-radius: 6px;
}
.linha-toggle a {
  background: rgba(255, 248, 235, 0.72);
  border-right-color: var(--rule);
}
.linha-toggle a[aria-selected="true"] {
  background: var(--accent);
  color: #fff8eb;
  font-weight: 700;
}

.cy-tooltip {
  background: rgba(33, 26, 21, 0.96);
  color: #fff8eb;
  border: 1px solid rgba(143, 48, 39, 0.42);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38), var(--glow);
}
.cy-tooltip b { color: #f0c18b; }
.cy-tooltip i { color: #b8d3a3; }
.cy-tooltip .cy-tooltip-quote {
  color: #efe3ce;
  font-family: var(--sans);
  font-style: normal;
}

.toast {
  background: #211a15;
  color: #fff8eb;
  border: 1px solid rgba(143, 48, 39, 0.38);
  border-radius: 8px;
}
.toast.error {
  background: var(--danger);
  color: #fff8eb;
}

.type-pill {
  border-radius: 6px;
  color: #fff8eb;
  font-weight: 700;
}
.type-pill.data { color: #fff8eb; }

/* ------ entidades pouco presentes ------ */
.rare-controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.rare-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1.05fr) minmax(260px, 0.95fr);
  gap: 1em;
  align-items: start;
}
.rare-list {
  display: grid;
  gap: 0.45em;
  max-height: 460px;
  overflow: auto;
  padding-right: 0.25em;
}
.rare-list button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: rgba(255, 248, 235, 0.78);
  color: var(--fg);
  padding: 0.55em 0.7em;
  cursor: pointer;
  font-family: var(--sans);
}
.rare-list button strong,
.rare-list button span {
  display: block;
}
.rare-list button strong {
  line-height: 1.2;
}
.rare-list button span {
  margin-top: 0.25em;
  color: var(--muted);
  font-size: 0.82em;
}
.rare-list button:hover,
.rare-list button.is-selected {
  border-color: var(--accent);
  background: rgba(143, 48, 39, 0.09);
}
.rare-list button.is-selected strong {
  color: var(--accent);
}
.rare-details h2 {
  margin-top: 0;
}
.rare-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.mini-count-list {
  list-style: none;
  padding: 0;
  margin: 0.35em 0 0.8em;
  font-family: var(--sans);
  font-size: 0.88em;
}
.mini-count-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.8em;
  border-bottom: 1px solid rgba(33, 26, 21, 0.12);
  padding: 0.22em 0;
}
.mini-count-list strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.inline-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  color: var(--fg);
  font-size: 0.78em;
  font-family: var(--sans);
  letter-spacing: 0.02em;
}
.inline-control select {
  min-width: 5em;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 1em;
  padding: 0.24em 0.5em;
  cursor: pointer;
  transition: border-color 120ms, box-shadow 120ms, background-color 120ms;
}
.inline-control select:hover {
  border-color: var(--accent);
  background: #fffaf1;
}
.inline-control select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(143, 48, 39, 0.22);
}
.inline-control select option {
  background: var(--surface);
  color: var(--fg);
}
/* Botões da barra de controle do grafo precisam estar tão visíveis quanto
   os selects ao lado — não querem ser fantasmas no painel escuro. */
.ego-actions button {
  background: var(--surface);
  border-color: var(--rule-strong);
}
.ego-actions button:hover {
  background: #fffaf1;
  border-color: var(--accent);
  color: var(--accent);
}
.ego-actions button[aria-pressed="true"] {
  background: rgba(143, 48, 39, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}
.ego-actions button[aria-pressed="false"] {
  background: #efe3ce;
  color: var(--muted);
  opacity: 0.78;
}
@media (max-width: 980px) {
  body { flex-direction: column; }
  #content { padding: 1.2em; overflow-x: hidden; }
  #sidebar { width: 100%; height: auto; position: relative; }
  .home-stats,
  .perfil-grid,
  .leitura-grid,
  .theses-grid,
  .mapa-grid,
  .chapter-summary,
  .compare-controls,
  .thesis-controls,
  .thesis-controls.three,
  .rare-layout,
  .rare-metrics,
  .compare-header,
  .metric-row { grid-template-columns: 1fr; }
  .grid-resizer { display: none; }
  /* controles do grafo (ego-network e rare-graph): quebra para evitar
     overflow horizontal que alarga o body e faz o footer parecer menor
     que a tela */
  .ego-actions { flex-wrap: wrap; }
  #ego-controls,
  .graph-controls { overflow-x: hidden; }
}

/* ════════════════════════════════════════════════════════════════════
   PAINEL LATERAL — redesign 2026
   --------------------------------------------------------------------
   Reescreve o #sidebar do explorador: superfície neutra e clara,
   controles modernos, hierarquia mais respirada e um DRAWER deslizante
   no mobile (≤980px). Este bloco fica por último de propósito: por
   cascata ele sobrescreve os estilos antigos do painel (gradiente
   dourado, glow, tiles com borda) sem precisar removê-los acima.
   Os ganchos de JS (#sidebar, #obras-list, .obra-*, #caps-list,
   #nav-visoes, #search-box, selects) são preservados.
   ════════════════════════════════════════════════════════════════════ */

:root {
  --sb-surface:      #f6f4ef;            /* painel — off-white neutro */
  --sb-surface-2:    #ffffff;            /* controles e cards */
  --sb-line:         #e6e1d4;            /* hairline */
  --sb-line-strong:  #d6cdb9;
  --sb-ink:          #211a15;
  --sb-ink-soft:     #574c3f;
  --sb-muted:        #8a7e6c;
  --sb-accent:       #8f3027;
  --sb-accent-ink:   #6f241d;
  --sb-accent-wash:  rgba(143, 48, 39, 0.075);
  --sb-radius:       10px;
  --sb-radius-sm:    8px;
  --sb-shadow:       0 1px 2px rgba(33, 26, 21, 0.05);
  --sb-drawer-w:     min(86vw, 344px);
}

/* ---- contêiner ---- */
#sidebar {
  width: 300px;
  background: var(--sb-surface);
  border-right: 1px solid var(--sb-line);
  box-shadow: none;
  backdrop-filter: none;
  padding: 1.5rem 1.1rem 1.6rem 1.25rem;
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--sb-ink);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #d0c8b6 transparent;
}
#sidebar::-webkit-scrollbar { width: 10px; }
#sidebar::-webkit-scrollbar-thumb {
  background: #d6cdba;
  border-radius: 10px;
  border: 3px solid var(--sb-surface);
}
#sidebar::-webkit-scrollbar-thumb:hover { background: #c4baa1; }

/* ---- cabeçalho do painel ---- */
#sidebar header {
  border-bottom: 1px solid var(--sb-line);
  padding-bottom: 1rem;
  margin-bottom: 1.35rem;
}
#sidebar h1 {
  font-family: var(--serif);
  font-size: 1.34rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.18;
  margin: 0 0 0.4rem;
}
#sidebar h1 a { color: var(--sb-ink); }
#sidebar h1 a:hover { color: var(--sb-accent); text-decoration: none; }
#sidebar-subtitle {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--sb-muted);
  margin: 0;
}
#sidebar .tag {
  display: inline-block;
  margin-top: 0.55rem;
  padding: 0.22rem 0.62rem;
  border: 0;
  border-radius: 999px;
  background: var(--sb-accent-wash);
  color: var(--sb-accent-ink);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* ---- ritmo das seções ---- */
#sidebar section { margin: 0 0 1.7rem; }
#sidebar h2 {
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sb-muted);
  margin: 0 0 0.7rem;
}

/* ---- campos do Perfil ---- */
#sidebar label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--sb-ink-soft);
  margin-bottom: 0.85rem;
}
#sidebar label:last-child { margin-bottom: 0; }

#sidebar select,
#sidebar input {
  width: 100%;
  margin-top: 0.34rem;
  padding: 0.55rem 0.7rem;
  min-height: 42px;
  border: 1px solid var(--sb-line-strong);
  border-radius: var(--sb-radius-sm);
  background: var(--sb-surface-2);
  color: var(--sb-ink);
  font-family: var(--sans);
  font-size: 0.875rem;
  box-shadow: var(--sb-shadow);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
#sidebar select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 2.1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%238a7e6c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  cursor: pointer;
}
#sidebar select:hover,
#sidebar input:hover { border-color: #c5bba3; }
#sidebar select:focus,
#sidebar input:focus {
  outline: none;
  border-color: var(--sb-accent);
  box-shadow: 0 0 0 3px var(--sb-accent-wash);
}
/* select com a entidade da rota atual selecionada */
#sidebar select.is-current {
  border-color: var(--sb-accent);
  box-shadow: none;
  background-color: color-mix(in srgb, var(--sb-accent) 5%, #fff);
}

/* ---- busca livre ---- */
#search-box {
  padding-left: 2.15rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%238a7e6c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M14.5 14.5l-3.6-3.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.7rem center;
}
#sidebar .small {
  font-size: 0.74rem;
  color: var(--sb-muted);
  margin: 0.5rem 0 0;
}

/* ---- lista de Obras ---- */
.sidebar-obras { margin-bottom: 1.7rem; }
.obras-list { display: flex; flex-direction: column; gap: 0.45rem; }
.obras-list-item {
  border: 1px solid var(--sb-line);
  border-radius: var(--sb-radius);
  background: var(--sb-surface-2);
  box-shadow: var(--sb-shadow);
  overflow: hidden;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}
.obras-list-item:hover { border-color: var(--sb-line-strong); }
.obras-list-item .obra-link,
.obras-list-item .obra-current {
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: stretch;
  padding: 0.72rem 0.78rem;
  min-height: 0;
  color: var(--sb-ink);
  text-decoration: none;
}
.obras-list-item .obra-link:hover {
  background: var(--sb-accent-wash);
  color: var(--sb-ink);
  text-decoration: none;
}
.obras-list-item.is-current {
  border-color: var(--sb-accent);
  background: var(--sb-accent-wash);
}
.obras-list-item.is-current .obra-titulo { color: var(--sb-accent-ink); }
.obra-mark {
  width: 5px;
  min-height: 100%;
  border-radius: 999px;
  background: var(--obra-cor, var(--sb-accent));
  box-shadow: none;
}
.obra-meta { display: flex; flex-direction: column; gap: 0.12rem; min-width: 0; line-height: 1.25; }
.obra-titulo {
  font-family: var(--serif);
  font-size: 0.94rem;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.obra-autor { font-size: 0.76rem; color: var(--sb-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obra-ano { font-size: 0.7rem; color: var(--sb-muted); letter-spacing: 0.02em; }
.obra-stats { margin-top: 0.32rem; font-size: 0.68rem; color: var(--sb-ink-soft); }

/* ---- Capítulos: chips em fluxo ---- */
#caps-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
#caps-list li { margin: 0; }
#caps-list li a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2.15rem;
  height: 2.15rem;
  padding: 0 0.5rem;
  border: 1px solid var(--sb-line);
  border-radius: var(--sb-radius-sm);
  background: var(--sb-surface-2);
  color: var(--sb-ink-soft);
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: var(--sb-shadow);
  transition: background 110ms ease, border-color 110ms ease, color 110ms ease;
}
#caps-list li a:hover {
  background: var(--sb-accent);
  border-color: var(--sb-accent);
  color: #fff;
  text-decoration: none;
}

/* ---- Visões exploratórias: menu ---- */
.nav-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.12rem; }
.nav-list li { margin: 0; }
.nav-list li a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.52rem 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--sb-radius-sm);
  color: var(--sb-ink);
  font-family: var(--sans);
  font-size: 0.875rem;
  transition: background 120ms ease, color 120ms ease;
}
.nav-list li a::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--sb-line-strong);
  transition: background 120ms ease;
}
.nav-list li a::after {
  content: "›";
  margin-left: auto;
  color: var(--sb-accent);
  font-size: 1.05rem;
  line-height: 1;
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.nav-list li a:hover {
  background: var(--sb-accent-wash);
  color: var(--sb-accent-ink);
  text-decoration: none;
}
.nav-list li a:hover::before { background: var(--sb-accent); }
.nav-list li a:hover::after { opacity: 1; transform: translateX(0); }

/* ---- botão genérico do painel ---- */
.sidebar-button {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--sb-accent);
  border-radius: var(--sb-radius-sm);
  background: var(--sb-accent);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: background 120ms ease;
}
.sidebar-button:hover { background: var(--sb-accent-ink); filter: none; transform: none; }
.sidebar-button:active { background: var(--sb-accent-ink); }

/* ---- rodapé do painel ---- */
#sidebar footer {
  margin-top: 1.7rem;
  padding-top: 1rem;
  border-top: 1px solid var(--sb-line);
}
#sidebar footer .small { margin-top: 0; }
#sidebar footer code {
  background: #ece6d8;
  color: var(--sb-ink-soft);
  border-radius: 4px;
  padding: 0.05rem 0.32rem;
}

/* ---- foco visível por teclado ---- */
#sidebar a:focus-visible,
.lica-sidebar-toggle:focus-visible,
.lica-sidebar-close:focus-visible,
.sidebar-button:focus-visible {
  outline: 2px solid var(--sb-accent);
  outline-offset: 2px;
  border-radius: var(--sb-radius-sm);
}

/* ---- elementos do drawer: ocultos no desktop ---- */
.lica-sidebar-toggle,
.lica-sidebar-backdrop,
.lica-sidebar-close { display: none; }

/* ════════════════════════════════════════════════════════════════════
   DRAWER — comportamento mobile (≤980px)
   O painel sai do fluxo e vira uma gaveta deslizante sobre o conteúdo.
   As regras do drawer são travadas em "body.lica-drawer-ready": a
   classe só é adicionada por explorador-ui.js. Assim, se o JS falhar,
   o painel cai no fallback empilhado (visível) em vez de ficar preso
   fora da tela.
   ════════════════════════════════════════════════════════════════════ */
@media (max-width: 980px) {
  body.lica-drawer-ready #sidebar {
    position: fixed !important;
    top: var(--lica-shell-header-h, 48px) !important;
    left: 0 !important;
    bottom: 0 !important;
    width: var(--sb-drawer-w) !important;
    max-width: 100%;
    height: auto !important;
    margin: 0 !important;
    padding: 1.4rem 1.1rem 2rem 1.25rem;
    border-right: 1px solid var(--sb-line);
    border-radius: 0 14px 14px 0;
    box-shadow: 0 18px 52px rgba(33, 26, 21, 0.3);
    z-index: 1200;
    transform: translateX(-102%);
    transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  body.lica-drawer-ready.sidebar-open #sidebar { transform: translateX(0); }

  /* fundo escurecido */
  body.lica-drawer-ready .lica-sidebar-backdrop {
    display: block;
    position: fixed;
    top: var(--lica-shell-header-h, 48px);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(33, 26, 21, 0.44);
    opacity: 0;
    visibility: hidden;
    z-index: 1100;
    transition: opacity 240ms ease, visibility 240ms ease;
    -webkit-tap-highlight-color: transparent;
  }
  body.lica-drawer-ready.sidebar-open .lica-sidebar-backdrop { opacity: 1; visibility: visible; }

  /* botão flutuante de abrir */
  body.lica-drawer-ready .lica-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    position: fixed;
    top: calc(var(--lica-shell-header-h, 48px) + 0.6rem);
    left: 0.7rem;
    z-index: 990;
    padding: 0.5rem 0.9rem 0.5rem 0.72rem;
    border: 1px solid var(--sb-line-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--sb-ink);
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(33, 26, 21, 0.16);
    cursor: pointer;
    transition: opacity 160ms ease, transform 120ms ease;
  }
  .lica-sidebar-toggle:active { transform: scale(0.97); }
  body.lica-drawer-ready.sidebar-open .lica-sidebar-toggle { opacity: 0; pointer-events: none; }
  .lica-sidebar-toggle .bars {
    position: relative;
    width: 16px;
    height: 11px;
    flex: 0 0 auto;
  }
  .lica-sidebar-toggle .bars::before,
  .lica-sidebar-toggle .bars::after,
  .lica-sidebar-toggle .bars span {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 2px;
    background: var(--sb-accent);
  }
  .lica-sidebar-toggle .bars::before { top: 0; }
  .lica-sidebar-toggle .bars span { top: 50%; transform: translateY(-50%); }
  .lica-sidebar-toggle .bars::after { bottom: 0; }

  /* botão de fechar dentro do drawer */
  body.lica-drawer-ready .lica-sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0.9rem;
    right: 0.85rem;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--sb-line-strong);
    border-radius: 999px;
    background: var(--sb-surface-2);
    color: var(--sb-ink-soft);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
  }
  .lica-sidebar-close:hover {
    background: var(--sb-accent-wash);
    color: var(--sb-accent-ink);
    border-color: var(--sb-accent);
  }
  /* espaço para o X não cobrir o título */
  body.lica-drawer-ready #sidebar header { padding-right: 2.7rem; }

  /* alvos de toque maiores (válido também no fallback empilhado) */
  #sidebar select,
  #sidebar input { min-height: 46px; font-size: 0.95rem; }
  #caps-list li a { min-width: 2.5rem; height: 2.5rem; font-size: 0.88rem; }
  .nav-list li a { padding: 0.72rem 0.62rem; font-size: 0.95rem; }
  .nav-list li a::after { opacity: 1; transform: none; }

  /* trava o scroll do fundo enquanto o drawer está aberto */
  body.lica-drawer-ready.sidebar-open { overflow: hidden; }

  /* afasta o conteúdo do botão flutuante */
  body.lica-drawer-ready #content { padding-top: 3.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  #sidebar,
  .lica-sidebar-backdrop,
  .lica-sidebar-toggle,
  .nav-list li a::after { transition: none !important; }
}

/* =========================================================================
   VISÕES EXPLORATÓRIAS — pegada modernizadora (2026-05-21)
   Substitui o gradiente "pergaminho amarelado" e as sombras pesadas dos
   cards de análise por uma superfície de papel clara, sem brilho e sem
   text-shadow nos números. Introduz o cabeçalho .visao-header (eyebrow +
   título + lead em serifa + "Como ler" recolhível) usado por todas as
   visões para receber o público mais amplo.
   ========================================================================= */

/* --- cabeçalho das visões: portal de entrada legível --- */
.visao-header {
  margin: 0.4em 0 1.6em;
}
.visao-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  background: rgba(143, 48, 39, 0.09);
  padding: 0.32em 0.85em 0.28em;
  border-radius: 999px;
  margin-bottom: 0.65em;
}
.visao-eyebrow::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}
.visao-header h1 {
  font-family: var(--sans);
  font-size: clamp(1.95rem, 3.2vw, 2.7rem);
  line-height: 1.04;
  letter-spacing: -0.012em;
  margin: 0 0 0.45em;
  color: var(--fg);
}
.visao-lead {
  font-family: var(--serif);
  font-size: 1.22em;
  line-height: 1.5;
  color: var(--fg);
  max-width: 68ch;
  margin: 0 0 0.9em;
}
.visao-lead em { color: var(--accent); font-style: italic; }
.visao-lead strong { color: var(--accent); font-weight: 700; }

.visao-howto {
  background: rgba(255, 248, 235, 0.78);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent-3);
  border-radius: 6px;
  margin: 0;
  max-width: 80ch;
  overflow: hidden;
}
.visao-howto > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.55em 0.95em;
  font-family: var(--sans);
  font-size: 0.85em;
  font-weight: 700;
  color: var(--accent-3);
  display: flex;
  align-items: center;
  gap: 0.55em;
  user-select: none;
}
.visao-howto > summary::-webkit-details-marker { display: none; }
.visao-howto > summary::before {
  content: "›";
  font-size: 1.45em;
  line-height: 0.7;
  color: var(--accent-3);
  transition: transform 160ms ease;
  display: inline-block;
}
.visao-howto[open] > summary::before { transform: rotate(90deg); }
.visao-howto[open] > summary { border-bottom: 1px solid var(--rule); }
.visao-howto .howto-body {
  padding: 0.75em 0.95em 0.85em;
  font-size: 0.92em;
  color: var(--fg-soft);
}
.visao-howto .howto-body p { margin: 0 0 0.55em; max-width: none; }
.visao-howto .howto-body p:last-child { margin-bottom: 0; }
.visao-howto .howto-body strong { color: var(--accent); }
.visao-howto .howto-body em { color: var(--accent-3); font-style: italic; }
.visao-howto .howto-body code {
  background: rgba(143, 48, 39, 0.07);
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .visao-howto > summary::before { transition: none; }
}

/* --- cards de análise: superfície de papel sem gradientes ----------------- */
.analysis-card,
.compare-header > div {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(33, 26, 21, 0.04);
  padding: 1.15em 1.25em 1.25em;
}
.analysis-card h2 {
  font-family: var(--sans);
  font-size: 1.12rem;
  letter-spacing: 0.005em;
  margin: 0 0 0.7em;
  padding-bottom: 0.45em;
  border-bottom: 1px solid var(--rule);
  color: var(--fg);
}
.analysis-card h3 {
  font-family: var(--sans);
  font-size: 0.95rem;
  margin: 1.1em 0 0.4em;
  color: var(--fg);
}

/* --- "stat cards" das métricas: sem brilho, com aresta colorida no topo --- */
.stat,
.metric {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow: none;
  padding: 0.85em 0.9em 0.78em;
}
.stat .n,
.metric span {
  font-family: var(--sans);
  font-size: 1.7em;
  font-weight: 700;
  color: var(--fg);
  text-shadow: none;
  letter-spacing: -0.01em;
  line-height: 1.05;
}
.stat .label,
.metric small {
  color: var(--muted);
  font-size: 0.74em;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-top: 0.4em;
  font-weight: 600;
}

/* --- paineis de controle planos, com legenda discreta ------------------ */
.thesis-controls,
.compare-controls {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: none;
  padding: 0.95em 1.05em;
}
.thesis-controls label.control-stack,
.compare-controls label {
  font-size: 0.74em;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  font-weight: 600;
}
.thesis-controls select,
.thesis-controls textarea,
.thesis-controls input[type="search"],
.compare-controls select {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

/* --- cabeçalhos das colunas de centralidade ---------------------------- */
.central-callouts h4 {
  font-family: var(--sans);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin: 0 0 0.45em;
  font-weight: 700;
}

/* --- toggle da linha do tempo em pílulas ------------------------------- */
.linha-toggle {
  border-radius: 999px;
  overflow: hidden;
  background: white;
}
.linha-toggle a {
  padding: 0.4em 1em;
  font-size: 0.85em;
  font-weight: 600;
}

/* --- "chips" auxiliares dentro do controles --------------------------- */
.control-stack .visao-hint {
  font-size: 0.78em;
  color: var(--muted);
  font-style: italic;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  line-height: 1.4;
  padding-top: 0.4em;
}

/* --- nota final discreta após uma análise ----------------------------- */
.analysis-card > .muted.small,
.analysis-card > p.muted {
  background: rgba(143, 48, 39, 0.04);
  border-left: 2px solid rgba(143, 48, 39, 0.25);
  padding: 0.55em 0.85em;
  border-radius: 0 4px 4px 0;
  margin-top: 0.9em;
}
