/* /library — category sidebar + grouped sections.
 *
 * Page-scoped plain CSS (linked only from library.html), so no Tailwind rebuild — the same
 * arrangement as 33-library-subject.css. Everything new on the page wears a lib-cat-* class.
 *
 * The problem this solves: one subject renders 30–38 category blocks (~1,000 rows for an
 * A-Level) as a single vertical stack with nothing to jump by. The blocks are now grouped into
 * SECTIONS (library_sections() in web/routes/site.py — the same keys, order, labels and hues as
 * the tabs on /library/<subject>) and a sticky sidebar lists them; on phones the same element
 * is a sticky horizontal strip under the site header. Category hues appear ONLY on the small
 * icon chip, the count pill and the active state — never as a wash — so a page whose picker
 * was just brought onto one cool ramp does not grow a rainbow somewhere else.
 */

/* ── Width ─────────────────────────────────────────────────────────────────────────────
   The grid view borrows base.html's main_class hook (as the video watch page does) so the
   cards keep their 3–4 columns beside a 15rem sidebar. Gated on the GRID view being shown:
   the PDF detail view keeps the 64rem column its fit-to-width sizing was tuned for
   (body.lib-detail-open, set by library.js's showLibView with the view switch). */
body:not(.lib-detail-open) #site-main.lib-wide { max-width: 86rem; }
/* The footer (rating card, logos) on the same edges as the wide grid above it. */
body:not(.lib-detail-open) #site-main.lib-wide ~ footer { max-width: 86rem; }

/* ── Layout ─────────────────────────────────────────────────────────────────────────── */
.lib-layout { display: grid; grid-template-columns: minmax(0, 1fr); }
.lib-grids { min-width: 0; }
/* A subject grid fills from /api/library-subject after first paint. While it waits it holds a
   screen's height, so the sections below appear below the fold instead of jumping down
   (CLS 0.5-0.66, speed audit 2026-11-16). */
.lib-grids[aria-busy="true"], .lib-grids [aria-busy="true"] { min-height: 100vh; }
/* Unpainted while held: the section nav lands above it with the rows, so a painted empty
   box would count as moved; hidden, the rows simply appear. */
.lib-grids[aria-busy="true"] { visibility: hidden; }
@media (min-width: 1024px) {
  /* :has(): with the nav hidden (no JS, or a subject with no sections) the column must go
     too, or the grid sits beside 15rem of nothing. */
  .lib-layout:not(:has(> .lib-cat-nav[hidden])) {
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
  }
}

/* ── Sections in the grid ──────────────────────────────────────────────────────────── */
/* display sits on :not(.hidden) so the search can still collapse an emptied section with
   Tailwind's .hidden (the documented .hidden-vs-component-rule trap, 02-auth-gate.css). */
.lib-cat-section:not(.hidden) { display: flex; flex-direction: column; gap: 1.5rem; }
.lib-cat-section + .lib-cat-section { margin-top: 1rem; }          /* 2.5rem with the grid's gap-6 */
/* Clearance for the sticky site header when a nav entry (or a #cat- link) lands here. */
.lib-cat-section, .lib-year-group[data-block] {
  scroll-margin-top: calc(var(--preview-sticky-top) + 0.75rem);
}

.lib-cat-heading { display: flex; align-items: center; gap: 0.625rem; min-width: 0; }
.lib-cat-heading-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem; height: 1.875rem;
  flex: none;
  border-radius: 0.5625rem;
  background: rgba(var(--accent-rgb), 0.16);
  color: rgb(var(--accent-rgb));
  box-shadow: 0 0 18px -8px rgba(var(--accent-rgb), 0.7);
}
.lib-cat-heading-icon svg { width: 1rem; height: 1rem; }
.lib-cat-heading-label {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
}
.lib-cat-heading-count {
  flex: none;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  padding: 0.0625rem 0.4375rem;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.14);
  color: rgb(var(--accent-rgb));
}
.lib-cat-heading-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(var(--accent-rgb), 0.35), transparent);
}

