:root {
    --cream: #f7f2e8; --cream-deep: #ede7d7; --gold: #7A5C12; --gold-soft: #d4b76e;
    --ink: #2a2118; --ink-soft: #544535; --rule: rgba(42,33,24,0.15); --card: #ffffff;
    --shadow: 0 2px 8px rgba(42,33,24,0.06);
    --selection-bg: var(--gold); --selection-fg: var(--cream);
  }
  :root[data-theme="dark"] {
    --cream: #1a1612; --cream-deep: #0f0c09; --gold: #c9a14a; --gold-soft: #8a6e30;
    --ink: #e8ddc7; --ink-soft: #b8a888; --rule: rgba(232,221,199,0.15); --card: #221d17;
    --shadow: 0 2px 10px rgba(0,0,0,0.4);
    --selection-bg: var(--gold); --selection-fg: var(--cream-deep);
  }
  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body {
    margin: 0; background: var(--cream); color: var(--ink);
    font-family: "EB Garamond", Georgia, serif;
    font-size: 1.06rem; line-height: 1.72;
    transition: background 0.3s ease, color 0.3s ease;
  }
  ::selection { background: var(--selection-bg); color: var(--selection-fg); }
  .skip-link { position: absolute; left: -9999px; top: auto; width: 1px; height: 1px; overflow: hidden; }
  .skip-link:focus { position: fixed; top: 1rem; left: 1rem; width: auto; height: auto; padding: 0.5rem 1rem; background: var(--gold); color: var(--cream); z-index: 1000; text-decoration: none; border-radius: 4px; }
  header.site-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 2rem; border-bottom: 1px solid var(--rule); background: var(--cream); position: sticky; top: 0; z-index: 50; backdrop-filter: blur(6px); }
  .crumb { font-family: "IM Fell English", Georgia, serif; font-style: italic; font-size: 0.95rem; color: var(--ink-soft); }
  .crumb a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px dotted var(--gold-soft); }
  .crumb a:hover, .crumb a:focus { color: var(--gold); }
  .controls { display: flex; gap: 0.5rem; }
  .toggle-btn { background: transparent; border: 1px solid var(--rule); color: var(--ink); padding: 0.4rem 0.7rem; border-radius: 4px; cursor: pointer; font-size: 1.1rem; transition: all 0.2s ease; line-height: 1; }
  .toggle-btn:hover, .toggle-btn:focus { border-color: var(--gold); color: var(--gold); outline: none; }
  main { max-width: 720px; margin: 0 auto; padding: 3rem 1.5rem 5rem; }

  .chapter-frame { text-align: center; margin-bottom: 3rem; padding-bottom: 2rem; border-bottom: 1px solid var(--rule); }
  .chapter-number { font-family: "Cinzel", serif; font-weight: 600; letter-spacing: 0.3em; font-size: 1.05rem; color: var(--gold); margin-bottom: 0.75rem; }
  h1.chapter-title { font-family: "Cinzel", serif; font-weight: 500; font-size: 1.85rem; letter-spacing: 0.08em; line-height: 1.25; margin: 0.25rem 0 1rem; color: var(--ink); }
  .chapter-subtitle { font-family: "IM Fell English", Georgia, serif; font-style: italic; font-size: 1.05rem; color: var(--ink-soft); margin-top: 0.75rem; }
  .chapter-pages { font-family: "IM Fell English", Georgia, serif; font-style: italic; font-size: 0.9rem; color: var(--ink-soft); margin-top: 1.25rem; opacity: 0.8; }

  h2.section-title { font-family: "Cinzel", serif; font-weight: 500; font-size: 1.1rem; letter-spacing: 0.22em; text-align: center; color: var(--gold); margin: 4rem 0 1.5rem; position: relative; }
  h2.section-title::before, h2.section-title::after { content: ""; display: inline-block; width: 2.5rem; height: 1px; background: var(--gold-soft); vertical-align: middle; margin: 0 0.9rem; }

  p { margin: 0 0 1.1rem; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
  p.first-para::first-letter { font-family: "Cinzel", serif; float: left; font-size: 3.2em; line-height: 0.85; padding: 0.15em 0.12em 0 0; color: var(--gold); font-weight: 500; }
  em, cite { font-style: italic; }

  .footnote-ref { font-size: 0.78em; vertical-align: super; line-height: 0; color: var(--gold); text-decoration: none; padding: 0 1px; }
  .footnote-ref:hover, .footnote-ref:focus { color: var(--ink); outline: none; }
  aside.footnotes { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-size: 0.92rem; line-height: 1.55; color: var(--ink-soft); }
  aside.footnotes h3 { font-family: "Cinzel", serif; font-size: 0.8rem; letter-spacing: 0.25em; font-weight: 500; color: var(--gold); margin: 0 0 1.25rem; }
  aside.footnotes ol { padding-left: 1.5rem; margin: 0; }
  aside.footnotes li { margin-bottom: 0.6rem; text-align: left; }
  aside.footnotes a { color: var(--gold); text-decoration: none; }
  aside.footnotes a:hover { color: var(--ink); }

  nav.chapter-nav { margin-top: 3rem; padding: 1.5rem 0; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
  nav.chapter-nav a { font-family: "IM Fell English", Georgia, serif; color: var(--gold); text-decoration: none; font-size: 1rem; padding: 0.5rem 0; border-bottom: 1px dotted var(--gold-soft); }
  nav.chapter-nav a:hover, nav.chapter-nav a:focus { color: var(--ink); border-bottom-color: var(--ink); }

  footer.site-foot { max-width: 720px; margin: 0 auto; padding: 2rem 1.5rem 3rem; text-align: center; font-family: "IM Fell English", Georgia, serif; font-style: italic; font-size: 0.9rem; color: var(--ink-soft); border-top: 1px solid var(--rule); }
  footer.site-foot a { color: var(--gold); text-decoration: none; border-bottom: 1px dotted var(--gold-soft); }
  footer.site-foot a:hover { color: var(--ink); border-bottom-color: var(--ink); }

  .ornament { text-align: center; color: var(--gold); margin: 2rem 0; font-size: 1.1rem; letter-spacing: 0.5em; }

  @media (max-width: 600px) {
    main { padding: 2rem 1.1rem 3.5rem; }
    header.site-head { padding: 0.9rem 1rem; }
    h1.chapter-title { font-size: 1.5rem; letter-spacing: 0.06em; }
    body { font-size: 1rem; }
    h2.section-title { font-size: 0.98rem; margin: 3rem 0 1.25rem; }
    h2.section-title::before, h2.section-title::after { width: 1.25rem; margin: 0 0.5rem; }
    nav.chapter-nav { flex-direction: column; align-items: flex-start; }
  }
  @media print {
    body { background: white; color: black; font-size: 11pt; }
    header.site-head, .controls, footer.site-foot, .skip-link, nav.chapter-nav { display: none; }
    main { max-width: 100%; padding: 0; }
    p.first-para::first-letter { color: black; }
    h1.chapter-title, h2.section-title, .chapter-number { color: black; }
    h2.section-title::before, h2.section-title::after { background: black; }
    a { color: black; }
    aside.footnotes { border-top-color: black; color: black; }
  }

/* skip-link:begin */
.skip-link{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0}
.skip-link:focus{position:fixed;top:.75rem;left:.75rem;z-index:1000;width:auto;height:auto;margin:0;padding:.6rem 1rem;overflow:visible;clip:auto;clip-path:none;background:#2a1a08!important;color:#FAF5EB!important;font-family:'Cinzel',Georgia,serif;font-size:.8rem;letter-spacing:.08em;text-decoration:none;border-radius:3px;outline:2px solid #FAF5EB;outline-offset:-4px;box-shadow:0 0 0 2px #2a1a08,0 0 0 4px #FAF5EB}
/* skip-link:end */
