@font-face {
  font-family: "Desk Serif";
  src: url("/media/stix-two-text-italic-variable.woff") format("woff");
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
}

/* Semantic defaults, followed by a small sheet of reusable layout utilities. */
:root {
  color-scheme: dark;
  --ground: #070612;
  --white: #ffffff;
  --ink: rgba(255, 255, 255, .8);
  --muted: #9ca3af;
  --line: rgba(255, 255, 255, .2);
  --glass: rgba(255, 255, 255, .1);
  --unit: 8px;
  --corner: 12px;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body, main, section, div, article, nav, aside, fieldset { min-width: 0; }
::selection { background: #e3d5ff; color: var(--ground); }
:focus-visible { outline: 3px solid #e3d5ff; outline-offset: 5px; }
a { color: var(--white); text-decoration-thickness: 1px; text-underline-offset: 5px; }
a:hover { text-decoration-color: var(--muted); }
p { margin: 0 0 16px; max-width: 72ch; }
h1, h2, h3 { color: var(--white); font-weight: 700; }
h1 { margin: 0; font-size: 2.25rem; line-height: 1.1; letter-spacing: -.045em; }
h1 em { font-family: "Desk Serif", Georgia, serif; font-weight: 500; letter-spacing: -.035em; }
h2 { margin: 0 0 16px; font-size: 1.5rem; line-height: 1.25; letter-spacing: -.025em; }
h3 { margin: 32px 0 12px; font-size: 1.125rem; line-height: 1.4; letter-spacing: -.015em; }
strong { font-weight: 600; color: var(--white); }
ul, ol { padding-left: 24px; }
li { margin-block: 8px; }
button, input, textarea { font: inherit; }
svg { flex-shrink: 0; }
img { display: block; max-width: 100%; height: auto; }

body > header {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: center;
  min-height: 88px;
  border-bottom: 1px solid var(--line);
}
body > header > a { display: inline-flex; align-items: center; gap: 12px; min-height: 48px; font-weight: 600; text-decoration: none; }
body > header nav { display: flex; gap: 24px; }
body > header nav a { display: inline-flex; align-items: center; min-height: 48px; text-decoration: none; color: var(--muted); }
body > header nav a[aria-current="page"] { color: var(--white); }
body > header nav a:hover { color: var(--white); }

#welcome-desk { position: relative; isolation: isolate; overflow: hidden; }
#welcome-desk > .u-wrap { position: relative; padding-block: 80px 72px; }
#welcome-desk .u-stack { max-width: 640px; }
#welcome-desk h1 { max-width: 14ch; font-size: clamp(2.5rem, 5vw, 4rem); line-height: 1.06; }
#welcome-desk .u-stack > p:not(.u-badge) { max-width: 52ch; font-size: 1.125rem; line-height: 1.6; }
#welcome-desk aside { max-width: 57ch; background: rgba(7, 6, 18, .76); backdrop-filter: blur(16px); }
#welcome-desk aside p { margin: 0; }
#welcome-desk aside p + p { margin-top: 8px; }
#still-life {
  position: absolute;
  z-index: -2;
  width: min(806px, 60%);
  height: 576px;
  right: 0;
  top: 16px;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 48% 44%, #644276 0, #291a38 28%, var(--ground) 67%);
}
#still-life img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  color: transparent;
  font-size: 0;
}
#welcome-desk::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, var(--ground) 0, rgba(7, 6, 18, .96) 24%, rgba(7, 6, 18, .28) 66%, rgba(7, 6, 18, .06));
}
#welcome-desk::after {
  content: "";
  position: absolute;
  z-index: -1;
  bottom: 0;
  inset-inline: 0;
  height: 160px;
  background: linear-gradient(transparent, var(--ground));
  pointer-events: none;
}

