:root {
  --paper: #F6F1E7;
  --sheet: #FBF8F0;
  --ink: #1F3A5F;
  --red: #C0392B;
  --blue: var(--ink);
  --soft: #52647B;
  --line: #1F3A5F55;
  --faint-line: #1F3A5F2D;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Be Vietnam Pro", system-ui, sans-serif;
  --hand: "Patrick Hand", cursive;
  font: 100%/1.55 var(--sans);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper) url("notebook-grid.svg"); }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.shell { width: min(100%, 1220px); padding-inline: clamp(20px, 4.1vw, 56px); margin-inline: auto; }
.mast { border-bottom: 1px solid var(--line); background-color: var(--paper); }
.bar { min-height: 60px; display: flex; align-items: center; gap: clamp(18px, 4.2vw, 64px); }
.logo { display: inline-flex; align-items: center; gap: 8px; font: 700 1.6rem/1.2 var(--serif); white-space: nowrap; }
.logo img { display: block; flex: none; }
.bar nav { display: flex; align-items: center; gap: clamp(16px, 3vw, 40px); }
.bar nav a { display: inline-flex; position: relative; align-items: center; min-height: 44px; padding: 4px 0 7px; font-size: .88rem; font-weight: 600; }

.bar nav a::after, .underlined::after, .grade strong::after {
  content: "";
  position: absolute;
  inset-inline: -1px;
  bottom: 4px;
  height: 6px;
  background: url("ink-underline.svg") center / 100% 100% no-repeat;
  pointer-events: none;
}
.bar nav a::after, .grade strong::after { visibility: hidden; }
.bar nav a[aria-current]::after, .bar nav a:hover::after, .bar nav a:focus-visible::after,
.grade[aria-pressed=true] strong::after, .grade:hover strong::after, .grade:focus-visible strong::after { visibility: visible; }
.underlined { position: relative; width: fit-content; padding-bottom: 9px; }
.underlined::after { height: 8px; bottom: 0; }

.session-bar { font-size: .86rem; }
.session-bar p:not(:empty) { margin-top: 12px; }
.library { padding-bottom: 60px; }
.cover, .entry-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(245px, 32%, 340px);
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding-block: clamp(26px, 3.9vw, 50px) 24px;
}
.cover h1, .entry-title h1 {
  font: 650 clamp(2.2rem, 5.1vw, 4rem)/1.07 var(--serif);
  letter-spacing: -.043em;
  text-wrap: balance;
}
.book-series { margin-top: 6px; font-size: .9rem; color: var(--soft); }
.cover-label {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  width: min(100%, 495px);
  margin-top: 17px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--sheet);
  overflow-wrap: anywhere;
}
.cover-label div { padding: 5px 12px 7px; }
.cover-label div + div { border-left: 1px solid var(--faint-line); }
.cover-label dt { font-size: .72rem; color: var(--soft); }
.cover-label dd { font-size: .92rem; font-weight: 600; }
.last-session { min-height: 1.7em; margin-top: 8px; color: var(--soft); font-size: .81rem; }
.last-session time { color: var(--ink); font-weight: 600; }

.plot { position: relative; width: min(100%, 340px); justify-self: end; }
.plot img { display: block; width: 100%; height: auto; }
.plot figcaption { position: absolute; top: 30%; left: 78.5%; white-space: nowrap; font: 1.38rem/1 var(--hand); transform: rotate(-4deg); }

