/* Primer.
 *
 * A clean, full-width layout on white. Courses are cards in a grid; each
 * course has sections, and each section shows its status as a familiar icon:
 * an empty circle (not started), a half-filled circle (in progress) or a
 * check (done). Instrument Sans for text, JetBrains Mono for labels, numbers
 * and code.
 *
 * Each subject has an accent colour. [data-subject] on any element sets
 * --accent and --accent-ink (text on a filled accent) for everything inside.
 * Dark mode lifts the accents that would sink into the background. Tokens are
 * set twice for it: once for an explicit choice ([data-theme="dark"], saved by
 * the toggle) and once for the system preference when no choice was made.
 */

:root {
  --bg: #ffffff;
  --bg-2: #f4f4f1;
  --ink: #111111;
  --ink-2: #4b4d52;
  --ink-3: #8a8c91;
  --rule: #e2e2dd;
  --focus: #0b63ce;
  --scrim: rgba(17, 17, 17, 0.5);
  --code-bg: #141518;
  --code-ink: #ececea;

  --c-physics: #d7261e;
  --c-math: #0b63ce;
  --c-chemistry: #00875a;
  --c-biology: #b98300;
  --c-cs: #c2185b;
  --c-engineering: #d86a0c;
  --c-astronomy: #22317a;
  --on-light: #ffffff;
  --on-dark: #111111;

  --font: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Full width: the frame spans the window, with side padding that grows
     with it. Only running text keeps a reading measure. */
  --gutter: clamp(16px, 4vw, 64px);
  --measure: 54rem;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0e0f11;
  --bg-2: #18191c;
  --ink: #f2f2ee;
  --ink-2: #b7b9bd;
  --ink-3: #7c7f85;
  --rule: #2a2c31;
  --focus: #3b82e0;
  --scrim: rgba(0, 0, 0, 0.65);
  --code-bg: #18191c;

  --c-physics: #e5392f;
  --c-math: #3b82e0;
  --c-chemistry: #16a36e;
  --c-biology: #d69a00;
  --c-cs: #e0457f;
  --c-engineering: #e8740f;
  --c-astronomy: #6f82e0;
  --on-light: #111111;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f11;
    --bg-2: #18191c;
    --ink: #f2f2ee;
    --ink-2: #b7b9bd;
    --ink-3: #7c7f85;
    --rule: #2a2c31;
    --focus: #3b82e0;
    --scrim: rgba(0, 0, 0, 0.65);
    --code-bg: #18191c;

    --c-physics: #e5392f;
    --c-math: #3b82e0;
    --c-chemistry: #16a36e;
    --c-biology: #d69a00;
    --c-cs: #e0457f;
    --c-engineering: #e8740f;
    --c-astronomy: #6f82e0;
    --on-light: #111111;
    color-scheme: dark;
  }
}

/* Subject accents. --on-light is white text in light mode and ink in dark
   mode, where the lifted colours need dark text to keep their contrast. */
[data-subject="physics"] {
  --accent: var(--c-physics);
  --accent-ink: var(--on-light);
}
[data-subject="math"] {
  --accent: var(--c-math);
  --accent-ink: var(--on-light);
}
[data-subject="chemistry"] {
  --accent: var(--c-chemistry);
  --accent-ink: var(--on-light);
}
[data-subject="biology"] {
  --accent: var(--c-biology);
  --accent-ink: var(--on-dark);
}
[data-subject="cs"] {
  --accent: var(--c-cs);
  --accent-ink: var(--on-light);
}
[data-subject="engineering"] {
  --accent: var(--c-engineering);
  --accent-ink: var(--on-dark);
}
[data-subject="astronomy"] {
  --accent: var(--c-astronomy);
  --accent-ink: var(--on-light);
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
}

.skip:focus {
  top: 12px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.wrap {
  width: 100%;
  padding: 0 var(--gutter);
}

.label {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.muted {
  color: var(--ink-2);
}

.section-title {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--accent, var(--ink));
  border-radius: 50%;
}

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition:
    background 120ms ease-out,
    color 120ms ease-out;
}

