/* Memorial acadêmico e pessoal — interface de leitura.
   Fonte do texto: Markdown. Esta folha só desenha; nunca altera o conteúdo. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #fffdf8;
  --surface: #f1eee5;
  --raise: #ffffff;
  --ink: #192d32;
  --muted: #3b4b4f;
  --accent: #075548;
  --on-accent: #fffdf8;
  --line: #a6b3ad;
  --focus: #893000;
  --sel: #cde6dd;
  --sel-ink: #10242a;
  --mark: #ffe09a;

  /* Barra, capa e rodapé mantêm o mundo escuro da ilustração em qualquer tema. */
  --bar: #0e2227;
  --bar-ink: #eef2ed;
  --gold: #d5bc78;
  --cover: #05080c;
  --cover-ink: #f1f2e9;
  --cover-muted: #b4c3be;
  --dark: #122b31;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --bar-expanded-h: 6rem;
  --bar-h: var(--bar-expanded-h);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --reading-scale: 1;
  --para-gap: 1.25em;
}
:root.spacious { --para-gap: 2.2em; }
:root.header-compact { --bar-h: 3.5rem; }

:root[data-theme="sepia"] {
  color-scheme: light;
  --bg: #f5e6c8;
  --surface: #ebd9b8;
  --raise: #f8ecd6;
  --ink: #302515;
  --muted: #483c28;
  --accent: #344719;
  --on-accent: #f8ecd6;
  --line: #8b7859;
  --focus: #802700;
  --sel: #dcc38a;
  --sel-ink: #261c0e;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10191c;
  --surface: #1e2a2d;
  --raise: #172327;
  --ink: #f1f2e9;
  --muted: #c4d1cc;
  --accent: #b6e7d6;
  --on-accent: #0e2227;
  --line: #738983;
  --focus: #ffdf81;
  --sel: #2f5f58;
  --sel-ink: #f5f6ee;
  --mark: #7a6420;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--bar-h) + 1rem); }
body {
  margin: 0;
  padding-top: var(--bar-expanded-h);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
[id] { scroll-margin-top: calc(var(--bar-h) + 1rem); }
#topo { scroll-margin-top: 0; }
img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 12px 30px -12px rgb(0 0 0 / 0.38);
}
figcaption {
  margin-top: 0.75rem;
  font-family: var(--sans);
  font-size: 0.85em;
  line-height: 1.55;
  color: var(--muted);
  overflow-wrap: anywhere;
}
p { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.4em; }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; overflow-wrap: anywhere; }
[hidden] { display: none !important; }

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.22em;
  overflow-wrap: anywhere;
}
a:hover { text-decoration-thickness: 0.14em; }

::selection { background: var(--sel); color: var(--sel-ink); }
::placeholder { color: var(--muted); opacity: 1; }
::marker { color: var(--muted); }
input, textarea { caret-color: var(--accent); }
input:is([type="checkbox"], [type="radio"]) { accent-color: var(--accent); }
* { scrollbar-color: var(--line) transparent; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip {
  position: absolute;
  left: 0.75rem; top: -10rem;
  z-index: 100;
  background: var(--raise);
  color: var(--ink);
  padding: 0.7em 1em;
  border-radius: 4px;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.3);
}
.skip:focus { top: 0.75rem; }

html:not(.js-ready) .js-only { display: none; }
.js-ready .no-js { display: none; }
.hint { font-size: 0.88rem; color: var(--muted); line-height: 1.55; }

/* ---------- Controles ---------- */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55em 1.15em;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.18s var(--ease);
}
button:hover, .button:hover { background: color-mix(in srgb, var(--accent) 82%, var(--ink)); }
button:active, .button:active { transform: translateY(1px); }
button:disabled { cursor: default; opacity: 0.55; }
button:disabled:hover { background: var(--accent); }
.quiet-button { background: transparent; color: var(--accent); }
.quiet-button:hover { background: var(--surface); }
.quiet-button:disabled:hover { background: transparent; }

