:root {
  color-scheme: dark;
  --bg: #101217;
  --surface: #181c24;
  --surface-raised: #202632;
  --text: #eef1f6;
  --muted: #adb5c4;
  --accent: #91b7ff;
  --accent-strong: #b7d0ff;
  --border: #343c4b;
  --focus: #ffd166;
  --sample: #e7b75b;
  --max-width: 76rem;
  --reading-width: 46rem;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.72 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration-thickness: .08em;
  text-underline-offset: .18em;
}

a:hover {
  color: var(--accent-strong);
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: .2rem solid var(--focus);
  outline-offset: .2rem;
  border-radius: .15rem;
}

.skip-link {
  position: absolute;
  z-index: 10;
  top: .75rem;
  left: .75rem;
  padding: .65rem .9rem;
  transform: translateY(-200%);
  background: var(--focus);
  color: #111;
  font-weight: 700;
}

.skip-link:focus {
  transform: none;
}

header.site {
  border-bottom: 1px solid var(--border);
  background: #12151b;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 4vw, 2rem);
}

header.site .title {
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  font-weight: 750;
  letter-spacing: -.02em;
}

header.site .tagline,
.muted {
  color: var(--muted);
}

header.site .tagline {
  margin-top: .15rem;
  font-size: .92rem;
}

nav.site {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.2rem;
  margin-top: .85rem;
}

nav.site a {
  padding: .2rem 0;
  font-size: .95rem;
}

nav.site a.active {
  color: var(--text);
  font-weight: 700;
  text-decoration-color: var(--accent);
}

main {
  max-width: var(--reading-width);
  min-height: 60vh;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4rem) clamp(1rem, 4vw, 2rem) 6rem;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -.025em;
}

h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2rem, 7vw, 3.25rem);
}

h2 {
  margin-top: 2.7rem;
  font-size: clamp(1.4rem, 4vw, 1.9rem);
}

h3 {
  margin-top: 2rem;
}

p,
ul,
ol,
blockquote,
pre,
table {
  margin-top: 1.2rem;
  margin-bottom: 1.2rem;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: .55rem;
}

blockquote {
  margin-left: 0;
  padding: .3rem 1.15rem;
  border-left: .25rem solid var(--accent);
  color: var(--muted);
}

pre,
code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .9em;
}

code {
  padding: .1em .35em;
  border: 1px solid var(--border);
  border-radius: .3rem;
  background: var(--surface);
}

pre {
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: .55rem;
  background: var(--surface);
}

pre code {
  padding: 0;
  border: 0;
  background: none;
}

table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  text-align: left;
}

th {
  background: var(--surface-raised);
}

.sample-badge {
  display: inline-block;
  margin: .25rem 0 1rem;
  padding: .2rem .55rem;
  border: 1px solid var(--sample);
  border-radius: 999px;
  color: #ffe0a3;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.post-card {
  margin: 0 0 1rem;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--border);
  border-radius: .7rem;
  background: var(--surface);
}

.post-card h2 {
  margin: 0;
  font-size: 1.25rem;
}

.post-card .muted {
  margin-bottom: 0;
  font-size: .88rem;
}

.post-card .sample-badge {
  margin: 0 0 .65rem;
}

.course-layout {
  display: grid;
  grid-template-columns: minmax(11rem, 15rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  width: min(72rem, calc(100vw - 2rem));
  margin-left: 50%;
  transform: translateX(-50%);
  align-items: start;
}

.toc {
  position: sticky;
  top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: .6rem;
  background: var(--surface);
  font-size: .9rem;
}

.toc strong {
  display: block;
  margin-bottom: .55rem;
}

.toc ol {
  margin: 0;
  padding-left: 1.25rem;
}

.toc li + li {
  margin-top: .45rem;
}

.course-body {
  min-width: 0;
}

.course-body section {
  scroll-margin-top: 1rem;
}

.course-body section:first-child h2 {
  margin-top: 0;
}

.toplink {
  margin-top: 2.5rem;
  font-size: .9rem;
}

.home-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.home-links a {
  display: flex;
  min-height: 7rem;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.2rem;
  border: 1px solid var(--border);
  border-radius: .7rem;
  background: var(--surface);
  font-size: 1.15rem;
  font-weight: 700;
}

.home-links span {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 400;
}

.address {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: .9rem;
}

footer.site {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 1.5rem clamp(1rem, 4vw, 2rem) 3rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .88rem;
}

@media (max-width: 46rem) {
  body {
    font-size: 1rem;
  }

  .course-layout {
    grid-template-columns: 1fr;
    width: auto;
    margin-left: 0;
    transform: none;
  }

  .toc {
    position: static;
  }

  .home-links {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