.btn:hover {
  background: var(--bg-2);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  color: var(--bg);
  background: var(--ink);
}

.btn--primary:hover {
  color: var(--bg);
  background: var(--ink-2);
  border-color: var(--ink-2);
}

.btn--hot,
.btn--danger {
  color: #ffffff;
  background: var(--c-physics);
  border-color: var(--c-physics);
}

.btn--hot:hover,
.btn--danger:hover {
  color: #ffffff;
  background: #b51f18;
  border-color: #b51f18;
}

.btn--lg {
  padding: 13px 24px;
  font-size: 16px;
}

.btn--sm {
  padding: 5px 12px;
  font-size: 13px;
}

.btn--flat {
  border-color: transparent;
}

.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.iconbtn:hover {
  background: var(--bg-2);
}

.iconbtn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-moon {
  display: none;
}

:root[data-theme="dark"] .icon-sun {
  display: none;
}

:root[data-theme="dark"] .icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun {
    display: none;
  }
  :root:not([data-theme="light"]) .icon-moon {
    display: block;
  }
}

.linkish {
  font-weight: 600;
  font-size: 14px;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: 999px;
}

.badge--premium {
  color: var(--bg);
  background: var(--ink);
}

.badge--draft {
  color: var(--ink-2);
  border: 1.5px dashed var(--ink-3);
}

.badge--next {
  color: var(--accent-ink, var(--bg));
  background: var(--accent, var(--ink));
}

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

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}

