/* Study site — nLab (ncatlab.org) look: dark-grey serif text on white, justified, blue underlined
   links, small grey sans-serif chrome, quiet hairlines. Three columns on wide screens:
   table of contents | reading column | margin notes. */

:root {
  --serif: "DejaVu Serif", Cambria, serif; /* nLab's stack: Times on a Mac */
  --sans: "Noto Sans", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;

  --toc-width: 15rem;
  --text-width: 52rem;
  --margin-width: 14rem;
  --gap: 3rem;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 1.5rem;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.3;
  text-rendering: optimizeLegibility;
}

/* --- Layout --------------------------------------------------------------------------------- */

.page {
  display: grid;
  grid-template-columns: [text] minmax(0, var(--text-width));
  justify-content: center;
  column-gap: var(--gap);
  padding: 0 1rem;
}

.text {
  grid-column: text;
  min-width: 0;
  padding-bottom: 4rem;
}

@media (min-width: 1000px) {
  .page.has-toc {
    grid-template-columns: [toc] var(--toc-width) [text] minmax(0, var(--text-width));
    padding: 0 2rem;
  }
}

/* Room on the right for margin notes. */
@media (min-width: 1480px) {
  .page.has-toc {
    grid-template-columns:
      [toc] var(--toc-width) [text] minmax(0, var(--text-width))
      [margin] var(--margin-width);
  }
}

/* --- Chrome: breadcrumbs, pager ------------------------------------------------------------- */

nav.crumbs,
nav.pager {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
}

nav.crumbs {
  padding: 1.25rem 0 0.5rem;
}

nav.crumbs a,
nav.pager a {
  color: var(--muted);
  text-decoration: none;
}

nav.crumbs a:hover,
nav.pager a:hover {
  color: var(--muted-dark);
  text-decoration: underline;
}

nav.pager {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

nav.pager a:last-child {
  text-align: right;
}

/* --- Prose ---------------------------------------------------------------------------------- */

main {
  text-align: justify;
  hyphens: auto;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--link-hover);
}

p {
  margin: 0.8em 0;
}

h1,
h2,
h3,
h4,
.chaptertitle,
.h,
.h1 {
  font-family: var(--serif);
  color: var(--ink);
  line-height: 1.25;
  text-align: left;
  hyphens: manual;
}

h1 {
  font-size: 2.2em;
  font-weight: normal;
  margin: 0.6em 0 0.8em;
}

h2,
.h {
  font-size: 1.6em;
  font-weight: normal;
  margin: 1.6em 0 0.6em;
}

h3,
.h1 {
  font-size: 1.25em;
  font-weight: bold;
  font-style: italic;
  margin: 1.4em 0 0.5em;
}

h4 {
  font-size: 1.05em;
  font-weight: bold;
  margin: 1.2em 0 0.4em;
}

strong,
b,
.bold {
  font-weight: bold;
}

em,
.italic {
  font-style: italic;
}

.underline {
  text-decoration: underline;
}

.sup,
.sub {
  font-size: 0.75em;
  line-height: 0;
}

.sup {
  vertical-align: super;
}

.sub {
  vertical-align: sub;
}

.hidden,
.noprint {
  display: none;
}

img {
  max-width: 100%;
  height: auto;
}

table {
  border-collapse: collapse;
  margin: 1.2em auto;
  font-size: 0.85em;
  text-align: left;
  display: block;
  overflow-x: auto;
}

td,
th {
  border: 1px solid var(--rule);
  padding: 0.4em 0.6em;
  vertical-align: top;
}

th {
  font-weight: bold;
}

blockquote,
.quote,
.epigraph {
  margin: 1em 2em;
  color: var(--muted-dark);
}

