/* A restrained, book-style interface inspired by a Quarto reading layout. */
:root {
  color-scheme: light;
  --paper: #ffffff;
  --sidebar-bg: #f7f7f7;
  --subtle: #f6f6f6;
  --text: #242424;
  --muted: #626262;
  --rule: #dedede;
  --strong-rule: #c9c9c9;
  --link: #1a619a;
  --link-hover: #134575;
  --selection: #e9edf1;
  --sidebar-width: 280px;
  --body-width: 790px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: 25px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1c1c1c;
  --sidebar-bg: #252525;
  --subtle: #292929;
  --text: #e6e6e6;
  --muted: #b8b8b8;
  --rule: #454545;
  --strong-rule: #626262;
  --link: #9ac8f2;
  --link-hover: #c1def7;
  --selection: #383e45;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font-size: 1.02rem;
  line-height: 1.65;
}
button, input { font: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-underline-offset: .16em; }
a:hover { color: var(--link-hover); }
button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 100;
  transform: translateY(-170%);
  padding: .5rem .85rem;
  border: 1px solid var(--rule);
  background: var(--paper);
}
.skip-link:focus { transform: none; }

/* Navigation */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--rule);
  padding: 2rem 1.3rem 1.3rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  z-index: 25;
}
.brand {
  display: block;
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -.017em;
  line-height: 1.3;
  text-decoration: none;
}
.brand:hover { color: var(--text); }
.sidebar-subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-top: .27rem;
  margin-bottom: 1.2rem;
}
.sidebar-search { margin: 0 0 1.3rem; }
.search-field {
  display: flex;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--strong-rule);
  border-radius: 4px;
  min-height: 37px;
  overflow: hidden;
}
.search-field:focus-within {
  border-color: var(--link);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--link) 12%, transparent);
}
.search-submit {
  display: grid;
  place-items: center;
  padding: .43rem .56rem;
  background: transparent;
  color: var(--muted);
  border: 0;
  flex-shrink: 0;
}
.search-field input {
  min-width: 0;
  width: 100%;
  padding: .36rem .42rem .36rem 0;
  color: var(--text);
  border: 0;
  outline: 0;
  background: transparent;
  font-size: .9rem;
}
.search-field input::placeholder { color: var(--muted); }
.search-field input:focus-visible { outline: 0; }
.sidebar-search-status { font-size: .8rem; color: var(--muted); margin: .35rem 0 0; line-height: 1.45; }
.side-nav { display: flex; flex-direction: column; gap: .05rem; }
.nav-link, .module-link {
  display: block;
  color: var(--text);
  font-size: .9rem;
  line-height: 1.42;
  padding: .35rem .32rem;
  text-decoration: none;
  border-radius: 3px;
}
.nav-link:hover, .module-link:hover { color: var(--link); background: color-mix(in srgb, var(--text) 4%, transparent); }
.nav-link.active, .module-link.active {
  color: var(--link);
  font-weight: 650;
}
.nav-group-label {
  color: var(--text);
  font-weight: 650;
  font-size: .9rem;
  margin: 1rem .32rem .2rem;
}
.module-link {
  position: relative;
  display: grid;
  grid-template-columns: 1.15rem minmax(0, 1fr) 12px;
  gap: .36rem;
  align-items: start;
  padding-left: .72rem;
}
.nav-idx { color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-check {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-top: .22rem;
  border: 1px solid var(--strong-rule);
  border-radius: 2px;
  position: relative;
}
.module-link.complete .nav-check { border-color: var(--link); background: var(--link); }
.module-link.complete .nav-check::after {
  content: "";
  position: absolute;
  top: 0;
  left: 3px;
  width: 4px;
  height: 7px;
  border: solid var(--paper);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.sidebar-bottom { border-top: 1px solid var(--rule); padding-top: 1rem; margin-top: 1.65rem; }
.sidebar-progress-label {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  align-items: center;
  font-size: .85rem;
}
.sidebar-progress-label strong { font-weight: 600; }
.sidebar-progress-label > span { color: var(--muted); font-variant-numeric: tabular-nums; }
.sidebar-progress p { color: var(--muted); font-size: .8rem; margin: .48rem 0 0; }
.sidebar-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 1.1rem; gap: .75rem; font-size: .86rem; }
.sidebar-tools a { color: var(--muted); }
.mobile-bar, .nav-overlay { display: none; }

/* Book-style page */
.main { margin-left: var(--sidebar-width); }
.page-layout {
  display: grid;
  grid-template-columns: minmax(0, var(--body-width)) minmax(155px, 210px);
  gap: 2.5rem;
  max-width: 1180px;
  margin-inline: auto;
  padding: 2.55rem 2.45rem 3rem;
  align-items: start;
}
.content-shell { min-width: 0; width: 100%; }
.page-outline {
  align-self: start;
  position: sticky;
  top: 2rem;
  font-size: .85rem;
  line-height: 1.5;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}
.toc-title { margin: 0 0 .45rem; font-weight: 650; color: var(--text); font-size: .92rem; }
.page-toc a {
  display: block;
  padding: .27rem .7rem;
  border-left: 1px solid var(--rule);
  color: var(--muted);
  text-decoration: none;
}
.page-toc a:hover { color: var(--link); }
.page-toc a.active { color: var(--link); border-left: 2px solid var(--link); padding-left: calc(.7rem - 1px); }
.section-anchor { scroll-margin-top: .25rem; }
h1, h2, h3, h4 {
  font-weight: 620;
  color: var(--text);
  letter-spacing: -.018em;
  line-height: 1.25;
}
h1 { font-size: clamp(2rem, 3.1vw, 2.5rem); margin: 0 0 .32rem; }
h2 { font-size: 1.7rem; margin: 0 0 1rem; border-bottom: 1px solid var(--rule); padding-bottom: .32rem; }
h3 { font-size: 1.22rem; margin: 1.5rem 0 .6rem; }
h4 { font-size: 1.09rem; margin: 1.1rem 0 .5rem; }
p { margin: 0 0 .95rem; }
ul, ol { margin: .35rem 0 1rem; padding-left: 1.6rem; }
li { margin-bottom: .35rem; }
code { font-family: var(--mono); font-size: .9em; overflow-wrap: anywhere; }
p code, li code, td code { background: var(--subtle); padding: .12em .25em; border-radius: 3px; }
.subtitle { color: var(--muted); font-size: 1.25rem; margin-bottom: 1rem; }
.page-date { color: var(--muted); font-size: .88rem; margin-bottom: 1.5rem; }
.plan-summary { font-weight: 600; margin: 1rem 0; }
.small-note { color: var(--muted); font-size: .85rem; line-height: 1.5; }
.section { margin-top: 2.6rem; }

/* Progress and study controls */
.progress-panel {
  margin: 1.35rem 0 .15rem;
  padding: 1rem 0 .8rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.progress-heading { display: flex; justify-content: space-between; align-items: baseline; gap: .8rem; }
.progress-heading strong { font-weight: 650; font-size: 1.05rem; }
.progress-heading span { font-size: .97rem; color: var(--muted); font-variant-numeric: tabular-nums; }
#main-completed { margin: .12rem 0 .5rem; color: var(--muted); font-size: .9rem; }
.progress-track { display: block; position: relative; height: 6px; border-radius: 3px; overflow: hidden; background: var(--rule); }
.progress-track.small { height: 5px; margin-top: .42rem; }
.progress-fill { display: block; height: 100%; width: 0; background: var(--link); border-radius: 3px; transition: width .16s linear; }
.progress-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .7rem;
  margin-top: .85rem;
}
#next-focus { font-size: .89rem; color: var(--muted); line-height: 1.4; }
.progress-buttons, .filter-actions { display: flex; gap: .85rem; flex-wrap: wrap; align-items: center; }
.button, .filter-tab {
  font-size: .9rem;
  font-weight: 550;
  line-height: 1.4;
  border: 1px solid var(--strong-rule);
  border-radius: 4px;
  min-height: 32px;
  padding: .38rem .72rem;
  color: var(--text);
  background: var(--paper);
}
.button:hover, .filter-tab:hover { background: var(--subtle); border-color: var(--link); }
.button.primary { border-color: var(--link); color: var(--paper); background: var(--link); }
.button.primary:hover { background: var(--link-hover); border-color: var(--link-hover); }
.text-button {
  color: var(--link);
  border: 0;
  background: none;
  text-decoration: underline;
  text-underline-offset: .14em;
  font-size: .86rem;
  line-height: 1.4;
  padding: .2rem 0;
}
.text-button:hover { color: var(--link-hover); }
.text-button:disabled { color: var(--muted); text-decoration: none; cursor: default; }
.progress-panel .small-note { margin: .72rem 0 0; }
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .65rem;
  flex-wrap: wrap;
  margin: 1.05rem 0 .35rem;
}
.filter-tabs { display: inline-flex; gap: .25rem; flex-wrap: wrap; }
.filter-tab { min-width: 57px; }
.filter-tab.selected { background: var(--selection); border-color: var(--strong-rule); font-weight: 650; }
.filter-status { margin: .45rem 0 .5rem; color: var(--muted); font-size: .86rem; }
.empty-state { padding: 1rem 0; border-top: 1px solid var(--rule); }
.empty-state p { margin-bottom: .65rem; }