.bar__inner {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.brand__mark {
  width: 30px;
  height: 30px;
}

.brand__bg {
  fill: var(--ink);
}

.brand__a {
  fill: var(--bg);
}

.brand__b {
  fill: var(--c-math);
}

.brand__c {
  fill: var(--c-physics);
}

.bar__nav {
  display: flex;
  gap: 4px;
}

.bar__nav a {
  padding: 7px 14px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border-radius: 999px;
  color: var(--ink-2);
}

.bar__nav a:hover {
  color: var(--ink);
}

.bar__nav a[aria-current="page"] {
  color: var(--ink);
  background: var(--bg-2);
}

.bar__end {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.account {
  position: relative;
}

.account__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 3px;
  background: transparent;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
}

.account__btn:hover {
  border-color: var(--ink-3);
}

.account__initial {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-weight: 700;
  font-size: 13px;
  color: var(--bg);
  background: var(--ink);
  border-radius: 50%;
}

.account__plan {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 250px;
  padding: 6px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 14px;
}

.menu__who {
  padding: 10px 10px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

.menu__who strong {
  display: block;
  font-size: 14px;
}

.menu a,
.menu button {
  display: block;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  font-size: 14px;
  text-decoration: none;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.menu a:hover,
.menu button:hover {
  background: var(--bg-2);
}

main {
  flex: 1;
  width: 100%;
}

main:focus {
  outline: none;
}

.foot {
  margin-top: 80px;
  border-top: 1px solid var(--rule);
}

.foot__inner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
  padding-bottom: 28px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

.foot a {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.loading {
  padding: 80px 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.empty {
  max-width: 720px;
  padding: 36px 32px;
  border: 1.5px dashed var(--ink-3);
  border-radius: 16px;
}

.empty h2 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.empty p {
  margin: 0 0 18px;
  color: var(--ink-2);
}

/* ------------------------------------------------ progress and statuses */

.progress {
  display: block;
  flex: 1;
  min-width: 60px;
  height: 6px;
  overflow: hidden;
  background: var(--rule);
  border-radius: 3px;
}

.progress__bar {
  display: block;
  height: 100%;
  background: var(--accent, var(--ink));
  border-radius: 3px;
}

/* Not started: an empty circle. In progress: the left half filled, inside
   a thin gap. Done: a filled circle with a check. */
.status-icon {
  position: relative;
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  padding: 2px;
  border: 2px solid var(--ink-3);
  border-radius: 50%;
  background-clip: content-box;
}

.status-icon[data-status="in_progress"] {
  border-color: var(--accent, var(--ink));
  background-image: linear-gradient(90deg, var(--accent, var(--ink)) 50%, transparent 50%);
}

.status-icon[data-status="completed"] {
  padding: 0;
  background: var(--accent, var(--ink));
  border-color: var(--accent, var(--ink));
}

.status-icon[data-status="completed"]::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid var(--accent-ink, var(--bg));
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ----------------------------------------------------------------- cards */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.grid > li {
  display: flex;
}

.card {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  text-decoration: none;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 16px;
  transition:
    border-color 120ms ease-out,
    transform 120ms ease-out,
    box-shadow 120ms ease-out;
}

.card:hover {
  border-color: var(--ink-3);
  transform: translateY(-2px);
}

.card:hover .card__title {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

/* The cover stands in for a course photo: the subject's colour with its
   line drawing (--motif, below) in the cover's text colour. */
.cover {
  position: relative;
  display: block;
  flex: none;
  height: 128px;
  color: var(--accent-ink, var(--bg));
  background: var(--accent, var(--ink));
}

.cover::after {
  content: "";
  position: absolute;
  inset: 12px 14px 10px 30%;
  background: currentColor;
  opacity: 0.9;
  -webkit-mask: var(--motif) right center / contain no-repeat;
  mask: var(--motif) right center / contain no-repeat;
}

.cover__badges {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 1;
  display: flex;
  gap: 6px;
}

.cover .badge {
  color: var(--ink);
  background: var(--bg);
}

.cover .badge--draft {
  color: var(--ink-2);
  border-color: var(--ink-3);
}

.card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 16px 18px 18px;
}

.card__subject {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.card__title {
  margin-top: 8px;
  font-size: 19px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.card__learn {
  display: -webkit-box;
  margin-top: 8px;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-2);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card__learn b {
  font-weight: 600;
  color: var(--ink);
}

.card__foot {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
}

.card__progress {
  display: flex;
  align-items: center;
  gap: 12px;
}

.card__progress .label {
  white-space: nowrap;
}

/* Cover drawings, one per subject, used as masks so they take the
   cover's text colour in both themes. Generated: keep both
   stylesheets in step when editing. */
[data-subject="physics"] {
  --motif: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 240 120%27%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M40 112Q140 -40 236 112%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M20 112H240%27/%3E%3Ccircle cx=%2764%27 cy=%2780%27 r=%275%27 fill=%27black%27/%3E%3Ccircle cx=%2792%27 cy=%2754%27 r=%275%27 fill=%27black%27/%3E%3Ccircle cx=%27120%27 cy=%2740%27 r=%275%27 fill=%27black%27/%3E%3Ccircle cx=%27148%27 cy=%2738%27 r=%275%27 fill=%27black%27/%3E%3Ccircle cx=%27176%27 cy=%2750%27 r=%275%27 fill=%27black%27/%3E%3Ccircle cx=%27204%27 cy=%2774%27 r=%275%27 fill=%27black%27/%3E%3C/svg%3E");
}
[data-subject="math"] {
  --motif: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 240 120%27%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M96 12V110H236%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M96 96C136 96 150 24 190 24S228 60 236 70%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 stroke-dasharray=%276 7%27 d=%27M146 24H236%27/%3E%3Ccircle cx=%27190%27 cy=%2724%27 r=%275%27 fill=%27black%27/%3E%3C/svg%3E");
}
[data-subject="chemistry"] {
  --motif: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 240 120%27%3E%3Cpolygon fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 points=%27150.0,26.0 179.4,43.0 179.4,77.0 150.0,94.0 120.6,77.0 120.6,43.0%27/%3E%3Cpolygon fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 points=%27208.9,26.0 238.3,43.0 238.3,77.0 208.9,94.0 179.5,77.0 179.5,43.0%27/%3E%3Ccircle fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 cx=%27150%27 cy=%2760%27 r=%2718%27/%3E%3C/svg%3E");
}
[data-subject="biology"] {
  --motif: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 240 120%27%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M90 30C120 30 120 90 150 90S180 30 210 30 240 90 240 90%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M90 90C120 90 120 30 150 30S180 90 210 90 240 30 240 30%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M105 36V84%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M135 36V84%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M165 36V84%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M195 36V84%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M225 36V84%27/%3E%3C/svg%3E");
}
[data-subject="cs"] {
  --motif: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 240 120%27%3E%3Cg fill=%27none%27 stroke=%27black%27 stroke-width=%276%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpath d=%27M130 26L96 60L130 94%27/%3E%3Cpath d=%27M202 26L236 60L202 94%27/%3E%3Cpath d=%27M180 16L152 104%27/%3E%3C/g%3E%3C/svg%3E");
}
[data-subject="engineering"] {
  --motif: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 240 120%27%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M70 96H240M100 40H240%27/%3E%3Cpath fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 d=%27M70 96L100 40L128 96L156 40L184 96L212 40L240 96%27/%3E%3Ccircle cx=%2770%27 cy=%2796%27 r=%275%27 fill=%27black%27/%3E%3C/svg%3E");
}
[data-subject="astronomy"] {
  --motif: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 240 120%27%3E%3Cellipse fill=%27none%27 stroke=%27black%27 stroke-width=%273%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27 cx=%27170%27 cy=%2764%27 rx=%2768%27 ry=%2724%27 transform=%27rotate%28-16 170 64%29%27/%3E%3Ccircle cx=%27170%27 cy=%2764%27 r=%2717%27 fill=%27black%27/%3E%3Ccircle cx=%27235%27 cy=%2745%27 r=%276%27 fill=%27black%27/%3E%3Ccircle cx=%2796%27 cy=%2720%27 r=%272.5%27 fill=%27black%27/%3E%3Ccircle cx=%27120%27 cy=%27104%27 r=%272.5%27 fill=%27black%27/%3E%3Ccircle cx=%27222%27 cy=%27104%27 r=%272.5%27 fill=%27black%27/%3E%3Ccircle cx=%27120%27 cy=%2740%27 r=%272.5%27 fill=%27black%27/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------- section list */

.sections {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 2px solid var(--ink);
}

.sections > li {
  border-bottom: 1px solid var(--rule);
}

.sections__row {
  display: grid;
  grid-template-columns: 24px 32px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 16px 10px;
  text-decoration: none;
  border-radius: 10px;
}

.sections__row:hover {
  background: var(--bg-2);
}

.sections__no {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-3);
}

.sections__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sections__status {
  min-width: 96px;
  text-align: right;
}

.sections--compact {
  border-top: 0;
}

.sections--compact > li {
  border-bottom: 0;
}

.sections--compact .sections__row {
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 10px;
}

.sections--compact .status-icon {
  width: 18px;
  height: 18px;
}

.sections--compact .status-icon[data-status="completed"]::after {
  left: 4px;
  top: 1px;
}

.sections--compact .sections__title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink-2);
}

.sections--compact .sections__row[aria-current="page"] {
  background: var(--bg-2);
}

.sections--compact .sections__row[aria-current="page"] .sections__title {
  font-weight: 700;
  color: var(--ink);
}

/* --------------------------------------------------------------- catalog */

.intro {
  padding: 56px 0 36px;
}

.intro h1 {
  margin: 0;
  font-size: clamp(48px, 7vw, 96px);
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.045em;
}

.intro p:not(.label) {
  max-width: 60ch;
  margin: 18px 0 0;
  font-size: 19px;
  color: var(--ink-2);
}

.resume {
  margin: 0 0 44px;
}

.resume__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.resume__card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  text-decoration: none;
  background: var(--bg-2);
  border-radius: 16px;
  border-left: 6px solid var(--accent, var(--ink));
  transition: background 120ms ease-out;
}

.resume__card:hover {
  background: var(--rule);
}

.resume__text {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.resume__text strong,
.resume__text > span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.resume__text > span {
  font-size: 14px;
}

.resume__text .progress {
  margin-top: 8px;
}

.resume__go {
  font-size: 22px;
  font-weight: 600;
}

.grid-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 18px;
}

.grid-head .section-title {
  margin: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

/* A search field in a pill, with a magnifier drawn in CSS. */
.search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(420px, 100%);
}

.search__icon {
  position: absolute;
  left: 16px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink-2);
  border-radius: 50%;
  pointer-events: none;
}

.search__icon::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: -5px;
  width: 7px;
  height: 2px;
  background: var(--ink-2);
  transform: rotate(45deg);
}

.search__input {
  width: 100%;
  padding: 11px 18px 11px 42px;
  font-size: 15px;
  background: var(--bg-2);
  border: 1.5px solid transparent;
  border-radius: 999px;
}

.search__input:hover {
  border-color: var(--rule);
}

.search__input:focus {
  background: var(--bg);
  border-color: var(--ink);
}

.search__input::placeholder {
  color: var(--ink-3);
}

.grid-count {
  margin: -4px 0 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
}

.chip:hover {
  border-color: var(--ink-3);
}

.chip[aria-pressed="true"] {
  color: var(--bg);
  background: var(--ink);
  border-color: var(--ink);
}

/* ---------------------------------------------------------------- course */

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 28px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.crumbs a {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* Wide screens put the course on the left and its sections on the right. */
.course {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 32px 72px;
  align-items: start;
  padding-top: 28px;
}

.course__side {
  position: sticky;
  top: 92px;
}

.course-head__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 0;
}

.course-head h1 {
  margin: 14px 0 14px;
  font-size: clamp(38px, 4.6vw, 64px);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.course-head__summary {
  max-width: 58ch;
  margin: 0 0 16px;
  font-size: 19px;
  color: var(--ink-2);
}

.course-head__progress {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 420px;
  margin: 16px 0 0;
  font-size: 15px;
  color: var(--ink-2);
}

.course-head__progress b {
  color: var(--ink);
}

.course-head .actions {
  margin-top: 24px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px 24px;
  margin: 28px 0 0;
  padding: 18px 22px;
  background: var(--bg-2);
  border-radius: 16px;
}

.notice p {
  margin: 0;
  max-width: 62ch;
}

.notice--premium {
  color: var(--bg);
  background: var(--ink);
}

.notice--done {
  color: var(--on-light);
  background: var(--c-chemistry);
}

.notice--premium .btn,
.notice--done .btn {
  color: inherit;
  border-color: currentColor;
}

.notice--premium .btn:hover,
.notice--done .btn:hover {
  background: rgba(127, 127, 127, 0.2);
}

.notice--premium .btn--primary {
  color: var(--ink);
  background: var(--bg);
  border-color: var(--bg);
}

.notice--premium .btn--primary:hover {
  color: var(--ink);
  background: var(--bg-2);
}

.sections-panel .section-title {
  margin-bottom: 10px;
}

/* ---------------------------------------------------------------- reader */

.reader {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: clamp(32px, 5vw, 88px);
  align-items: start;
  padding-top: 28px;
}

.rail {
  position: sticky;
  top: 88px;
}

.rail summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 12px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  list-style: none;
}

.rail summary::-webkit-details-marker {
  display: none;
}

.page {
  padding-top: 26px;
  border-top: 6px solid var(--accent, var(--ink));
}

.page h1 {
  max-width: 22ch;
  margin: 10px 0 28px;
  font-size: clamp(34px, 4.4vw, 58px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
}

.page__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: var(--measure);
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}

.page .notice {
  max-width: var(--measure);
}

.page__nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 28px;
}

.page__prev {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
}

.page__prev:hover {
  color: var(--ink);
}

.page__next {
  display: grid;
  gap: 2px;
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
}

.page__next:hover span:last-child {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-decoration-color: var(--accent, var(--ink));
}

.check__box {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid currentColor;
  border-radius: 6px;
}

.check__box svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  visibility: hidden;
}

