@font-face {
  font-family: "ChulabhornLikitText";
  src: url("../assets/fonts/ChulabhornLikitText/ChulabhornLikitText-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "ChulabhornLikitText";
  src: url("../assets/fonts/ChulabhornLikitText/ChulabhornLikitText-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "ChulabhornLikitText";
  src: url("../assets/fonts/ChulabhornLikitText/ChulabhornLikitText-Bold.woff2") format("woff2");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "ChulabhornLikitDisplay";
  src: url("../assets/fonts/ChulabhornLikitDisplay/ChulabhornLikitDisplay-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Source Code Pro";
  src: url("../assets/fonts/SourceCodePro/SourceCodePro-Regular.ttf.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Source Code Pro";
  src: url("../assets/fonts/SourceCodePro/SourceCodePro-Semibold.ttf.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Trirong";
  src: url("../assets/fonts/TrirongStyle/Trirong/Trirong-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Trirong";
  src: url("../assets/fonts/TrirongStyle/Trirong/Trirong-Medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Trirong";
  src: url("../assets/fonts/TrirongStyle/Trirong/Trirong-SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "Trirong";
  src: url("../assets/fonts/TrirongStyle/Trirong/Trirong-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "Chonburi";
  src: url("../assets/fonts/TrirongStyle/Chonburi/Chonburi-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../assets/fonts/TrirongStyle/JetBrainsMono/JetBrainsMono-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../assets/fonts/TrirongStyle/JetBrainsMono/JetBrainsMono-SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Thai Looped";
  src: url("../assets/fonts/HALPlex/IBMPlexSansThaiLooped/IBMPlexSansThaiLooped-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Thai Looped";
  src: url("../assets/fonts/HALPlex/IBMPlexSansThaiLooped/IBMPlexSansThaiLooped-Medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Thai Looped";
  src: url("../assets/fonts/HALPlex/IBMPlexSansThaiLooped/IBMPlexSansThaiLooped-SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Thai Looped";
  src: url("../assets/fonts/HALPlex/IBMPlexSansThaiLooped/IBMPlexSansThaiLooped-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  src: url("../assets/fonts/HALPlex/IBMPlexSansThai/IBMPlexSansThai-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  src: url("../assets/fonts/HALPlex/IBMPlexSansThai/IBMPlexSansThai-Medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  src: url("../assets/fonts/HALPlex/IBMPlexSansThai/IBMPlexSansThai-SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans Thai";
  src: url("../assets/fonts/HALPlex/IBMPlexSansThai/IBMPlexSansThai-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/HALPlex/IBMPlexMono/IBMPlexMono-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("../assets/fonts/HALPlex/IBMPlexMono/IBMPlexMono-SemiBold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font-text: "IBM Plex Sans Thai Looped", Arial, sans-serif;
  --font-display: "IBM Plex Sans Thai", "IBM Plex Sans Thai Looped", Arial, sans-serif;
  --font-code: "IBM Plex Mono", Menlo, Consolas, Monaco, monospace;
  --body-size: 18px;
  --ink: #151515;
  --ink-soft: #555;
  --paper: #fff;
  --paper-warm: #f4f4f4;
  --paper-cool: #f8f8f8;
  --nav: #111;
  --nav-soft: #b8b8b8;
  --rule: #d7d7d7;
  --link: #242424;
  --link-hot: #000;
  --code-bg: #f7f7f7;
  --code-line: #ddd;
  --challenge: #f1f1f1;
  --challenge-code: #e6e6e6;
  --design-note: #f7f7f7;
  --design-note-code: #e9e9e9;
  --warning: #efefef;
  --syntax-text: #000;
  --syntax-key: #7a3e9d;
  --syntax-name: #325cc0;
  --syntax-type: #325cc0;
  --syntax-string: #448c27;
  --syntax-number: #7a3e9d;
  --syntax-comment: #aa3731;
  --syntax-accent: #7a3e9d;
  --syntax-punctuation: #777;
  --syntax-invalid: #660000;
  --code-insert-bg: #f0f0f0;
  --code-delete-stripe: #ddd;
  --measure: 39rem;
  --side-rail: 18rem;
  --wide-nav: 21rem;
  --gutter: 3rem;
  --radius: 6px;
  --leading: 1.68;
}

html[data-font-style="chulabhorn"] {
  --font-text: "ChulabhornLikitText", Georgia, "Times New Roman", serif;
  --font-display: "ChulabhornLikitDisplay", "ChulabhornLikitText", Georgia, serif;
  --font-code: "Source Code Pro", Menlo, Consolas, Monaco, monospace;
  --leading: 1.62;
  --measure: 40rem;
}

html[data-font-style="trirong"] {
  --font-text: "Trirong", Georgia, "Times New Roman", serif;
  --font-display: "Chonburi", "Trirong", Georgia, serif;
  --font-code: "JetBrains Mono", Menlo, Consolas, Monaco, monospace;
  --leading: 1.74;
  --measure: 41rem;
}

html[data-font-style="hal-plex"] {
  --font-text: "IBM Plex Sans Thai Looped", Arial, sans-serif;
  --font-display: "IBM Plex Sans Thai", "IBM Plex Sans Thai Looped", Arial, sans-serif;
  --font-code: "IBM Plex Mono", Menlo, Consolas, Monaco, monospace;
  --leading: 1.68;
  --measure: 39rem;
}

html[data-reading-tone="ilford"] {
  --ink: #151515;
  --ink-soft: #555;
  --paper: #fff;
  --paper-warm: #f4f4f4;
  --paper-cool: #f8f8f8;
  --nav: #111;
  --nav-soft: #b8b8b8;
  --rule: #d7d7d7;
  --link: #242424;
  --link-hot: #000;
  --code-bg: #f7f7f7;
  --code-line: #ddd;
  --challenge: #f1f1f1;
  --challenge-code: #e6e6e6;
  --design-note: #f7f7f7;
  --design-note-code: #e9e9e9;
  --warning: #efefef;
  --syntax-text: #000;
  --syntax-key: #7a3e9d;
  --syntax-name: #325cc0;
  --syntax-type: #325cc0;
  --syntax-string: #448c27;
  --syntax-number: #7a3e9d;
  --syntax-comment: #aa3731;
  --syntax-accent: #7a3e9d;
  --syntax-punctuation: #777;
  --syntax-invalid: #660000;
  --code-insert-bg: #f0f0f0;
  --code-delete-stripe: #ddd;
}

html[data-reading-tone="nystrom"] {
  --ink: #202832;
  --ink-soft: #4f5e68;
  --paper: #fffdf8;
  --paper-warm: #f7f1e7;
  --paper-cool: #edf5f7;
  --nav: #273241;
  --nav-soft: #7793a9;
  --rule: #d9e4e8;
  --link: #127c94;
  --link-hot: #0d5c72;
  --code-bg: #fbf7ef;
  --code-line: #ded5ca;
  --challenge: #eef5f7;
  --challenge-code: #e1edf0;
  --design-note: #f3f7ee;
  --design-note-code: #e9f0e2;
  --warning: #fff3d8;
  --syntax-text: #65625f;
  --syntax-key: #087fb0;
  --syntax-name: #1b668a;
  --syntax-type: #008d9a;
  --syntax-string: #a97119;
  --syntax-number: #c55e31;
  --syntax-comment: #9b9995;
  --syntax-accent: #8956b8;
  --syntax-punctuation: #9a948c;
  --syntax-invalid: #8b2c2c;
  --code-insert-bg: #f2ece3;
  --code-delete-stripe: #ded5ca;
}

html[data-reading-tone="caffeine"] {
  --ink: #30271f;
  --ink-soft: #6c5948;
  --paper: #fff4df;
  --paper-warm: #f4e2c4;
  --paper-cool: #f2eadf;
  --nav: #342c28;
  --nav-soft: #b89479;
  --rule: #ead8bf;
  --link: #9a5f20;
  --link-hot: #714010;
  --code-bg: #fff8ed;
  --code-line: #e5cdb0;
  --challenge: #f6ead4;
  --challenge-code: #f1dfbf;
  --design-note: #f4edd7;
  --design-note-code: #ebdec0;
  --warning: #ffe9bd;
  --syntax-text: #6c5948;
  --syntax-key: #8c4f16;
  --syntax-name: #6e533a;
  --syntax-type: #8d693d;
  --syntax-string: #9a5f20;
  --syntax-number: #b75e2a;
  --syntax-comment: #9b8b79;
  --syntax-accent: #6f4b2f;
  --syntax-punctuation: #9b8b79;
  --syntax-invalid: #7a2d1d;
  --code-insert-bg: #f2ece3;
  --code-delete-stripe: #e5cdb0;
}

html[data-reading-tone="green-tea"] {
  --ink: #17251e;
  --ink-soft: #4b6357;
  --paper: #f4faee;
  --paper-warm: #e1edcf;
  --paper-cool: #e6f1e8;
  --nav: #132a23;
  --nav-soft: #94b8a5;
  --rule: #ccdbc8;
  --link: #2e7a4f;
  --link-hot: #185436;
  --code-bg: #f8fbf3;
  --code-line: #c8d8bc;
  --challenge: #e8f1de;
  --challenge-code: #dcebcf;
  --design-note: #edf4df;
  --design-note-code: #dfebcd;
  --warning: #fff0c2;
  --syntax-text: #4b6357;
  --syntax-key: #2b7550;
  --syntax-name: #245a40;
  --syntax-type: #327d5b;
  --syntax-string: #62791e;
  --syntax-number: #7a6630;
  --syntax-comment: #7a897d;
  --syntax-accent: #315e45;
  --syntax-punctuation: #7a897d;
  --syntax-invalid: #6b2e25;
  --code-insert-bg: #edf4df;
  --code-delete-stripe: #c8d8bc;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--body-size);
  line-height: var(--leading);
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 160ms ease, border-color 220ms ease;
}

a:hover,
a:focus-visible {
  color: var(--link-hot);
  border-bottom-color: var(--rule);
}

code {
  padding: 0.08em 0.22em;
  border-radius: 3px;
  background: var(--code-bg);
  color: #60605e;
  font-family: var(--font-code);
  font-size: 0.9em;
  white-space: nowrap;
}

strong {
  font-weight: 700;
}

.keyword-link {
  font-weight: 500;
}

.keyword-link::after {
  content: "";
  display: inline-block;
  width: 0.28em;
  height: 0.28em;
  margin-left: 0.15em;
  border-radius: 999px;
  background: var(--link);
  vertical-align: 0.16em;
}

.style-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.3rem;
  width: 100%;
  max-width: 13.2rem;
  margin: 0.9rem 0 0;
  padding: 0.35rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink-soft);
  font-family: var(--font-text);
  font-size: 0.62rem;
  line-height: 1.15;
}

.style-switcher--floating {
  position: fixed;
  right: 0.8rem;
  bottom: 0.8rem;
  z-index: 60;
  box-shadow: 0 12px 36px rgba(32, 40, 50, 0.12);
}

html[data-reading-tone="caffeine"] .style-switcher {
  background: rgba(255, 244, 223, 0.95);
  box-shadow: 0 12px 36px rgba(48, 39, 31, 0.12);
}

html[data-reading-tone="green-tea"] .style-switcher {
  background: rgba(244, 250, 238, 0.95);
  box-shadow: 0 12px 36px rgba(23, 37, 30, 0.12);
}

.style-switcher-group {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.35rem;
  align-items: center;
  min-width: 0;
}

.style-switcher-label {
  display: block;
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--font-code);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.style-switcher select {
  width: 100%;
  min-height: 1.38rem;
  padding: 0.1rem 1.25rem 0.1rem 0.35rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
}

.style-switcher select:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 1px;
  border-color: var(--link);
}

nav .style-switcher,
.style-switcher-row .style-switcher {
  max-width: none;
  border-color: #3b4b5e;
  background: rgba(255, 255, 255, 0.05);
}

nav .style-switcher-label,
.style-switcher-row .style-switcher-label {
  color: var(--nav-soft);
}

nav .style-switcher select,
.style-switcher-row .style-switcher select {
  background: #202938;
  border-color: #3b4b5e;
  color: #dbe8ee;
}

.style-switcher-row {
  display: none;
  background: var(--nav);
  color: var(--nav-soft);
  font-family: var(--font-text);
}

.style-switcher-row .style-switcher {
  width: 100%;
  margin: 0;
}

.root-home .style-switcher,
.splash .style-switcher {
  max-width: 13.2rem;
}

html[data-font-style="trirong"] .splash-hero h1,
html[data-font-style="trirong"] .splash-section h2,
html[data-font-style="trirong"] .contents-page h1,
html[data-font-style="trirong"] .contents-page h2,
html[data-font-style="trirong"] .chapter h1,
html[data-font-style="trirong"] .chapter > h2,
html[data-font-style="trirong"] .chapter > h3,
html[data-font-style="trirong"] .toc-card h3,
html[data-font-style="trirong"] .root-home h1,
html[data-font-style="trirong"] .root-links strong {
  font-weight: 400;
  line-height: 1.18;
}

html[data-font-style="trirong"] .chapter h1 {
  max-width: 34rem;
}

.splash {
  background: var(--paper);
}

.splash-hero {
  position: relative;
  min-height: 82vh;
  display: grid;
  align-items: end;
  padding: 7rem clamp(1.5rem, 6vw, 6rem) 5rem;
  background: var(--nav) url("../assets/img/hero-ink-page.png") center / cover no-repeat;
  color: #f8fbfc;
}

.splash-hero.learn-ruby-hero {
  min-height: 84vh;
  background-image: url("../assets/img/learn-ruby-hero.jpg");
  background-position: center;
}

.splash-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(20, 29, 39, 0.56);
}

.splash-hero.learn-ruby-hero::before {
  background: linear-gradient(90deg, rgba(10, 10, 10, 0.74), rgba(10, 10, 10, 0.42));
}

.hero-copy {
  position: relative;
  max-width: 44rem;
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: #bdd5df;
  font-family: var(--font-code);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.splash-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 6.4rem);
  font-weight: 500;
  line-height: 0.95;
}

.hero-description {
  max-width: 34rem;
  margin: 1.4rem 0 0;
  color: #edf5f7;
  font-size: clamp(1.12rem, 2.4vw, 1.45rem);
  line-height: 1.48;
}

.hero-caption {
  max-width: 34rem;
  margin: 1.1rem 0 0;
  color: #bdd5df;
  font-size: 0.92rem;
}

.hero-caption a,
.hero-description a {
  color: #eef7fb;
  border-bottom-color: rgba(238, 247, 251, 0.28);
}

.splash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.6rem;
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  background: var(--link);
  color: #fff;
  font-family: var(--font-text);
  font-weight: 700;
}

.button.secondary {
  background: rgba(255, 255, 255, 0.12);
}

.button:hover,
.button:focus-visible {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.52);
}

.splash-section {
  max-width: 68rem;
  margin: 0 auto;
  padding: 4rem clamp(1.5rem, 5vw, 4rem);
}

.splash-section h2,
.contents-page h1,
.contents-page h2,
.chapter h1,
.chapter > h2,
.chapter > h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.12;
}

.splash-section h2 {
  margin: 0 0 1.2rem;
  font-size: clamp(2rem, 4vw, 3rem);
}

.rough-toc {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--rule);
  background: var(--rule);
}

.toc-card {
  min-height: 12rem;
  padding: 1.3rem;
  background: #fff;
}

.toc-card .book-cover {
  margin: 0 0 0.8rem;
}

.toc-card .book-cover img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--rule);
  background: var(--paper-warm);
}

.toc-card .book-cover figcaption {
  margin-top: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.68rem;
  line-height: 1.35;
}

.toc-card .num {
  display: block;
  color: var(--link);
  font-family: var(--font-code);
  font-size: 0.88rem;
  font-weight: 600;
}

.toc-card h3 {
  margin: 0.5rem 0 0.8rem;
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.15;
}

.toc-card p {
  margin: 0;
  color: var(--ink-soft);
}

.toc-card a {
  border-bottom-color: var(--rule);
}

.language-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 1.5rem;
  border: 1px solid var(--rule);
  background: var(--rule);
}

.language-choice a {
  min-height: 9rem;
  padding: 1.3rem;
  background: var(--paper);
  border: 0;
}

.language-choice strong,
.language-choice span {
  display: block;
}

.language-choice strong {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1.12;
}

.language-choice span {
  margin-top: 0.55rem;
  color: var(--ink-soft);
}

.book-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 2rem 0 0;
  border: 1px solid var(--rule);
  background: var(--rule);
}

.book-meta div {
  padding: 1rem;
  background: var(--paper);
}

.book-meta dt {
  margin: 0 0 0.35rem;
  color: var(--ink-soft);
  font-family: var(--font-code);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.book-meta dd {
  margin: 0;
}

.author-strip {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

.author-strip img {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-warm);
}

.book-layout {
  min-height: 100vh;
}

.book-nav-wide,
.book-nav-float,
.book-nav-compact {
  background: var(--nav);
  color: var(--nav-soft);
  font-family: var(--font-text);
}

.book-nav-wide {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--wide-nav);
  padding: 3rem 3rem 2rem;
  overflow-y: auto;
}

.book-brand {
  display: block;
  margin-bottom: 2rem;
  color: #f4fafc;
  border-bottom: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.1;
}

.book-nav-wide h2,
.book-nav-float h2 {
  margin: 0 0 0.6rem;
  color: #f4fafc;
  font-family: var(--font-code);
  font-size: 0.84rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-list {
  margin: 0;
  padding: 0.75rem 0;
  border-top: 1px solid #3b4b5e;
  border-bottom: 1px solid #3b4b5e;
  list-style: none;
}

.nav-list li + li {
  margin-top: 0.45rem;
}

.nav-list a {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr);
  gap: 0.45rem;
  color: var(--nav-soft);
  border: 0;
  font-size: 0.93rem;
  line-height: 1.25;
}

.nav-list a:hover,
.nav-list a:focus-visible,
.nav-list a.is-active {
  color: #f4fafc;
}

.nav-list small {
  color: #526b82;
  font-family: var(--font-code);
  font-size: 0.78rem;
  text-align: right;
}

.prev-next {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  color: var(--nav-soft);
  font-size: 0.84rem;
  text-transform: uppercase;
}

.prev-next a {
  color: var(--nav-soft);
  border: 0;
}

.book-nav-float {
  display: none;
  position: sticky;
  top: 0;
  z-index: 10;
  width: min(100%, 22rem);
  margin-left: auto;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}

.book-nav-float .float-panel {
  max-height: 0;
  overflow: hidden;
  padding: 0 1rem;
  transition: max-height 260ms ease;
}

.book-nav-float[data-open="true"] .float-panel {
  max-height: 70vh;
  padding-bottom: 1rem;
  overflow-y: auto;
}

.nav-toggle {
  width: 100%;
  min-height: 2.4rem;
  border: 0;
  background: transparent;
  color: var(--nav-soft);
  cursor: pointer;
  font-family: var(--font-code);
  font-size: 1.1rem;
}

.book-nav-compact {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 3.2rem;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 4rem;
}

.book-nav-compact .book-brand {
  margin: 0;
  font-size: 1.1rem;
  text-align: center;
}

.book-nav-compact .prev,
.book-nav-compact .next {
  position: absolute;
  top: 0.45rem;
  color: #f4fafc;
  border: 0;
  font-size: 1.6rem;
}

.book-nav-compact .prev {
  left: 1.2rem;
}

.book-nav-compact .next {
  right: 1.2rem;
}

.book-main {
  width: min(72rem, calc(100vw - var(--wide-nav) - 5rem));
  margin-left: calc(var(--wide-nav) + 3rem);
  padding: 0 0 2rem;
}

.book-page {
  position: relative;
  max-width: calc(var(--measure) + var(--gutter) + var(--side-rail));
}

.chapter,
.contents-page {
  position: relative;
  width: var(--measure);
  max-width: 100%;
}

.chapter {
  padding-top: 5.4rem;
}

.chapter-number {
  position: absolute;
  top: 2.3rem;
  left: calc(var(--measure) + 2.9rem);
  color: var(--rule);
  font-family: var(--font-code);
  font-size: 5.2rem;
  line-height: 1;
}

.chapter h1 {
  margin: 0 0 1.4rem;
  font-size: clamp(2.75rem, 6vw, 4rem);
}

.chapter > p,
.chapter > ul,
.chapter > ol {
  margin: 1.55rem 0;
}

.chapter .task-list-item {
  list-style: none;
  margin-left: -1.45rem;
}

.chapter .task-list-checkbox {
  width: 1em;
  height: 1em;
  margin: 0 0.55em 0 0;
  vertical-align: -0.14em;
  accent-color: var(--link);
}

.chapter > h2,
.chapter > h3 {
  position: relative;
}

.chapter > h2 {
  margin: 4.4rem 0 1.2rem;
  font-size: 2rem;
}

.chapter > h3 {
  margin: 3.5rem 0 1rem;
  font-size: 1.5rem;
  font-style: normal;
}

.chapter > .numbered::before {
  content: attr(data-number);
  float: right;
  margin-left: 1rem;
  color: var(--ink-soft);
  font-family: var(--font-code);
  font-size: 0.78em;
  font-weight: 400;
}

.chapter > .numbered a {
  color: var(--ink);
  border: 0;
}

.chapter > .numbered a::before {
  content: "section";
  position: absolute;
  left: -3.3rem;
  width: 2.5rem;
  color: transparent;
  font-family: var(--font-code);
  font-size: 0.72rem;
  text-align: right;
  transition: color 160ms ease;
}

.chapter > .numbered a:hover::before,
.chapter > .numbered a:focus-visible::before {
  color: var(--rule);
}

.epigraph {
  position: relative;
  margin: 2rem 0 2.2rem;
  padding: 0 2.2rem;
  color: #5b8091;
  font-family: var(--font-display);
  font-size: 1.55rem;
  line-height: 1.48;
}

.epigraph::before,
.epigraph::after {
  position: absolute;
  top: -1.2rem;
  color: var(--rule);
  font-family: Georgia, serif;
  font-size: 4.2rem;
  line-height: 1;
}

.epigraph::before {
  content: open-quote;
  left: 0;
}

.epigraph::after {
  content: close-quote;
  right: 0;
}

.epigraph cite {
  display: block;
  margin-top: 0.8rem;
  color: var(--nav-soft);
  font-family: var(--font-text);
  font-size: 1rem;
  font-style: normal;
  text-align: right;
}

.note-anchor {
  scroll-margin-top: 5rem;
}

.sidenote {
  position: absolute;
  left: calc(100% + var(--gutter));
  width: var(--side-rail);
  padding-top: 0.8rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.sidenote p {
  margin: 0 0 0.75rem;
}

.sidenote code {
  font-size: 0.82em;
}

.sidenote[data-comment-thread]::after {
  content: "Reader discussion ready";
  display: block;
  margin-top: 0.8rem;
  color: var(--link);
  font-family: var(--font-code);
  font-size: 0.7rem;
  text-transform: uppercase;
}

.ink-figure {
  margin: 2rem 0;
}

.ink-figure img {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-warm);
}

.ink-figure .placeholder-box {
  aspect-ratio: 16 / 9;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, transparent calc(50% - 1px), var(--rule) 50%, transparent calc(50% + 1px)),
    linear-gradient(45deg, transparent calc(50% - 1px), var(--rule) 50%, transparent calc(50% + 1px)),
    var(--paper-warm);
}

.ink-figure.wide {
  width: calc(var(--measure) + var(--gutter) + var(--side-rail));
  max-width: calc(100vw - var(--wide-nav) - 6rem);
}

.ink-figure figcaption {
  margin-top: 0.55rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  text-align: right;
}

.video-embed {
  margin: 2rem 0;
}

.video-embed.wide {
  width: calc(var(--measure) + var(--gutter) + var(--side-rail));
  max-width: calc(100vw - var(--wide-nav) - 6rem);
}

.video-frame {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-warm);
}

.video-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-embed figcaption {
  display: grid;
  gap: 0.2rem;
  margin-top: 0.55rem;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: right;
}

.video-embed figcaption small {
  font-size: 0.78rem;
}

.code-figure {
  position: relative;
  margin: 2rem 0;
  padding: 0.9rem;
  border-radius: var(--radius);
  background: var(--code-bg);
  color: var(--syntax-text);
}

.code-figure pre {
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  font-family: var(--font-code);
  font-size: 0.84rem;
  line-height: 1.55;
}

.code-figure code {
  display: block;
  padding: 0;
  background: transparent;
  white-space: inherit;
}

.code-figure figcaption {
  position: absolute;
  top: 0.9rem;
  left: calc(100% + var(--gutter));
  width: var(--side-rail);
  color: #9a948c;
  font-family: var(--font-code);
  font-size: 0.7rem;
  line-height: 1.45;
}

.code-figure figcaption::before {
  content: "<<";
  position: absolute;
  left: -2.4rem;
  width: 2rem;
  color: var(--code-line);
  text-align: center;
}

.code-insert {
  display: block;
  margin: 0 -0.9rem;
  padding: 0 0.75rem;
  border-left: 2px solid var(--code-line);
  border-right: 2px solid var(--code-line);
  background: var(--code-insert-bg);
}

.code-delete {
  display: block;
  margin: 0 -0.9rem;
  padding: 0 0.75rem;
  border-left: 2px solid var(--code-line);
  border-right: 2px solid var(--code-line);
  color: #a9a39d;
  background: repeating-linear-gradient(-45deg, var(--code-delete-stripe), var(--code-delete-stripe) 1px, transparent 1px, transparent 6px);
}

.tok-key,
.k {
  color: var(--syntax-key);
}

.tok-name,
.i {
  color: var(--syntax-name);
}

.tok-type,
.t {
  color: var(--syntax-type);
}

.tok-string,
.s {
  color: var(--syntax-string);
}

.tok-number,
.n {
  color: var(--syntax-number);
}

.tok-comment,
.c {
  color: var(--syntax-comment);
}

.tok-accent,
.a {
  color: var(--syntax-accent);
}

.tok-punctuation,
.p,
.tok-operator,
.o {
  color: var(--syntax-punctuation);
}

.tok-invalid,
.err {
  color: var(--syntax-invalid);
}

.callout {
  margin: 2rem -0.8rem;
  padding: 1rem;
  border-radius: var(--radius);
  color: #3f4a50;
  font-family: var(--font-text);
}

.callout h2,
.callout h3 {
  margin: 0 0 0.8rem;
  font-family: var(--font-code);
  font-size: 0.82rem;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: uppercase;
}

.callout.challenge {
  background: var(--challenge);
}

.callout.challenge code,
.callout.challenge .code-figure {
  background: var(--challenge-code);
}

.callout.design-note {
  background: var(--design-note);
}

.callout.design-note code,
.callout.design-note .code-figure {
  background: var(--design-note-code);
}

.callout.warning {
  background: var(--warning);
}

.chapter-footer {
  position: relative;
  margin: 4rem 0 2rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--nav-soft);
  font-family: var(--font-text);
  text-align: center;
}

