:root {
  color: #111;
  background: #f7f7f4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
}

a {
  color: inherit;
  text-underline-offset: 0.18em;
}

button,
textarea {
  border-radius: 0;
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 0.18rem 0;
  background: transparent;
  cursor: pointer;
}

button:hover,
a:hover {
  background: #e8e8e2;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 2px solid #111;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-180%);
  border: 1px solid #111;
  padding: 0.55rem;
  background: white;
}

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

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  min-height: 3.6rem;
  align-items: center;
  gap: 1.25rem;
  padding: 0.8rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid #111;
  background: #f7f7f4;
  font-size: 0.76rem;
}

.wordmark {
  margin-right: auto;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
}

.progress-summary {
  color: #666;
}

.book-link {
  overflow: hidden;
  max-width: 32ch;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  width: min(100% - 2rem, 78ch);
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 7rem) 0 7rem;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

h1 {
  max-width: 18ch;
  margin: 0 0 1.25rem;
  font-size: clamp(2.25rem, 7vw, 5rem);
  font-weight: 500;
  letter-spacing: -0.06em;
  line-height: 0.96;
}

h2 {
  margin-top: 2.8rem;
  font-size: 1.15rem;
}

h3 {
  font-size: 0.94rem;
}

p,
li,
blockquote {
  line-height: 1.65;
}

main > p,
main > ol,
main > ul,
main > blockquote,
.exercise > p,
.answer > p {
  font-family: Georgia, "Times New Roman", serif;
}

blockquote {
  margin: 1.5rem 0 2.5rem;
  border-left: 3px solid #111;
  padding: 0.75rem 1rem;
  background: #ecece7;
}

table {
  width: 100%;
  margin: 1.25rem 0 2rem;
  border-collapse: collapse;
  background: white;
  font-size: 0.82rem;
}

th,
td {
  border-bottom: 1px solid #d8d8d2;
  padding: 0.7rem 0.8rem;
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}

th {
  border-top: 1px solid #111;
  border-bottom-color: #111;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

.book-card {
  min-height: 13rem;
  border: 1px solid #111;
  padding: 1.25rem;
  background: white;
}

.book-card h2 {
  margin-top: 0;
}

.book-card p:last-child {
  margin-bottom: 0;
  color: #666;
  font-family: inherit;
  font-size: 0.78rem;
}

pre {
  overflow: auto;
  margin: 1rem 0 1.5rem;
  border: 1px solid #d8d8d2;
  padding: 1rem;
  background: white;
  font-size: 0.78rem;
  line-height: 1.62;
  tab-size: 2;
}

code {
  font-family: inherit;
}

/* Keyword, control-flow, and import tokens */
.sourceCode .kw,
.sourceCode .cf,
.sourceCode .im {
  color: #6d28d9;
  font-weight: 600;
}

/* Type, built-in, and constant tokens */
.sourceCode .dt,
.sourceCode .bu,
.sourceCode .cn {
  color: #0369a1;
}

/* Function and exception tokens */
.sourceCode .fu,
.sourceCode .ex {
  color: #b91c1c;
}

/* Attribute and variable tokens */
.sourceCode .at,
.sourceCode .va {
  color: #0f766e;
}

/* String, character, and escape tokens */
.sourceCode .st,
.sourceCode .vs,
.sourceCode .ss,
.sourceCode .ch,
.sourceCode .sc {
  color: #047857;
}

/* Numeric tokens */
.sourceCode .dv,
.sourceCode .bn,
.sourceCode .fl {
  color: #b45309;
}

/* Operator and preprocessor tokens */
.sourceCode .op,
.sourceCode .pp {
  color: #334155;
}

/* Comment and annotation tokens */
.sourceCode .co,
.sourceCode .an,
.sourceCode .do,
.sourceCode .cv {
  color: #6b7280;
  font-style: italic;
}

/* Warning, error, and alert tokens */
.sourceCode .wa,
.sourceCode .er,
.sourceCode .al {
  color: #be123c;
  font-weight: 600;
}

:not(pre) > code {
  padding: 0.08em 0.24em;
  background: #ecece7;
}

.exercise {
  margin-top: 4rem;
  border-top: 1px solid #111;
  padding-top: 1rem;
}

.exercise-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #666;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.exercise > h2 {
  margin-top: 1rem;
}

.mark-review[aria-pressed="true"] {
  color: #111;
  font-weight: 700;
}

.reveal-answer {
  margin-top: 1rem;
  border: 1px solid #111;
  padding: 0.55rem 0.7rem;
  background: white;
}

.answer {
  display: none;
  margin-top: 1rem;
  border: 1px solid #111;
  padding: 1rem;
  background: #ecece7;
}

.answer h3 {
  margin-top: 0;
}

.exercise.answer-open + .answer {
  display: block;
}

.grade-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  align-items: center;
  margin-top: 1.2rem;
  border-top: 1px solid #aaa;
  padding-top: 0.9rem;
  color: #666;
  font-size: 0.75rem;
}

.grade-controls button[aria-pressed="true"] {
  color: #111;
  font-weight: 700;
}

.mark-page {
  margin-top: 3rem;
  border: 1px solid #111;
  padding: 0.55rem 0.7rem;
  background: white;
}

.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 4rem;
  border-top: 1px solid #111;
  padding-top: 1rem;
  font-size: 0.76rem;
}

.page-nav a:last-child {
  margin-left: auto;
  text-align: right;
}

.review-item {
  margin: 1.5rem 0;
  border-top: 1px solid #111;
  padding-top: 1rem;
}

.review-item p {
  margin: 0.45rem 0;
}

.notice {
  position: fixed;
  z-index: 30;
  right: 1rem;
  bottom: 1rem;
  max-width: calc(100vw - 2rem);
  transform: translateY(150%);
  border: 1px solid #111;
  padding: 0.75rem 1rem;
  background: white;
  font-size: 0.75rem;
  transition: transform 150ms ease;
}

.notice.visible {
  transform: none;
}

@media (max-width: 680px) {
  .site-header {
    gap: 0.75rem;
  }

  .progress-summary {
    display: none;
  }

  .book-grid {
    grid-template-columns: 1fr;
  }

  main {
    padding-top: 3rem;
  }
}

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

  .notice {
    transition: none;
  }
}