.check[aria-pressed="true"],
.check[aria-pressed="true"]:hover {
  color: var(--on-light);
  background: var(--c-chemistry);
  border-color: var(--c-chemistry);
}

.check[aria-pressed="true"] .check__box svg {
  visibility: visible;
}

/* ----------------------------------------------------------------- prose */

.prose {
  max-width: var(--measure);
  font-size: 18px;
  line-height: 1.7;
}

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

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose .table-wrap,
.prose pre,
.prose .callout,
.prose .math-block {
  margin: 0 0 1.15em;
}

.prose h2 {
  margin: 1.9em 0 0.5em;
  font-size: 27px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.025em;
}

.prose h3 {
  margin: 1.5em 0 0.4em;
  font-size: 20px;
  font-weight: 700;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li {
  margin: 0.3em 0;
}

.prose li::marker {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--ink-3);
}

.prose strong {
  font-weight: 700;
}

.prose a {
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-decoration-color: var(--accent, var(--ink));
}

.prose a:hover {
  text-decoration-thickness: 3px;
}

.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

.prose code {
  padding: 0.1em 0.38em;
  font-family: var(--mono);
  font-size: 0.84em;
  background: var(--bg-2);
  border-radius: 6px;
}

.prose pre {
  position: relative;
  padding: 20px 22px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  color: var(--code-ink);
  background: var(--code-bg);
  border-radius: 14px;
}