/* ── The nav: shared item grammar ──────────────────────────────────────────────────── */
.lib-cat-nav[hidden] { display: none; }
/* A subject page (/library/<subject>) always has sections, so the server marks the layout
   [data-nav-reserved] and the nav's place is held, unpainted, until library.js builds it:
   the sidebar column on desktop, the one-row picker on phones. Arriving after first paint it
   moved the whole grid (CLS 0.05-0.09, speed audit 2026-11-16). */
.lib-layout[data-nav-reserved] > .lib-cat-nav[hidden] { display: block; visibility: hidden; }
@media (min-width: 1024px) {
  .lib-layout[data-nav-reserved] { grid-template-columns: 15rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }
}
@media (max-width: 1023px) {
  .lib-layout[data-nav-reserved] > .lib-cat-nav[hidden] { margin-top: 1.5rem; height: calc(3.25rem + 2px); }
}
.lib-cat-nav { font-size: 0.8125rem; }
.lib-cat-nav-list, .lib-cat-nav-sub { list-style: none; margin: 0; padding: 0; }
.lib-cat-nav-list { display: flex; flex-direction: column; gap: 0.125rem; }
.lib-cat-nav-item { min-width: 0; }

/* A section entry: hue-tinted icon chip, neutral label, count pill — the .libsub-tab look
   from /library/<subject>, so the two pages share one visual grammar. */
.lib-cat-nav-section {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: 0.625rem;
  border: 1px solid transparent;
  color: rgb(203, 213, 225);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.lib-cat-nav-section:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.lib-cat-nav-section:focus-visible { outline: 2px solid rgba(56, 189, 248, 0.7); outline-offset: -2px; }
.lib-cat-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem; height: 1.5rem;
  flex: none;
  border-radius: 0.4375rem;
  background: rgba(var(--accent-rgb), 0.16);
  color: rgb(var(--accent-rgb));
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.lib-cat-nav-icon svg { width: 0.875rem; height: 0.875rem; }
.lib-cat-nav-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.lib-cat-nav-count {
  flex: none;
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  padding: 0 0.375rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(148, 163, 184, 0.9);
}
/* The current section: the hue arrives as a soft, low-opacity bloom (the site's glow
   language), never a solid fill. */
.lib-cat-nav-item.is-active > .lib-cat-nav-section {
  border-color: rgba(var(--accent-rgb), 0.35);
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.18) 0%, rgba(var(--accent-rgb), 0.05) 70%);
  color: #fff;
  box-shadow: 0 8px 24px -14px rgba(var(--accent-rgb), 0.9);
}
.lib-cat-nav-item.is-active .lib-cat-nav-icon {
  background: rgba(var(--accent-rgb), 0.3);
  box-shadow: 0 0 14px -4px rgba(var(--accent-rgb), 0.7);
}
.lib-cat-nav-item.is-active .lib-cat-nav-count { background: rgba(var(--accent-rgb), 0.22); color: #fff; }

/* Block entries, nested under their section behind a hairline. */
.lib-cat-nav-sub {
  margin: 0.125rem 0 0.375rem 1.25rem;
  padding-left: 0.625rem;
  border-left: 1px solid rgba(255, 255, 255, 0.07);
}
.lib-cat-nav-block {
  display: block;
  padding: 0.2rem 0.5rem;
  border-radius: 0.4rem;
  color: rgb(148, 163, 184);
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  box-shadow: inset 2px 0 0 transparent;
  transition: background-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.lib-cat-nav-block:hover { color: rgb(226, 232, 240); background: rgba(255, 255, 255, 0.04); }
.lib-cat-nav-block:focus-visible { outline: 2px solid rgba(56, 189, 248, 0.7); outline-offset: -2px; }
.lib-cat-nav-block.is-active {
  color: #fff;
  background: rgba(var(--accent-rgb), 0.1);
  box-shadow: inset 2px 0 0 rgba(var(--accent-rgb), 0.75);
}

/* ── Desktop: sticky sidebar in its own scroll box ─────────────────────────────────── */
@media (min-width: 1024px) {
  .lib-cat-nav:not([hidden]) {
    position: sticky;
    top: calc(var(--preview-sticky-top) + 0.5rem);
    margin-top: 2rem;                                   /* aligns with the grid's mt-8 */
    max-height: calc(100vh - var(--preview-sticky-top) - 1.5rem);
    overflow-y: auto;
    overflow-x: hidden;
    /* Repeated wheel gestures at either end must not scroll the page and
       trigger scrollspy to pull this navigator back to the current section. */
    overscroll-behavior-y: contain;
    padding: 0.375rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(8, 14, 30, 0.55);
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.22) transparent;
  }
  .lib-cat-nav::-webkit-scrollbar { width: 8px; }
  .lib-cat-nav::-webkit-scrollbar-track { background: transparent; }
  .lib-cat-nav::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.22);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
  }
}