/* Module sections */
.module-list { display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.module-card { border-bottom: 1px solid var(--rule); }
.module-summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: grid;
  grid-template-columns: 13px minmax(0,1fr) minmax(64px,88px);
  gap: .62rem;
  align-items: start;
  padding: 1rem 0;
}
.module-summary::-webkit-details-marker { display: none; }
.module-summary::marker { content: ""; }
.module-summary:hover .module-name { color: var(--link); }
.module-summary:focus-visible { outline-offset: 3px; }
.chevron {
  width: 7px;
  height: 7px;
  border: solid var(--muted);
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(-45deg);
  margin-top: .52rem;
  margin-left: .12rem;
}
.module-card[open] .chevron { transform: rotate(45deg); margin-top: .44rem; }
.module-info { min-width: 0; display: block; }
.module-name { display: block; font-size: 1.24rem; font-weight: 620; letter-spacing: -.01em; line-height: 1.36; }
.module-kicker { display: block; font-size: .85rem; color: var(--muted); margin: .25rem 0 .22rem; line-height: 1.45; }
.module-abstract { display: block; font-size: 1rem; line-height: 1.5; margin-top: .3rem; color: var(--muted); }
.module-progress { display: block; font-size: .79rem; color: var(--muted); align-self: start; padding-top: .2rem; }
.module-progress-label { display: flex; justify-content: flex-end; align-items: baseline; gap: .4rem; font-variant-numeric: tabular-nums; }
.module-progress-label strong { font-weight: 600; color: var(--text); white-space: nowrap; }
.module-progress .progress-track { margin-top: .37rem; height: 3px; }
.module-card.complete .module-progress-label strong { color: var(--link); }
.module-body { padding: .18rem 0 1.55rem 1.4rem; }
.module-columns { display: block; }
.module-column-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; margin: 1.15rem 0 .65rem; }
.module-column-head h4 { margin: 0; }
.column-meta { color: var(--muted); font-size: .8rem; }
.topic-list { display: grid; gap: .45rem; }
.topic-row {
  display: flex;
  gap: .67rem;
  align-items: flex-start;
  cursor: pointer;
  padding: .25rem 0;
}
.topic-row input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin: .26rem 0 0;
  accent-color: var(--link);
  cursor: pointer;
}
.topic-text { display: block; min-width: 0; }
.topic-text strong { display: block; font-weight: 600; font-size: 1rem; line-height: 1.5; }
.topic-text > span { display: block; font-size: 1.01rem; color: var(--muted); line-height: 1.6; margin-top: .13rem; }
.resources-column { margin-top: 1.5rem; }
.resource-list { margin-bottom: 1rem; }
.resource-item { padding: .7rem 0 1rem; border-bottom: 1px solid var(--rule); }
.resource-item:last-child { border-bottom: 0; padding-bottom: .2rem; }
.resource-title-row { display: flex; gap: .8rem; align-items: baseline; justify-content: space-between; }
.resource-title { font-size: 1.03rem; font-weight: 600; line-height: 1.4; }
.resource-duration { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.resource-publisher { font-size: .84rem; color: var(--muted); margin: .2rem 0 .5rem; }
.resource-item p { margin: .35rem 0 0; line-height: 1.58; font-size: 1.01rem; }
.resource-item .omit { color: var(--muted); }
.reading-marker, .skip-marker { font-weight: 600; }
.build-gate {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--strong-rule);
  background: var(--subtle);
  padding: .95rem 1.05rem .75rem;
  margin-top: 1.25rem;
  border-radius: 3px;
}
.build-gate h4 { margin: 0 0 .45rem; font-weight: 650; }
.build-gate p { margin: .4rem 0; font-size: 1rem; line-height: 1.6; }
.build-gate .pass { margin-top: .6rem; }

