:root {
  --ink: #172033;
  --muted: #53627a;
  --line: #d9e1ea;
  --soft: #f8fafc;
  --blue: #3266a8;
  --teal: #20836f;
  --amber: #b56b1c;
  --rose: #a84d77;
  --violet: #5b65c6;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

a {
  color: var(--blue);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover,
a:focus {
  color: #244a7c;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  position: sticky;
  top: 0;
  z-index: 10;
}

.nav {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 720;
  color: var(--ink);
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 0.94rem;
}

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

.nav-links a:hover,
.nav-links a:focus,
.nav-links a[aria-current="page"] {
  color: var(--ink);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 34px 20px 56px;
}

.lead {
  max-width: 820px;
  font-size: 1.16rem;
  color: #2c394d;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.08;
}

h2 {
  margin: 44px 0 14px;
  font-size: 1.55rem;
}

h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
}

p {
  margin: 0 0 14px;
}

.meta {
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  list-style: none;
}

.meta li,
.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: var(--soft);
  font-size: 0.9rem;
}

.course-map {
  margin: 30px 0 8px;
}

.course-map img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

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

.card,
.session {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px;
  background: var(--white);
}

.session {
  margin: 18px 0;
}

.session-header {
  display: flex;
  gap: 12px;
  align-items: baseline;
  justify-content: space-between;
}

.session-number {
  color: var(--teal);
  font-weight: 720;
  white-space: nowrap;
}

.materials-list,
.reference-list,
.plain-list {
  padding-left: 1.1rem;
  margin: 10px 0 0;
}

.materials-list li,
.reference-list li,
.plain-list li {
  margin: 6px 0;
}

.reference-list li {
  margin-bottom: 10px;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.resource-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  background: var(--soft);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.94rem;
}

.resource-link:hover,
.resource-link:focus {
  border-color: var(--blue);
  color: var(--blue);
}

.homework-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

#assignment-viewer {
  scroll-margin-top: 90px;
}

.assignment-picker {
  position: sticky;
  top: 82px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--soft);
}

.assignment-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.assignment-button:hover,
.assignment-button:focus,
.assignment-button[aria-current] {
  border-color: var(--blue);
  background: #edf5ff;
}

.assignment-button span {
  display: block;
  font-weight: 700;
}

.assignment-button small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.markdown-body {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 24px;
  background: var(--white);
}

.markdown-body h1 {
  margin: 0 0 14px;
  font-size: 1.9rem;
  line-height: 1.16;
}

.markdown-body h2 {
  margin: 30px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 1.28rem;
}

.markdown-body h1 + h2,
.markdown-body .link-row + h1 + h2 {
  border-top: 0;
  padding-top: 0;
}

.markdown-body h3 {
  margin: 22px 0 8px;
  font-size: 1.04rem;
}

.markdown-body ul,
.markdown-body ol {
  margin: 8px 0 16px;
  padding-left: 1.35rem;
}

.markdown-body li {
  margin: 7px 0;
}

.markdown-body pre {
  overflow-x: auto;
  margin: 14px 0 18px;
  border-radius: 6px;
  padding: 14px 16px;
  background: #111827;
  color: #f8fafc;
  line-height: 1.45;
}

.markdown-body pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.markdown-body code {
  border-radius: 4px;
  padding: 0.08rem 0.24rem;
  background: #eef2f7;
  color: #223047;
}

.inline-file-link {
  color: var(--blue);
  text-decoration: none;
}

.inline-file-link code {
  color: inherit;
  background: #edf5ff;
}

.inline-file-link:hover code,
.inline-file-link:focus code {
  text-decoration: underline;
}

.markdown-body .table-wrap {
  margin: 12px 0 18px;
}

.markdown-body table {
  min-width: 0;
}

.r-code-panel {
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.r-code-panel h2 {
  margin-top: 0;
}

.callout {
  margin: 20px 0;
  border-left: 4px solid var(--teal);
  background: #f0fdf4;
  padding: 14px 16px;
  border-radius: 0 6px 6px 0;
}

.warning {
  border-left-color: var(--amber);
  background: #fff7e6;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--soft);
  color: #26354a;
  font-weight: 700;
}

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.94em;
}

.footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 22px 20px 36px;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  font-size: 0.92rem;
}

@media (max-width: 820px) {
  .nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .grid,
  .grid.two {
    grid-template-columns: 1fr;
  }

  .session-header {
    display: block;
  }

  .homework-layout {
    grid-template-columns: 1fr;
  }

  .assignment-picker {
    position: static;
  }

  .markdown-body {
    padding: 18px;
  }

  table {
    min-width: 620px;
  }
}
