/* Catholic Courses reader. Night matches the main site; sepia and light are
   for long reading in daylight. Every colour comes from these tokens. */
:root {
  --paper: #121214;
  --paper-2: #1b1b1e;
  --ink: #e4e4e7;
  --muted: #a1a1aa;
  --line: #2e2e34;
  --accent: #d4af37;
  --rubric: #e28a6b;
  --on-accent: #121214;
  --hl-yellow: rgba(242, 193, 78, 0.34);
  --hl-blue: rgba(120, 170, 230, 0.32);
  --hl-pink: rgba(232, 130, 150, 0.32);
  --sketch-paper: #f7f3e8;
  --font-serif: 'EB Garamond', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --fs: 19px;
  --bar-h: 52px;
  color-scheme: dark;
}
:root[data-rt="sepia"] {
  --paper: #f4ecd8;
  --paper-2: #eadfc4;
  --ink: #2a211a;
  --muted: #6e5a3e;
  --line: #d3c29c;
  --accent: #8a6710;
  --rubric: #9e2b1f;
  --on-accent: #f4ecd8;
  --hl-yellow: rgba(236, 180, 40, 0.38);
  --hl-blue: rgba(90, 140, 210, 0.30);
  --hl-pink: rgba(220, 100, 120, 0.28);
  color-scheme: light;
}
:root[data-rt="light"] {
  --paper: #ffffff;
  --paper-2: #f3f3f5;
  --ink: #1a1a1d;
  --muted: #5e5e66;
  --line: #e2e2e6;
  --accent: #8a6710;
  --rubric: #a2362a;
  --on-accent: #ffffff;
  --hl-yellow: rgba(245, 196, 60, 0.42);
  --hl-blue: rgba(100, 160, 230, 0.30);
  --hl-pink: rgba(235, 120, 140, 0.28);
  color-scheme: light;
}

/* OpenDyslexic, self-hosted (SIL Open Font License, see fonts/). The browser
   only downloads it when someone picks it. */