input, select {
  max-width: 100%;
  min-height: 44px;
  padding: 0.45em 0.65em;
  border: 1px solid var(--muted);
  border-radius: 4px;
  background: var(--raise);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
select { width: 100%; }
input:is([type="checkbox"], [type="radio"]) { min-height: auto; width: 1.15em; height: 1.15em; margin: 0 0.6em 0 0; padding: 0; flex: none; }
label { display: block; font-weight: 700; font-size: 0.92rem; margin: 0.85em 0 0.3em; }
label.check { display: flex; align-items: center; min-height: 44px; font-weight: 400; margin: 1em 0; cursor: pointer; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
/* legend flutuante: fica dentro do fieldset em vez de cortar a borda superior */
legend { float: left; width: 100%; font-family: var(--sans); font-size: 1.2rem; font-weight: 600; padding: 0; margin-bottom: 0.5rem; }
legend + * { clear: both; }

/* ---------- Barra superior ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  height: var(--bar-h);
  background: transparent;
  color: var(--ink);
  transition: height 0.25s var(--ease), background-color 0.25s var(--ease), color 0.25s var(--ease);
}
.header-compact .topbar { background: var(--bar); color: var(--bar-ink); }
.topbar .brand, .topbar .bar-link, header.topbar button.bar-link { color: inherit; }
.topbar .brand-name { font-size: 1.05rem; transition: font-size 0.25s var(--ease); }
.header-compact .topbar .brand-name { font-size: 0.82rem; }
.topbar .brand-text small { color: var(--gold); font-style: italic; }
.topbar .here-pos { color: var(--accent); }
.header-compact .topbar .here-pos { color: var(--gold); }
html:not(.header-compact) .topbar .bar-link:hover,
html:not(.header-compact) .topbar .tools[open] > summary { background: var(--surface); }
html:not(.header-compact) .topbar :focus-visible { outline-color: var(--focus); }
.topbar :focus-visible { outline-color: var(--gold); outline-offset: 2px; }
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 clamp(0.75rem, 2.5vw, 2rem);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--bar-ink);
  text-decoration: none;
  flex: none;
  min-width: 44px;
  min-height: 44px;
  border-radius: 4px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 2.25rem; height: 2.25rem;
  background: #1c3b43;
  border-radius: 3px;
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fffdf8;
  border: 1px solid var(--gold);
  line-height: 1;
  letter-spacing: 0;
}
.brand-text { display: grid; line-height: 1.2; }
.brand-initial { color: var(--gold); font-family: Georgia, "Times New Roman", serif; font-style: italic; }
.brand-name { font-weight: 400; letter-spacing: 0.02em; font-size: 0.82rem; }
.brand-text small { font-size: 0.78rem; color: #b8c8c2; }

.here { flex: 1; min-width: 0; margin: 0; line-height: 1.2; }
.here > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.here-title { font-family: var(--sans); font-size: 1rem; font-weight: 500; }
.here-pos { font-size: 0.78rem; color: var(--gold); margin-top: 0.1rem; }

.topbar-nav { display: flex; align-items: center; gap: 0.15rem; margin-left: auto; }
.here + .topbar-nav { margin-left: 0; }
.bar-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-height: 44px;
  padding: 0 0.8rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--bar-ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  transition: background-color 0.18s var(--ease);
}
.bar-link:hover, .topbar button.bar-link:hover { background: rgb(255 255 255 / 0.1); }
.bar-link[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 0.4em; }
summary.bar-link::-webkit-details-marker { display: none; }
summary.bar-link::after {
  content: "";
  width: 0.45em; height: 0.45em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.12em) rotate(45deg);
  transition: transform 0.25s var(--ease);
}
.tools[open] > summary.bar-link { background: rgb(255 255 255 / 0.14); }
.tools[open] > summary.bar-link::after { transform: translateY(0.1em) rotate(-135deg); }
.topbar button.bar-link { background: transparent; color: var(--bar-ink); border: 0; }

.progress {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 3px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}
body:not([data-kind="part"]) .progress { display: none; }

.tools .short { display: none; }

/* Painel "Leitura e recursos" */
.tools-panel {
  position: fixed;
  left: 0; right: 0; top: var(--bar-h);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2rem 2.5rem;
  max-height: calc(100svh - var(--bar-h));
  overflow-y: auto;
  padding: 1.75rem max(1rem, calc((100% - 1320px) / 2)) 2.25rem;
  background: var(--raise);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 24px 40px -18px rgb(0 0 0 / 0.45);
  font-size: 0.95rem;
  overscroll-behavior: contain;
}
body:not([data-kind="part"]) .tools-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .tools-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .tools-panel, body:not([data-kind="part"]) .tools-panel { grid-template-columns: minmax(0, 1fr); }
}
.tools-col { display: grid; gap: 1.75rem; align-content: start; min-width: 0; }
.tools-panel :focus-visible { outline-color: var(--focus); }
.tools-panel p { margin: 0 0 0.8em; }
.tool + .tool { padding-top: 1.5rem; border-top: 1px solid var(--line); }
.tool button { margin: 0.5rem 0.4rem 0.5rem 0; font-size: 0.9rem; }
.tool select { font-size: 1rem; }
.radio-group { border: 0; padding: 0; margin: 1rem 0; min-width: 0; }
.radio-group legend { float: none; width: auto; font-size: 0.92rem; margin: 0 0 0.4rem; }
.radio-group .check { margin: 0; gap: 0.6rem; }
.reading-points { max-height: 18rem; overflow-y: auto; padding-inline-end: 0.5rem; overscroll-behavior: contain; }
.tools-panel-footer { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.accessibility-page { max-width: 72ch; }
.accessibility-page p, .accessibility-page li { font-size: calc(1rem * var(--reading-scale)); }
.accessibility-page h2 { margin-top: 2.2rem; }
.accessibility-page li { margin-block: 0.6em; }
.page-toc { margin-block: 2rem; padding-block: 1.25rem; border-block: 1px solid var(--line); }
.accessibility-page .page-toc h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.page-toc :is(ul, ol) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.25rem 1.5rem; list-style: none; padding: 0; margin: 0; }
.accessibility-page .page-toc li { margin: 0; min-width: 0; }
.page-toc a { display: flex; align-items: center; min-height: 44px; padding: 0.4rem 0.5rem; border-radius: 4px; line-height: 1.4; text-decoration-thickness: 1px; }
.page-toc a:hover { background: var(--surface); }
@media (max-width: 600px) { .page-toc :is(ul, ol) { grid-template-columns: 1fr; } }
.plain-list { list-style: none; padding: 0; margin: 0 0 0.8em; }
.plain-list li { margin: 0.7em 0; }
.control-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 0.5rem; }
.control-row button { margin: 0; }
.shortcut-list { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 0.5rem 0.75rem; margin: 0 0 1em; font-size: 0.88rem; }
.shortcut-list dt { font-weight: 700; font-variant-numeric: tabular-nums; }
.shortcut-list dd { margin: 0; }
a[aria-disabled="true"] { color: var(--muted); text-decoration-style: dashed; }
#speech-progress { font-size: 0.88rem; color: var(--muted); }
#preferences-status:empty, #clear-status:empty, #speech-status:empty, #speech-progress:empty,
#libras-status:empty, #shortcut-status:empty { margin: 0; }