/* light-dark() keeps native controls, SVG charts, and system changes on the same palette. */
:root {
  color-scheme: light dark;
  --ink: light-dark(#333, #e0dfdc);
  --muted: light-dark(#888, #a4a6ab);
  --muted-dark: light-dark(#555, #b9bbc0);
  --rule: light-dark(#ddd, #41454c);
  --paper: light-dark(#fff, #191b20);
  --link: light-dark(#2222aa, #a4baff);
  --link-hover: light-dark(#2c66d8, #c5d4ff);
  --toc-link: light-dark(#226622, #a0c79a);
  --toc-visited: light-dark(#164416, #8daf88);
  --toc-opacity: 0.55;
  --surface: light-dark(#f7f7f5, #24272d);
  --grid: light-dark(#eee, #363a42);
  --rule-soft: light-dark(#f0f0f0, #30343b);
  --control-border: light-dark(#c2c5cf, #565d69);
  --control-hover: light-dark(#b5b5b0, #868d99);
  --highlight: light-dark(#fff6cc, #4a3e22);
  --error: light-dark(#a3262a, #ff9d99);
  --error-surface: light-dark(#fdf3f2, #382527);
  --syntax-keyword: light-dark(#7a2a8c, #d5a0e5);
  --syntax-string: light-dark(#2f7a2f, #a3ce91);
  --syntax-number: light-dark(#1c5cab, #9cc6ff);
  --syntax-comment: light-dark(#8a8a80, #a1a49a);
  --syntax-builtin: light-dark(#795e26, #ddc18b);
  --map-paper: light-dark(#fafafa, #16181c);
  --map-week-one: light-dark(#f3f2fb, #2b2b40);
  --map-week-two: light-dark(#f0f6f1, #24382c);
  --map-selected: light-dark(#eeedff, #3b4265);
  --map-edge: light-dark(#b6bac7, #737b8b);
}

:root[data-theme="light"] {
  color-scheme: light;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --toc-opacity: 0.8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --toc-opacity: 0.8;
  }
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  padding: 1.25rem 0 0.5rem;
}
.page-header nav.crumbs {
  padding: 0;
}
.theme-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  color: var(--muted-dark);
  font: 12px/1.5 var(--sans);
  white-space: nowrap;
}
.theme-picker[hidden] {
  display: none;
}
.theme-select {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--control-border);
  border-radius: 3px;
  padding: 0.2rem 0.3rem;
  cursor: pointer;
}
.theme-select:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

/* Imported figures and cached scientific plots have fixed colors, sometimes on transparent backgrounds.
   Give them a light canvas without inverting the data or changing their color scales. */
main img,
.cell .plot svg {
  background: white;
}
@media print {
  :root[data-theme],
  :root {
    color-scheme: light;
  }
  .theme-picker {
    display: none;
  }
}

/* --- Table of contents ---------------------------------------------------------------------- */

.toc {
  grid-column: toc;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.4;
}

.toc-tab {
  display: none;
}

.toc-panel {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.25rem 0.5rem 3rem 0;
  scrollbar-width: thin;
  /* Faded until you reach for it. */
  opacity: var(--toc-opacity);
  transition: opacity 0.25s;
}

.toc:hover .toc-panel,
.toc:focus-within .toc-panel {
  opacity: 1;
}

.toc a {
  display: block;
  padding: 0.15rem 0;
  color: var(--toc-link);
  text-decoration: none;
}

.toc a:visited {
  color: var(--toc-visited);
}

.toc a:hover {
  color: var(--link-hover);
}

.toc-book {
  margin-bottom: 0.75rem;
  font-weight: bold;
  color: var(--ink) !important;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-chapter {
  margin-bottom: 0.4rem;
  color: var(--ink) !important;
}

/* All-caps titles stay capitals in the rail: small caps are illegible at this size. */
.toc .caps {
  text-transform: none;
  font-variant: normal;
  font-size: 0.88em;
  letter-spacing: 0.03em;
}

.toc-sections {
  margin: 0.2rem 0 0.6rem !important;
  border-left: 1px solid var(--rule);
}

.toc-sections a {
  padding-left: 0.6rem;
}

.toc-sections a.active {
  margin-left: -1px;
  border-left: 2px solid var(--toc-link);
  padding-left: calc(0.6rem - 1px);
  color: var(--ink);
}

/* Too narrow for a rail: the contents slide out from a tab on the left edge. */
@media (max-width: 999px) {
  .toc {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
    width: min(20rem, 85vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    background: var(--paper);
    box-shadow: 0 0 0 1px var(--rule);
  }

  .toc:hover,
  .toc:focus-within,
  .toc.open {
    transform: none;
  }

  .toc-panel {
    opacity: 1;
    padding: 1.25rem 1rem 3rem;
  }

  .toc-tab {
    display: block;
    position: absolute;
    top: 5rem;
    left: 100%;
    padding: 0.6rem 0.35rem;
    border: 1px solid var(--rule);
    border-left: none;
    border-radius: 0 3px 3px 0;
    background: var(--paper);
    color: var(--muted-dark);
    font: 12px var(--sans);
    letter-spacing: 0.05em;
    writing-mode: vertical-rl;
    cursor: pointer;
  }

  .toc.open .toc-tab,
  .toc:hover .toc-tab {
    color: var(--ink);
  }

  /* Keep the page clear of the tab, which sits on the left edge. */
  .page.has-toc {
    padding-left: 1.9rem;
  }
}

/* --- Margin notes (Tufte) --------------------------------------------------------------------
   Markup, placed inline right after the word being annotated:
     numbered:   <span class="sidenote-number"></span><span class="sidenote">Note text.</span>
     unnumbered: <span class="marginnote">Note text.</span>
   Wide screens (≥1480px) put them in the right margin; narrower ones show them as indented asides. */

main {
  counter-reset: sidenote;
}

.sidenote-number {
  counter-increment: sidenote;
}

.sidenote-number::after,
.sidenote::before {
  content: counter(sidenote);
  font-family: var(--sans);
  font-size: 0.7em;
  color: var(--muted-dark);
}

.sidenote-number::after {
  vertical-align: super;
  line-height: 0;
  margin-left: 0.05em;
}

.sidenote::before {
  margin-right: 0.4em;
}

.sidenote,
.marginnote {
  display: block;
  margin: 0.6rem 0 0.6rem 1.5rem;
  padding-left: 0.75rem;
  border-left: 1px solid var(--rule);
  color: var(--muted-dark);
  font-size: 0.85em;
  line-height: 1.45;
  text-align: left;
  text-indent: 0;
}

@media (min-width: 1480px) {
  .has-toc .sidenote,
  .has-toc .marginnote {
    float: right;
    clear: right;
    width: var(--margin-width);
    margin: 0.3rem calc(-1 * (var(--margin-width) + var(--gap))) 0.9rem 0;
    padding-left: 0;
    border-left: none;
  }
}

/* --- Course / book index pages -------------------------------------------------------------- */

.byline {
  margin-top: -0.6em;
  color: var(--muted-dark);
  font-style: italic;
}

ol.chapters {
  padding-left: 0;
  list-style: none;
  text-align: left;
  hyphens: manual;
}

ol.chapters li {
  margin: 0.35em 0;
}

.caps {
  text-transform: lowercase;
  font-variant: small-caps;
}

/* --- Practical Electronics (pdf converter) -------------------------------------------------- */

.chnum {
  display: block;
  font-family: var(--sans);
  font-size: 0.4em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.secnum {
  margin-right: 0.35em;
  color: var(--muted);
}

figure {
  margin: 1.5em 0;
  text-align: center;
}

figcaption,
.caption {
  margin-top: 0.4em;
  font-size: 0.85em;
  color: var(--muted-dark);
  text-align: center;
}

img.eq,
p > img {
  display: block;
  margin: 0.5em auto;
}

/* --- Structural Bioinformatics (epub converter, Wiley markup) ------------------------------- */

.chaptertitle + .chaptertitle {
  font-size: 2.2em;
  font-weight: normal;
  color: var(--ink);
  margin: 0 0 0.4em;
}

.chaptertitle {
  font-size: 1.1em;
  font-weight: normal;
  color: var(--muted);
  margin: 1.2em 0 0;
}

.chapterauthor {
  font-style: italic;
  color: var(--muted-dark);
  margin-bottom: 2em;
}

.para {
  text-indent: 1.5em;
  margin: 0;
}

.paraaftertitle {
  margin: 0.4em 0 0;
}

.figure {
  margin: 1.5em 0 0.4em;
  text-align: center;
}

.figurecaption,
.tablefootnote,
.tablesource {
  font-size: 0.85em;
  color: var(--muted-dark);
  text-align: left;
}

.listbulleted,
.listnumbered,
.featurelistbulleted {
  margin: 0.3em 0 0.3em 1.5em;
  text-align: left;
}

.equationnumbered {
  margin: 0.8em 2em;
  text-align: left;
}

.reference {
  font-size: 0.85em;
  padding-left: 1.5em;
  text-indent: -1.5em;
  text-align: left;
}

/* Citation superscripts (converters/epub/citations.py) and the reference list they link to. Grey
   and unadorned so the prose reads through them; hover shows the reference (client/cite.ts). */

sup.cite {
  font-size: 0.68em;
  line-height: 0;
  color: var(--muted);
  font-variant-numeric: lining-nums;
  white-space: nowrap;
}

sup.cite a {
  color: inherit;
  text-decoration: none;
  padding: 0 0.05em;
  scroll-margin-top: 30vh;
}

sup.cite a:hover,
sup.cite a:focus-visible {
  color: var(--link-hover);
}

/* Back from the reference list (client/cite.ts): the number you clicked, lit up mid-screen. */
sup.cite a:target {
  color: var(--link-hover);
  background: var(--highlight);
}

ol.references {
  font-size: 0.85em;
  padding-left: 2.4em;
  text-align: left;
}

ol.references li {
  margin: 0.3em 0;
  padding: 0.1em 0.3em;
  scroll-margin-top: 30vh;
}

ol.references li:target {
  background: var(--highlight);
}

ol.references li::marker {
  color: var(--muted);
}

.cite-back {
  margin-left: 0.4em;
  color: var(--muted);
  text-decoration: none;
}

.cite-back:hover {
  color: var(--link-hover);
}

.cite-card {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  max-width: min(26rem, calc(100vw - 1rem));
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--control-border);
  border-radius: 5px;
  background: var(--paper);
  box-shadow: 0 3px 16px #00000014;
  font: 13px/1.45 var(--sans);
  color: var(--ink);
  text-align: left;
}

.cite-card[hidden] {
  display: none;
}

.cite-card-number {
  color: var(--muted);
}

.bodytable {
  width: 100%;
}

.headercell {
  font-weight: bold;
}

/* --- Course overview: schedule table, project milestones, references ----------------------- */

.course-resources {
  margin: 1.5em 0 2em;
  padding: 0.8em 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 15px;
  text-align: left;
}

.course-resources ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6em 2em;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 520px) {
  .course-resources ul {
    grid-template-columns: minmax(0, 1fr);
  }
}

main p.note {
  font-size: 0.9em;
  color: var(--muted-dark);
  text-align: left;
}

table.schedule,
table.milestones {
  display: table;
  width: 100%;
  margin: 1em 0 2em;
  font-size: 16px;
  line-height: 1.35;
  text-align: left;
  hyphens: manual;
}

table.schedule th {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: normal;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

table.schedule td,
table.schedule th,
table.milestones td {
  border: none;
  border-bottom: 1px solid var(--rule);
  padding: 0.6em 0.8em 0.6em 0;
}

table.schedule td.wk {
  width: 2.5em;
  color: var(--muted);
  white-space: nowrap;
}

table.schedule td:nth-child(3) {
  width: 30%;
}

table.schedule td > div + div {
  margin-top: 0.3em;
}

.keywords {
  margin-top: 0.25em;
  font-size: 0.9em;
  color: var(--muted-dark);
}

ol.lectures {
  margin: 0.3em 0 0;
  padding: 0;
  list-style: none;
}

ol.lectures .n {
  display: inline-block;
  min-width: 2.2em;
  color: var(--muted);
}

ol.lectures a {
  text-decoration: none;
}

ol.lectures a:hover {
  text-decoration: underline;
}

a.transcript {
  color: var(--muted);
}

.tag {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
}

tr.exam td {
  background: var(--surface);
}

.missing {
  color: var(--muted);
}

table.milestones td.when {
  width: 7em;
  white-space: nowrap;
  color: var(--muted-dark);
}

/* References as a bibliography: keys right-aligned in their own column, so the brackets line up and
   every citation (and its wrapped lines) starts at the same edge. */
ul.refs {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 0.6em;
  row-gap: 0.45em;
  align-items: baseline;
  padding-left: 0;
  list-style: none;
  text-align: left;
  hyphens: manual;
}

ul.refs li {
  display: contents;
}

.refkey {
  justify-self: end;
  font-family: var(--sans);
  font-size: 0.75em;
  color: var(--muted);
}

/* Narrow screens: stack each row's cells. */
@media (max-width: 700px) {
  table.schedule thead {
    display: none;
  }

  table.schedule tr,
  table.schedule td {
    display: block;
    width: auto !important;
  }

  table.schedule td {
    border: none;
    padding: 0.2em 0;
  }

  table.schedule tr {
    padding: 0.6em 0;
    border-bottom: 1px solid var(--rule);
  }
}

/* --- Week, exam, and lab pages ---------------------------------------------------------------- */

.kicker {
  margin: 1.2em 0 -0.4em;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

p.also {
  margin-top: -0.4em;
  color: var(--muted-dark);
}

a.week-title {
  font-weight: bold;
  color: var(--ink);
  text-decoration: none;
}

a.week-title:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

ul.objectives li {
  margin: 0.3em 0;
}

/* Reading, lectures, parts, past exams: quiet two- or three-column tables in the text's own size. */
table.detail {
  display: table;
  width: 100%;
  margin: 0.6em 0 1.2em;
  font-size: 16px;
  line-height: 1.35;
  text-align: left;
  hyphens: manual;
}

table.detail td,
table.detail th {
  border: none;
  border-bottom: 1px solid var(--rule);
  padding: 0.45em 0.8em 0.45em 0;
  vertical-align: top;
}

table.detail th {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: normal;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

table.reading td.ref {
  width: 30%;
}

table.detail td.n,
table.detail td.qty {
  width: 2.5em;
  color: var(--muted);
}

table.detail td.time {
  width: 4.5em;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

table.parts td.note {
  color: var(--muted-dark);
}

ol.steps > li {
  margin: 0.6em 0;
}

ol.steps ul {
  margin: 0.2em 0 0;
}

div.paper {
  margin: 0.8em 0 1.2em;
}

div.paper p {
  margin: 0.3em 0;
}

/* Homework and lab headings open their handouts, but read as headings. */
main h2 a,
main h3 a {
  color: inherit;
  text-decoration-color: var(--rule);
}

/* The total under a column of run times. */
table.lectures tfoot td {
  border-bottom: none;
}

table.lectures tfoot td.time {
  color: var(--ink);
}

/* The page icon in the "PDF" link after a citation. */
a.pdf {
  text-decoration: none;
  white-space: nowrap;
}

a.pdf:hover {
  text-decoration: underline;
}

.pdf-icon {
  margin-right: 0.15em;
  vertical-align: -0.05em;
}

.pdf-label {
  font-size: 0.6em;
  line-height: 0;
  vertical-align: super;
}

/* The graph is the entire surface; controls and details float above it. */
body.canvas-page {
  overflow: hidden;
}
.objective-map {
  position: fixed;
  inset: 0;
  text-align: left;
  hyphens: none;
}
.map-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--map-paper);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.map-viewport.dragging {
  cursor: grabbing;
}
.map-view {
  position: absolute;
  inset: 0;
}
.map-view svg {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: 0 0;
}
.map-view a {
  cursor: pointer;
}
.map-view .node text {
  fill: var(--ink);
}
.map-view .node path,
.map-view .node polygon {
  stroke: var(--control-border);
}
.map-view [fill="#f3f2fb"] {
  fill: var(--map-week-one);
}
.map-view [fill="#f0f6f1"] {
  fill: var(--map-week-two);
}
.map-view [fill="#f3f3f3"] {
  fill: var(--surface);
}
.map-view .edge path,
.map-view .edge polygon {
  stroke: var(--map-edge);
}
.map-view .edge polygon {
  fill: var(--map-edge);
}
.map-view .node:hover path,
.map-view .node:hover polygon,
.map-view .node.selected path,
.map-view .node.selected polygon {
  stroke: var(--link);
  stroke-width: 2;
  fill: var(--map-selected);
}
.map-view .node.selected text {
  fill: var(--link);
}
.map-tools {
  position: absolute;
  z-index: 10;
  top: 1rem;
  left: 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
  max-width: calc(100% - 2rem);
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--paper);
  box-shadow: 0 2px 8px #0000000a;
  font: 13px/1.5 var(--sans);
  color: var(--muted-dark);
}
.map-back {
  white-space: nowrap;
  text-decoration: none;
}
.map-tools select,
.map-tools button {
  font: inherit;
  border: 1px solid var(--control-border);
  border-radius: 3px;
  padding: 0.25rem 0.55rem;
  background: var(--paper);
  color: var(--ink);
}
.map-tools button {
  cursor: pointer;
}
.map-tools button:hover {
  background: var(--map-week-one);
}
.map-zoom,
.map-legend {
  display: flex;
  gap: 0.3rem;
}
.map-legend {
  gap: 0.7rem;
}
.map-legend span::before {
  content: "";
  display: inline-block;
  height: 0.7rem;
  width: 0.7rem;
  border: 1px solid var(--control-border);
  margin-right: 0.3rem;
  background: var(--map-week-one);
}
.map-legend .week-two::before {
  background: var(--map-week-two);
}
.map-detail {
  position: absolute;
  z-index: 20;
  top: 0.75rem;
  bottom: 0.75rem;
  right: 0.75rem;
  width: min(24rem, calc(100% - 2rem));
  overflow: auto;
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 4px 24px #0000001a;
  font-size: 16px;
}
#close-objective {
  position: sticky;
  top: 0;
  float: right;
  margin: -0.75rem -0.75rem 0 0.5rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 4px;
  background: var(--paper);
  color: var(--muted-dark);
  font: 24px/1 var(--sans);
  cursor: pointer;
}
#close-objective:hover {
  background: var(--map-week-one);
}
.objective-detail h2 {
  font-size: 1.65rem;
  margin: 0.15rem 0 1rem;
}
.objective-detail h3 {
  font-size: 1rem;
  font-style: normal;
  margin-top: 1.25rem;
}
.objective-detail .kicker {
  margin-top: 0;
}
.objective-detail ul {
  padding-left: 1.2rem;
}
.objective-detail li {
  margin: 0.6rem 0;
}
.prerequisite-reason {
  display: block;
  margin-top: 0.25rem;
  font-size: 14px;
  color: var(--muted-dark);
}
.objective-detail summary {
  cursor: pointer;
  color: var(--link);
  font: 13px var(--sans);
}
#map-tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  max-width: min(23rem, calc(100vw - 1rem));
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--control-border);
  border-radius: 5px;
  background: var(--paper);
  box-shadow: 0 3px 16px #00000014;
  font: 14px/1.5 var(--sans);
}
#map-tooltip p {
  margin: 0.35rem 0 0;
}
.objective-map [hidden] {
  display: none;
}
.objective-map :focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@media (max-width: 600px) {
  .map-legend {
    display: none;
  }
  .map-tools {
    top: 0.5rem;
    left: 0.5rem;
    gap: 0.35rem;
    padding: 0.4rem;
  }
  .map-detail {
    top: 0.5rem;
    bottom: 0.5rem;
    right: 0.5rem;
  }
}

/* Locally imported lecture players and exercises. */
@media (max-width: 999px) {
  .courseware-page .page {
    padding-left: 2.5rem;
  }
}

.course-video {
  margin: 1em 0 1.6em;
}
.course-video iframe,
.course-video video {
  display: block;
  border: 0;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
}
.transcript {
  margin-top: 0.7em;
}
.transcript[open] {
  max-height: 28em;
  overflow: auto;
}
.transcript p {
  margin: 0.4em 0;
}
.transcript button {
  border: 0;
  background: none;
  padding: 0;
  color: var(--link);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.exercise {
  margin: 1.5em 0 2em;
  padding: 1em 0;
  border-top: 1px solid var(--rule);
}
.exercise h3 {
  margin-top: 0;
}
.exercise img,
main .xblock img {
  max-width: 100%;
  height: auto;
}
.exercise fieldset {
  border: 0;
  padding: 0;
  margin: 0.5em 0;
  min-width: 0;
}
.exercise .field {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  margin: 0.4em 0;
}
.exercise .field label {
  flex: 1;
}
.exercise input[type="text"],
.exercise select,
.exercise textarea {
  font: inherit;
  padding: 0.35em 0.5em;
  max-width: 100%;
  border: 1px solid var(--rule);
  background: var(--paper, white);
  color: var(--ink);
  border-radius: 3px;
  box-sizing: border-box;
}
.exercise input[type="text"] {
  width: 14em;
}
.exercise [aria-invalid="true"] {
  outline: 2px solid #a74b39;
  outline-offset: 2px;
}
.exercise-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em;
  align-items: center;
  margin: 1em 0;
}
.exercise-actions button {
  font: inherit;
  padding: 0.35em 0.8em;
  cursor: pointer;
  color: var(--ink);
  border: 1px solid var(--rule);
  background: var(--paper, white);
  border-radius: 3px;
}
.exercise-feedback {
  font-size: 0.9em;
}
.answer-key {
  padding: 0.5em 0;
}
.answer-key summary,
.transcript summary {
  cursor: pointer;
  color: var(--link);
}
.placement-diagram {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 1em 0;
}
.placement-diagram > img {
  display: block;
  max-width: 100%;
  height: auto;
}
.placement-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 1.6em;
  height: 1.6em;
  border-radius: 50%;
  border: 1px solid #334f64;
  background: #edf5fc;
  color: #173b55;
  font: bold 13px var(--sans);
}
.placement-responses {
  display: grid;
  gap: 0.6em;
}
.placement-response {
  display: flex;
  align-items: center;
  gap: 1em;
  flex-wrap: wrap;
}
.placement-response label {
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-width: 6em;
}
.placement-label {
  max-height: 4em;
  max-width: 8em;
}
.course-credit {
  border-top: 1px solid var(--rule);
  padding-top: 1em;
  margin-top: 3em;
  font-size: 0.8em;
  color: var(--muted-dark);
}
.image-response {
  position: relative;
  width: fit-content;
  max-width: 100%;
}
.image-response > img {
  display: block;
  cursor: crosshair;
}
.image-response > input {
  display: block;
  margin-top: 0.6em;
}
.image-selection {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #334f64;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.image-selection[hidden] {
  display: none;
}
.region-answer {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin: 0.8em 0;
}
.region-answer img {
  display: block;
}
.correct-region {
  position: absolute;
  border: 2px solid #356b49;
  background: #5f9d7626;
  box-sizing: border-box;
  pointer-events: none;
}

/* A lecture's own page: the video stays in view while the transcript below it scrolls. */
.course-video.lecture video {
  margin-bottom: 0.6em;
}
@media (min-height: 760px) {
  .course-video.lecture video {
    position: sticky;
    top: 0;
    z-index: 1;
  }
}
.lecture-transcript p {
  margin: 0.5em 0;
}
.lecture-transcript button.time {
  border: 0;
  background: none;
  padding: 0;
  margin-right: 0.3em;
  color: var(--link);
  font: inherit;
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.lecture-transcript button.time:hover {
  text-decoration: underline;
}
p.due {
  margin-top: -0.4em;
  color: var(--muted-dark);
}

/* Lesson pages (site/lessons.ts): the meta line, code cells and their output, margin notes, self-checks,
   solutions, 3D structure figures, the unit list in the rail, and the exit-criteria table. */

.lesson-meta {
  margin: -0.4em 0 1.6em;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted-dark);
  text-align: left;
}

/* --- Math (MathML from temml) ---------------------------------------------------------------- */

math {
  font-size: 1.05em;
}

.math-display {
  margin: 0.9em 0;
  overflow-x: auto;
  text-align: center;
}

/* --- Code cells ------------------------------------------------------------------------------ */

.cell {
  margin: 1.2em 0;
}

.cell pre,
main pre {
  margin: 0;
  padding: 0.7em 0.9em;
  overflow-x: auto;
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.45;
  text-align: left;
  hyphens: none;
}

.cell pre.code,
main > pre {
  background: var(--surface);
  border-left: 3px solid var(--rule);
}

.cell pre.stdout {
  color: var(--muted-dark);
  border-left: 3px solid transparent;
}

.cell pre.error {
  color: var(--error);
  background: var(--error-surface);
  border-left: 3px solid #e34948;
}

.cell .plot {
  margin: 0.4em 0;
  text-align: center;
}

.cell .plot svg {
  max-width: 100%;
  height: auto;
}

.cell .html-out {
  margin: 0.6em 0;
  overflow-x: auto;
}

details.cell-code > summary {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

code {
  font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
}

/* Pygments, quietly: keywords and builtins in ink, strings green, numbers blue, comments grey. */
.code .k,
.code .kn,
.code .kc,
.code .ow {
  color: var(--syntax-keyword);
}
.code .s,
.code .s1,
.code .s2,
.code .sa,
.code .si,
.code .sd {
  color: var(--syntax-string);
}
.code .mi,
.code .mf {
  color: var(--syntax-number);
}
.code .c1,
.code .c,
.code .ch {
  color: var(--syntax-comment);
  font-style: italic;
}
.code .nf,
.code .nc {
  color: var(--syntax-number);
}
.code .nb,
.code .bp {
  color: var(--syntax-builtin);
}

/* --- Margin notes: ::: aside blocks use .marginnote from rail.css; this trims their paragraphs. */

.marginnote > :first-child {
  margin-top: 0;
}

.marginnote > :last-child {
  margin-bottom: 0;
}

/* --- Self-checks and solutions --------------------------------------------------------------- */

.check {
  margin: 1.2em 0;
  padding: 0.6em 1em;
  border: 1px solid var(--rule);
  border-left: 3px solid #86b6ef;
}

.check > :first-child {
  margin-top: 0.2em;
}

details.answer,
details.solution {
  margin: 0.6em 0 0.2em;
}

details.answer > summary,
details.solution > summary {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--link);
  cursor: pointer;
}

details.solution {
  padding: 0.3em 0 0.3em 1em;
  border-left: 3px solid var(--rule);
}

/* --- Figures: 3D structures and widgets ------------------------------------------------------ */

figure.structure,
figure.widget {
  margin: 1.6em 0;
}

figure.structure .viewer {
  position: relative;
  width: 100%;
  border: 1px solid var(--rule);
  cursor: grab;
}

figure.structure .viewer.active {
  border-color: #86b6ef;
}

figure figcaption {
  margin-top: 0.5em;
  font-size: 15px;
  line-height: 1.35;
  color: var(--muted-dark);
  text-align: left;
}

figure figcaption > p {
  display: inline;
  margin: 0;
}

figure figcaption p + p::before {
  content: " ";
}

a.molstar {
  font-family: var(--sans);
  font-size: 13px;
  white-space: nowrap;
}

figure.structure .legend {
  margin: 0.4em 0 0;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted-dark);
}

.legend .key {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  margin-right: 1em;
}

.legend .swatch {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 2px;
}

/* --- Rail: units and their lessons ----------------------------------------------------------- */

.toc-units > li {
  margin-bottom: 0.8rem;
}

.toc-unit {
  display: block;
  padding: 0.15rem 0;
  font-weight: bold;
  color: var(--muted-dark);
}

.toc-units ol {
  padding-left: 0.4rem !important;
}

/* --- Where a lesson leads; exit criteria ----------------------------------------------------- */

section.prepares {
  margin-top: 3em;
  font-size: 16px;
}

section.prepares h2 {
  font-size: 1.3em;
}

table.exit {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

table.exit th {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: normal;
  color: var(--muted);
  text-align: left;
  border-bottom: 1px solid var(--rule);
}

table.exit td {
  padding: 0.5em 0.8em 0.5em 0;
  vertical-align: top;
  text-align: left;
  border-bottom: 1px solid var(--rule-soft);
}

table.exit td.where {
  width: 30%;
}

table.exit .desc {
  margin-top: 0.2em;
  font-size: 14px;
  color: var(--muted-dark);
}

.gap {
  color: var(--error);
}

ol.lessons .n {
  display: inline-block;
  min-width: 2.2em;
  color: var(--muted);
}

figure.structure .scenes {
  display: flex;
  justify-content: flex-start;
}

/* --- Glossary: linked terms in lessons, and the glossary page ------------------------------- */

a.gloss {
  position: relative;
  color: inherit;
  text-decoration: underline dotted #9a9a9a;
  text-underline-offset: 0.2em;
}

a.gloss:hover::after,
a.gloss:focus-visible::after {
  content: attr(data-def);
  position: absolute;
  left: 0;
  top: 1.5em;
  z-index: 20;
  width: min(22em, 80vw);
  padding: 0.45em 0.65em;
  font: 13px/1.45 var(--sans);
  color: var(--ink);
  text-align: left;
  white-space: normal;
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

dl.glossary dt {
  margin-top: 0.9em;
  font-weight: bold;
}

dl.glossary dd {
  margin: 0.2em 0 0 1.5em;
}

.gloss-where {
  font-family: var(--sans);
  font-size: 13px;
  white-space: nowrap;
}

.toc-extra {
  margin-top: 0.4rem;
  color: var(--muted-dark) !important;
}

.gloss-views > input {
  position: absolute;
  opacity: 0;
}

.gloss-views > label {
  display: inline-block;
  margin: 0.4em 0.3em 0.8em 0;
  padding: 0.25em 0.7em;
  font: 13px var(--sans);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
}

.gloss-views > input:checked + label {
  color: #fff;
  background: #2a78d6;
  border-color: #2a78d6;
}

.gloss-views > input:focus-visible + label {
  outline: 2px solid #86b6ef;
}

.gloss-alpha,
#gloss-az:checked ~ .gloss-lessons {
  display: none;
}

#gloss-az:checked ~ .gloss-alpha {
  display: block;
}

.gloss-lessons h2 {
  font-size: 1.25em;
}

.gloss-lessons h2 a {
  color: inherit;
  text-decoration: none;
}

/* Interactive widgets (site/client/widgets/): controls, charts, tooltips. Small grey sans-serif chrome around
   the figure, like the rest of the site; the data marks carry the color. */

.widget-root {
  position: relative;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  text-align: left;
}

.widget-root input:not([type="range"]),
.widget-root textarea,
.widget-root select {
  color: var(--ink);
  background: var(--paper);
}

.widget-loading,
.widget-error {
  margin: 0;
  padding: 2em 1em;
  color: var(--muted);
  border: 1px dashed var(--rule);
  text-align: center;
}

.widget-error {
  color: var(--error);
}

.w-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6em 1.4em;
  margin: 0.5em 0;
}

.w-label {
  margin-right: 0.5em;
  color: var(--muted-dark);
}

.w-slider {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.w-slider input[type="range"] {
  width: 10em;
  accent-color: #2a78d6;
}

.w-slider output {
  min-width: 3.5em;
  font-variant-numeric: tabular-nums;
}

.w-text input {
  font-family: "DejaVu Sans Mono", Menlo, monospace;
  font-size: 13px;
  padding: 0.25em 0.4em;
  border: 1px solid var(--rule);
  min-width: 18em;
}

.w-choice {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3em;
}

.widget-root button,
figure.structure button {
  font-family: var(--sans);
  font-size: 13px;
  padding: 0.25em 0.7em;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 3px;
  cursor: pointer;
}

.widget-root button:hover,
figure.structure button:hover {
  border-color: var(--control-hover);
}

button[aria-pressed="true"] {
  color: #fff !important;
  background: #2a78d6 !important;
  border-color: #2a78d6 !important;
}

figure.structure .scenes {
  margin-bottom: 0.5em;
}

.w-readout {
  margin: 0.4em 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.w-chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

/* :where() keeps these weak, so a widget's own fill attribute on a label wins. */
:where(.w-chart) text {
  font-family: var(--sans);
}

:where(.w-chart text:not([fill])) {
  fill: var(--muted-dark);
}

.w-tick {
  font-size: 11px;
}

.w-axis-label {
  font-size: 12px;
}

.w-chart .w-direct {
  font-size: 12px;
}
:where(.w-chart .w-direct:not([fill])) {
  fill: var(--ink);
}

.w-tip {
  position: absolute;
  z-index: 5;
  display: none;
  max-width: 18em;
  padding: 0.4em 0.6em;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

.w-table {
  border-collapse: collapse;
  font-size: 13px;
}

.w-table th,
.w-table td {
  padding: 0.25em 0.6em;
  text-align: left;
  border-bottom: 1px solid var(--rule-soft);
}

.w-table th {
  font-weight: normal;
  color: var(--muted);
}

.w-mono {
  font-family: "DejaVu Sans Mono", Menlo, monospace;
}

.widget-root .legend {
  margin: 0.4em 0;
  color: var(--muted-dark);
}