/* ── Phones / tablets: a sticky chip strip under the site header ───────────────────── */
@media (max-width: 1023px) {
  .lib-cat-nav:not([hidden]) {
    position: sticky;
    top: var(--preview-sticky-top);
    z-index: 15;                                        /* under .site-header (z-20), over the cards */
    margin-top: 1.5rem;
    padding: 0.5rem 0;
    background: rgba(1, 4, 14, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }
  .lib-cat-nav::-webkit-scrollbar { display: none; }
  .lib-cat-nav-list { flex-direction: row; gap: 0.375rem; width: max-content; padding: 0 0.125rem; }
  .lib-cat-nav-sub { display: none; }
  .lib-cat-nav-section {
    padding: 0.3rem 0.625rem 0.3rem 0.3rem;
    border-radius: 999px;
    border-color: rgba(var(--accent-rgb), 0.2);
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.1) 0%, rgba(255, 255, 255, 0.02) 65%);
    white-space: nowrap;
  }
  .lib-cat-nav-label { overflow: visible; }
  /* The strip sits under the header's fixed corner widgets, so a jump has to clear both. */
  .lib-cat-section, .lib-year-group[data-block] {
    scroll-margin-top: calc(var(--preview-sticky-top) + 3.75rem);
  }
}
/* Phones: nothing is pinned at the top. .site-header is position: relative and scrolls
   away, and below 768px the brand wordmark and the account chip are `absolute`, i.e. they
   scroll away with it (07-header-preview-chrome.css, 13-account.css). A strip parked at
   --preview-sticky-top would leave a 72px band of page content scrolling ABOVE it, so here
   it sticks to the very top and a jump only has to clear the strip itself. */
