:root {
  color-scheme: light;
  --fg: #2b241d;
  --bg: #fbf8f3;
  --bg-alt: #f2ece2;
  --accent: #7a2e2e;
  --accent-2: #9c5a1e;
  --muted: #746a5c;
  --border: #e2d8c7;
  --sidebar-width: 19rem;
  --link: #6b3a12;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Lora", Georgia, "Times New Roman", serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.65;
  font-size: 17px;
}

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; align-items: flex-start; }
.sidebar {
  width: var(--sidebar-width); flex-shrink: 0;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 1.75rem 1.5rem 3rem;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.site-nav { flex: 1 1 auto; overflow-y: auto; padding-bottom: 1rem; }
main {
  flex: 1 1 auto; min-width: 0;
  padding: 2.5rem 2rem 5rem;
}
.prose { max-width: 44rem; margin: 0 auto; }

/* ---------- Sidebar header ---------- */
.site-title-wrap { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.site-logo { height: 2.75rem; width: auto; border-radius: 3px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.site-title {
  font-family: "Inter", sans-serif; font-size: 1.5rem; font-weight: 700;
  color: var(--accent); letter-spacing: -0.01em;
}
.site-subtitle {
  margin: 0.5rem 0 1.25rem; color: var(--muted); font-style: italic; font-size: 0.9rem;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 { font-family: "Inter", sans-serif; color: var(--accent); line-height: 1.25; }
h1 { font-size: 2rem; margin: 0 0 1.25rem; }
h2 { font-size: 1.4rem; margin-top: 2.25rem; }
h3 { font-size: 1.15rem; margin-top: 1.75rem; color: var(--accent-2); }
main img { max-width: 100%; height: auto; border-radius: 3px; }
.pdf-viewer-wrap { max-width: 68rem; margin: 0 auto 2rem; }
.pdf-viewer { height: calc(100vh - 3rem); min-height: 640px; }
.pdf-viewer iframe {
  width: 100%; height: 100%; border: 1px solid var(--border); border-radius: 4px;
  background: #fff; display: block;
}
.pdf-viewer-fallback { margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--muted); text-align: center; }
a { color: var(--link); text-decoration-color: color-mix(in srgb, var(--link) 35%, transparent); }
a:hover { text-decoration-color: var(--link); }
main p, main li { hyphens: auto; }
blockquote {
  margin: 1.25rem 0; padding: 0.25rem 1.25rem; border-left: 3px solid var(--accent-2);
  color: var(--muted); font-style: italic;
}

/* ---------- Sidebar nav (vertical tree) ---------- */
.site-nav { font-family: "Inter", sans-serif; font-size: 0.88rem; }
.nav-tree, .nav-tree ul { list-style: none; margin: 0; padding: 0; }
.nav-tree > li { margin-bottom: 0.15rem; }
.nav-tree a {
  display: block; padding: 0.35rem 0.5rem; border-radius: 4px;
  text-decoration: none; color: var(--fg);
}
.nav-tree a:hover { background: var(--border); }
.nav-tree summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
  padding: 0.35rem 0.5rem; border-radius: 4px; font-weight: 600; color: var(--accent);
}
.nav-tree summary:hover { background: var(--border); }
.nav-tree summary::-webkit-details-marker { display: none; }
.nav-tree summary::after { content: "▸"; font-size: 0.7em; color: var(--muted); margin-left: 0.5rem; flex-shrink: 0; }
.nav-tree details[open] > summary::after { content: "▾"; }
.nav-tree ul { padding-left: 0.9rem; margin: 0.1rem 0 0.1rem 0.6rem; border-left: 1px solid var(--border); }

/* ---------- Search (Pagefind UI) ---------- */
.site-search { margin-bottom: 1.25rem; }
.pagefind-ui { --pagefind-ui-font: "Inter", sans-serif; --pagefind-ui-text: var(--fg); --pagefind-ui-background: var(--bg); --pagefind-ui-border: var(--border); --pagefind-ui-primary: var(--accent); --pagefind-ui-scale: 0.92; }
.pagefind-ui__search-input { font-family: "Inter", sans-serif; }
.pagefind-ui__results-area {
  position: absolute; z-index: 300; width: min(28rem, 90vw);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18); padding: 0.5rem;
  max-height: 70vh; overflow-y: auto;
}

/* ---------- Attachments / footer ---------- */
.attachments { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.attachments h2 { margin-top: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.attachments ul { padding-left: 1.2rem; }
.site-footer { color: var(--muted); font-size: 0.85rem; }
.page-list li { margin-bottom: 0.4rem; }

/* ---------- Mobile sidebar toggle ---------- */
.sidebar-toggle-input { display: none; }
.sidebar-toggle-btn {
  display: none; position: fixed; top: 1rem; left: 1rem; z-index: 400;
  width: 2.75rem; height: 2.75rem; border-radius: 6px;
  background: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer;
}
.sidebar-toggle-btn span { width: 1.4rem; height: 2px; background: #fff; border-radius: 1px; }
.sidebar-overlay { display: none; }

@media (max-width: 860px) {
  .sidebar-toggle-btn { display: flex; }
  .layout { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 350;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: 4px 0 16px rgba(0,0,0,0.2);
  }
  .sidebar-toggle-input:checked ~ .layout .sidebar { transform: translateX(0); }
  .sidebar-toggle-input:checked ~ .sidebar-overlay {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 340;
  }
  main { max-width: 100%; padding: 4.5rem 1.25rem 4rem; }
}
