/* ============================================================
   Statistische Physik — Vorlesungsnotizen
   Modern, readable, responsive stylesheet.  Light + dark modes.
   ============================================================ */

:root {
  --bg: #fdfdfc;
  --bg-elev: #ffffff;
  --bg-soft: #f4f4f2;
  --border: #e5e5e2;
  --border-strong: #cfcfcb;
  --fg: #1f2024;
  --fg-muted: #55575d;
  --fg-soft: #7a7c83;
  --accent: #2f5eaa;
  --accent-soft: #dfeaff;
  --accent-strong: #1b3f7a;
  --eqbox-bg: #eef4ff;
  --eqbox-border: #b7c9ea;
  --sidecomment: #6a6c73;
  --lecture: #1f3864;          /* = chaptercolor in preamble.tex */
  --lecture-soft: #e6ecf7;
  --mma-red: #dd1100;
  --code-bg: #f2f2f0;
  --font-serif: "Charter", "Georgia", "Cambria", "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
  --measure: 68ch;
  --sidebar-w: 300px;
  --header-h: 60px;
  --font-scale: 1;
}

/* ---- persistable preferences (JS toggles data-* on <html>) ---- */
html[data-fontsize="-2"] { --font-scale: 0.82; }
html[data-fontsize="-1"] { --font-scale: 0.9;  }
html[data-fontsize="0"]  { --font-scale: 1;    }
html[data-fontsize="1"]  { --font-scale: 1.12; }
html[data-fontsize="2"]  { --font-scale: 1.25; }
html[data-fontsize="3"]  { --font-scale: 1.4;  }

html[data-width="narrow"] { --measure: 58ch; }
html[data-width="normal"] { --measure: 68ch; }
html[data-width="wide"]   { --measure: 88ch; }
html[data-width="full"]   { --measure: none;  }

html.dark {
  --bg: #14161a;
  --bg-elev: #1a1d22;
  --bg-soft: #1f2328;
  --border: #2c3037;
  --border-strong: #3a4049;
  --fg: #e8e9eb;
  --fg-muted: #a4a8b0;
  --fg-soft: #7c8089;
  --accent: #7ea9ff;
  --accent-soft: #1e2c4a;
  --accent-strong: #a8c3ff;
  --eqbox-bg: #1c2536;
  --eqbox-border: #35507f;
  --sidecomment: #8c9099;
  --lecture: #9cb8ee;
  --lecture-soft: #1d2740;
  --mma-red: #ff5140;
  --code-bg: #1e2126;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }

/* Root font-size drives every `rem`, `em`, MathJax size, and figure width.
   Adjusting --font-scale re-scales the whole page proportionally. */
html {
  font-size: calc(17px * var(--font-scale));
}

body {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* --------------------------------------------------- header --------- */

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  backdrop-filter: saturate(160%) blur(6px);
}
.site-header .wrap {
  display: flex; align-items: center; height: 100%;
  padding: 0 1.25rem; gap: 1rem;
}
.brand {
  display: flex; flex-direction: column; text-decoration: none;
  color: var(--fg); line-height: 1.15;
}
.brand-title { font-family: var(--font-sans); font-weight: 600; font-size: 1.05rem; }
.brand-sub   { font-family: var(--font-sans); font-size: 0.78rem; color: var(--fg-muted); }
.header-tools {
  margin-left: auto;
  display: flex; align-items: center; gap: 0.35rem;
}
.theme-toggle, .nav-toggle, .prefs-toggle {
  background: transparent; border: 1px solid var(--border);
  color: var(--fg); border-radius: 8px; height: 38px; min-width: 38px;
  padding: 0 0.55rem;
  cursor: pointer; font-size: 0.95rem; font-family: var(--font-sans);
  display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover, .nav-toggle:hover, .prefs-toggle:hover {
  background: var(--bg-soft);
}
.prefs-toggle[aria-expanded="true"] {
  background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent);
}
.nav-toggle { display: none; }

/* ------------------------------------------------- prefs panel ------ */

.prefs-panel {
  position: absolute; top: var(--header-h); right: 1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  padding: 0.9rem 1rem;
  min-width: 320px;
  z-index: 30;
  font-family: var(--font-sans);
}
html.dark .prefs-panel {
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
}
.prefs-panel[hidden] { display: none; }
.prefs-row { display: grid; grid-template-columns: 8.5rem 1fr;
             align-items: center; gap: 0.75rem;
             padding: 0.35rem 0; }
.prefs-label { font-size: 0.83rem; color: var(--fg-muted); font-weight: 500; }
.prefs-controls { display: flex; gap: 0.35rem; align-items: center; }
.prefs-controls button {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--fg); border-radius: 6px;
  padding: 0.3rem 0.6rem; cursor: pointer;
  font-family: inherit; font-size: 0.85rem;
}
.prefs-controls button:hover { background: var(--bg-soft); }
.prefs-controls button[aria-pressed="true"],
.prefs-controls button.active {
  background: var(--accent-soft); color: var(--accent-strong);
  border-color: var(--accent);
}
.prefs-segmented { flex-wrap: wrap; }
.prefs-value {
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted); min-width: 3.6em; text-align: center;
  font-size: 0.85rem;
}