.chapter-footer .next {
  position: absolute;
  top: -0.9rem;
  right: 0;
  padding-left: 0.5rem;
  background: var(--paper);
  font-family: var(--font-code);
  font-size: 0.82rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.contents-page {
  padding: 5.4rem 0 2rem;
}

.contents-page h1 {
  margin: 0 0 2rem;
  font-size: 2.6rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.contents-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem 3rem;
  width: calc(var(--measure) + var(--gutter) + var(--side-rail));
  max-width: 100%;
}

.contents-part h2 {
  margin: 0 0 0.7rem;
  color: var(--ink);
  font-family: var(--font-code);
  font-size: 0.9rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.contents-part ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.contents-part li {
  display: grid;
  grid-template-columns: 3.2rem minmax(0, 1fr);
  gap: 0.6rem;
  padding: 0.35rem 0;
}

.contents-part .num {
  color: var(--nav-soft);
  font-family: var(--font-code);
  font-size: 0.82rem;
  text-align: right;
}

.contents-part .design-note {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.contents-part .design-note .num {
  color: transparent;
}

.source-map-table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.source-map-table th,
.source-map-table td {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--rule);
  vertical-align: top;
}

.source-map-table th {
  background: var(--paper-warm);
  color: var(--ink);
  font-family: var(--font-code);
  font-size: 0.78rem;
  text-align: left;
  text-transform: uppercase;
}

.source-map-table td:first-child {
  font-family: var(--font-code);
  font-size: 0.82rem;
}

@media (max-width: 1280px) {
  .book-nav-wide {
    display: none;
  }

  .book-nav-float {
    display: block;
  }

  .book-main {
    width: min(72rem, calc(100vw - 3rem));
    margin: 0 auto;
  }

  .chapter,
  .contents-page {
    margin-right: calc(var(--side-rail) + var(--gutter));
  }

  .chapter-number {
    left: auto;
    right: 0;
  }

  .ink-figure.wide {
    max-width: calc(100vw - 3rem);
  }

  .video-embed.wide {
    max-width: calc(100vw - 3rem);
  }
}

@media (max-width: 960px) {
  body {
    font-size: 17px;
  }

  .book-nav-float {
    display: none;
  }

  .book-nav-compact {
    display: flex;
  }

  .style-switcher-row {
    display: flex;
    position: sticky;
    top: 3.2rem;
    z-index: 19;
    min-height: 2.35rem;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 1rem;
    box-shadow: 0 1px 0 #3b4b5e;
  }

  .style-switcher-row .style-switcher {
    max-width: none;
    margin: 0;
  }

  .book-main {
    width: auto;
    margin: 0 clamp(1.4rem, 5vw, 3rem);
  }

  .book-page,
  .chapter,
  .contents-page {
    width: auto;
    max-width: none;
    margin: 0;
  }

  .chapter {
    padding-top: 3.2rem;
  }

  .chapter-number {
    top: 1.2rem;
    right: 0;
    font-size: 4rem;
  }

  .sidenote {
    position: static;
    width: auto;
    margin: 1rem 0 1.4rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--rule);
  }

  .code-figure figcaption {
    position: static;
    width: auto;
    margin-top: 0.7rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--code-line);
    text-align: right;
  }

  .code-figure figcaption::before {
    content: none;
  }

  .ink-figure.wide {
    width: auto;
    max-width: 100%;
  }

  .video-embed.wide {
    width: auto;
    max-width: 100%;
  }

  .contents-grid,
  .rough-toc,
  .language-choice,
  .book-meta {
    grid-template-columns: 1fr;
  }

  .author-strip {
    grid-template-columns: 10rem minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .splash-hero {
    min-height: 78vh;
    padding: 6rem 1.25rem 3rem;
  }

  .splash-section {
    padding: 3rem 1.25rem;
  }

  .author-strip {
    grid-template-columns: 1fr;
  }

  .author-strip img {
    width: min(14rem, 70vw);
  }

  .book-main {
    margin: 0 1.25rem;
  }

  .chapter h1 {
    font-size: 2.55rem;
  }

  .chapter > h2 {
    font-size: 1.6rem;
  }

  .chapter > h3 {
    font-size: 1.28rem;
  }

  .chapter > .numbered::before {
    float: none;
    display: block;
    margin: 0 0 0.25rem;
  }

  .chapter > .numbered a::before {
    content: none;
  }

  .epigraph {
    padding: 0 1.2rem;
    font-size: 1.28rem;
  }

  .callout {
    margin-left: 0;
    margin-right: 0;
  }

  .style-switcher {
    grid-template-columns: 1fr;
    max-width: 10rem;
  }

  .style-switcher-row .style-switcher {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }

  .style-switcher--floating {
    right: 0.7rem;
    bottom: 0.7rem;
  }
}

@media print {
  .book-nav-wide,
  .book-nav-float,
  .book-nav-compact,
  .style-switcher-row,
  .splash-actions {
    display: none;
  }

  .style-switcher {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }

  .book-main {
    width: auto;
    margin: 0;
  }

  .sidenote,
  .code-figure figcaption {
    position: static;
    width: auto;
  }
}
