:root {
  --page: #efe4ce;
  --card: #f8f1e0;
  --inset: #ede1c7;
  --text: #261710;
  --muted: #6b5344;
  --border: #c5b08e;
  --accent: #8b1e1e;
  --on-accent: #fdfaf2;
  font: 16px/1.45 Georgia, serif;
  scrollbar-gutter: stable;
}
[data-theme="pergaminho_escuro"] {
  --page: #14100d;
  --card: #1f1914;
  --inset: #15110d;
  --text: #ede0cc;
  --muted: #a69279;
  --border: #69513c;
  --accent: #d99b43;
  --on-accent: #14100d;
}
[data-theme="obsidiana"] {
  --page: #09090b;
  --card: #121215;
  --inset: #09090b;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --border: #66666e;
  --accent: #fbbf24;
  --on-accent: #09090b;
  font-family: system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); }
main { max-width: 90rem; margin: auto; padding: clamp(.75rem, 2vw, 1.5rem); }
header, form, nav { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; }
header { justify-content: space-between; margin-bottom: 1rem; }
h1 { font-size: 1.5rem; margin: 0; }
form { padding: .85rem; background: var(--card); border: 1px solid var(--border); border-radius: .6rem; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; }
label:first-child { flex: 1 1 17rem; min-width: 0; }
select, input, button, .button { font: inherit; color: inherit; border: 1px solid var(--border); border-radius: .3rem; background: var(--inset); padding: .55rem .7rem; min-height: 2.5rem; }
select { width: 100%; min-width: 0; }
input { width: 6.5rem; }
button, .button { cursor: pointer; }
.button { display: inline-flex; align-items: center; text-decoration: none; }
button.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); font-weight: bold; }
:is(a, button, select, input):focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
#bookStatus { margin: .7rem 0 .2rem; font-weight: bold; }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 .75rem; }
.reader-toolbar { display: flex; gap: .5rem; margin-bottom: .5rem; }
.reader-toolbar select { width: auto; flex: 1; }
.reader-toolbar button { min-width: 2.6rem; }
.reader-toolbar :disabled { opacity: .45; cursor: default; }
#bookReader { display: block; width: 100%; height: 75vh; height: 75dvh; min-height: 24rem; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: .4rem; background: var(--inset); padding: .5rem; }
.pdf-page { position: relative; background: white; color: black; margin-inline: auto; }
.pdf-page canvas { display: block; }
#bookReader[aria-busy="true"] .pdf-page { opacity: .5; }
@media (max-width: 35rem) {
  header { align-items: flex-start; }
  form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  label:first-child, form nav { grid-column: 1 / -1; }
  input { width: 100%; }
  form > button { padding-inline: .35rem; }
  nav { align-items: stretch; }
  nav .button { flex: 1; justify-content: center; padding-inline: .35rem; font-size: .85rem; white-space: nowrap; }
}
@media print {
  body { color: #000; background: #fff; }
  header a, form, .hint { display: none; }
  .reader-toolbar { display: none; }
  #bookReader { height: auto; overflow: visible; }
}
/* A textura acompanha a ficha; o PDF permanece intacto e legível. */
body[data-backdrop="textured"] { background-image: repeating-linear-gradient(25deg, transparent 0 3px, #98856a0b 3px 4px), radial-gradient(ellipse at top, #a2875a18, transparent 75%); }