/* ---------- Estrutura ---------- */
.shell { min-height: calc(100svh - var(--bar-h)); }
.shell.has-rail { display: grid; grid-template-columns: minmax(0, 1fr); }

/* Sumário lateral: fixo em tela larga, gaveta em tela estreita */
.rail {
  position: fixed;
  top: var(--bar-h); bottom: 0; left: 0;
  z-index: 40;
  width: min(23rem, 90vw);
  overflow-y: auto;
  padding: 1.25rem 1rem 2rem 1.25rem;
  background: var(--raise);
  border-right: 1px solid var(--line);
  box-shadow: 18px 0 36px -18px rgb(0 0 0 / 0.4);
  transform: translateX(-100%);
  visibility: hidden;
  transition: transform 0.32s var(--ease), visibility 0s linear 0.32s;
  overscroll-behavior: contain;
}
.contents-open .rail { transform: none; visibility: visible; transition-delay: 0s; }
.scrim { position: fixed; inset: var(--bar-h) 0 0 0; z-index: 30; background: rgb(5 8 12 / 0.55); }
.rail-title { font-family: var(--sans); font-size: 1.15rem; font-weight: 600; margin: 0 0 0.75rem 0.6rem; }
.rail-list { list-style: decimal-leading-zero; margin: 0; padding: 0 0 0 2rem; }
.rail-list > li::marker { content: counter(list-item, decimal-leading-zero) "  "; color: var(--muted); font-size: 0.93rem; font-variant-numeric: tabular-nums lining-nums; }
.rail-list > li.is-current::marker { color: var(--accent); font-weight: 700; }
.rail-list li { margin: 0; padding: 0; }
.rail-list a, .rail-list .pending {
  display: block;
  padding: 0.55rem 0.6rem;
  border-radius: 4px;
  color: var(--ink);
  font-size: 0.93rem;
  line-height: 1.35;
  text-decoration: none;
}
.rail-list a:hover { background: var(--surface); }
.rail-list a[aria-current="page"] { background: var(--surface); font-weight: 700; }
.rail-list .pending { color: var(--muted); }
.rail-list .pending small { display: block; font-size: 0.78rem; }
.rail-sections, .rail-sections ul { list-style: none; margin: 0; padding: 0; }
.rail-sections { margin: 0.25rem 0 0.75rem 0.6rem; border-inline-start: 1px solid var(--line); }
.rail-list .rail-sections a { display: flex; align-items: center; min-height: 44px; padding: 0.5rem 0.65rem; font-size: 0.85rem; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.rail-sections ul { padding-inline-start: 0.75rem; }
.rail-more { margin: 1rem 0 0 0.6rem; font-size: 0.9rem; }

main { min-width: 0; }

@media (min-width: 1050px) {
  .shell.has-rail { grid-template-columns: 19.5rem minmax(0, 1fr); }
  .rail {
    position: sticky;
    top: var(--bar-h);
    align-self: start;
    z-index: auto;
    width: auto;
    height: calc(100svh - var(--bar-h));
    background: var(--bg);
    box-shadow: none;
    transform: none;
    visibility: visible;
    transition: none;
  }
  .scrim { display: none; }
  #contents-toggle { display: none !important; }
}

/* ---------- Leitura ---------- */
.prose {
  max-width: 66ch;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(1.25rem, 4vw, 2rem) clamp(2rem, 4vw, 3rem);
  font-family: var(--sans);
  font-size: calc(1.1875rem * var(--reading-scale));
  font-weight: 400;
  line-height: 1.72;
  font-kerning: normal;
  hyphens: manual;
  overflow-wrap: anywhere;
}
.prose p { margin: 0 0 var(--para-gap); text-wrap: pretty; }
.prose .empty-source { display: none; }
.prose .relato { margin-block: 1.6em; padding-block: 1.25em; border-block: 1px solid var(--line); }
.prose .relato .relato { margin: 0; padding: 0; border: 0; }
.section-anchor { display: inline-flex; vertical-align: middle; align-items: center; justify-content: center; width: 44px; min-height: 44px; margin-inline-start: 0.25rem; color: var(--accent); }
.section-anchor svg { flex: none; }
.titlepage { padding-bottom: 2rem; margin-bottom: 3rem; border-bottom: 1px solid var(--line); }
.prose .titlepage h1 { margin-bottom: 0.5em; font-weight: 500; }
.prose .titlepage h2 { margin: 0 0 1.5rem; font-size: 1.25em; font-weight: 500; }
.prose .titlepage-motto { margin-bottom: 0.25em; font-style: italic; }
.prose .titlepage-description { margin-top: 2rem; font-size: 0.85em; color: var(--muted); }
.titlepage-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin-top: 2rem; font-family: var(--sans); font-size: 0.8em; color: var(--muted); }
.prose h1, .prose h2, .prose h3 { font-family: var(--sans); color: var(--ink); text-wrap: balance; }
.prose h1 {
  font-size: clamp(1.45em, 1.15em + 1.2vw, 1.8em);
  font-weight: 650;
  line-height: 1.22;
  letter-spacing: 0.012em;
  margin: 0 0 1.5em;
}
.prose h2 { font-size: 1.5em; font-weight: 600; margin: 2.2em 0 0.8em; }
.prose h1:has(.chapter-title) { font-size: 1em; font-weight: 400; letter-spacing: normal; }
.chapter-number { display: block; margin-bottom: 0.75rem; font-family: var(--sans); font-size: 0.85em; font-weight: 500; line-height: 1.4; color: var(--muted); }
.chapter-title { display: block; font-family: var(--sans); font-size: clamp(2em, 1.5em + 2vw, 3em); font-weight: 500; line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance; }
.prose h3 { font-size: 1.22em; font-weight: 600; margin: 1.9em 0 0.7em; }
.prose a { text-decoration-thickness: 0.07em; text-underline-offset: 0.22em; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.prose a:hover { text-decoration-color: currentColor; text-decoration-thickness: 0.12em; }
.prose blockquote { margin: 1.6em 0 1.6em 1.4em; padding: 0; font-style: italic; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose figure { margin: 2em 0; }
.prose img { display: block; margin: 1.5em auto; max-height: 85svh; width: auto; object-fit: contain; border-radius: 6px; }
.prose figcaption, .prose .caption { margin-top: 0.6em; font-family: var(--sans); font-size: 0.8em; line-height: 1.55; color: var(--muted); }
.prose .memorial-figure { margin: 0; }

.memorial-figure > p { margin: 0; }
.prose .memorial-figure img { margin: 0 auto; height: auto; max-height: 65svh; }
.memorial-figure figcaption { padding: 0.85rem 0 0; }
.memorial-figure figcaption p { margin: 0.25em 0; }
.prose .figure-caption { color: var(--ink); font-weight: 600; font-style: normal; }
.figure-caption em { font-style: normal; }
.prose .figure-source, .prose .document-source { font-family: var(--sans); font-size: 0.78em; color: var(--muted); line-height: 1.6; overflow-wrap: anywhere; }
.prose .figure-source { font-size: 0.9em; }
.memorial-figure figcaption blockquote { margin: 0; font-style: normal; }
.prose .image-treatment { font: inherit; color: inherit; margin: 0; }
.image-treatment a { display: inline-flex; align-items: center; min-height: 44px; }
.document-details { border-block: 1px solid var(--line); margin: 0; }
.document-details + .document-details { border-top: 0; }
.document-details > summary { padding: 0.7rem 0; min-height: 44px; font-family: var(--sans); font-size: 0.8em; font-weight: 600; cursor: pointer; color: var(--accent); }
.document-details > summary:hover { color: var(--ink); }
.document-details[open] { padding-bottom: 1rem; }
.document-details > p { margin: 0.6em 0 var(--para-gap); }
.original-image-dialog { width: min(1000px, calc(100% - 2rem)); max-height: calc(100svh - 2rem); padding: clamp(1rem, 3vw, 1.5rem); border: 0; background: var(--raise); color: var(--ink); box-shadow: 0 20px 60px -15px rgb(0 0 0 / 0.5); overflow: auto; }
.original-image-dialog::backdrop { background: rgb(0 0 0 / 0.72); }
.original-image-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.original-image-header h2 { margin: 0; font-family: var(--sans); font-size: 1.4rem; font-weight: 500; }
.original-image-header button { flex: none; margin: 0; }
.original-image-dialog img { display: block; width: auto; height: auto; max-width: 100%; max-height: 75svh; object-fit: contain; margin: 0 auto; border-radius: 6px; }
.original-image-dialog [role="status"] { font-size: 0.85rem; margin: 0.75rem 0 0; }
.original-image-dialog [role="status"]:empty { display: none; }
html:has(.original-image-dialog[open]) { overflow: hidden; }
.prose .document-transcription { margin: 0.75em 0 0; padding: 1.1em 1.25em; background: var(--surface); font-size: 0.92em; font-style: normal; }
.prose .quote-attribution { display: block; margin-top: 0.65em; font-family: var(--sans); font-size: 0.8em; font-style: normal; color: var(--muted); }
.document-source cite { font-style: normal; }
.prose .source-document { margin: 2em 0; padding: clamp(1rem, 3vw, 2rem); background: var(--surface); border-block: 1px solid var(--line); overflow-wrap: anywhere; }
.prose .source-document blockquote { margin: 0; padding: 0; font-style: normal; }
.source-document .relato { background: transparent; border: 0; padding: 0; margin: 0; }
.prose .source-document blockquote p { margin-bottom: 1em; }
.source-email em, .source-letter em { font-style: normal; }
.prose .source-document .source-document-header { font-family: var(--sans); font-size: 0.82em; line-height: 1.55; margin-bottom: 0.4em; color: var(--muted); }
.source-document blockquote:has(.source-document-header) + blockquote:not(:has(.source-document-header)) { margin-top: 1.2em; padding-top: 1.2em; border-top: 1px solid var(--line); }
.prose .source-document .source-document-signature { font-family: var(--sans); font-size: 0.85em; line-height: 1.6; margin-bottom: 0.35em; }
.prose .source-letter { background: var(--raise); border: 1px solid var(--line); }
.source-letter .source-document-signature { margin-top: 1.2em; }
.prose .source-law .source-document-header { color: var(--ink); text-align: center; }
.source-law .source-document-header:last-child { font-weight: 700; }
.prose .source-record .source-document-header { font-family: var(--sans); font-size: 1.1em; font-weight: 600; color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.5em; margin: 0 0 var(--para-gap); }
.prose li { margin: 0.5em 0; padding-left: 0.2em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-family: var(--sans); font-size: 0.8em; line-height: 1.45; margin: 1.6em 0; }
.prose th, .prose td { padding: 0.55em 0.8em; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--surface); }
.prose sup { line-height: 0; }
.prose .footnotes { border-top: 1px solid var(--line); font-size: 0.9em; margin-top: 3rem; padding-top: 1rem; }
mark { background: var(--mark); color: #17272a; padding: 0 0.05em; border-radius: 2px; }
:root[data-theme="dark"] mark { color: #fff7e0; }

/* Trecho aberto por link (busca, marcador) e trecho em leitura pelo narrador */
.prose :target, .prose [data-speaking="true"] {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding-inline: 0.4em;
  margin-inline: -0.4em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  border-radius: 4px;
}
.prose [data-speaking="true"] { background: color-mix(in srgb, var(--accent) 20%, transparent); }

/* Fim da parte: mesma coluna e mesma escala do texto */
.prose .part-output { margin: -0.5rem 0 1.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; font-size: 0.75em; }
.part-output a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 400; }
.part-end {
  max-width: 66ch;
  margin: 0 auto;
  font-family: var(--sans); /* 66ch só coincide com .prose se a fonte for a mesma */
  padding: 0 clamp(1.25rem, 4vw, 2rem) clamp(3rem, 6vw, 5rem);
  font-size: calc(1.1875rem * var(--reading-scale));
}
.end-note { font-family: var(--sans); font-style: italic; font-size: 1em; color: var(--muted); padding-top: 1.75rem; border-top: 1px solid var(--line); margin-bottom: 1.25rem; }
.end-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15em), 1fr)); gap: 0.75rem; }
.end-link {
  display: grid;
  gap: 0.2em;
  padding: 0.9em 1.1em;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.end-link:hover { background: var(--surface); border-color: var(--accent); }
.end-next { text-align: right; }
.end-next:only-child { grid-column: 1 / -1; }
.end-dir { font-family: var(--sans); font-size: 0.72em; color: var(--muted); }
.end-title { font-family: var(--sans); font-size: 1.05em; line-height: 1.3; color: var(--accent); }
.end-top { margin: 1.5rem 0 0; font-family: var(--sans); font-size: 0.78em; color: var(--muted); }

/* ---------- Capa e página inicial ---------- */
.cover {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 5rem);
  min-height: calc(100svh - var(--bar-h));
  padding: clamp(2rem, 5vw, 4rem) max(1.25rem, calc((100% - 1320px) / 2));
  background: var(--cover);
  color: var(--cover-ink);
}
.cover :focus-visible { outline-color: var(--gold); }
.cover-copy { max-width: 36rem; }
.cover h1 {
  margin: 0 0 1rem;
  font-family: var(--sans);
  font-size: clamp(2.5rem, 1.6rem + 3.4vw, 4.5rem);
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -0.025em;
}
.cover-author { margin: 0 0 1.5rem; font-family: var(--sans); font-style: italic; font-size: 1.55rem; font-weight: 400; color: var(--gold); }
.cover-sub { margin: 0 0 2rem; font-family: var(--sans); font-size: 1.2rem; line-height: 1.6; color: var(--cover-muted); max-width: 30rem; }
.cover-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.5rem; margin: 0; }
.cover .button { background: var(--gold); border-color: var(--gold); color: #0e2227; }
.cover .button:hover { background: #e4d097; }
.text-link { color: var(--cover-ink); font-weight: 600; font-size: 0.95rem; padding: 0.7rem 0; text-underline-offset: 0.3em; }
.cover-edition { margin: 2.5rem 0 0; font-size: 0.85rem; color: #9fb0ab; }
.cover-art { margin: 0; justify-self: end; max-width: 100%; }
.cover-art img { display: block; width: auto; max-width: 100%; max-height: calc(100svh - var(--bar-h) - 9rem); }
.cover-art figcaption { margin-top: 1rem; font-family: var(--sans); font-style: italic; font-size: 1.1rem; color: #e4dcc3; text-align: center; }

@keyframes arrive { from { opacity: 0; transform: translateY(10px); } }
.cover-copy > * { animation: arrive 0.9s var(--ease) backwards; }
.cover-copy > :nth-child(2) { animation-delay: 0.08s; }
.cover-copy > :nth-child(3) { animation-delay: 0.16s; }
.cover-copy > :nth-child(4) { animation-delay: 0.24s; }
.cover-copy > :nth-child(5) { animation-delay: 0.32s; }
.cover-art { animation: arrive 1.1s var(--ease) 0.1s backwards; }

.home-body { max-width: 1224px; margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3rem) clamp(2rem, 5vw, 4rem); }
.home-body h2 { font-family: var(--sans); font-size: clamp(1.7rem, 1.3rem + 1.2vw, 2.25rem); font-weight: 500; letter-spacing: -0.01em; margin: 0 0 1rem; }
.way { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 2rem clamp(2rem, 6vw, 5rem); align-items: start; }
.way-intro { max-width: 36rem; }
.way:not(:has(.topics)) { grid-template-columns: minmax(0, 1fr); }
.resume:not(:empty) { margin-top: 1.5rem; padding: 1rem 1.25rem; background: var(--surface); border-radius: 6px; }
.resume h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.resume ul { margin: 0; padding-left: 1.2em; }
.topic-links { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.topic-links li { margin: 0; border-bottom: 1px solid var(--line); }
.topic-links a { display: block; padding: 0.95rem 0.25rem; color: var(--ink); font-family: var(--sans); font-size: 1.2rem; text-decoration: none; }
.topic-links a:hover { background: var(--surface); text-decoration: underline; }

.contents { margin-top: clamp(3rem, 7vw, 5rem); padding-top: 3rem; border-top: 1px solid var(--line); }
.chapter-list { list-style: decimal-leading-zero; padding: 0; margin: 1.5rem 0 0 3.25rem; border-top: 1px solid var(--line); }
.chapter-list li { position: relative; display: list-item; margin: 0; padding: 1.1rem 0.5rem; border-bottom: 1px solid var(--line); transition: background-color 0.18s var(--ease); }
.chapter-list li:not(.is-pending):hover, .chapter-list li:focus-within { background: var(--surface); }
.chapter-list > li::marker { content: counter(list-item, decimal-leading-zero) "  "; font-family: var(--sans); font-size: 1.5rem; color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.chapter-list a, .chapter-list .entry-title { font-family: var(--sans); font-size: 1.4rem; line-height: 1.3; color: var(--ink); text-decoration: none; }
.chapter-list a::after { content: ""; position: absolute; inset: 0; }
.chapter-list a:hover { text-decoration: underline; }
.chapter-list .entry-title { color: var(--muted); }
.chapter-list .printed { margin: 0.4rem 0 0; font-size: 0.82rem; line-height: 1.5; color: var(--muted); }

/* ---------- Busca ---------- */
.utility { max-width: 48rem; margin: 0 auto; padding: clamp(2rem, 5vw, 4rem) clamp(1.25rem, 4vw, 2rem) 4rem; }
.utility h1 { font-family: var(--sans); font-size: clamp(2rem, 1.5rem + 1.6vw, 2.6rem); font-weight: 500; margin: 0 0 1rem; letter-spacing: -0.01em; }
.utility h2 { font-family: var(--sans); font-size: 1.5rem; font-weight: 500; margin: 2rem 0 0.5rem; }
.search-controls { display: flex; gap: 0.6rem; }
.search-controls input { flex: 1; min-width: 0; }
.search-results { list-style: none; padding: 0; }
.search-results li { margin: 0; padding: 1.4rem 0; border-top: 1px solid var(--line); }
.search-results h3 { margin: 0 0 0.6rem; font-family: var(--sans); font-size: 1.25rem; font-weight: 500; }
.search-results .snippet { margin: 0; font-family: var(--sans); font-size: calc(1.02rem * var(--reading-scale)); line-height: 1.65; overflow-wrap: anywhere; }
.search-results .result-meta { margin: 0 0 0.4rem; font-size: 0.8rem; color: var(--muted); }
#result-status { margin-top: 1.5rem; }

/* A preferência acompanha também o texto usado para encontrar uma parte. */
.way-intro { font-size: calc(1rem * var(--reading-scale)); overflow-wrap: anywhere; }
.chapter-list a, .chapter-list .entry-title { font-size: calc(1.4rem * var(--reading-scale)); }
.search-results h3 { font-size: calc(1.25rem * var(--reading-scale)); }
.utility > p { font-size: calc(1rem * var(--reading-scale)); overflow-wrap: anywhere; }

/* ---------- Rodapé ---------- */
.shell.has-rail + .site-footer { margin-top: 0; } /* a linha do sumário lateral chega até o rodapé */
.site-footer { margin-top: 3rem; padding: clamp(2.5rem, 6vw, 5rem) clamp(1.25rem, 4vw, 3rem) 1.25rem; background: var(--dark); color: var(--bar-ink); font-size: 0.93rem; }
.site-footer :focus-visible { outline-color: var(--gold); }
.footer-inner { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 2.5rem clamp(2rem, 7vw, 6rem); max-width: 1224px; margin: 0 auto; }
.footer-author { max-width: 18ch; margin: 0 0 1rem; font-family: var(--sans); font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem); line-height: 1.18; text-wrap: balance; }
.footer-title { margin: 0 0 1.25rem; font-family: var(--sans); font-size: 1.15rem; font-style: italic; color: var(--gold); }
.site-footer ul { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.site-footer li { margin: 0; }
.site-footer a { display: inline-flex; align-items: center; gap: 0.75rem; min-height: 44px; padding: 0.6rem 0; color: var(--bar-ink); }
.site-footer nav a { display: flex; border-bottom: 1px solid var(--line); padding-block: 0.85rem; text-decoration: none; }
.site-footer nav a:hover { text-decoration: underline; }
.footer-parent svg, .footer-top svg { flex: none; color: var(--gold); }
.footer-bottom { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.site-footer .fine { margin: 0; color: var(--cover-muted); font-size: 0.85rem; }
@media (max-width: 600px) {
  .footer-inner { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
}

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .cover { grid-template-columns: minmax(0, 1fr); gap: 1.75rem; min-height: 0; padding-block: 1.75rem 2.75rem; }
  .cover-art { order: -1; justify-self: center; }
  .cover-art img { max-height: 38svh; }
  .cover-art figcaption { margin-top: 0.6rem; }
  .cover-copy { max-width: none; }
  .way { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .brand-text { display: none; }
  .topbar-inner { gap: 0.5rem; }
  .bar-link { padding: 0 0.6rem; }
  .tools-panel { padding-inline: 1rem; }
  .shortcut-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  .here-pos { margin: 0; }
  .brand-text { display: none; }
  .bar-link { padding: 0 0.5rem; font-size: 0.88rem; }
  .tools .long { display: none; }
  .tools .short { display: inline; }
  .prose, .part-end { font-size: calc(1.0625rem * var(--reading-scale)); }
  .chapter-list { margin-inline-start: 2.4rem; }
  .chapter-list > li::marker { font-size: 1.25rem; }
  .chapter-list a, .chapter-list .entry-title { font-size: calc(1.2rem * var(--reading-scale)); }
  .search-controls { flex-direction: column; }
  .end-next { text-align: left; }
}
@media (hover: none) {
  button:hover, .button:hover { background: var(--accent); }
}

/* ---------- Preferências do sistema ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
@media (min-width: 1024px) {
  .prose, .part-end { max-width: 80ch; }
}
@media (forced-colors: active) {
  button, .button { border: 1px solid ButtonText; }
  .brand-mark { border: 1px solid CanvasText; }
  .progress { background: Highlight; }
  .rail-list a[aria-current="page"] { outline: 2px solid Highlight; }
  .prose :target, .prose [data-speaking="true"] { outline: 2px solid Highlight; background: transparent; }
  .scrim { background: transparent; }
}
@media print {
  @page { size: A4; margin: 3cm 2cm 2cm 3cm; }
  .part-output { display: none !important; }
  img { box-shadow: none; }
  .original-image-dialog { display: none !important; }
  .document-details > * { display: block !important; }
  .section-anchor { display: none; }
  .skip, .topbar, .rail, .scrim, .part-end, .site-footer, .resume { display: none !important; }
  body { padding-top: 0; background: #fff !important; color: #000 !important; font-size: 11pt; }
  .shell, .shell.has-rail { display: block; min-height: 0; }
  .prose { max-width: none; margin: 0; padding: 0; font-size: 11pt !important; --para-gap: 1em; }
  .prose h1 { font-size: 22pt; }
  .prose h1:has(.chapter-title) { font-size: 11pt; }
  .chapter-number { font-size: 10pt; }
  .chapter-title { font-size: 22pt; }
  .prose h2 { font-size: 16pt; }
  .prose h3 { font-size: 13pt; }
  .prose a { color: #000; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; overflow-wrap: anywhere; }
  .prose img { max-height: 18cm; }
  .prose :target, .prose [data-speaking="true"] { background: transparent; outline: 0; }
  h1, h2, h3 { break-after: avoid; }
  p { orphans: 3; widows: 3; }
  .cover { display: block; min-height: 0; padding: 0; background: #fff; color: #000; }
  .cover h1, .cover-author, .cover-sub, .cover-edition, .cover-art figcaption { color: #000; }
  .cover-actions { display: none; }
  .cover-art { max-width: 10cm; }
  .home-body { padding: 1cm 0; }
}