/* ------------------------------------------------- preview tooltip -- */

.preview-tooltip {
  position: fixed; z-index: 40;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  padding: 0.7rem 0.9rem;
  max-width: min(560px, calc(100vw - 2rem));
  max-height: 60vh;
  overflow: auto;
  font-family: var(--font-serif);
  font-size: 0.95em;
  pointer-events: auto;
  opacity: 0; transform: translateY(2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
html.dark .preview-tooltip {
  box-shadow: 0 8px 24px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.35);
}
.preview-tooltip[data-visible] { opacity: 1; transform: none; }
.preview-tooltip .preview-label {
  display: block; font-family: var(--font-sans); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--fg-muted); margin-bottom: 0.4rem;
}
.preview-tooltip mjx-container[display="true"] { margin: 0.2em 0 !important; }
.preview-tooltip figure.figure { margin: 0.2em 0; }
.preview-tooltip figure.figure img { max-height: 40vh; }

/* Style anchor refs that get enhanced by hover.js */
a.xref { text-decoration: none; border-bottom: 1px dashed var(--accent); }
a.xref:hover { border-bottom-style: solid; }

/* A ref into a chapter the site doesn't build yet (e.g. past a
   WEBBUILD:STOP cutoff): show its number as plain text, not a link. */
.xref-stub { color: inherit; }

/* Brief highlight on click-to-jump */
@keyframes xrefFlash {
  0%   { background: var(--accent-soft); box-shadow: 0 0 0 6px var(--accent-soft); }
  100% { background: transparent; box-shadow: 0 0 0 0 transparent; }
}
.xref-flash { animation: xrefFlash 1.4s ease-out; border-radius: 6px; }

.skip-link {
  position: absolute; left: -9999px;
}
.skip-link:focus {
  left: 1rem; top: 1rem; padding: .5rem 1rem; background: var(--accent);
  color: #fff; border-radius: 6px; z-index: 100;
}

/* --------------------------------------------------- layout --------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--header-h));
}

.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 1.5rem 1.25rem 4rem;
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: 0.92rem;
}

.nav-heading {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; color: var(--fg-muted);
  margin: 1.5rem 0 0.5rem;
}
.nav-heading:first-child { margin-top: 0; }

.nav-chapters, .nav-sections {
  list-style: none; margin: 0; padding: 0;
}
.nav-chapters li a, .nav-sections li a {
  display: flex; align-items: baseline; gap: 0.6rem;
  color: var(--fg); text-decoration: none;
  padding: 0.35rem 0.5rem; border-radius: 6px;
  line-height: 1.3;
}
.nav-chapters li a:hover, .nav-sections li a:hover {
  background: var(--bg-soft); color: var(--accent);
}
.nav-num {
  font-variant-numeric: tabular-nums;
  color: var(--fg-soft); font-size: 0.85em; min-width: 1.2em;
}
.nav-chapters .current a {
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 600;
}

.toc-h2 a { font-weight: 500; }
.toc-h3 a { padding-left: 1.5rem; color: var(--fg-muted); font-size: 0.88rem; }

/* --------------------------------------------------- content -------- */

.content {
  padding: 2.5rem 3rem 6rem;
  max-width: calc(var(--measure) + 6rem);
  margin: 0 auto;
  width: 100%;
}
html[data-width="full"] .content { max-width: none; }

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  color: var(--fg);
  line-height: 1.25;
  font-weight: 700;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