@font-face { font-family: 'OpenDyslexic'; src: url('/read/fonts/opendyslexic-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'OpenDyslexic'; src: url('/read/fonts/opendyslexic-latin-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'OpenDyslexic'; src: url('/read/fonts/opendyslexic-latin-700-normal.woff2') format('woff2'); font-weight: 600 700; font-style: normal; font-display: swap; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(0.75rem, env(safe-area-inset-right, 0px)) 0 max(0.75rem, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar .title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar a, .bar button {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.4rem;
  cursor: pointer;
  white-space: nowrap;
}
.bar a:hover, .bar button:hover { color: var(--accent); }
.bar .aa { font-family: var(--font-serif); font-size: 1.15rem; }
@media (max-width: 600px) { .bar .nb-link { display: none; } }

/* ---------- library ---------- */
.lib { max-width: 1000px; margin: 0 auto; padding: 1.25rem 1rem 4rem; display: grid; gap: 2rem; }
.lib h1 { font-family: var(--font-serif); font-weight: 500; font-size: 2.2rem; color: var(--accent); margin: 0; line-height: 1.1; }
.lib .intro { color: var(--muted); max-width: 60ch; margin: 0.35rem 0 0; }
.cont {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.9rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
  max-width: 480px;
}
.cont .cover { width: 56px; flex: none; }
.cont small { display: block; color: var(--muted); font-size: 0.78rem; }
.cont b { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 600; display: block; line-height: 1.25; }
.meter { height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 0.45rem; }
.meter i { display: block; height: 100%; background: var(--accent); }
.shelf h2 { font-family: var(--font-serif); font-weight: 600; font-size: 1.35rem; margin: 0; }
.shelf .about { color: var(--muted); font-size: 0.82rem; margin: 0.1rem 0 0.9rem; }
.row {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 0.9rem;
  border-bottom: 6px solid var(--line);
  scroll-snap-type: x proximity;
}
.book { width: 112px; flex: none; text-decoration: none; display: grid; gap: 0.35rem; align-content: start; scroll-snap-align: start; }
.book span { font-size: 0.82rem; font-weight: 500; line-height: 1.3; }
.book small { color: var(--muted); font-size: 0.72rem; }
.cover { display: block; width: 100%; aspect-ratio: 2 / 3; border-radius: 3px; overflow: hidden; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); }
.cover svg, .cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.libfoot { color: var(--muted); font-size: 0.8rem; max-width: 60ch; }
@media (min-width: 700px) {
  .row { flex-wrap: wrap; overflow: visible; }
  .book { width: 132px; }
}

/* ---------- reader ---------- */
.progress { position: sticky; top: calc(var(--bar-h) + env(safe-area-inset-top, 0px)); z-index: 19; height: 2px; background: transparent; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.reader { max-width: 1320px; margin: 0 auto; }
.toc-col { display: none; }
.margin { display: none; }
.chapter {
  max-width: 38em;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 7rem 2.3rem;
  font-family: var(--read-font, var(--font-serif));
  font-size: calc(var(--fs) * var(--read-scale, 1));
  line-height: 1.6;
  position: relative;
}
.chapter .kick {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--rubric);
  text-align: center;
}
.chapter h1 {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.15em;
  line-height: 1.35;
  text-align: center;
  font-variant: small-caps;
  letter-spacing: 0.02em;
  color: var(--rubric);
  margin: 0.35rem auto 1.5rem;
  max-width: 28em;
  text-wrap: balance;
}
.chapter p { margin: 0 0 0.9em; position: relative; hyphens: auto; -webkit-hyphens: auto; }
.chapter p.first::first-letter {
  float: left;
  font-size: 3.1em;
  line-height: 0.85;
  padding: 0.06em 0.08em 0 0;
  color: var(--rubric);
}
.sn {
  position: absolute;
  left: -1.9rem;
  top: 0.35em;
  width: 1.6rem;
  text-align: right;
  font-family: var(--font-sans);
  font-size: 0.62rem;
  color: var(--rubric);
  font-variant-numeric: tabular-nums;
  user-select: none;
  -webkit-user-select: none;
}
sup.fn {
  font-family: var(--font-sans);
  font-size: 0.6em;
  color: var(--rubric);
  cursor: pointer;
  padding: 0 0.15em;
  user-select: none;
  -webkit-user-select: none;
}
mark.hl { color: inherit; border-radius: 2px; cursor: pointer; background: var(--hl-yellow); }
mark.hl.blue { background: var(--hl-blue); }
mark.hl.pink { background: var(--hl-pink); }
mark.hl.has-note { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.listen { display: grid; gap: 0.4rem; margin: 0 0 1.5rem; font-family: var(--font-sans); font-size: 0.8rem; color: var(--muted); }
.listen audio { width: 100%; }

.prompt {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin: 0.4rem 0 1.4rem;
  display: grid;
  gap: 0.6rem;
}
.prompt .lbl { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.prompt p { margin: 0; font-family: var(--read-font, var(--font-serif)); font-size: calc(var(--fs) * 0.95); line-height: 1.45; }
.prompt .thumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.prompt .thumbs img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--rubric); }
.prompt .btn { justify-self: start; }

.chnav { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; font-family: var(--font-sans); }
.chnav a { flex: 1; text-decoration: none; border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.9rem; font-size: 0.85rem; display: grid; gap: 0.1rem; }
.chnav a small { color: var(--muted); font-size: 0.72rem; }
.chnav a.next { text-align: right; }
.chnav a:hover { border-color: var(--accent); }
.srcline { font-family: var(--font-sans); font-size: 0.75rem; color: var(--muted); margin-top: 2rem; }

.rfoot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 1rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
  font-size: 0.72rem;
  color: var(--muted);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  font-variant-numeric: tabular-nums;
}

/* Desktop study layout: contents | text | margin notes */
@media (min-width: 1100px) {
  .reader { display: grid; grid-template-columns: 240px minmax(0, 1fr) 280px; gap: 1.5rem; padding: 0 1.5rem; }
  .toc-col {
    display: block;
    position: sticky;
    top: calc(var(--bar-h) + 1rem);
    align-self: start;
    max-height: calc(100vh - var(--bar-h) - 3rem);
    overflow-y: auto;
    padding: 1.5rem 0.5rem 2rem 0;
    border-right: 1px solid var(--line);
  }
  .margin { display: block; position: relative; border-left: 1px solid var(--line); }
  .bar .toc-btn { display: none; }
  .chapter { padding-left: 2.6rem; padding-right: 1rem; }
}
.toc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.1rem; font-size: 0.85rem; }
.toc-list a { display: grid; grid-template-columns: 2.2rem 1fr; gap: 0.3rem; text-decoration: none; padding: 0.4rem 0.5rem; border-radius: 8px; color: var(--muted); line-height: 1.35; }
.toc-list a b { font-weight: 500; font-family: var(--font-serif); color: var(--rubric); font-size: 0.95rem; }
.toc-list a:hover { background: var(--paper-2); color: var(--ink); }
.toc-list a.cur { background: var(--paper-2); color: var(--ink); }
.toc-list a.done span::after { content: " ✓"; color: var(--accent); }
.toc-col h2, .sheet-panel h2 { font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0 0 0.6rem 0.5rem; }

