/* Screen typography: readable prose, visible navigation, and explicit proof steps. */
@media screen {
  :root {
    --muted: #454545;
    --strong-rule: #242424;
    --margin: 200px;
    --gutter: 28px;
    --reading: calc(100% - var(--margin) - var(--gutter));
    --prose-font: Georgia, 'Times New Roman', serif;
  }
  html[data-theme=dark] {
    --ink: #f2f2f2;
    --muted: #c2c2c2;
    --strong-rule: #d8d8d8;
  }
  html { scroll-padding-top: 0; }
  .chapter { scroll-margin-top: 84px; }
  body {
    font: 22px/1.5 var(--prose-font);
    -webkit-font-smoothing: auto;
  }
  p { margin-bottom: 13px; }
  .site-header { height: 64px; padding: 0 26px; }
  .course-name { font: 750 27px/1.15 var(--sans); letter-spacing: -.5px; }
  .header-actions { font: 600 15px/1.4 var(--sans); gap: 18px; }
  .header-actions button, .header-actions a { min-height: 44px; }
  .notes-layout { grid-template-columns: 244px minmax(0,1fr); max-width: 1540px; }
  .contents-rail {
    top: 64px;
    height: calc(100vh - 64px);
    padding: 24px 18px 24px 23px;
    font: 15.5px/1.4 var(--sans);
  }
  .rail-label { font-size: 13px; font-weight: 600; color: var(--muted); }
  .chapter-code { font-size: 13px !important; font-weight: 600 !important; }
  .nav-chapter > .chapter-link { font-size: 16px; font-weight: 750; padding: 7px 0; }
  .section-links a { font-size: 15px; line-height: 1.4; padding: 8px 0; color: var(--muted); }
  .section-links a[aria-current=location] { font-weight: 750; text-decoration: underline; text-underline-offset: 4px; }
  .section-links a[aria-current=location]:before { height: 18px; width: 4px; top: 10px; }
  .rail-topic { font-size: 15px; padding: 9px 0; }
  .rail-note { font-size: 13px; }
  .notes-main { max-width: none; padding: 25px 28px 48px; }
  .document-line { font-size: 14px; color: var(--muted); }
  .chapter-header { margin-bottom: 24px; }
  .chapter-header h1 { font: 750 40px/1.15 var(--sans); letter-spacing: -.8px; margin-bottom: 9px; }
  .chapter-header .chapter-source { font-size: 13.5px; line-height: 1.5; }
  .note-section { margin-bottom: 29px; scroll-margin-top: 84px; }
  .note-section h2 { font: 750 27px/1.25 var(--sans); margin-bottom: 14px; }
  .section-number { font: 650 18px/1.3 var(--sans); color: var(--ink); margin-right: 11px; }
  h3, .exercise h3 { font: 750 21px/1.35 var(--sans); margin: 20px 0 9px; }
  strong, b { font-weight: 700; color: var(--ink); }
  .statement { border-left: 3px solid var(--strong-rule); padding-left: 13px; margin: 16px 0; }
  .statement strong { font-style: normal; }
  .statement em { font-style: normal; font-weight: 700; color: var(--ink); }
  .sidenote, .note-section > .sidenote { font: 16px/1.5 var(--sans); color: var(--muted); }
  .sidenote b { font-size: 15px; font-weight: 750; line-height: 1.4; margin-bottom: 7px; }
  .sidenote p { margin-bottom: 10px; }
  .source-ref { font: 13px/1.5 var(--sans); color: var(--muted); }
  .derivation { list-style: none; counter-reset: proof-step; padding: 0; margin: 14px 0 18px; }
  .derivation li { position: relative; counter-increment: proof-step; padding-left: 38px; margin-bottom: 13px; }
  .derivation li::before { content: counter(proof-step) '.'; position: absolute; left: 0; top: 0; font: 750 21px/1.4 var(--sans); color: var(--ink); }
  .derivation li > strong:first-child { display: block; font: 750 18px/1.4 var(--sans); margin-bottom: 5px; }
  .learning-cue { font: 18px/1.5 var(--sans); margin: 10px 0 12px; }
  .learning-cue strong { font-weight: 750; }
  .katex { font-size: 1em; }
  .katex-display { font-size: 1em; margin: 12px 0 15px; }
  table { font: 16px/1.5 var(--sans); }
  th, td { padding: 8px; }
  th { font-weight: 750; color: var(--ink); }
  caption, figcaption { font: 15px/1.5 var(--sans); color: var(--muted); }
  figcaption { margin-top: 11px; }
  summary { font: 650 16px/1.4 var(--sans); color: var(--ink); min-height: 44px; padding: 12px 0; }
  .aside-detail > p, .solution > p { font-size: inherit; }
  .exercise .solution summary { padding: 10px 0; }
  .chapter-navigation { font: 600 15px/1.4 var(--sans); }
  .notes-end { font: 14px/1.5 var(--sans); }
  .reference-table { font-size: 16px; }
  .reference-table td { padding: 10px 8px; }
  .reference-table small { display: block; font: 14px/1.5 var(--sans); }
  .footnote-text { font-size: 19px; }
  .dialog-close { font-size: 15px; }
  .topic-plan p { font-size: 20px; }
  .topic-plan ul { font-size: 16px; }
  .topic-plan .plan-meta { font-size: 14px; }

  [data-lab] { font: 17px/1.5 var(--sans); }
  [data-lab] .note { font: 15px/1.5 var(--sans); }
  [data-lab] legend { font: 700 16px/1.4 var(--sans); }
  [data-lab] button { font: 600 15px/1.4 var(--sans); min-height: 44px; padding: 8px 10px; }
  [data-lab] .lab-adjustments > summary { font: 650 16px/1.4 var(--sans); padding: 12px 0; min-height: 44px; }
  [data-lab] .lab-output { font: 21px/1.5 var(--prose-font); }
  [data-lab] .lab-output .katex-display { font-size: 1em; }
  [data-lab] .massbar { height: 32px; }
  [data-lab] .mass-segment { font-size: 13px; }
  [data-lab] .mass-segment.event-b { font-size: 0; }
  [data-lab] .mass-legend li { font: 15px/1.5 var(--sans); }
  [data-lab] .mass-key { width: 12px; height: 12px; }
  [data-lab] .lab-slider label, [data-lab] .lab-slider output { font-size: 15px; }
  [data-lab] .lab-slider label { font-weight: 650; }
  [data-lab] .lab-slider input { min-height: 44px; }
  [data-lab] .lab-steps { font-size: 17px; line-height: 1.5; }
  [data-lab] .children-outcomes .outcome { font-size: 14px; }
  [data-lab] .children-outcomes .outcome strong { font-size: 16px; }
  [data-lab] .frequency-table { font-size: 15px; }
  [data-lab] .frequency-table caption, [data-lab] .lab-positive-cohort > p { font-size: 15px; }

  @media (max-width:1150px) {
    :root { --reading: 100%; }
    .note-row { display: block; }
    .sidenote { display: block; padding: 3px 0 7px; margin: 7px 0 12px; max-width: 72ch; }
    .sidenote b { display: inline; margin-right: 8px; }
    .sidenote p { display: inline; margin: 0; }
    .sidenote p + p:before { content: ' '; }
    .sidenote:before { content: ''; }
    .document-line { display: block; }
    .document-line .attribution { display: block; margin: 5px 0 0; }
  }
  @media (max-width:900px) {
    body { font-size: 20px; line-height: 1.5; }
    .site-header { height: 68px; padding: 0 18px; gap: 12px; }
    .course-name { font-size: 23px; white-space: normal; max-width: 54%; line-height: 1.1; }
    .header-actions { font-size: 15px; gap: 13px; }
    .header-actions #all-notes, .header-actions .pdf-link, .header-actions #print-notes { display: none; }
    .menu-button { display: inline-flex !important; }
    .notes-layout { display: block; }
    .contents-rail { position: fixed; top: 68px; left: 0; bottom: 0; width: 340px; max-width: 90vw; height: calc(100dvh - 68px); padding: 20px 23px; background: var(--paper); z-index: 45; visibility: hidden; transform: translateX(-100%); }
    .menu-open .contents-rail { visibility: visible; transform: translateX(0); }
    .menu-open .drawer-backdrop { display: block; position: fixed; inset: 68px 0 0; z-index: 40; background: rgba(0,0,0,.3); }
    .section-links a { font-size: 15px; padding: 10px 0; }
    .nav-chapter > .chapter-link { font-size: 16px; padding: 10px 0; }
    .rail-label, .rail-note { font-size: 13px; }
    .rail-topic { font-size: 15px; padding: 12px 0; }
    .notes-main { padding: 21px 20px 40px; }
    .chapter-header h1 { font-size: 34px; line-height: 1.2; }
    .chapter-header .chapter-source { font-size: 13px; }
    .note-section h2 { font-size: 25px; line-height: 1.3; }
    h3, .exercise h3 { font-size: 20px; }
    .section-number { font-size: 17px; }
    .sidenote, .note-section > .sidenote { font-size: 16px; line-height: 1.5; }
    .sidenote b { font-size: 15px; }
    .document-line { font-size: 13px; }
    .source-ref { font-size: 12.5px; }
    .katex, .katex-display { font-size: 1em; }
    .derivation li { padding-left: 31px; }
    .derivation li::before { font-size: 20px; }
    .derivation li > strong:first-child { font-size: 17px; }
    table { font-size: 15px; }
    th, td { padding: 7px 5px; }
    .mobile-tools { display: flex !important; font-size: 15px; gap: 19px; }
    .mobile-tools button, .mobile-tools a { min-height: 44px; }
    .chapter-navigation { font-size: 14px; }
    .notes-end { font-size: 13px; }
    [data-lab] .lab-output { font-size: 20px; }
    [data-lab] .lab-output .katex-display { font-size: 1em; }
    [data-lab] .mass-legend { grid-template-columns: 1fr; }
    [data-lab] .frequency-table { font-size: 14px; }
    [data-lab] .children-outcomes { grid-template-columns: repeat(2,minmax(0,1fr)); }
    [data-lab=bayes] .lab-adjustments fieldset { grid-template-columns: 1fr; }
  }
  @media (max-width:600px) {
    .reference-table td:first-child { font: 700 15px/1.4 var(--sans); color: var(--ink); }
    .reference-table td:last-child { font: 20px/1.5 var(--prose-font); }
    .reference-table td small { font: 14px/1.5 var(--sans); }
  }
  @media (max-width:360px) {
    .site-header { padding: 0 12px; }
    .course-name { font-size: 20px; max-width: 51%; }
    .header-actions { font-size: 14px; gap: 10px; }
    .notes-main { padding: 19px 15px 36px; }
    .chapter-header h1 { font-size: 31px; }
    .note-section h2 { font-size: 23px; }
    .learning-cue { font-size: 17px; }
    [data-lab] .frequency-table { font-size: 13px; }
  }
}
/* The paper edition uses the same hierarchy with comfortable print sizes. */
@media print {
  .exercise, .solution { break-inside: avoid; }
  #reference { break-before: page; }
  body { font: 12pt/1.4 Georgia, 'Times New Roman', serif; }
  .chapter-header h1 { font-family: var(--sans); font-weight: 700; }
  .note-section h2, h3 { font-family: var(--sans); font-weight: 700; }
  .statement strong { font-style: normal; }
  .statement em { font-style: normal; font-weight: 700; }
  .sidenote, .note-section > .sidenote { font-size: 9.5pt; color: #333; }
  .sidenote b { font-size: 9.5pt; }
  .source-ref { font-size: 8.5pt; }
  .aside-detail > p, .solution > p { font-size: 12pt; }
  table { font-size: 9.5pt; }
  caption, figcaption { font-size: 9pt; }
  .learning-cue { font: 10pt/1.4 var(--sans); }
  .derivation li > strong:first-child { font-family: var(--sans); font-size: 10pt; }
  .reference-table { font-size: 10pt; }
}
