:root {
  --ink: #2b2620;
  --muted: #8a8177;
  --accent: #7b4a2d;
  --paper: #faf7f2;
  --rule: #e4ddd2;
}

* { box-sizing: border-box; }

/* Toggled by the tab-switch and spoiler-reveal scripts in base.html */
.hidden { display: none; }

/* Always reserve the scrollbar gutter: otherwise the viewport width jumps
   ~15px when the scrollbar (dis)appears, which can flap the sidebar media
   query right at the breakpoint and settle it in the wrong state. */
html { overflow-y: scroll; }

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.125rem; /* 18px: long-form reading size; also keeps CPL in range */
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
}

header {
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 1.5rem;
}

.brand {
  font-size: 1.25rem;
  font-weight: bold;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-decoration: none;
}

/* Measure tuned with 18px Georgia to ~75 characters per line */
main {
  max-width: 38rem;
  margin: 0 auto;
  padding: 1.5rem;
}

/* Sidebar collapses away below the breakpoint; breadcrumb carries wayfinding */
.sidebar { display: none; }

@media (min-width: 60rem) {
  /* Sidebar anchors to the left edge (docs-site style); only the
     sidebar-less pages stay centered. */
  .layout.has-sidebar {
    display: grid;
    grid-template-columns: 16rem minmax(0, 38rem);
    gap: 2rem;
  }
  .layout.has-sidebar main { margin: 0; }
  .sidebar {
    display: block;
    padding: 1.5rem 0 1.5rem 1.5rem;
    font-size: 0.85rem;
    border-right: 1px solid var(--rule);
  }
}

.side-title { font-weight: bold; margin: 0.5rem 0 0.25rem; }
.side-title a { color: var(--ink); text-decoration: none; }
.side-list { list-style: none; margin: 0; padding: 0 0.75rem 0 0; }
.side-list li { margin: 0.15rem 0; }
.side-list a { text-decoration: none; }
.side-list a[aria-current="page"] {
  color: var(--ink);
  font-weight: bold;
}

.side-tabs {
  display: flex;
  gap: 0.25rem;
  margin: 0.5rem 0 0.75rem;
  border-bottom: 1px solid var(--rule);
}
.side-tab {
  font: inherit;
  font-size: 0.85rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.2rem 0.5rem;
  margin-bottom: -1px;
  color: var(--accent);
  cursor: pointer;
}
.side-tab.active {
  color: var(--ink);
  font-weight: bold;
  border-bottom-color: var(--accent);
}

/* Reading progress: visited chapter links recede */
.chapter-list a:visited,
.side-list a:visited { color: var(--muted); }
.side-list a[aria-current="page"]:visited { color: var(--ink); }

footer {
  max-width: 46rem;
  margin: 2rem auto 0;
  padding: 1rem 1.5rem 2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
}

a { color: var(--accent); }
a:hover { color: var(--ink); }

h1 { font-size: 1.7rem; margin: 0.5rem 0 0.25rem; }
h2 { font-size: 1.15rem; margin: 1.75rem 0 0.5rem; border-bottom: 1px solid var(--rule); padding-bottom: 0.25rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 0.1rem; }

.muted { color: var(--muted); }

.crumbs { font-size: 0.85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

.book-list li, .chapter-list li { margin: 0.3rem 0; }

.char-list {
  list-style: none;
  padding: 0;
  columns: 2;
}
.char-list li { margin: 0.25rem 0; break-inside: avoid; }
@media (max-width: 40rem) { .char-list { columns: 1; } }

.entry-list { list-style: none; padding: 0; }
.entry-list li { margin: 0.75rem 0; }
.entry-names { font-weight: bold; }

.appearance .names-line { margin: 0 0 0.2rem; font-size: 0.85rem; }
.appearance p { margin: 0.2rem 0; }

.spoiler { margin-top: 2rem; }
.spoiler-notice {
  font: inherit;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted);
  background: none;
  border: 1px dashed var(--rule);
  border-radius: 4px;
  padding: 0.6rem 0.9rem;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.spoiler-notice:hover { color: var(--ink); border-color: var(--muted); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: 0.9rem;
}