nav[aria-label="Chapter index"] { align-self: start; position: sticky; top: 32px; }
nav[aria-label="Chapter index"] > p { color: var(--muted); font-size: 1rem; font-weight: 500; margin-bottom: 16px; }
nav[aria-label="Chapter index"] ol { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
nav[aria-label="Chapter index"] li { margin: 0; border-bottom: 1px solid var(--line); }
nav[aria-label="Chapter index"] a { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 16px 0; min-height: 56px; font-size: 1rem; text-decoration: none; line-height: 1.45; }
nav[aria-label="Chapter index"] a svg { width: 20px; height: 20px; color: var(--muted); }
nav[aria-label="Chapter index"] a:hover { color: #e3d5ff; }

section[id] { scroll-margin-top: 32px; }
section > header { margin-bottom: 32px; }
section > header > p:first-child { color: var(--muted); font-weight: 500; margin-bottom: 12px; }
section > header > p:last-child { margin-bottom: 0; }
section > header h2 { max-width: 29ch; }
article { border: 1px solid var(--line); border-radius: var(--corner); padding: 24px; background: #171622; }
article h3 { margin-top: 0; }
article p:last-child { margin-bottom: 0; }
aside { border: 1px solid var(--line); border-radius: var(--corner); padding: 24px; }
aside[aria-label="Chapter recap"] { margin-top: 24px; background: rgba(255, 255, 255, .04); border-inline-start: 2px solid rgba(255, 255, 255, .6); }
aside[aria-label="Chapter recap"] p { margin: 0; }
aside[aria-label="Chapter recap"] strong { display: block; margin-bottom: 8px; font-family: "Desk Serif", Georgia, serif; font-weight: 600; font-style: italic; font-size: 1.125rem; }

fieldset { margin: 32px 0 0; padding: 24px; border: 1px solid var(--line); border-radius: var(--corner); }
legend { padding-inline: 8px; color: var(--white); font-size: 1rem; font-weight: 600; max-width: 100%; line-height: 1.5; }
fieldset > label:has(input) { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 16px; align-items: center; min-height: 64px; cursor: pointer; }
fieldset > label:has(input) + label { border-top: 1px solid rgba(255, 255, 255, .12); margin-top: 8px; padding-top: 8px; }
input[type="checkbox"] { appearance: none; margin: 0; width: 44px; height: 44px; border: 1px solid rgba(255, 255, 255, .45); border-radius: 8px; cursor: pointer; background: rgba(255, 255, 255, .04); position: relative; }
input[type="checkbox"]:checked { background: var(--white); border-color: var(--white); }
input[type="checkbox"]:checked::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; font-weight: 600; color: var(--ground); }
label[for] { display: block; margin: 0 0 12px; color: var(--ink); font-size: 1rem; font-weight: 500; }
textarea { display: block; width: 100%; max-width: 100%; min-height: 112px; padding: 16px; border: 1px solid rgba(255, 255, 255, .4); border-radius: var(--corner); background: rgba(255, 255, 255, .035); color: var(--white); line-height: 1.6; resize: vertical; }
textarea:hover { border-color: rgba(255, 255, 255, .55); }
textarea:focus { background: rgba(255, 255, 255, .07); }
details { border: 1px solid var(--line); border-radius: var(--corner); margin-top: 24px; background: rgba(255, 255, 255, .025); }
summary { padding: 20px 24px; color: var(--white); font-weight: 500; font-size: 1rem; cursor: pointer; min-height: 64px; line-height: 1.5; }
summary::marker { color: var(--muted); }
details[open] summary { border-bottom: 1px solid var(--line); }
details > div { padding: 8px 24px 16px; }
details > div > p { margin-top: 16px; }
details ul { list-style: none; padding: 0; margin: 0; }
details li { margin: 0; }
details li + li { border-top: 1px solid rgba(255, 255, 255, .12); }
details a { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 12px; min-height: 48px; font-size: 1rem; overflow-wrap: anywhere; }
details a span { flex-shrink: 0; text-decoration: none; }
dl { margin: 24px 0; }
dt { margin-top: 24px; color: var(--white); font-weight: 600; }
dd { margin: 8px 0 0; max-width: 68ch; }
#warning-signs > ul { list-style: none; padding: 0; margin: 0; }
#warning-signs > ul li { margin: 0; padding: 24px 0; border-top: 1px solid var(--line); }
#warning-signs > ul li strong { display: block; margin-bottom: 8px; }
#warning-signs > ul li p { margin: 0; }
#worksheet-opener { padding-block: 72px 64px; }
#worksheet-opener h1 { max-width: 20ch; margin-block: 24px; }
#worksheet-opener > p:not(.u-badge) { max-width: 64ch; }
#worksheet-opener > a { margin-top: 8px; }
#missing-page { min-height: 60vh; padding-block: 88px; }
#missing-page h1 { margin-block: 24px; }
body > footer { margin-top: 64px; padding-block: 32px 48px; border-top: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 48px; }
body > footer > p { max-width: 48ch; font-size: 1rem; color: var(--muted); margin: 0; }
body > footer nav { display: flex; gap: 24px; flex-wrap: wrap; }
body > footer a { min-height: 48px; display: inline-flex; align-items: center; font-size: 1rem; white-space: nowrap; }

.u-wrap { width: calc(100% - 64px); max-width: 1280px; margin-inline: auto; }
.u-stack { display: grid; gap: 24px; }
.u-stack > * { margin-block: 0; }
.u-actions { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.u-pill { display: inline-flex; align-items: center; justify-content: center; gap: 16px; min-height: 56px; padding: 12px 24px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .2); backdrop-filter: blur(16px); font-size: 1rem; font-weight: 500; text-decoration: none; text-align: center; line-height: 1.5; max-width: 100%; }
.u-pill:hover { background: rgba(255, 255, 255, .28); border-color: rgba(255, 255, 255, .5); }
.u-solid { background: var(--white); color: var(--ground); border-color: var(--white); }
.u-solid:hover { background: #e9e5f1; border-color: #e9e5f1; }
.u-badge { display: inline-flex; align-items: center; gap: 8px; width: fit-content; max-width: 100%; padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--glass); color: var(--ink); font-size: 1rem; font-weight: 500; line-height: 1.5; }
.u-reading { display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 80px; align-items: start; padding-top: 32px; }
.u-chapters { max-width: 840px; }
.u-chapters > section { padding-block: 24px 56px; }
.u-chapters > section + section { border-top: 1px solid var(--line); padding-top: 56px; }
.u-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.u-gap { gap: 24px; }
.u-notes { margin-block: 24px; }
.u-skip { position: absolute; top: 8px; left: 16px; z-index: 10; min-height: 48px; padding: 12px 16px; background: var(--white); color: var(--ground); border-radius: 8px; transform: translateY(-160%); }
.u-skip:focus { transform: translateY(0); }

@media (prefers-reduced-motion: no-preference) {
  .u-badge { animation: settle 540ms ease-out; }
  #still-life { animation: desk-glow 12s ease-in-out infinite alternate; }
  .u-pill { transition: background-color 180ms ease, border-color 180ms ease; }
  @keyframes settle { from { filter: blur(3px); } to { filter: blur(0); } }
  @keyframes desk-glow { from { opacity: .8; } to { opacity: 1; } }
}

@media (min-width: 1120px) {
  .u-chapters > section:nth-child(even) > header { padding-left: 40px; }
  .u-chapters > section:nth-child(odd) > fieldset,
  .u-chapters > section:nth-child(odd) > .u-notes { margin-inline-end: 48px; }
  .u-chapters > section:nth-child(even) > fieldset,
  .u-chapters > section:nth-child(even) > .u-notes { margin-inline-start: 48px; }
}

@media (max-width: 1000px) {
  .u-reading { grid-template-columns: 200px minmax(0, 1fr); gap: 40px; }
  .u-split { grid-template-columns: minmax(0, 1fr); }
  body > footer { flex-direction: column; gap: 16px; }
  #still-life { opacity: .55; }
}

@media (max-width: 700px) {
  .u-wrap { width: calc(100% - 40px); }
  body > header { flex-wrap: wrap; gap: 0; padding-block: 12px; }
  body > header > a { font-size: 1rem; }
  body > header nav { gap: 24px; width: 100%; }
  body > header nav a { min-height: 44px; }
  #welcome-desk > .u-wrap { padding-block: 48px 40px; }
  #welcome-desk .u-stack { gap: 24px; }
  #welcome-desk .u-stack > p:not(.u-badge) { font-size: 1rem; }
  #welcome-desk h1 { max-width: 13ch; }
  #still-life { top: 40px; width: 100%; height: 640px; }
  #welcome-desk::before { background: rgba(7, 6, 18, .7); }
  .u-actions { flex-direction: column; align-items: stretch; }
  .u-actions > a { width: 100%; }
  .u-reading { display: block; padding-top: 24px; }
  nav[aria-label="Chapter index"] { position: static; margin-bottom: 40px; }
  nav[aria-label="Chapter index"] ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  nav[aria-label="Chapter index"] a { font-size: 1rem; padding-block: 16px; min-height: 72px; }
  nav[aria-label="Chapter index"] a svg { width: 16px; height: 16px; }
  .u-chapters > section { padding-bottom: 40px; }
  .u-chapters > section + section { padding-top: 40px; }
  #worksheet-opener { padding-block: 48px 24px; }
  #worksheet-opener h1 { max-width: 13ch; }
  fieldset, aside, article { padding: 20px; }
  fieldset > label:has(input) { gap: 12px; }
  summary { padding: 20px; }
  details > div { padding-inline: 20px; }
  body > footer { margin-top: 32px; }
  body > footer nav { column-gap: 24px; row-gap: 8px; }
}

@media print {
  :root { color-scheme: light; }
  html, body { background: #fff; color: #111; }
  body { font-size: 16px; }
  h1, h2, h3, strong, a, label, legend, dt, summary { color: #111; }
  body > header, nav[aria-label="Chapter index"], .u-skip, #still-life, .u-actions, .u-pill, body > footer nav { display: none; }
  .u-wrap { width: 100%; max-width: none; }
  #welcome-desk > .u-wrap, #worksheet-opener { padding-block: 0 24px; }
  #welcome-desk .u-stack { max-width: none; display: block; }
  #welcome-desk .u-stack > * { margin-bottom: 20px; }
  #welcome-desk h1 { font-size: 2.25rem; max-width: none; }
  #welcome-desk aside, article, aside[aria-label="Chapter recap"], textarea, details, .u-badge { background: #fff; backdrop-filter: none; color: #111; border-color: #888; }
  #welcome-desk::before, #welcome-desk::after { display: none; }
  .u-reading { display: block; padding-top: 0; }
  .u-chapters { max-width: none; }
  .u-chapters > section { padding-block: 24px; }
  .u-chapters > section + section { padding-top: 24px; border-color: #888; }
  .u-chapters > section:nth-child(even) > header { padding-left: 0; }
  .u-chapters > section > fieldset,
  .u-chapters > section > .u-notes { margin-inline: 0 !important; }
  section > header > p:first-child, body > footer > p { color: #333; }
  fieldset, article, aside { border-color: #888; break-inside: avoid; }
  fieldset > label:has(input) + label, details li + li, details[open] summary { border-color: #aaa; }
  input[type="checkbox"] { border-color: #666; background: #fff; }
  input[type="checkbox"]:checked { border-color: #111; background: #ddd; print-color-adjust: exact; }
  textarea { min-height: 120px; resize: none; }
  details > * { display: block !important; }
  details::details-content { content-visibility: visible; display: block; }
  summary { list-style: none; }
  details { break-inside: avoid; }
  .u-split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body > footer { display: block; padding-block: 24px 0; border-color: #888; }
  * { animation: none !important; transition: none !important; }
}