.m-item {
  position: absolute;
  left: 1rem;
  right: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 0.35rem;
  transition: background 0.3s;
}
.m-item .lbl { display: block; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--rubric); font-weight: 600; margin-bottom: 0.15rem; }
.m-item.note { color: var(--ink); cursor: pointer; }
.m-item.note q { display: block; font-family: var(--font-serif); font-style: italic; color: var(--muted); quotes: none; margin-bottom: 0.2rem; }
.m-item img { display: block; width: 100%; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; }
.m-item.flash { background: var(--paper-2); }

/* ---------- selection bar ---------- */
#selbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(2.6rem + env(safe-area-inset-bottom, 0px));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem;
  border-radius: 14px;
  background: #26241f;
  color: #f4efe6;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}
/* Phones: sit above Chrome's tap-to-search bar, which covers the bottom edge. */
@media (pointer: coarse) { #selbar { bottom: calc(5.5rem + 20px + env(safe-area-inset-bottom, 0px)); } }
#selbar button { background: none; border: 0; color: inherit; padding: 0.5rem 0.6rem; cursor: pointer; border-radius: 8px; }
#selbar button:hover { background: rgba(255, 255, 255, 0.08); }
#selbar .sep { width: 1px; align-self: stretch; background: #57524c; margin: 0 0.15rem; }
.dot { width: 22px; height: 22px; border-radius: 50%; display: inline-block; vertical-align: middle; border: 2px solid transparent; }
.dot.yellow { background: #f2c14e; }
.dot.blue { background: #8fc1e8; }
.dot.pink { background: #e89aa6; }
#selbar button.color { padding: 0.35rem; }

/* ---------- bottom sheet ---------- */
#sheet { position: fixed; inset: 0; z-index: 50; }
#sheet .scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.45); }
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 1.1rem max(1.1rem, env(safe-area-inset-right, 0px)) calc(1.2rem + env(safe-area-inset-bottom, 0px)) max(1.1rem, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 0.9rem;
}
@media (min-width: 700px) {
  .sheet-panel { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 2rem)); border-radius: 16px; border: 1px solid var(--line); }
}
.sheet-panel q { font-family: var(--font-serif); font-size: 1.1rem; font-style: italic; quotes: none; line-height: 1.45; }
.sheet-panel .fnote { font-family: var(--font-serif); font-size: 1.08rem; line-height: 1.5; }
.sheet-panel textarea {
  width: 100%;
  min-height: 6.5rem;
  resize: vertical;
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  font: 1rem/1.45 var(--font-sans);
}
.sheet-panel .acts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sheet-panel .acts .grow { flex: 1; }
.colors { display: flex; gap: 0.6rem; }
.colors button { background: none; border: 0; padding: 0; cursor: pointer; }
.colors .dot { width: 30px; height: 30px; }
.colors button[aria-pressed="true"] .dot { border-color: var(--ink); }
.seg { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.seg button { flex: 1; min-width: 5rem; border: 1px solid var(--line); background: var(--paper-2); border-radius: 10px; padding: 0.6rem; cursor: pointer; }
.seg button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.sheet-panel .big-img { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--sketch-paper); }

/* ---------- sketch pad ---------- */
#pad { position: fixed; inset: 0; z-index: 60; background: var(--paper); display: flex; flex-direction: column; }
#pad header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 0.75rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
#pad header .q { flex: 1; min-width: 0; font-family: var(--font-serif); font-style: italic; color: var(--muted); font-size: 0.95rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; text-align: center; }
#pad canvas { flex: 1; width: 100%; min-height: 0; touch-action: none; background: var(--sketch-paper); cursor: crosshair; display: block; }
#pad .tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}
#pad .tools button { background: none; border: 1px solid transparent; border-radius: 10px; padding: 0.45rem 0.6rem; cursor: pointer; color: var(--ink); }
#pad .tools button[aria-pressed="true"] { border-color: var(--accent); }
#pad .tools .ink { padding: 0.3rem; }
#pad .tools .ink .dot { width: 26px; height: 26px; }
#pad .tools .sep { width: 1px; height: 1.6rem; background: var(--line); }

/* ---------- notebook ---------- */
.nb { max-width: 720px; margin: 0 auto; padding: 1.25rem 1rem 4rem; display: grid; gap: 1.2rem; }
.nb h1 { font-family: var(--font-serif); font-weight: 500; font-size: 2rem; color: var(--accent); margin: 0; }
.nb .list { display: grid; gap: 0.75rem; }
.nb-item {
  display: grid;
  gap: 0.4rem;
  text-align: left;
  text-decoration: none;
  width: 100%;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  cursor: pointer;
}
.nb-item:hover { border-color: var(--accent); }
.nb-item q { font-family: var(--font-serif); font-size: 1.08rem; line-height: 1.45; quotes: none; }
.nb-item .note { font-size: 0.9rem; }
.nb-item small { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.75rem; }
.nb-item small .dot { width: 10px; height: 10px; border: 0; }
.nb-item img { width: 100%; max-height: 260px; object-fit: contain; background: var(--sketch-paper); border-radius: 8px; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.backup { border-top: 1px solid var(--line); padding-top: 1.2rem; display: grid; gap: 0.7rem; }
.backup h2 { font-size: 1rem; margin: 0; }
.backup p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.backup .acts { display: flex; gap: 0.5rem; flex-wrap: wrap; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(3.2rem + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 1rem);
  z-index: 70;
  background: var(--ink);
  color: var(--paper);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  width: max-content;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { color: var(--muted); text-align: center; padding: 4rem 1rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- course styles ---------- */
.badge {
  justify-self: start;
  font-style: normal;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.guided { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.badge.illustrated { border-color: var(--accent); color: var(--accent); }
.featured h2 { font-family: var(--font-serif); font-weight: 600; font-size: 1.35rem; margin: 0; }
.featured .about { color: var(--muted); font-size: 0.82rem; margin: 0.1rem 0 0.9rem; }
.feat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1rem; }
.feat-card {
  display: flex;
  gap: 1rem;
  align-items: center;
  text-decoration: none;
  padding: 1rem;
  border: 1px solid var(--accent);
  border-radius: 14px;
  background: var(--paper-2);
}
.feat-card .cover { width: 84px; flex: none; }
.feat-card > span:last-child { display: grid; gap: 0.35rem; min-width: 0; }
.feat-card b { font-family: var(--font-serif); font-size: 1.25rem; font-weight: 600; line-height: 1.25; }
.feat-card small { color: var(--muted); font-size: 0.78rem; }

.thoughts {
  font-family: var(--font-sans);
  border-top: 1px solid var(--line);
  margin-top: 2rem;
  padding-top: 1.2rem;
  display: grid;
  gap: 0.75rem;
}
.thoughts .lbl, .prompt .lbl { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.thoughts p { margin: 0; font-family: var(--read-font, var(--font-serif)); font-size: var(--fs); line-height: 1.55; }
.thoughts .listen { margin: 0; }

.prompt-acts { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.linkish { background: none; border: 0; padding: 0.3rem 0; color: var(--muted); font: inherit; font-size: 0.82rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkish:hover { color: var(--accent); }
.teacher { margin: 0; display: grid; gap: 0.4rem; }
.teacher img { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--sketch-paper); cursor: zoom-in; }
.teacher figcaption { font-size: 0.75rem; color: var(--muted); }
.teacher audio { width: 100%; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.pair > span { display: grid; gap: 0.25rem; }
.pair img { height: 180px; }

.cover.photo { position: relative; background: #1b1b1e; }
.cover.photo .ct {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 1.6em 0.5em 0.55em;
  background: linear-gradient(to top, rgba(10, 8, 6, 0.92), rgba(10, 8, 6, 0.6) 60%, transparent);
  color: #f3e9cc;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  line-height: 1.2;
  text-align: center;
  text-wrap: balance;
}
.cont .cover.photo .ct, .feat-card .cover.photo .ct { display: none; }

.tip {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.5;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin: 0 0 1.6rem;
  display: grid;
  gap: 0.6rem;
}
.tip .lbl { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.tip .btn { justify-self: start; }
.help-list { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.35rem; font-family: var(--font-sans); font-size: 0.9rem; line-height: 1.5; }
.help-list b { font-weight: 600; }

.libtabs { max-width: 480px; }
.libtabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.shelf .feat-row { margin-top: 0.2rem; }

.fonts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.fonts button { display: grid; gap: 0.1rem; text-align: left; border: 1px solid var(--line); background: var(--paper-2); border-radius: 10px; padding: 0.6rem 0.75rem; cursor: pointer; font-size: 1.05rem; line-height: 1.25; }
.fonts button small { font-family: var(--font-sans); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.fonts button[aria-pressed="true"] { border-color: var(--accent); }
.fonts button[aria-pressed="true"] span { color: var(--accent); }
:root[data-font="dyslexic"] .chapter p { word-spacing: -0.12em; line-height: 1.7; }
:root[data-font="dyslexic"] .chapter p.first::first-letter,
:root[data-font="plexmono"] .chapter p.first::first-letter { float: none; font-size: inherit; padding: 0; color: inherit; }

/* ---------- homepage opening ---------- */
.bar .mark { color: var(--accent); font-size: 1.3rem; padding: 0.35rem 0.4rem; }
/* Phones: title, sketch, buttons, then the description, so the sketch and
   the buttons are on the first screen. Wide screens: text left, sketch right. */
.hero { display: grid; gap: 1.1rem; padding-top: 0.2rem; }
.hero h1 { font-family: var(--font-serif); font-weight: 500; font-size: clamp(2.3rem, 6.5vw, 4rem); line-height: 1.02; color: var(--accent); margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
.hero .tag { font-family: var(--font-serif); font-style: italic; font-size: clamp(1.2rem, 2.4vw, 1.6rem); color: var(--ink); opacity: 0.85; margin: 0.3rem 0 0; }
.hero .tag em { color: var(--accent); opacity: 1; }
.hero .sub { font-size: 1rem; line-height: 1.6; color: var(--muted); margin: 0; max-width: 32em; }
.hero-acts { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.hero-acts .btn { padding: 0.75rem 1.15rem; font-size: 0.95rem; }
.hero .fine { font-size: 0.8rem; color: var(--muted); margin: -0.4rem 0 0; }
.board { margin: 0; display: grid; gap: 0.7rem; }
.board .paper { background: #fff; border-radius: 6px; padding: 6px; box-shadow: 0 14px 36px rgba(0, 0, 0, 0.4); }
.board .paper img { display: block; width: 100%; height: auto; max-height: 42vh; object-fit: contain; border-radius: 2px; }
.board .quote {
  display: block; border-left: 3px solid var(--accent); padding: 0.1rem 0 0.1rem 0.8rem;
  font-family: var(--font-serif); font-size: 1rem; line-height: 1.45; color: var(--ink); text-decoration: none;
}
.board .quote small { display: block; font-family: var(--font-sans); font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--rubric); margin-bottom: 0.2rem; }
.board .quote mark { background: var(--hl-yellow); color: inherit; border-radius: 2px; }
.board .quote:hover small { color: var(--accent); }
.hero.compact { gap: 0; }
.hero.compact h1 { font-size: clamp(2.1rem, 5vw, 2.8rem); }
.hero.compact .tag { font-size: 1.2rem; }
@media (min-width: 900px) {
  .hero:not(.compact) {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    grid-template-areas: "title board" "sub board" "acts board" "fine board";
    grid-template-rows: auto auto auto 1fr;
    column-gap: 3.5rem; row-gap: 1.2rem; align-items: start; padding: 1rem 0 0.5rem;
  }
  .hero .h-title { grid-area: title; }
  .hero .board { grid-area: board; align-self: center; }
  .hero .hero-acts { grid-area: acts; }
  .hero .sub { grid-area: sub; font-size: 1.05rem; }
  .hero .fine { grid-area: fine; margin: 0; }
  .board .paper img { max-height: 52vh; }
}
#shelves { scroll-margin-top: calc(var(--bar-h) + 1rem); }
.about-site { border-top: 1px solid var(--line); padding-top: 1.4rem; display: grid; gap: 0.7rem; max-width: 42em; }
.about-site h2 { font-family: var(--font-serif); font-weight: 600; font-size: 1.35rem; margin: 0; }
.about-site p { margin: 0; color: var(--muted); line-height: 1.6; }
.lib { max-width: 1120px; }

/* ---------- imported pages: headings, lists, quotations, tables, links ---------- */
.chapter p.sh { font-family: var(--font-serif); font-weight: 600; font-size: 1.12em; line-height: 1.3; color: var(--ink); margin: 1.6em 0 0.6em; text-wrap: balance; }
.chapter p.sh .sn { top: 0.45em; }
.chapter p.li { padding-left: 1.3em; margin-bottom: 0.45em; }
.chapter p.li::before { content: "•"; position: absolute; left: 0.35em; color: var(--accent); }
.chapter p.li.ol::before { content: attr(data-n) "."; left: 0; font-size: 0.85em; top: 0.1em; color: var(--muted); }
.chapter p.bq { margin-left: 1.1em; padding-left: 0.9em; border-left: 2px solid var(--line); font-style: italic; color: var(--ink); opacity: 0.92; }
.chapter p.bq .sn { left: -3em; }
.chapter a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.chapter .tbl { position: relative; overflow-x: auto; margin: 0.4em 0 1.2em; font-family: var(--font-sans); font-size: 0.82em; line-height: 1.45; }
.chapter .tbl table { border-collapse: collapse; min-width: 100%; }
.chapter .tbl td, .chapter .tbl th { border: 1px solid var(--line); padding: 0.4em 0.6em; vertical-align: top; text-align: left; }
.chapter .tbl tr:first-child td, .chapter .tbl th { background: var(--paper-2); font-weight: 600; }
.chapter .tbl .sn { display: none; }

/* ---------- site menu, search, seasonal reminder ---------- */
.libbar { flex-wrap: wrap; row-gap: 0; }
.libbar .title { flex: 1; }
.menu { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 0.2rem; }
.menu .support { color: var(--accent); font-weight: 600; }
@media (max-width: 600px) {
  .libbar .title { display: none; }
  .menu { flex: 1; justify-content: flex-end; }
  .menu a, .menu button { padding: 0.45rem 0.35rem; font-size: 0.82rem; }
}
.libsearch input {
  width: 100%; max-width: 480px; background: var(--paper-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 0.7rem 0.85rem; font: 1rem var(--font-sans);
}
.libsearch input:focus { border-color: var(--accent); outline: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#seasonal {
  position: relative; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 0.2rem 0.6rem;
  padding: 0.45rem 2.4rem 0.45rem 0.8rem; background: var(--paper-2); border-bottom: 1px solid var(--accent);
  font-size: 0.8rem; text-align: center; color: var(--ink);
}
#seasonal a { color: var(--accent); font-weight: 600; white-space: nowrap; }
#seasonal button { position: absolute; right: 0.4rem; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 0.25rem 0.4rem; }
/* Never let one long item (e.g. a sketch that failed to load and shows its
   description instead) widen the page past the screen. */
.lib > *, .hero > * { min-width: 0; }
.hero { grid-template-columns: minmax(0, 1fr); }
.board .paper img { overflow: hidden; }

/* ---------- sketch colourways ---------- */
/* My sketches follow the page: light ink on dark paper at night, brown ink
   on cream in sepia, and as drawn in light. Readers' own sketches stay as
   they drew them. */
:root { --ink-paper: #1d1d21; }
:root[data-rt="sepia"] { --ink-paper: #fbf5e6; }
:root[data-rt="light"] { --ink-paper: #ffffff; }
img.ink { filter: url(#ink-night); background: var(--ink-paper) !important; }
:root[data-rt="sepia"] img.ink { filter: url(#ink-sepia); }
:root[data-rt="light"] img.ink { filter: none; }
.board .paper { background: var(--ink-paper); }

/* ---------- quotes and text search ---------- */
.nb-item.quote { cursor: default; }
.qacts { display: flex; gap: 0.5rem; flex-wrap: wrap; }
#texthits:empty { display: none; }
#texthits h2 { font-family: var(--font-serif); font-weight: 600; font-size: 1.35rem; margin: 0 0 0.6rem; }
#texthits h2 small { font-family: var(--font-sans); font-weight: 400; font-size: 0.8rem; color: var(--muted); margin-left: 0.4rem; }
#texthits .hint { font-size: 0.8rem; color: var(--muted); margin: 0.6rem 0 0; }
.hits { display: grid; gap: 0.6rem; }
.hit { display: grid; gap: 0.35rem; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-2); color: inherit; text-decoration: none; font-family: var(--font-serif); font-size: 1.02rem; line-height: 1.45; }
.hit:hover { border-color: var(--accent); }
.hit mark { background: rgba(242, 193, 78, 0.35); color: inherit; border-radius: 3px; padding: 0 1px; }
.hit small { font-family: var(--font-sans); font-size: 0.75rem; color: var(--muted); }

/* Notebook filters: three on the first line, two on the second. */
.nb .seg { display: grid; grid-template-columns: repeat(6, 1fr); }
.nb .seg button { min-width: 0; grid-column: span 2; }
.nb .seg button:nth-child(n + 4) { grid-column: span 3; }

/* Why sketch: the one-time explainer and the look-back nudge */
.sketch-tip ol { margin: 0.4rem 0 0.8rem; padding-left: 1.2rem; }
.sketch-tip li { margin: 0.2rem 0; }
.sketch-tip p { margin: 0.3rem 0 0; }
.sketch-tip .acts { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.lookback { font-family: var(--font-sans); font-size: 0.85rem !important; color: var(--muted); margin: 0.2rem 0 0.6rem !important; }

/* "The" sits small above "Catholic Sketchbook" */
.lib h1 small { display: block; font-size: 0.36em; letter-spacing: 0.22em; text-transform: uppercase; font-weight: 600; margin-bottom: 0.15em; }