h1 { font-size: 2.15rem; margin: 0 0 0.35em; letter-spacing: -0.01em; }
.header-section-number {
  color: var(--fg-muted);
  font-weight: 400;
  margin-right: 0.5em;
  font-variant-numeric: tabular-nums;
}
/* Prefs toggle: hide the injected numbers when the reader turns them off. */
html[data-secnums="off"] .header-section-number { display: none; }
h2 { font-size: 1.55rem; margin: 2.5rem 0 0.6rem;
     padding-top: 0.75rem; border-top: 1px solid var(--border); }
h3 { font-size: 1.2rem; margin: 2rem 0 0.4rem; }
h4 { font-size: 1.02rem; margin: 1.4rem 0 0.3rem; color: var(--fg-muted); }

p { margin: 0.9em 0; }
p:first-child { margin-top: 0; }

a { color: var(--accent); text-decoration: none;
    border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: currentColor; }

em, i { color: inherit; }
strong { color: var(--fg); }

/* Lists */
ul, ol { padding-left: 1.4em; }
li { margin: 0.2em 0; }
li > p:first-child { margin-top: 0; }
li > p:last-child { margin-bottom: 0; }

/* --------------------------------------------------- math ----------- */

mjx-container[display="true"] {
  margin: 1.2em 0 !important;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  padding: 0.4em 0.1em;   /* room for descenders when scrolling */
}
mjx-container[display="true"]::-webkit-scrollbar { height: 6px; }
mjx-container[display="true"]::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 4px;
}
mjx-container { color: var(--fg); }

/* --------------------------------------------------- boxes / envs --- */

.eqbox, .eqboxn {
  background: var(--eqbox-bg);
  border: 1px solid var(--eqbox-border);
  border-radius: 10px;
  padding: 0.4rem 1.1rem;
  margin: 1.4rem 0;
  overflow-x: auto;
}
.eqbox mjx-container, .eqboxn mjx-container { margin: 0.4em 0 !important; }
.eqbox p, .eqboxn p { margin: 0.4em 0; }

.sidecomment {
  color: var(--sidecomment);
  font-style: italic;
  font-size: 0.94rem;
  margin: 1em 0;
  padding: 0.1em 1em;
  border-left: 3px solid var(--border-strong);
}
.sidecomment .mma-text { font-style: normal; }
.sidecomment p:first-child { margin-top: 0.2em; }
.sidecomment p:last-child { margin-bottom: 0.2em; }

.beispiel, .beispiele, .bemerkung {
  background: var(--bg-soft);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 0.8rem 1.1rem;
  margin: 1.4rem 0;
}
.beispiel-label, .beispiele-label, .bemerkung-label {
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--accent-strong);
  margin-bottom: 0.4em;
  font-size: 0.95rem;
}
.beispiel-title, .beispiele-title, .bemerkung-title {
  font-weight: 500; color: var(--fg-muted);
}

/* --------------------------------------------------- Mathematica --- */