/* Reference sections */
.code-card { border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; margin-bottom: .6rem; background: var(--subtle); }
.code-toolbar { display: flex; align-items: center; justify-content: space-between; padding: .52rem .8rem; gap: .6rem; border-bottom: 1px solid var(--rule); background: var(--paper); }
.code-toolbar code { color: var(--muted); font-size: .87rem; overflow-wrap: anywhere; }
.copy-button { border: 1px solid var(--rule); background: var(--paper); color: var(--text); font-size: .8rem; border-radius: 3px; padding: .22rem .52rem; }
.copy-button:hover { border-color: var(--link); }
pre { margin: 0; padding: .9rem 1rem; font-family: var(--mono); font-size: .86rem; line-height: 1.55; tab-size: 2; white-space: pre-wrap; overflow-wrap: anywhere; }
pre code { font: inherit; background: transparent; padding: 0; }
.table-scroll { max-width: 100%; overflow-x: auto; margin: .75rem 0 1.2rem; }
table { width: 100%; border-collapse: collapse; font-size: .98rem; }
th, td { padding: .53rem .64rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
th { font-weight: 650; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--strong-rule); background: var(--subtle); }
.cut-row, .signal-card { padding: .8rem 0; border-bottom: 1px solid var(--rule); }
.cut-row:last-child, .signal-card:last-child { border: 0; }
.cut-row h3, .signal-card h3 { font-size: 1.12rem; font-weight: 620; margin: 0 0 .25rem; }
.cut-label, .signal-meta { color: var(--muted); font-size: .84rem; margin: 0 0 .35rem; }
.cut-row p, .signal-card p { margin: 0 0 .35rem; }
.signal-links { display: flex; flex-wrap: wrap; gap: .45rem 1.1rem; font-size: .92rem; margin: .3rem 0; }
.footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 1px solid var(--rule);
  padding: 1.15rem 0 0;
  margin-top: 2.75rem;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .83rem;
}
.footer a { color: var(--muted); }