.library-spread {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 25%);
  gap: clamp(20px, 4.3vw, 60px);
  align-items: start;
  padding-top: 20px;
}
.library-contents { min-width: 0; }
.grade-grid {
  display: grid;
  grid-template-columns: 1fr 1.13fr .93fr;
  align-items: center;
  gap: clamp(9px, 1.45vw, 19px);
  padding: 5px 5px 7px;
}
.grade {
  position: relative;
  display: grid;
  justify-items: start;
  align-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 85px;
  padding: 8px 9px 9px 20px;
  border: 1px solid var(--ink);
  border-bottom-width: 3px;
  border-left-width: 3px;
  border-radius: 5px;
  text-align: left;
}
.grade::before { content: ""; position: absolute; inset: 0 auto 0 9px; border-left: 1px solid var(--line); }
.g10 { background: #B9CBD6; transform: rotate(-1.6deg); }
.g11 { background: #C7CEB6; min-height: 94px; transform: rotate(.9deg); }
.g12 { background: #D9BEA2; min-height: 81px; transform: rotate(-.9deg); }
.grade:only-child { grid-column: 1 / -1; width: min(100%, 230px); }
.grade strong { position: relative; display: block; z-index: 1; padding-bottom: 5px; font: 650 clamp(1.25rem, 2.5vw, 1.69rem)/1.02 var(--serif); }
.grade strong::after { bottom: 0; }
.grade small { font-size: .75rem; line-height: 1.3; }
.grade-mark { position: absolute; right: 10px; bottom: 5px; color: #1F3A5F80; font: 1.15rem/1 var(--hand); }
.grade[aria-pressed=true] { border-bottom-width: 4px; }

.shelf { margin-top: 18px; }
.shelf-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding-bottom: 10px; }
.shelf-top h2, .account-view > h1 { font: 650 clamp(1.75rem, 3.2vw, 2.35rem)/1.13 var(--serif); letter-spacing: -.035em; }
.searchbox {
  display: flex;
  align-items: center;
  gap: 7px;
  width: min(100%, 238px);
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--sheet);
  padding: 5px 9px;
}
.searchbox:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.searchbox input { min-width: 0; width: 100%; min-height: 30px; padding: 0; border: 0; outline: none; background: transparent; font-size: .88rem; }
.search-icon { position: relative; width: 12px; height: 12px; flex: none; margin-inline: 3px 5px; border: 1px solid currentColor; border-radius: 50%; }
.search-icon::after { content: ""; position: absolute; right: -5px; bottom: -3px; width: 6px; border-top: 1px solid; transform: rotate(45deg); }

.chapter { border-top: 1px solid var(--line); }
.chapter:last-child { border-bottom: 1px solid var(--line); }
.chapter summary {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 51px;
  padding: 5px 8px 5px 4px;
  cursor: pointer;
  list-style: none;
}
.chapter summary::-webkit-details-marker { display: none; }
.chapter summary::after { content: ""; width: 7px; height: 7px; flex: none; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(-45deg); }
.chapter[open] summary::after { transform: rotate(45deg); }
.chapter summary:hover, .chapter[open] summary { background-color: #1F3A5F06; }
.chapter-no { flex: none; min-width: 34px; text-align: center; font: 650 1.95rem/.95 var(--serif); }
.chapter-title { font: 650 clamp(1.1rem, 2.2vw, 1.38rem)/1.16 var(--serif); overflow-wrap: anywhere; }
.chapter-count { margin-left: auto; flex: none; font-size: .74rem; color: var(--soft); }
.chapter-lessons { padding-bottom: 5px; }
.lesson {
  display: flex;
  align-items: baseline;
  gap: 9px;
  width: 100%;
  min-height: 44px;
  padding: 8px 9px 8px 6px;
  border: 0;
  border-top: 1px solid var(--faint-line);
  background: transparent;
  text-align: left;
  line-height: 1.3;
}
.lesson:enabled:hover { background: var(--sheet); }
.lesson-number { min-width: 42px; color: var(--red); font-size: .75rem; font-weight: 600; white-space: nowrap; }
.lesson-name { min-width: 0; font-size: .92rem; font-weight: 600; overflow-wrap: anywhere; }
.lesson-leader { flex: 1 0 13px; border-bottom: 1px dotted var(--line); align-self: baseline; }
.lesson-details { display: inline-flex; align-items: center; justify-content: end; flex: none; gap: 7px; color: var(--soft); white-space: nowrap; font-size: .76rem; }
.lesson-details time { color: var(--ink); font-variant-numeric: tabular-nums; }
.lesson-details svg { width: 15px; height: 15px; vertical-align: middle; }
.lesson-details .learned { display: inline-flex; align-items: center; gap: 3px; color: var(--red); font: 1rem/1 var(--hand); }
.lesson:disabled { color: var(--soft); }
.lesson:disabled .lesson-number { color: var(--soft); }
.lesson:disabled .lesson-name { font-weight: 400; }
.results { border-bottom: 1px solid var(--line); }
.empty, .hit-count { padding: 10px 0; color: var(--soft); font-size: .88rem; }

.book-margin { min-width: 0; margin-top: 3px; padding-left: 17px; border-left: 1px solid #C0392B9E; }
.margin-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.margin-heading h2 { font: 1.55rem/1.16 var(--hand); }
.text-button {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 6px 2px 3px;
  font-size: .76rem;
  font-weight: 600;
}
.text-button:hover { border-color: var(--red); }
.margin-entry {
  padding: 7px 0 9px;
  border-bottom: 1px solid var(--faint-line);
  font: 1.34rem/1.38 var(--hand);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.margin-entry.blank { min-height: 32px; border-bottom-style: dotted; }
.book-references { margin-top: 18px; color: var(--soft); font-size: .78rem; }
.book-references summary { cursor: pointer; padding: 6px 0; }
.book-references ul { margin: 4px 0 0; padding-left: 17px; }
.book-references li + li { margin-top: 7px; }
.book-references a { text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.book-references a:hover { text-decoration-color: var(--red); }

/* Presentation controls. The slide renderer and printable layout live in lecture.css. */
dialog { padding: 0; border: 1px solid var(--ink); border-radius: 6px; color: var(--ink); width: min(940px, 95vw); max-height: 95dvh; background: var(--paper); }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #1F3A5F5E; }
body:has(dialog[open]) { overflow: hidden; }
.viewer-head, .viewer-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px; }
.viewer-head { border-bottom: 1px solid var(--line); }
.viewer-head > div { flex: 1; min-width: 0; }
.viewer-head .icon-button { background: var(--sheet); border: 1px solid var(--line); border-radius: 5px; width: 35px; height: 35px; font-size: 1.4rem; flex: none; line-height: 1; }
#deck-meta { font-size: .76rem; color: var(--soft); }
#slide { overflow: auto; }
.viewer-foot { border-top: 1px solid var(--line); }
.tools, .pager { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.viewer-foot button { border: 1px solid var(--line); border-radius: 5px; padding: 6px 9px; background: var(--sheet); font-size: .84rem; }
.viewer-foot button:disabled { opacity: .5; }
.viewer-foot .primary { color: var(--sheet); border-color: var(--ink); background: var(--ink); }
#count { font-variant-numeric: tabular-nums; }
#viewer:fullscreen #slide, :fullscreen #viewer #slide { flex: 1; align-content: center; }
#print-pages { display: none; }
.diagram { margin: 0; border: 1px solid #dce1ef; border-radius: 9px; background: #fff; padding: 7px; }
.diagram canvas { display: block; width: 100%; height: auto; }
.diagram figcaption { text-align: center; font-size: .86rem; color: #555d73; line-height: 1.4; padding: 4px 7px; }
@media print {
  body > * { display: none !important; }
  body > #print-pages { display: block !important; }
  body:has(dialog[open]) { overflow: visible; }
  body { print-color-adjust: exact; }
  .diagram { max-width: 78mm; }
}

@media (max-width: 760px) {
  .library-spread { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .cover { grid-template-columns: minmax(0, 1fr) minmax(150px, 32%); gap: 8px; }
  .book-margin { max-width: none; }
  .grade-grid { gap: 12px; }
  .grade-mark { display: none; }
}
@media (max-width: 500px) {
  .shell { padding-inline: 16px; }
  .bar { gap: 5px 16px; flex-wrap: wrap; min-height: 53px; padding-block: 5px; }
  .logo { font-size: 1.37rem; }
  .bar nav { order: 4; flex-basis: 100%; gap: 22px; }
  .bar nav a { min-height: 36px; font-size: .82rem; }
  .cover { grid-template-columns: minmax(0, 1fr); padding-top: 22px; padding-bottom: 12px; }
  .cover h1 { text-wrap: wrap; }
  .cover-plot { width: min(54%, 182px); margin-top: -3px; }
  .plot figcaption { font-size: 1.14rem; }
  .library-spread { padding-top: 13px; }
  .grade-grid { gap: 8px; padding-inline: 3px; }
  .grade { padding-left: 12px; min-height: 71px; }
  .grade::before { left: 5px; }
  .g11 { min-height: 78px; }
  .g12 { min-height: 69px; }
  .grade small { font-size: .68rem; }
  .shelf { margin-top: 13px; }
  .shelf-top h2 { margin-right: auto; }
  .searchbox { width: 100%; }
  .lesson { gap: 5px; padding-inline: 3px; }
  .lesson-number { min-width: 34px; font-size: .69rem; }
  .lesson-name { font-size: .84rem; }
  .lesson-leader { flex-basis: 7px; }
  .lesson-details { gap: 3px; font-size: .69rem; }
  .lesson-details .learned { font-size: .9rem; }
  .lesson-details svg { width: 12px; height: 12px; }
  .chapter-no { min-width: 28px; font-size: 1.65rem; }
}