.mma {
  color: var(--mma-red);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.94em;
  white-space: nowrap;
}
.mma-logo {
  display: inline-block;
  width: 0.9em; height: 0.9em;
  vertical-align: -0.13em;
  background: radial-gradient(circle at 50% 50%, var(--mma-red) 0%, var(--mma-red) 30%, transparent 32%),
              conic-gradient(from 0deg, var(--mma-red), #9f0a00, var(--mma-red), #9f0a00,
                             var(--mma-red), #9f0a00, var(--mma-red), #9f0a00,
                             var(--mma-red), #9f0a00, var(--mma-red), #9f0a00, var(--mma-red));
  -webkit-mask: radial-gradient(circle at 50% 50%,
    #000 0%, #000 15%, transparent 16%,
    transparent 100%);
  border-radius: 50%;
  margin-right: 0.15em;
  transform: rotate(15deg);
  filter: drop-shadow(0 0 1px rgba(0,0,0,0.25));
}
/* Simpler fallback: a 12-point star via CSS clip */
.mma-logo {
  background: var(--mma-red);
  -webkit-mask: none; mask: none;
  clip-path: polygon(
    50% 0%, 57% 32%, 82% 12%, 68% 40%, 100% 35%, 75% 50%,
    100% 65%, 68% 60%, 82% 88%, 57% 68%, 50% 100%, 43% 68%,
    18% 88%, 32% 60%,  0% 65%, 25% 50%,   0% 35%, 32% 40%,
    18% 12%, 43% 32%
  );
}

.mma-label { font-weight: 700; }
.mma-text  { font-weight: 400; }

/* ---- \mathematicaAN: Download von Teil- und Eltern-Notebook, Platzhalter ----
   Der Animations-Baustein selbst bringt sein CSS mit (siehe animations/);
   hier steht nur, was build.py drumherum erzeugt. */
.mma-anim-dl {
  margin: -0.4rem 0 1.1rem; font-style: normal;
  display: flex; flex-wrap: wrap; gap: 0.6rem;
}
.mma-anim-dl a {
  display: inline-flex; align-items: baseline; gap: 0.5em;
  font-family: var(--font-sans); font-size: 0.82rem;
  color: var(--accent); text-decoration: none;
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 0.35em 0.8em; background: var(--bg-elev);
}
.mma-anim-dl a::before { content: "\2193"; font-weight: 700; }
.mma-anim-dl a:hover { border-color: var(--accent); background: var(--accent-soft); }
.mma-anim-dl a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mma-anim-dl-meta { color: var(--fg-soft); font-size: 0.92em; }

/* app.js adds .xref to any in-page #-link (dashed underline + hover
   preview + click-to-jump flash); this just adds a focus ring. */
.mma-anim-ref:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.mma-anim-missing {
  font-family: var(--font-sans); font-style: normal; font-size: 0.85rem;
  color: var(--fg-muted); background: var(--bg-soft);
  border: 1px dashed var(--border-strong); border-radius: 8px;
  padding: 0.9rem 1rem; margin: 1.1rem 0;
}

/* --------------------------------------------------- figures ------- */

figure.figure {
  margin: 1.5rem 0;
  text-align: center;
}
figure.figure.center { text-align: center; }
figure.figure img {
  max-width: 100%;
  height: auto;
  color: var(--fg);
  /* SVGs use currentColor for strokes/fills when possible */
}
html.dark figure.tikz img {
  /* invert TikZ black-on-white line art for dark mode; keeps colours legible */
  filter: invert(1) hue-rotate(180deg);
}
figcaption {
  margin-top: 0.6em;
  font-size: 0.88rem;
  color: var(--fg-muted);
  font-family: var(--font-sans);
}

/* --------------------------------------------------- misc ---------- */

hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px;
       font-family: var(--font-mono); font-size: 0.92em; }

/* --------------------------------------------------- landing ------ */

.landing .site-header .brand { pointer-events: none; opacity: 0.9; }
.landing .hero {
  max-width: 900px;
  margin: 0 auto;
  padding: 4rem 2rem 6rem;
}
.hero-eyebrow {
  font-family: var(--font-sans); font-size: 0.85rem;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--fg-muted); margin: 0 0 1rem;
}
.hero-title {
  font-family: var(--font-sans);
  font-size: 3rem; font-weight: 700; line-height: 1.1;
  margin: 0 0 0.5rem; letter-spacing: -0.02em;
}
.hero-lead { font-size: 1.25rem; margin: 0 0 0.4rem; color: var(--fg); }
.hero-meta { color: var(--fg-muted); margin: 0 0 3rem; max-width: 60ch; }

.chapter-cards {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr; gap: 0.8rem;
}
@media (min-width: 700px) { .chapter-cards { grid-template-columns: 1fr 1fr; } }
.chapter-card a {
  display: flex; gap: 1rem;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
  text-decoration: none; color: var(--fg);
  transition: border-color 0.15s, transform 0.15s;
}
.chapter-card a:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  border-bottom-color: var(--accent);
}
.card-num {
  font-family: var(--font-sans);
  font-size: 1.6rem; font-weight: 700; color: var(--accent);
  min-width: 1.6rem; line-height: 1;
}
.card-body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.card-title {
  font-family: var(--font-sans); font-weight: 600; font-size: 1.02rem;
}
.card-subtitle {
  font-size: 0.86rem; color: var(--fg-muted); line-height: 1.35;
}

/* Marks a link to a figure in body text */
.figref { font-variant-numeric: tabular-nums; }