@media (max-width: 1200px) {
  .page-layout { grid-template-columns: minmax(0, var(--body-width)); max-width: 100%; justify-content: center; padding: 2.35rem 2.1rem 3rem; }
  .page-outline { display: none; }
}
@media (max-width: 980px) {
  :root { --sidebar-width: 250px; }
  .sidebar { padding: 1.6rem 1rem 1rem; }
  .page-layout { padding: 1.9rem 1.6rem 2.5rem; }
}
@media (max-width: 760px) {
  :root { scroll-padding-top: 64px; }
  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: .7rem;
    height: 53px;
    padding: 0 .95rem;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--rule);
  }
  .mobile-brand { text-decoration: none; color: var(--text); font-size: 1rem; font-weight: 650; }
  .menu-toggle {
    display: grid;
    place-items: center;
    width: 36px;
    height: 35px;
    border: 1px solid var(--rule);
    border-radius: 3px;
    background: var(--paper);
    color: var(--text);
  }
  .sidebar {
    top: 53px;
    width: min(290px, 87vw);
    visibility: hidden;
    transform: translateX(-105%);
    transition: transform .17s ease, visibility .17s;
    z-index: 40;
    padding: 1.05rem 1.1rem;
  }
  .nav-open .sidebar { visibility: visible; transform: none; }
  .nav-open .nav-overlay:not([hidden]) { display: block; position: fixed; inset: 53px 0 0; z-index: 35; border: 0; background: rgba(0,0,0,.34); }
  .nav-open { overflow: hidden; }
  .sidebar .brand { display: none; }
  .sidebar-subtitle { margin-top: 0; }
  .main { margin-left: 0; }
  .page-layout { display: block; padding: 1.45rem 1.05rem 2rem; }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.18rem; }
  .section { margin-top: 2.1rem; }
  .progress-actions { align-items: flex-start; flex-wrap: wrap; gap: .55rem; }
  .progress-buttons { gap: .75rem; }
  .module-summary { grid-template-columns: 10px minmax(0,1fr) minmax(48px,60px); gap: .46rem; }
  .module-name { font-size: 1.12rem; }
  .module-progress { font-size: .76rem; }
  .module-progress-label { display: flex; flex-wrap: wrap; gap: .1rem .25rem; justify-content: flex-end; }
  .module-body { padding-left: .15rem; }
  .column-meta { font-size: .78rem; }
  .build-gate { padding: .8rem .8rem .65rem; }
  th, td { padding: .45rem .48rem; }
  .footer { flex-direction: column; gap: .45rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
@media print {
  :root { color-scheme: light; --paper: #fff; --text: #222; --muted: #555; --subtle: #f7f7f7; --rule: #ddd; --link: #174b75; }
  .sidebar, .mobile-bar, .page-outline, .filter-bar, .filter-status, .progress-panel, .copy-button, .nav-overlay { display: none !important; }
  .main { margin: 0; }
  .page-layout { display: block; padding: 0; }
  .section { margin-top: 1.7rem; }
  .module-body { display: block !important; }
  .module-summary { break-after: avoid; }
  .resource-item, .build-gate, .code-card { break-inside: avoid; }
}