.prose pre code {
  padding: 0;
  font-size: inherit;
  background: none;
}

.prose pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8a8c91;
}

.prose blockquote {
  margin-left: 0;
  padding: 2px 0 2px 18px;
  border-left: 4px solid var(--rule);
  color: var(--ink-2);
}

.callout {
  --tag: var(--c-math);
  --tag-ink: var(--on-light);
  padding: 16px 20px 4px;
  font-size: 16px;
  background: var(--bg-2);
  border-radius: 14px;
}

.callout--tip {
  --tag: var(--c-chemistry);
}

.callout--warning {
  --tag: var(--c-physics);
}

.callout--example {
  --tag: var(--c-biology);
  --tag-ink: var(--on-dark);
}

.callout__label {
  display: inline-block;
  margin: 0 0 8px !important;
  padding: 1px 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.6;
  text-transform: uppercase;
  color: var(--tag-ink);
  background: var(--tag);
  border-radius: 999px;
}

.callout > p:not(.callout__label) {
  margin: 0 0 12px;
}

.table-wrap {
  overflow-x: auto;
}

.prose table {
  border-collapse: collapse;
  min-width: 50%;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.prose th,
.prose td {
  padding: 9px 16px 9px 0;
  text-align: left;
  border-bottom: 1px solid var(--rule);
}

.prose th {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  border-bottom: 2px solid var(--ink);
}

.prose th .katex {
  font-size: 16px;
  text-transform: none;
  letter-spacing: 0;
}

.prose .align-right {
  text-align: right;
}

.prose .align-center {
  text-align: center;
}

.math-block {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 0;
  text-align: center;
}

.math--source {
  font-family: var(--mono);
  font-size: 0.88em;
  white-space: pre-wrap;
}

.prose .katex {
  font-size: 1.08em;
}

/* ----------------------------------------------------------------- admin */

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 44px 0 26px;
}

