:root {
  color-scheme: light;
  --paper: #fffdf8;
  --surface: #f6f2e8;
  --ink: #172d49;
  --muted: #4c5a6b;
  --accent: #795618;
  --line: #c9c1b0;
  --reading-size: 1.25rem;
}
:root[data-theme="sepia"] {
  --paper: #f6ecd8;
  --surface: #eee0c6;
  --ink: #403326;
  --muted: #5f503e;
  --accent: #704910;
  --line: #b8a98d;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121b2a;
  --surface: #1c293d;
  --ink: #edf0f6;
  --muted: #b7c2d3;
  --accent: #f2cd83;
  --line: #57657a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1rem/1.55 system-ui, sans-serif;
  overflow-wrap: anywhere;
}
a { color: var(--accent); text-underline-offset: .22em; }
a:focus-visible, button:focus-visible, summary:focus-visible, select:focus-visible, [tabindex="0"]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
button, select, summary {
  min-height: 44px;
  padding: .5rem .8rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }
button:hover:not(:disabled), summary:hover { background: var(--surface); }
.skip { position: fixed; top: .5rem; left: .5rem; padding: .7rem; background: var(--paper); z-index: 3; }
.skip:not(:focus) { transform: translateY(-200%); }
.reader-header {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.reader-bar {
  position: relative;
  width: min(68rem, 100% - 2rem);
  min-height: 64px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.reader-home { font-weight: 700; color: var(--ink); padding-block: .7rem; }
.reader-settings summary { list-style: none; font-weight: 650; }
.reader-settings summary::-webkit-details-marker { display: none; }
.reader-settings summary strong { font: 1.25em Georgia, serif; margin-inline-end: .2em; }
.settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + .4rem);
  width: min(22rem, 100%);
  padding: 1rem;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: .5rem;
  background: var(--paper);
  box-shadow: 0 .75rem 2rem #0003;
}
.setting-line, .size-controls, .swatches, .book-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.setting-line { justify-content: space-between; }
.size-controls output { min-width: 3rem; text-align: center; }
fieldset { border: 0; margin: 1rem 0 0; padding: 0; min-width: 0; }
legend { margin-bottom: .4rem; }
.swatches button { flex: 1; }
.swatches [aria-pressed="true"] { box-shadow: 0 0 0 2px var(--accent); font-weight: 700; }
.swatches [data-theme-choice="light"] { color: #172d49; background: #fffdf8; }
.swatches [data-theme-choice="sepia"] { color: #403326; background: #f6ecd8; }
.swatches [data-theme-choice="dark"] { color: #edf0f6; background: #121b2a; }
.reader-page { width: min(47rem, 100% - 2rem); margin: auto; }
.book-heading { padding: clamp(1.5rem, 5vw, 3rem) 0 1.5rem; }
.book-heading h1 {
  font: 600 clamp(2.25rem, 6vw, 3.65rem)/1.08 Georgia, serif;
  margin: .4rem 0 .7rem;
}
.book-heading > p:not(.reader-label) { max-width: 40rem; color: var(--muted); }
.reader-label { color: var(--accent); font: 750 .8rem/1.4 system-ui, sans-serif; letter-spacing: .1em; }
.book-actions { gap: .6rem 1.25rem; margin-top: 1.15rem; }
.language-picker { display: inline-flex; gap: .25rem; padding: .2rem; background: var(--surface); border-radius: .5rem; }
.language-picker a {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: .45rem .75rem;
  border-radius: .35rem;
  color: var(--ink);
  text-decoration: none;
}
.language-picker [aria-current="page"] { background: var(--paper); box-shadow: 0 0 0 1px var(--line); font-weight: 700; }
.chapter-picker { display: grid; gap: .35rem; padding-block: .8rem; border-block: 1px solid var(--line); }
.chapter-picker label { font-weight: 650; }
.chapter-picker select { width: 100%; min-width: 0; text-overflow: ellipsis; }
#reading {
  scroll-margin-top: 5.25rem;
  margin-block: 1.75rem 2rem;
  font: var(--reading-size)/1.75 Georgia, serif;
}
#chapter-title { font-size: 1.48em; line-height: 1.2; margin: .3em 0 .8em; }
#chapter-body h3 { font-size: 1.05em; line-height: 1.4; margin: 1.35em 0 .45em; }
#chapter-body p, #chapter-body ul { margin: 0 0 .85em; }
#chapter-body ul { padding-inline-start: 1.4em; }
#chapter-body blockquote { margin: 1em 0; padding-inline-start: 1em; border-inline-start: 3px solid var(--accent); font-style: italic; }
.course-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 1rem;
  padding: .85em;
  background: var(--surface);
  border: 1px solid var(--line);
  margin-block: 1em;
}
.course-table { overflow: auto; margin-block: 1em; }
.course-table table { border-collapse: collapse; min-width: 28rem; width: 100%; }
.course-table td { border: 1px solid var(--line); padding: .55em; vertical-align: top; }
.answer-line { min-height: 1.2em; border-bottom: 1px solid var(--line); margin-bottom: .35em; }
.chapter-navigation { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.reader-next { margin-top: 2.5rem; padding: 1rem 1.25rem 1.25rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--surface); }
.reader-next h2 { font: 600 1.55rem/1.25 Georgia, serif; margin: .4rem 0 .8rem; }
.reader-credit { width: min(47rem, 100% - 2rem); margin: 1.5rem auto; color: var(--muted); font-size: .88rem; }
.reader-credit p { margin: .3em 0; }

.course-illustration { display: block; max-width: 100%; height: auto; margin-block: 1em; }