/* Invisible anchor placed just before each \eqtag'd display equation so
   \ref{eq:X} scrolls into view with the header offset. */
.eq-anchor {
  display: block;
  height: 0;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}

/* Active section link (via IntersectionObserver in app.js) */
.nav-sections a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

/* --------------------------------------------------- empty chapter -- */
.chapter-empty {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--fg-muted);
  font-family: var(--font-sans);
}
.chapter-empty h1 { margin-bottom: 1rem; color: var(--fg); }
.chapter-empty p { font-size: 1.05rem; }

/* Appended after a chapter truncated by a WEBBUILD:STOP marker -- unlike
   .chapter-empty this follows real content, so it reads as a note, not a
   full-page placeholder. */
.chapter-wip {
  margin: 2.5rem 0 1rem;
  padding: 0.9rem 1.2rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--fg-muted);
  font-family: var(--font-sans);
}
.chapter-wip p { margin: 0; font-size: 0.95rem; }

/* --------------------------------------------------- lectures ------ */

/* In-text marker for \newlecture.  The print version sets a rule, the
   label, the numeral and a date in the outer margin; on screen there is no
   margin to speak of, so the same pieces run across the text column. */
.lecture-mark {
  margin: 3.2rem 0 1.4rem;
  scroll-margin-top: calc(var(--header-h) + 1rem);
}
/* Directly under a heading the marker needs less air above it. */
h1 + .lecture-mark, h2 + .lecture-mark,
h3 + .lecture-mark, h4 + .lecture-mark { margin-top: 1.7rem; }
.lecture-rule {
  height: 2px; border-radius: 2px;
  background: var(--lecture); opacity: 0.85;
}
.lecture-meta {
  display: flex; align-items: baseline; gap: 0.5rem;
  font-family: var(--font-sans);
  margin-top: 0.4rem;
  color: var(--lecture);
}
.lecture-link {
  display: inline-flex; align-items: baseline; gap: 0.45rem;
  color: inherit; text-decoration: none; border-bottom: none;
}
.lecture-link:hover { border-bottom: none; opacity: 0.75; }
.lecture-kicker {
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.15em; text-transform: uppercase;
}
.lecture-num {
  font-size: 1.3rem; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.lecture-date {
  margin-left: auto;
  font-size: 0.78rem; color: var(--fg-soft);
  font-variant-numeric: tabular-nums;
}
/* A marker placed between two \item's lands inside the list item; pull it
   back out to the text column so the rule still spans the full measure. */
li > .lecture-mark { margin-left: -1.4em; }

/* Prefs toggle: readers who don't want the lecture boundaries in the running
   text hide the markers -- and with them the sidebar chips that point at
   them.  The overview page is unaffected.

   Hidden means hidden -- no exceptions, or the toggle stops being
   predictable.  The marker still keeps its place in the flow (zero height
   rather than display:none) so a #vorlesung-N link from the overview page
   still scrolls to the right spot in the text. */
html[data-lectures="off"] .lecture-mark {
  visibility: hidden; height: 0; margin: 0; overflow: hidden;
}
html[data-lectures="off"] .lecture-nav { display: none; }

/* Sidebar: one chip per lecture starting in this chapter. */
.lecture-nav .nav-heading {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.5rem;
}
.nav-heading-link {
  text-transform: none; letter-spacing: 0; font-weight: 500;
  font-size: 0.72rem; color: var(--accent);
}
.lecture-chips {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.35rem;
}
.lecture-chips a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2rem; padding: 0.15rem 0.45rem;
  border: 1px solid var(--border-strong); border-radius: 6px;
  color: var(--lecture); text-decoration: none;
  font-size: 0.85rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.lecture-chips a:hover {
  background: var(--lecture-soft); border-color: var(--lecture);
}

/* Sidebar: download of the whole script as PDF. */
.pdf-dl {
  display: block; text-decoration: none;
  border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 0.5rem 0.65rem; background: var(--bg-elev);
  line-height: 1.35;
}
.pdf-dl:hover { border-color: var(--accent); background: var(--accent-soft); }
.pdf-dl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pdf-dl-title {
  display: block; font-size: 0.85rem; font-weight: 600; color: var(--accent);
}
.pdf-dl-title::before { content: "\2193"; font-weight: 700; margin-right: 0.45em; }
.pdf-dl-meta {
  display: block; font-size: 0.72rem; color: var(--fg-muted);
  margin-top: 0.15rem;
}

/* Overview page (web counterpart of \listoflectures). */
.back-link { color: var(--fg-muted); text-decoration: none; }
.back-link:hover { color: var(--accent); }
.hero-links {
  margin: -1rem 0 2.5rem; font-family: var(--font-sans);
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
}
.hero-links:empty { display: none; }     /* lectures.html, when no PDF exists */
.hero-link {
  display: inline-block;
  font-size: 0.92rem; font-weight: 600;
  color: var(--accent); text-decoration: none;
  border: 1px solid var(--border-strong); border-radius: 999px;
  padding: 0.4rem 0.95rem;
}
.hero-link:hover { background: var(--bg-soft); border-color: var(--accent); }

/* Download of the PDF built from the same (truncated) source as the site. */
.hero-link-pdf::before { content: "\2193"; font-weight: 700; margin-right: 0.45em; }
.hero-link-meta {
  color: var(--fg-soft); font-weight: 400; font-size: 0.86em;
  margin-left: 0.55em;
}

.lec-list { list-style: none; margin: 0; padding: 0; }
.lec-row + .lec-row { border-top: 1px solid var(--border); }
.lec-row a {
  display: grid;
  grid-template-columns: 8.5rem 7rem minmax(0, 1fr);
  align-items: baseline; gap: 1rem;
  padding: 1rem 0.6rem;
  color: var(--fg); text-decoration: none;
  border-radius: 8px; border-bottom: none;
}
.lec-row a:hover { background: var(--bg-soft); border-bottom: none; }
.lec-name {
  display: inline-flex; align-items: baseline; gap: 0.45rem;
  color: var(--lecture); font-family: var(--font-sans);
}
.lec-kicker {
  font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.lec-num {
  font-size: 1.25rem; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.lec-date {
  font-family: var(--font-sans); font-size: 0.85rem;
  color: var(--fg-muted); font-variant-numeric: tabular-nums;
}
.lec-date-empty { color: var(--fg-soft); }
/* No \newlecture carries a date yet -- drop the column rather than show a
   row of dashes. */
.lec-list.no-dates .lec-row a { grid-template-columns: 8.5rem minmax(0, 1fr); }
.lec-list.no-dates .lec-date { display: none; }
/* What a lecture covers: a chapter line, then one line per section with its
   subsections run on underneath. */
.lec-where { display: block; line-height: 1.4; }
.lec-chap {
  display: block;
  font-family: var(--font-sans); font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--fg-soft);
  margin: 0.7rem 0 0.25rem;
}
.lec-chap:first-child { margin-top: 0; }
.lec-sec { display: block; margin: 0.2rem 0; }
.lec-sec-num {
  color: var(--fg-muted); font-variant-numeric: tabular-nums;
  margin-right: 0.3em;
}
.lec-subs {
  display: block; padding-left: 0.9rem; margin-top: 0.05rem;
  font-size: 0.86rem; color: var(--fg-muted); line-height: 1.5;
}
.lec-sub-num { color: var(--fg-soft); font-variant-numeric: tabular-nums; }
.lec-sub-more { color: var(--fg-soft); }
.lec-more {
  display: block; margin-top: 0.5rem;
  font-family: var(--font-sans); font-size: 0.76rem; color: var(--fg-soft);
}
.lec-empty { color: var(--fg-muted); }

@media (max-width: 620px) {
  .lec-row a {
    grid-template-columns: 1fr auto;
    gap: 0.35rem 1rem;
  }
  .lec-where { grid-column: 1 / -1; }
}

/* --------------------------------------------------- responsive ---- */

@media (max-width: 960px) {
  :root { --sidebar-w: 260px; }
  .content { padding: 1.5rem 1.5rem 4rem; }
}

@media (max-width: 760px) {
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--header-h); left: 0; right: 0;
    max-height: calc(100vh - var(--header-h));
    border-right: none; border-bottom: 1px solid var(--border);
    transform: translateY(-100%);
    transition: transform 0.2s ease;
    z-index: 15; background: var(--bg-elev);
  }
  .sidebar.open { transform: translateY(0); }
  .content { padding: 1.25rem 1rem 3rem; }
  body { font-size: 16px; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.35rem; }
}