.admin-head h1 {
  margin: 8px 0 0;
  font-size: clamp(40px, 5.5vw, 68px);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.admin-head p {
  max-width: 62ch;
  margin: 12px 0 0;
  color: var(--ink-2);
}

.ledger {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0 28px;
  margin: 0 0 36px;
}

.ledger div {
  padding: 12px 0 0;
  border-top: 2px solid var(--ink);
}

.ledger dt {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.ledger dd {
  margin: 4px 0 0;
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.panel {
  margin: 0 0 24px;
  padding: 22px 24px 24px;
  border: 1px solid var(--rule);
  border-radius: 18px;
}

.panel > h2 {
  margin: 0 0 16px;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel--danger {
  border-color: var(--c-physics);
}

.form-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field + .field {
  margin-top: 14px;
}

.form-row .field + .field {
  margin-top: 0;
}

.field > span {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.input {
  width: 100%;
  padding: 10px 14px;
  font-size: 16px;
  background: var(--bg);
  border: 1.5px solid var(--ink-3);
  border-radius: 12px;
}

.input:hover {
  border-color: var(--ink-2);
}

.input:focus {
  border-color: var(--ink);
}

select.input {
  appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 55%,
    calc(100% - 14px) 55%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

textarea.input {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1.5px solid var(--ink-3);
  border-radius: 999px;
}

.seg label {
  position: relative;
}

.seg input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.seg span {
  display: block;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
}

.seg input:checked + span {
  color: var(--bg);
  background: var(--ink);
}

.seg input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.scroll-x {
  overflow-x: auto;
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.grid-table th {
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ink-2);
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}

.grid-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}

.grid-table tr:last-child td {
  border-bottom: 0;
}

.grid-table .num {
  text-align: right;
}

.grid-table .title-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.grid-table .title-cell a {
  text-decoration: none;
}

.grid-table .title-cell a:hover {
  text-decoration: underline;
}

.order {
  display: inline-flex;
  gap: 4px;
}

.order button {
  width: 30px;
  height: 30px;
  padding: 0;
  font-weight: 600;
  background: transparent;
  border: 1.5px solid var(--ink-3);
  border-radius: 50%;
  cursor: pointer;
}

.order button:hover:not([disabled]) {
  background: var(--bg-2);
}

.order button[disabled] {
  opacity: 0.3;
  cursor: default;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.publish-state {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
}

.publish-state p {
  margin: 0;
}

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.editor__source {
  display: flex;
  flex-direction: column;
}

.editor__source textarea {
  flex: 1;
  min-height: 62vh;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  tab-size: 2;
}

.editor__preview {
  max-height: calc(62vh + 40px);
  overflow: auto;
  padding: 24px 28px;
  border: 1px solid var(--rule);
  border-radius: 16px;
}

.editor__preview .prose {
  font-size: 17px;
}

.editor__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}

.editor__help {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

.editor__help code {
  color: var(--ink);
}

.tabs {
  display: none;
}

.save-state[data-state="dirty"] {
  color: var(--c-physics);
}

.count[data-over="true"] {
  color: var(--c-physics);
  font-weight: 700;
}

/* ---------------------------------------------------- sheets and toasts */

.sheet {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 20px;
}

.sheet::backdrop {
  background: var(--scrim);
}

.sheet__body {
  padding: 28px 28px 26px;
}

.sheet__body h2 {
  margin: 8px 0 10px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

.sheet__body p {
  margin: 0 0 20px;
  color: var(--ink-2);
}

.toast {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 60;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--bg);
  background: var(--ink);
  border-radius: 12px;
}

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

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

  .course__side {
    position: static;
  }
}

@media (max-width: 900px) {
  .reader {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .rail {
    position: static;
    padding: 14px 16px;
    background: var(--bg-2);
    border-radius: 16px;
  }

  .rail summary {
    padding: 0;
  }

  .rail summary::after {
    content: "+";
    margin-left: auto;
    font-family: var(--mono);
    font-size: 18px;
    font-weight: 700;
  }

  .rail details[open] summary {
    padding-bottom: 10px;
  }

  .rail details[open] summary::after {
    content: "\2212";
  }

  .two-col,
  .editor {
    grid-template-columns: minmax(0, 1fr);
  }

  .tabs {
    display: inline-flex;
  }

  .editor[data-tab="write"] .editor__preview,
  .editor[data-tab="preview"] .editor__source {
    display: none;
  }

  .editor__preview {
    max-height: none;
  }

  .ledger {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 24px;
  }
}

@media (max-width: 720px) {
  .bar__inner {
    gap: 12px;
  }

  .brand__name,
  .account__plan {
    display: none;
  }

  .intro {
    padding: 36px 0 28px;
  }

  .intro p:not(.label) {
    font-size: 17px;
  }

  .grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }


  .course-head__summary {
    font-size: 17px;
  }

  .sections__row {
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 4px 12px;
  }

  .sections__no {
    display: none;
  }

  .sections__mins,
  .sections__status {
    grid-column: 2;
    min-width: 0;
    text-align: left;
  }

  .sections__mins {
    display: none;
  }

  .prose {
    font-size: 17px;
  }

  .page__next {
    text-align: left;
  }

  .form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .foot__inner {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
