* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
}

a {
  color: var(--accent-deep);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible,
/* Claim moves focus to this status paragraph; without the site ring the UA
   default outline makes it read as an empty input. */
.practice-status:focus-visible {
  outline: 3px solid var(--accent-deep);
  outline-offset: 3px;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1120px;
  min-height: 68px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.site-title {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-decoration: none;
  white-space: nowrap;
}

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

.site-nav-menu {
  display: block;
}

.nav-toggle {
  display: none;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.2rem;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.65rem;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: var(--second-wash);
  color: var(--ink);
}

.site-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.site-main--wide {
  max-width: none;
  padding-right: 1rem;
  padding-left: 1rem;
}

.site-main h1,
.site-main h2,
.site-main h3 {
  color: var(--ink);
  line-height: 1.18;
}

.site-main h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.4rem, 7vw, 4.8rem);
}

.site-main h2 {
  margin-top: 2.5rem;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
}

.site-main h3 {
  margin-top: 1.75rem;
  font-size: clamp(1.15rem, 2vw, 1.5rem);
}

.site-main--default h1 {
  font-size: clamp(1.8rem, 3vw, 2.3rem);
}

.site-main--default h2 {
  font-size: clamp(1.3rem, 2.2vw, 1.6rem);
}

.site-main p,
.site-main ul,
.site-main ol,
.site-main table,
.site-main pre,
.site-main blockquote {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

.site-main li + li {
  margin-top: 0.4rem;
}

.site-main hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

.site-main blockquote {
  margin-right: 0;
  margin-left: 0;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--second);
  border-radius: 0 12px 12px 0;
  background: var(--second-wash);
  color: var(--ink-2);
}

.site-main table {
  width: 100%;
  border: 1px solid var(--line);
  border-collapse: collapse;
  background: var(--panel);
  font-size: 0.95rem;
}

.site-main th,
.site-main td {
  padding: 0.8rem;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.site-main th {
  background: var(--second-wash);
  color: var(--ink);
  font-weight: 750;
}

.site-main tbody tr:nth-child(even) td {
  background: var(--paper);
}

.site-main tbody tr:hover td {
  background: var(--second-wash);
}

.site-main code {
  padding: 0.1em 0.3em;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--second-wash);
  color: var(--accent-deep);
  font-size: 0.9em;
}

.site-main pre {
  overflow-x: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.site-main pre code {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
}

.course-intro,
.lecture-card {
  max-width: 720px;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.course-intro {
  margin-top: 1rem;
}

.course-intro__eyebrow {
  margin-bottom: 0.35rem;
  color: var(--second);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.course-intro p:last-of-type,
.lecture-note {
  color: var(--ink-2);
}

.course-links {
  padding-left: 1.2rem;
}

.correct,
.is-correct,
[data-result="correct"] {
  color: var(--ok);
}

.incorrect,
.is-incorrect,
[data-result="incorrect"] {
  color: var(--err);
}

.practice-shell {
  display: grid;
  gap: 1.25rem;
  max-width: 720px;
}

.practice-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.practice-head h1 {
  min-width: 0;
  margin: 0;
}

.practice-corner-button {
  display: inline-flex;
  flex: none;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--accent-deep);
  cursor: pointer;
}

.practice-corner-button:hover {
  border-color: var(--accent-deep);
  color: var(--ink);
}

.practice-corner-button svg {
  flex: none;
  width: 22px;
  height: 22px;
}

.practice-corner-label {
  font-weight: 650;
  white-space: nowrap;
}

.practice-lede {
  margin: 0;
  color: var(--ink-2);
  font-size: 1.08rem;
}

/*
 * The shell is a 1.25rem grid, and .site-main adds a 1.25rem bottom margin to
 * every p/ul: dropping that margin on the blocks under a practice heading
 * leaves them one gap below their heading, two gaps below the section before.
 */
.site-main .practice-subhead {
  margin: 0;
  font-size: 1.25rem;
}

.site-main .practice-instructions {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--ink-2);
}

.site-main .practice-rail-note {
  margin: 0;
  color: var(--ink-2);
}

/*
 * The lecture rail is a bare row of pill links on --paper: no panel, border,
 * or radius around it. practice.js fills it from site/questions/manifest.json
 * with one link per published lecture, labelled "Lecture N · K questions".
 * The pills size to their own text, so the row is a wrapping flex line, and a
 * shared minimum width keeps the wrapped rows on an even rhythm.
 */
.lecture-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lecture-rail a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 7rem;
  min-height: 48px;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--node-text);
  font-size: 0.95rem;
  font-weight: 750;
  text-decoration: none;
}