@media (max-width: 767px) {
  .lib-cat-nav:not([hidden]) { top: 0; }
  .lib-cat-section, .lib-year-group[data-block] { scroll-margin-top: 3.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .lib-cat-nav-section, .lib-cat-nav-icon, .lib-cat-nav-block { transition: none; }
}

/* "Download all" beside the title (the button itself: 11-library-detail.css). Its report shares
   the title's line; on a phone it takes a line of its own below instead of squeezing the title. */
.lib-cat-heading .lib-zip-note {
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 639px) {
  .lib-cat-heading { flex-wrap: wrap; row-gap: 0.375rem; }
  .lib-cat-heading-rule { min-width: 1rem; }
  .lib-cat-heading .lib-zip-note { order: 1; flex-basis: 100%; white-space: normal; }
}
/* Mobile section picker: every category is visible when expanded, with no sideways
   hunting. The collapsed current-section label keeps the navigator one row tall. */
.lib-cat-picker-summary { display: none; }
.lib-cat-picker:not([open]) > .lib-cat-nav-list { display: flex; }
@media (max-width: 1023px) {
  .lib-cat-nav:not([hidden]) {
    overflow: visible;
    padding: 0;
    background: var(--reading-surface);
    border: 1px solid rgba(148, 163, 184, .25);
    border-radius: .875rem;
    backdrop-filter: none;
  }
  .lib-cat-picker-summary {
    display: flex; align-items: center; gap: .625rem;
    min-height: 3.25rem; padding: .75rem;
    cursor: pointer; list-style: none; color: #e2e8f0;
  }
  .lib-cat-picker-summary::-webkit-details-marker { display: none; }
  .lib-cat-picker-title { font-weight: 600; }
  .lib-cat-picker-current { margin-left: auto; color: #cbd5e1; font-size: .75rem; }
  .lib-cat-picker-chevron { font-size: 1.125rem; }
  .lib-cat-picker[open] .lib-cat-picker-chevron { transform: rotate(180deg); }
  .lib-cat-picker-summary:focus-visible { outline: 2px solid #38bdf8; outline-offset: 2px; border-radius: .875rem; }
  .lib-cat-picker:not([open]) > .lib-cat-nav-list { display: none; }
  .lib-cat-picker[open] > .lib-cat-nav-list {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
    width: auto; gap: .375rem; padding: .5rem;
    max-height: 60vh; max-height: 60dvh; overflow-y: auto;
    border-top: 1px solid rgba(148, 163, 184, .2);
    overscroll-behavior: contain;
  }
  .lib-cat-nav-item { min-width: 0; }
  .lib-cat-nav-section {
    min-height: 2.75rem; padding: .5rem; border-radius: .625rem;
    white-space: normal; background: var(--reading-surface);
  }
  .lib-cat-nav-label { white-space: normal; overflow-wrap: anywhere; line-height: 1.25; }
  .lib-cat-nav-item.is-active > .lib-cat-nav-section { background: var(--reading-surface); border-color: rgb(var(--accent-rgb)); }
  html[data-theme="light"] .lib-cat-nav:not([hidden]),
  html[data-theme="light"] .lib-cat-nav-section { background: var(--reading-surface); background-image: none; }
  html[data-theme="light"] .lib-cat-picker-summary { color: #1e293b; }
  html[data-theme="light"] .lib-cat-picker-current { color: #475569; }
}
@media (max-width: 1023px) {
  .lib-cat-nav-section:hover { background: var(--reading-surface); }
  .lib-cat-nav-count, .lib-cat-nav-item.is-active .lib-cat-nav-count { background: transparent; color: #cbd5e1; }
  html[data-theme="light"] .lib-cat-nav-section:hover { background: var(--reading-surface); }
  html[data-theme="light"] .lib-cat-nav-count { background: transparent; color: #475569; }
}
@media (max-width: 359px) {
  .lib-cat-picker[open] > .lib-cat-nav-list { grid-template-columns: minmax(0, 1fr); }
}
/* Wrapped titles stay within the original 62px card footprint. */
.lib-card .lib-paper-name {
  white-space: normal; overflow-wrap: anywhere; text-overflow: clip;
  max-height: 2rem; overflow: hidden; font-size: .8125rem; line-height: 1.05;
}
.lib-sidebar-item.lib-sidebar-item--paper {
  height: 1.88rem; padding-block: .15rem; white-space: normal;
  overflow-wrap: anywhere; text-overflow: clip; line-height: 1.05;
}

.lib-card.lib-paper-name-tight {
  gap: .1875rem; min-height: 3.875rem;
  height: 3.875rem; padding: .1875rem .25rem;
}
.lib-card.lib-paper-name-tight .lib-paper-name { max-height: 3.375rem; }
.lib-card.lib-paper-name-tight > div:first-child { width: 1.25rem; height: 1.25rem; }
.lib-card.lib-paper-name-tight > a { padding: .25rem; }
.lib-card.lib-paper-name-tight > .lib-lock {
  position: absolute; left: .5rem; bottom: .1875rem;
}

/* The text surface stays as dark as the page; document color lives on its edges
   and on an opaque icon tile, so the card fill never bleeds through the glyph. */
#lib-grid-view .lib-card {
  position: relative;
  contain: layout style;
  height: 3.875rem;
  border-color: rgba(var(--doc-rgb, 96, 165, 250), .4);
  background: var(--reading-surface);
  box-shadow: inset 2px 0 rgb(var(--doc-rgb, 96, 165, 250));
}
#lib-grid-view .lib-card .lib-file-icon {
  isolation: isolate;
  background: color-mix(in srgb, rgb(var(--doc-rgb, 96, 165, 250)) 18%, var(--reading-surface));
  border: 1px solid rgba(var(--doc-rgb, 96, 165, 250), .3);
}
html[data-theme="light"] #lib-grid-view .lib-card {
  background: linear-gradient(135deg, rgba(var(--doc-rgb, 96, 165, 250), .12),
    rgba(var(--doc-rgb, 96, 165, 250), .025)), var(--reading-surface);
}

/* ── Readability pass (design audit 2026-11-24) ──────────────────────────────────────
   Section icons ≥ 20px in their own hue, file and download glyphs 20px in each document's
   colour (they were 16px and the download arrows all one cyan), titles 14px, labels and
   counts ≥ 12px at #cbd5e1. Applies to the server-rendered subject and the JS-built ones,
   which share these classes (library.js buildSubjectGrid). */
.lib-cat-heading { gap: 0.75rem; }
.lib-cat-heading-icon { width: 2.375rem; height: 2.375rem; border-radius: 0.7rem; border: 1px solid rgba(var(--accent-rgb), 0.35); background: rgba(var(--accent-rgb), 0.18); }
.lib-cat-heading-icon svg { width: 1.3rem; height: 1.3rem; }
.lib-cat-heading-label { font-size: 1.1875rem; font-weight: 700; }
.lib-cat-heading-count { font-size: 0.78rem; font-weight: 600; padding: 0.08rem 0.5rem; }
html.space-root:not([data-theme="light"]) .lib-cat-heading-count { color: color-mix(in srgb, rgb(var(--accent-rgb)) 45%, #fff); background: rgba(var(--accent-rgb), 0.2); }
.lib-cat-nav { font-size: 0.875rem; }
.lib-cat-nav-icon { width: 1.875rem; height: 1.875rem; border-radius: 0.5rem; }
.lib-cat-nav-icon svg { width: 1.15rem; height: 1.15rem; }
.lib-cat-nav-count { font-size: 0.75rem; color: rgb(203, 213, 225); }
.lib-cat-nav-block { font-size: 0.8125rem; color: rgb(190, 201, 216); }

/* Year / category labels above each run of cards ("2024", "Questions by topic"). */
#lib-grid-view .lib-block-label { font-size: 0.8125rem; letter-spacing: 0.1em; }
#lib-grid-view .lib-block-label svg { width: 1.25rem; height: 1.25rem; }
#lib-grid-view .lib-block-label.text-slate-200 { font-size: 0.9375rem; font-weight: 700; color: #f1f5f9; letter-spacing: 0; }
html.space-root:not([data-theme="light"]) #lib-grid-view .lib-cat-section .lib-block-label.inline-flex { color: #e2e8f0; }
html.space-root:not([data-theme="light"]) #lib-grid-view .lib-cat-section .lib-block-label svg { color: color-mix(in srgb, rgb(var(--accent-rgb, 56, 189, 248)) 80%, #fff); }
#lib-grid-view .lib-session-group > div > span[title] { height: 1.5rem; min-width: 1.6rem; padding: 0 0.4rem; font-size: 0.75rem; color: rgb(226, 232, 240); border-color: rgba(148, 163, 184, 0.3); }

/* The document cards. */
#lib-grid-view .lib-card .lib-paper-name { font-size: 0.875rem; line-height: 1.12; color: #f1f5f9; }
#lib-grid-view .lib-card .lib-file-icon { width: 2.375rem; height: 2.375rem; border-radius: 0.65rem; }
#lib-grid-view .lib-card .lib-file-icon svg { width: 1.25rem; height: 1.25rem; }
#lib-grid-view .lib-card > a[download], #lib-grid-view .lib-card > a:last-child { padding: 0.45rem; }
#lib-grid-view .lib-card > a svg { width: 1.25rem; height: 1.25rem; }
html.space-root:not([data-theme="light"]) #lib-grid-view .lib-card > a:last-child { color: color-mix(in srgb, rgb(var(--doc-rgb, 96, 165, 250)) 70%, #fff); }
html.space-root:not([data-theme="light"]) #lib-grid-view .lib-card > a:last-child:hover { color: #fff; background: rgba(var(--doc-rgb, 96, 165, 250), 0.2); }
#lib-grid-view .lib-card .lib-lock svg { width: 1.15rem; height: 1.15rem; }
#lib-grid-view .lib-card.lib-paper-name-tight > div:first-child { width: 1.5rem; height: 1.5rem; }
#lib-grid-view .lib-card.lib-paper-name-tight .lib-file-icon svg { width: 1rem; height: 1rem; }

/* ── Past papers: one box per paper (owner, 2026-11-26) ──────────────────────────────
   library.js _paperSetHtml / library.html _library_session_cards. A box holds one paper's
   documents (questions, answers, insert, listening audio, transcript) as compact rows, so a
   paper reads as one unit; session-wide documents share a last, quieter box. */
.lib-paper-set {
  --set-rgb: 148, 163, 184;
  position: relative; isolation: isolate;
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  padding: .4375rem .375rem .3125rem;
  border: 1px solid rgba(var(--set-rgb), .32);
  border-radius: 1.05rem;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(var(--set-rgb), .2), transparent 58%),
    linear-gradient(180deg, rgba(var(--set-rgb), .07), rgba(var(--set-rgb), .015) 60%),
    var(--reading-surface, #0b1120);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 14px 30px -22px rgba(var(--set-rgb), .55);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}
/* The coloured top edge: the box's hue at a glance. */
.lib-paper-set::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px; z-index: -1;
  background: linear-gradient(90deg, rgb(var(--set-rgb)), rgba(var(--set-rgb), .15));
}
.lib-paper-set:hover {
  border-color: rgba(var(--set-rgb), .6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 18px 36px -20px rgba(var(--set-rgb), .7);
}
.lib-paper-set.hidden { display: none; }
.lib-session-cards--sets { align-items: start; }
/* Session heading inside a year ("May / June"): a sub-heading under the year, with its own
   hairline, so each session's row of paper boxes reads as one group. */
.lib-session-head { display: flex; align-items: center; gap: .625rem; padding: .125rem 0 .125rem .125rem; }
#lib-grid-view .lib-session-label { font-size: .875rem; font-weight: 700; color: #7dd3fc; letter-spacing: .01em; white-space: nowrap; }
.lib-session-rule { flex: 1; height: 1px; background: linear-gradient(to right, rgba(125, 211, 252, .28), transparent); }
.lib-paper-set--session { border-style: dashed; box-shadow: none; }
.lib-paper-set--session::before { display: none; }
.lib-paper-set-head {
  display: flex; align-items: center; gap: .625rem;
  margin: 0 0 .25rem; padding: .25rem .375rem .5rem;
  border-bottom: 1px solid rgba(var(--set-rgb), .2);
  font-size: .875rem; font-weight: 700; line-height: 1.2; color: #f1f5f9;
}
.lib-paper-set-tile {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.125rem; height: 2.125rem; padding: 0 .375rem; border-radius: .7rem;
  font-size: .9375rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em;
  color: #fff;
  background: linear-gradient(140deg, rgb(var(--set-rgb)), rgba(var(--set-rgb), .55));
  box-shadow: 0 6px 16px -6px rgba(var(--set-rgb), .8), inset 0 1px 0 rgba(255, 255, 255, .3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}
.lib-paper-set-tile svg { width: 1.125rem; height: 1.125rem; }
.lib-paper-set--session .lib-paper-set-tile {
  color: #cbd5e1; background: rgba(148, 163, 184, .16); box-shadow: none; text-shadow: none;
}
.lib-paper-set-title { flex: 1; min-width: 0; color: color-mix(in srgb, rgb(var(--set-rgb)) 30%, #fff); }
.lib-paper-set--session .lib-paper-set-head { font-weight: 600; }
.lib-paper-set--session .lib-paper-set-title { color: #cbd5e1; }
.lib-paper-set-head .lib-lock { color: #fbbf24; display: inline-flex; }
.lib-paper-set-head .lib-lock svg { width: 1rem; height: 1rem; }
.lib-paper-set-docs { display: flex; flex-direction: column; gap: .125rem; }
#lib-grid-view .lib-card.lib-card--in-set {
  height: 2.625rem; padding: .25rem .25rem .25rem .3125rem; gap: .625rem;
  border: 0; border-radius: .625rem; background: transparent; box-shadow: none;
}
#lib-grid-view .lib-card.lib-card--in-set:hover {
  transform: none; box-shadow: none;
  background: rgba(var(--doc-rgb, 96, 165, 250), .14);
}
#lib-grid-view .lib-card.lib-card--in-set .lib-file-icon { width: 2rem; height: 2rem; border-radius: .55rem; }
#lib-grid-view .lib-card.lib-card--in-set .lib-file-icon svg { width: 1.125rem; height: 1.125rem; }
#lib-grid-view .lib-card.lib-card--in-set .lib-paper-name { font-size: .875rem; max-height: 2.1rem; }
#lib-grid-view .lib-card.lib-card--in-set > a:last-child { padding: .375rem; }
.lib-set-tag {
  display: inline-block; margin-left: .25rem; padding: 0 .3rem; border-radius: .3rem;
  font-size: .6875rem; font-weight: 600; font-variant-numeric: tabular-nums;
  color: #cbd5e1; background: rgba(148, 163, 184, .16); vertical-align: .05em;
}
/* Off-screen document groups skip rendering until scrolled near (13k elements on a subject page).
   Desktops with a mouse only: on phones (iOS Safari, in-app browsers) skipped boxes came back
   empty, so past papers looked missing on mobile (owner, 2026-11-30). */
@media (hover: hover) and (pointer: fine) {
  .lib-paper-set { content-visibility: auto; contain-intrinsic-size: auto 420px; }
}
/* The in-page player for a listening recording (library.js playLibAudio), under its card. */
.lib-audio-player { grid-column: 1 / -1; padding: .25rem .25rem .375rem; }
.lib-audio-player audio { display: block; width: 100%; height: 2.5rem; }

/* ▼▼ LIGHT THEME — GENERATED by scripts/build_light_theme.py from the rules above. Do not edit by hand: run the builder. Hand tuning goes in 36-theme-light.css. ▼▼ */
html[data-theme="light"] .lib-cat-heading-icon{color:color-mix(in srgb,rgb(var(--accent-rgb)) 44%,#0f172a);box-shadow:0px 5px 18px -8px rgb(15 23 42/0.12)}
html[data-theme="light"] .lib-cat-heading-label{color:rgb(51 63 82)}
html[data-theme="light"] .lib-cat-heading-count{color:color-mix(in srgb,rgb(var(--accent-rgb)) 44%,#0f172a)}
html[data-theme="light"] .lib-cat-nav-section{color:rgb(48 65 85)}
html[data-theme="light"] .lib-cat-nav-section:hover{background-color:rgb(15 23 42/0.05);color:rgb(51 63 82)}
html[data-theme="light"] .lib-cat-nav-icon{color:color-mix(in srgb,rgb(var(--accent-rgb)) 44%,#0f172a)}
html[data-theme="light"] .lib-cat-nav-count{background-color:rgb(15 23 42/0.07);color:rgb(61 75 94/0.9)}
html[data-theme="light"] .lib-cat-nav-item.is-active > .lib-cat-nav-section{color:rgb(51 63 82);box-shadow:0px 8px 24px -14px rgb(15 23 42/0.14)}
html[data-theme="light"] .lib-cat-nav-item.is-active .lib-cat-nav-icon{box-shadow:0px 4px 14px -4px rgb(15 23 42/0.12)}
html[data-theme="light"] .lib-cat-nav-item.is-active .lib-cat-nav-count{color:rgb(51 63 82)}
html[data-theme="light"] .lib-cat-nav-sub{border-left-color:rgb(15 23 42/0.098)}
html[data-theme="light"] .lib-cat-nav-block{color:rgb(61 75 94)}
html[data-theme="light"] .lib-cat-nav-block:hover{color:rgb(44 63 88);background-color:rgb(15 23 42/0.04)}
html[data-theme="light"] .lib-cat-nav-block.is-active{color:rgb(51 63 82);box-shadow:inset 2px 0px rgb(15 23 42/0.14)}
@media (min-width: 1024px){html[data-theme="light"] .lib-cat-nav:not([hidden]){border-color:rgb(15 23 42/0.098);background-color:rgb(248 248 251/0.55)}}
@media (max-width: 1023px){html[data-theme="light"] .lib-cat-nav:not([hidden]){background-color:rgb(252 252 253/0.82);border-bottom-color:rgb(15 23 42/0.084)}html[data-theme="light"] .lib-cat-nav-section{background-image:linear-gradient(135deg, rgba(var(--accent-rgb), 0.1) 0%, rgb(15 23 42/0.02) 65%)}}
@media (max-width: 1023px){html[data-theme="light"] .lib-cat-picker-summary{color:rgb(44 63 88)}html[data-theme="light"] .lib-cat-picker-current{color:rgb(48 65 85)}}
@media (max-width: 1023px){html[data-theme="light"] .lib-cat-nav-count,html[data-theme="light"] .lib-cat-nav-item.is-active .lib-cat-nav-count{color:rgb(48 65 85)}}
html[data-theme="light"] #lib-grid-view .lib-card{box-shadow:inset 2px 0px rgb(15 23 42/0.14)}
html[data-theme="light"] .lib-cat-nav-count{color:rgb(48 65 85)}
html[data-theme="light"] .lib-cat-nav-block{color:rgb(49 64 84)}
html[data-theme="light"] #lib-grid-view .lib-block-label.text-slate-200{color:rgb(38 66 94)}
html[data-theme="light"] #lib-grid-view .lib-session-group > div > span[title]{color:rgb(44 63 88)}
html[data-theme="light"] #lib-grid-view .lib-card .lib-paper-name{color:rgb(38 66 94)}
html[data-theme="light"] .lib-paper-set{background:radial-gradient(120% 80% at 0% 0%, rgba(var(--set-rgb), .2), transparent 58%),
    linear-gradient(180deg, rgba(var(--set-rgb), .07), rgba(var(--set-rgb), .015) 60%),
    var(--reading-surface, rgb(247 248 251));box-shadow:0px 14px 30px -22px rgb(15 23 42/0.14)}
html[data-theme="light"] .lib-paper-set:hover{box-shadow:0px 18px 36px -20px rgb(15 23 42/0.14)}
html[data-theme="light"] #lib-grid-view .lib-session-label{color:rgb(0 90 133)}
html[data-theme="light"] .lib-paper-set-head{color:rgb(38 66 94)}
html[data-theme="light"] .lib-paper-set-tile{color:rgb(51 63 82);box-shadow:0px 6px 16px -6px rgb(15 23 42/0.14);text-shadow:0px 1px 2px rgb(15 23 42/0.112)}
html[data-theme="light"] .lib-paper-set--session .lib-paper-set-tile{color:rgb(48 65 85)}
html[data-theme="light"] .lib-paper-set-title{color:color-mix(in srgb, color-mix(in srgb,rgb(var(--set-rgb)) 44%,#0f172a) 30%, rgb(51 63 82))}
html[data-theme="light"] .lib-paper-set--session .lib-paper-set-title{color:rgb(48 65 85)}
html[data-theme="light"] .lib-paper-set-head .lib-lock{color:rgb(127 92 0)}
html[data-theme="light"] .lib-set-tag{color:rgb(48 65 85)}
/* ▲▲ LIGHT THEME END ▲▲ */