.lecture-rail a:hover {
  background: var(--accent-deep);
  color: var(--node-text);
}

.lecture-rail a[aria-current] {
  box-shadow: 0 0 0 3px var(--accent-deep);
}

.recovery-dialog {
  width: min(38rem, calc(100vw - 2rem));
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
}

.recovery-dialog::backdrop {
  background: var(--paper);
  opacity: 0.82;
}

.recovery-dialog h2 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.15rem, 2vw, 1.5rem);
}

.recovery-dialog > p {
  margin: 0 0 1rem;
  color: var(--ink-2);
}

.recovery-form {
  display: grid;
  gap: 0.5rem;
}

.recovery-dialog .recovery-subhead {
  margin: 1.5rem 0 0.35rem;
  font-size: 1.05rem;
}

.recovery-dialog > .recovery-intro {
  margin: 0 0 0.75rem;
  color: var(--ink-2);
}

.recovery-dialog > .practice-status {
  margin-top: 0.5rem;
}

.recovery-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem;
}

.recovery-controls--claim {
  grid-template-columns: minmax(0, 1fr) auto;
}

.recovery-controls input {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.recovery-close {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.practice-button {
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--node-text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.practice-button:hover {
  border-color: var(--accent-deep);
  background: var(--accent-deep);
  color: var(--node-text);
}

.practice-button--quiet,
.practice-button--quiet:hover {
  background: transparent;
  color: var(--ink);
}

.practice-button--quiet {
  border-color: var(--line);
}

.practice-button--quiet:hover {
  border-color: var(--ink-2);
}

.question-list {
  display: grid;
  gap: 1rem;
}

.practice-status,
.practice-progress {
  margin: 0;
  color: var(--ink-2);
}

[hidden] {
  display: none;
}

@media (max-width: 560px) {
  .recovery-controls {
    grid-template-columns: 1fr;
  }

  /* The title and the labelled corner button no longer fit one line. */
  .practice-head {
    flex-wrap: wrap;
  }
}

.site-footer {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 768px) {
  .site-header__inner {
    min-height: 64px;
    padding: 0.5rem 1rem;
  }

  .site-nav-menu {
    position: relative;
    margin-left: auto;
  }

  .nav-toggle {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    padding: 0.6rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--second-wash);
    cursor: pointer;
    list-style: none;
  }

  .nav-toggle::-webkit-details-marker {
    display: none;
  }

  .nav-toggle::marker {
    content: "";
  }

  .nav-toggle__bar {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--ink);
  }

  .site-nav-menu:not([open]) .site-nav {
    display: none;
  }

  .site-nav-menu[open] .site-nav {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 10;
    display: flex;
    width: min(20rem, calc(100vw - 2rem));
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    box-shadow: 0 18px 36px var(--paper);
  }

  .site-nav a {
    width: 100%;
    min-height: 44px;
    padding: 0.65rem 0.75rem;
  }

  .site-main {
    padding: 2rem 1rem 3rem;
  }

  .site-main--wide {
    padding-right: 1rem;
    padding-left: 1rem;
  }

  .site-main table {
    display: block;
    overflow-x: auto;
  }

  .site-footer {
    padding: 1rem;
  }
}
