:root {
  --reader-bg: #fffdfa;
  --paper: #fffdfa;
  --text: #262626;
  --muted: #6b7280;
  --soft: #f5f1ea;
  --line: #e7dfd3;
  --accent: #7c3aed;
  --chapter-accent: #7c3aed;
  --chapter-bg: #f5f3ff;
  --card-bg: #f7f3ff;
  --check: #c2410c;
  --note: #64748b;
  --header-height: 56px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--reader-bg);
  font-family:
    "Pretendard Variable",
    Pretendard,
    "Noto Sans KR",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 18px;
  line-height: 1.9;
  letter-spacing: 0;
  overflow-x: hidden;
  word-break: keep-all;
}

a {
  color: var(--chapter-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.reader-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 56px;
  align-items: center;
  height: var(--header-height);
  padding: 0 14px;
  border-bottom: 1px solid rgba(231, 223, 211, .84);
  background: rgba(255, 253, 250, .92);
  transition: opacity .2s ease, transform .2s ease;
}

.reader-header.is-cover {
  background: transparent;
  border-bottom-color: transparent;
}

.toc-button {
  display: inline-grid;
  align-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.toc-button span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
}

.reader-title {
  min-width: 0;
  overflow: hidden;
  color: #3f3a34;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-progress {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.toc-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: min(88vw, 380px);
  padding: 22px;
  background: #fffdfa;
  border-right: 1px solid var(--line);
  transform: translateX(-102%);
  transition: transform .24s ease;
  overflow: auto;
}

.toc-drawer.is-open {
  transform: translateX(0);
}

.toc-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.toc-drawer__header strong {
  font-size: 20px;
}

.toc-drawer__close {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.toc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(38, 38, 38, .34);
}

.toc-backdrop.is-open {
  display: block;
}

.toc-list {
  display: grid;
  gap: 2px;
}

.toc-list a {
  display: block;
  color: #34302b;
  text-decoration: none;
}

.toc-list__chapter {
  margin-top: 16px;
  padding: 10px 0 6px;
  font-size: 16px;
  font-weight: 800;
}

.toc-list__section {
  padding: 5px 0 5px 16px;
  color: var(--muted) !important;
  font-size: 14px;
  line-height: 1.55;
}

.toc-list a.is-active {
  color: var(--chapter-accent) !important;
}

.reader {
  min-height: 100vh;
}

.reader-content {
  width: min(calc(100% - 40px), 690px);
  margin: 0 auto;
}

.book-cover,
.back-cover {
  position: relative;
  display: grid;
  align-items: center;
  min-height: 100vh;
  padding: 96px 0 64px;
}

.book-cover__art,
.back-cover__art {
  position: absolute;
  inset: 0 calc(50% - 50vw);
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 28%, rgba(124, 58, 237, .14), transparent 26%),
    radial-gradient(circle at 24% 70%, rgba(100, 116, 139, .11), transparent 30%),
    linear-gradient(145deg, #fffdfa 0%, #f5f1ea 52%, #ede9fe 100%);
}

.book-cover__art img,
.back-cover__art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-cover__art picture,
.back-cover__art picture {
  display: block;
  width: 100%;
  height: 100%;
}

.book-cover__art img.is-missing,
.back-cover__art img.is-missing,
.figure__image.is-missing {
  display: none;
}

.book-cover__content {
  padding: 48px 0;
  transform: translateY(-5vh);
}

.book-cover__eyebrow,
.book-toc__label,
.chapter-cover__label {
  margin: 0 0 14px;
  color: var(--chapter-accent);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .12em;
}

.book-cover__eyebrow {
  font-size: 12px;
  letter-spacing: .14em;
}

.book-cover h1 {
  margin: 0;
  color: #191714;
  font-size: clamp(44px, 10vw, 88px);
  line-height: 1.08;
  font-weight: 900;
}

.book-cover__subtitle {
  margin: 22px 0 0;
  color: #6b6258;
  font-size: clamp(18px, 3vw, 25px);
  font-weight: 560;
}

.scroll-cue {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-grid;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-decoration: none;
}

.scroll-cue span {
  width: 1px;
  height: 28px;
  background: currentColor;
  opacity: .7;
}

.intro,
.author-page {
  padding: 72px 0 36px;
}

.intro h2 {
  margin-top: 28px;
  margin-bottom: 38px;
}

.intro .lead-paragraph {
  color: #1f2937;
  font-size: 1.12em;
  line-height: 1.9;
  font-weight: 520;
}

.intro::after {
  content: "";
  display: block;
  width: 54px;
  height: 1px;
  margin: 48px auto 0;
  background: var(--line);
}

.book-toc {
  min-height: 82vh;
  padding: 110px 0;
  display: grid;
  align-content: center;
  gap: 4px;
}

.book-toc__item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 22px;
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}

.book-toc__item:hover .book-toc__number,
.book-toc__item:hover strong {
  color: var(--chapter-accent);
}

.book-toc__number {
  color: var(--chapter-accent);
  font-size: 18px;
  font-weight: 900;
}

.book-toc strong {
  display: block;
  font-size: 22px;
  font-weight: 900;
}

.book-toc small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.chapter {
  margin: 0;
  --chapter-accent: var(--accent);
  --chapter-bg: #f5f3ff;
}

.chapter[data-theme="slate"] { --chapter-accent: #64748b; --chapter-bg: #f8fafc; --card-bg: #eef2f7; }
.chapter[data-theme="violet"] { --chapter-accent: #7c3aed; --chapter-bg: #f5f3ff; --card-bg: #f0eafa; }
.chapter[data-theme="teal"] { --chapter-accent: #0f766e; --chapter-bg: #ecfdf5; --card-bg: #e6f7f0; }
.chapter[data-theme="orange"] { --chapter-accent: #c2410c; --chapter-bg: #fff7ed; --card-bg: #ffedd5; }

.chapter-cover {
  position: relative;
  min-height: 82vh;
  margin: 80px calc(50% - 50vw) 54px;
  padding: 80px max(20px, calc(50vw - 360px));
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  background: var(--chapter-bg);
  background:
    radial-gradient(circle at 78% 72%, color-mix(in srgb, var(--chapter-accent) 18%, transparent), transparent 34%),
    linear-gradient(135deg, var(--chapter-bg), #fffdfa 74%);
}

.chapter-cover__number {
  position: absolute;
  right: max(26px, calc(50vw - 410px));
  bottom: 40px;
  color: var(--chapter-accent);
  font-size: clamp(90px, 20vw, 230px);
  line-height: 1;
  font-weight: 900;
  opacity: .09;
  pointer-events: none;
}

.chapter-cover h2 {
  position: relative;
  z-index: 1;
  max-width: 610px;
  margin: 0;
  color: #191714;
  font-size: clamp(38px, 7vw, 68px);
  line-height: 1.12;
  font-weight: 900;
}

.chapter-cover__subtitle {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin: 20px 0 0;
  color: #57534e;
  font-size: clamp(16px, 1.7vw, 20px);
  font-weight: 540;
}

.chapter-cover__cue {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  width: max-content;
  margin-top: 46px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
}

.chapter-cover__cue::before {
  content: "";
  width: 1px;
  height: 26px;
  background: var(--chapter-accent);
  opacity: .45;
}

.chapter-body {
  padding-bottom: 64px;
}

h2,
h3,
h4 {
  color: #191714;
  line-height: 1.34;
  scroll-margin-top: calc(var(--header-height) + 18px);
}

h2 {
  margin: 72px 0 24px;
  font-size: 34px;
}

h3 {
  margin: 76px 0 26px;
  font-size: 25px;
  scroll-margin-top: calc(var(--header-height) + 32px);
}

h3::before {
  content: "";
  display: block;
  width: 28px;
  height: 2px;
  margin-bottom: 14px;
  background: var(--chapter-accent);
}

h4 {
  margin: 48px 0 18px;
  font-size: 20px;
  font-weight: 780;
}

p {
  margin: 0 0 1.48em;
}

.intro > p:not(.lead-paragraph),
.chapter-body > p,
.author-page > p {
  margin-bottom: 1.05em;
}

ul,
ol {
  margin: 1.2em 0 1.7em;
  padding-left: 1.3em;
}

li + li {
  margin-top: .42em;
}

hr {
  width: 42px;
  margin: 58px auto;
  border: 0;
  border-top: 1px solid var(--line);
}

strong {
  color: inherit;
  font-weight: 820;
}

code {
  padding: 0;
  background: transparent;
  color: #b4534b;
  font-family: inherit;
  font-size: 0.85em;
  font-style: normal;
  font-weight: 500;
  white-space: nowrap;
}

blockquote {
  margin: 28px 0;
  padding: 6px 0 6px 20px;
  border-left: 2px solid var(--chapter-accent);
  background: transparent;
  color: #3f3a34;
  font-size: 1.08em;
}

blockquote p {
  margin: 0;
}

.problem-notice {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: #fff5f3;
  border: 1px solid #f0d2cc;
  border-left: 4px solid #c96f61;
  border-radius: 10px;
}

.problem-notice p {
  margin: 0;
}

.problem-notice p + p {
  margin-top: 0.5rem;
}

.problem-notice a {
  display: inline-block;
  padding: 0.08rem 0.42rem 0.12rem;
  border: 1px solid #e6bdb5;
  border-radius: 6px;
  background: #fffdfa;
  color: #9f4f43;
  font-weight: 700;
  text-decoration: none;
}

.problem-notice a:hover,
.problem-notice a:focus-visible {
  background: #ffe9e5;
  border-color: #c96f61;
  color: #813d34;
}

.problem-notice--sky {
  background: #f2f8fd;
  border-color: #cfe3f4;
  border-left-color: #4f8fcf;
}

.problem-notice--sky a {
  border-color: #b8d6ed;
  color: #4f8fcf;
}

.problem-notice--sky a:hover,
.problem-notice--sky a:focus-visible {
  background: #e3f1fb;
  border-color: #4f8fcf;
  color: #2f6fa7;
}

.reader-question {
  margin: 36px -16px;
  padding: 28px 34px;
  background: #eef6ff;
  border: 0;
  border-radius: 4px;
}

.reader-question::before {
  content: none;
}

.reader-question p {
  margin: 0;
  color: #3f3a34;
  font-size: 1.04em;
  line-height: 1.75;
}

@media (max-width: 820px) {
  .reader-question {
    margin-right: 0;
    margin-left: 0;
  }
}

@media (max-width: 760px) {
  .reader-question {
    margin: 32px 0;
    padding: 24px 20px;
  }
}

.editorial-card {
  margin: 54px -16px;
  padding: 34px 34px;
  border: 0;
  border-radius: 4px;
  background: var(--card-bg);
  break-inside: avoid;
}

.editorial-card::before {
  content: "";
  display: block;
  width: 34px;
  height: 2px;
  margin-bottom: 16px;
  background: var(--chapter-accent);
}

.editorial-card__label {
  display: block;
  margin-bottom: 14px;
  color: var(--chapter-accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
}

.editorial-card--check {
  --chapter-accent: #c2410c;
  --card-bg: #fff7ed;
}

.editorial-card--note {
  --chapter-accent: #64748b;
  --card-bg: #f8fafc;
}

.editorial-card--key {
  --chapter-accent: #b45309;
  --card-bg: #fff8e7;
}

.editorial-card--copyright {
  --chapter-accent: #64748b;
  --card-bg: #f9fafb;
}

.editorial-card__lead {
  margin-bottom: .9em;
  color: #1f2937;
  font-size: 1.2em;
  line-height: 1.65;
  font-weight: 850;
}

.editorial-card__support {
  color: #5b554f;
  font-size: .96em;
}

.editorial-card p {
  margin-bottom: 1.05em;
}

.editorial-card p:last-child,
.editorial-card ul:last-child,
.editorial-card ol:last-child {
  margin-bottom: 0;
}

.disabled-link {
  color: var(--muted);
  font-size: .95em;
}

.process-list {
  list-style: none;
  margin: 40px 0;
  padding: 0;
  counter-reset: process;
}

.process-list li {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  min-height: 54px;
  margin: 0;
  padding: 0 0 24px;
}

.process-list li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 19px;
  top: 34px;
  bottom: 4px;
  width: 1px;
  background: var(--line);
}

.process-list__number {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 28px;
  color: var(--chapter-accent);
  background: var(--reader-bg);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.process-list__text {
  display: block;
  margin: -.16em 0 0;
}

/* .question-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin: 40px 0;
  padding: 0;
  list-style: none;
}

.question-list li {
  position: relative;
  margin: 0;
  padding-left: 22px;
}

.question-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .78em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--chapter-accent);
} */

.question-card {
  margin: 32px 0;
  padding: 22px 24px;
  background: #f5f0ff;
  border: 1px solid #ddd0ff;
  border-radius: 10px;
}

.question-list {
  margin: 0;
  padding-left: 0.9rem;
}

.question-list li {
  padding-left: 2px;
  line-height: 1.6;
}

.question-list li + li {
  margin-top: 6px;
}

.question-list li::marker {
  color: #a78bfa;
  font-size: 0.72em;
}

.prompt-card {
  margin: 48px 0;
  padding: 30px 32px 32px;
  border-radius: 6px;
  background: #111827;
  color: #e5e7eb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em;
  line-height: 1.75;
}

.prompt-card p {
  max-width: 62ch;
  margin: 18px 0 0;
}

.prompt-label {
  color: #c4b5fd;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .12em;
}

.prompt-dots {
  display: flex;
  gap: 7px;
  margin-bottom: 18px;
}

.prompt-dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94a3b8;
  opacity: .72;
}

.state-list,
.compare-list {
  display: grid;
  gap: 14px;
  margin: 26px 0;
  padding: 0;
  list-style: none;
}

.state-list li,
.compare-list li {
  position: relative;
  padding: 10px 0 10px 26px;
  border-bottom: 1px solid rgba(100, 116, 139, .24);
}

.state-list {
  counter-reset: state;
}

.state-list li {
  counter-increment: state;
}

.state-list li::before,
.compare-list li::before {
  position: absolute;
  left: 0;
  color: var(--chapter-accent);
  font-size: 12px;
  font-weight: 900;
}

.state-list li::before {
  content: counter(state, decimal-leading-zero);
}

.compare-list li::before {
  content: "";
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--chapter-accent);
}

.choice-line {
  margin-top: -4px;
  color: var(--chapter-accent);
  font-weight: 850;
  text-align: center;
}

.relation-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vw, 42px);
  margin: 36px auto 8px;
  min-width: 0;
}

.relation-node {
  min-width: 96px;
  padding: 12px 10px;
  border-top: 1px solid var(--chapter-accent);
  border-bottom: 1px solid var(--chapter-accent);
  text-align: center;
}

.relation-node strong,
.relation-node span {
  display: block;
}

.relation-node strong {
  font-size: 34px;
  line-height: 1.05;
}

.relation-node span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .12em;
}

.relation-arrow {
  color: var(--chapter-accent);
  font-size: 22px;
}

table {
  width: 100%;
  margin: 46px 0;
  border-collapse: collapse;
  border-top: 2px solid var(--text);
  border-bottom: 1px solid var(--line);
  table-layout: fixed;
  break-inside: avoid;
}

th,
td {
  padding: 13px 8px;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: normal;
  word-break: keep-all;
}

th {
  background: transparent;
  color: var(--muted);
  font-size: .84em;
}

td code {
  color: var(--chapter-accent);
}

td:nth-child(2) {
  width: 34%;
  color: var(--chapter-accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .94em;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.figure {
  width: min(820px, calc(100% + 32px));
  margin: 52px 0 48px;
  transform: translateX(max(-16px, calc((690px - 820px) / 2)));
  break-inside: avoid;
}

.figure__button {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  max-height: 410px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(124, 58, 237, .08), rgba(100, 116, 139, .08)),
    #fff;
  cursor: default;
  overflow: hidden;
}

.figure__button::after {
  content: "이미지를 불러오는 중입니다…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(255, 255, 255, .72) 50%,
    transparent 70%
  );
  background-size: 220% 100%;
  animation: image-loading 1.4s ease-in-out infinite;
}

.figure__button.has-image::after {
  display: none;
}

.figure__button.has-image {
  cursor: zoom-in;
}

.figure__button.has-image-error::after {
  content: "이미지를 불러오지 못했습니다.";
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  background: transparent;
  animation: none;
}

@keyframes image-loading {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .figure__button::after {
    animation: none;
  }
}

.figure__image {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

figcaption {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.process-flow {
  margin: 42px 0;
  padding: 4px 0;
}

.process-flow__item {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  padding-bottom: 24px;
}

.process-flow__item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 21px;
  top: 34px;
  bottom: 5px;
  width: 1px;
  background: var(--line);
}

.process-flow__number {
  color: var(--chapter-accent);
  font-size: 13px;
  font-weight: 900;
}

.process-flow__item p {
  margin: -.28em 0 0;
}

.process-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 0;
  margin: 32px 0 38px;
  color: #3f3a34;
  font-size: .95em;
  font-weight: 720;
}

.process-summary span {
  display: inline-flex;
  align-items: center;
}

.process-summary span:not(:last-child)::after {
  content: "→";
  margin: 0 11px;
  color: var(--chapter-accent);
  font-weight: 900;
}

.author-page {
  margin: 60px 0 0;
  padding: 52px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.author-page h2 {
  margin-top: 0;
}

.back-cover {
  min-height: 72vh;
  margin-top: 72px;
  text-align: center;
}

.back-cover__content {
  padding: 80px 0;
}

.back-cover h2 {
  margin: 0 0 14px;
  font-size: clamp(34px, 8vw, 70px);
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(30, 27, 24, .78);
}

.image-modal.is-open {
  display: flex;
}

.image-modal img {
  max-width: min(96vw, 1440px);
  max-height: 82vh;
  object-fit: contain;
  background: #fff;
}

.image-modal p {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: 18px;
  margin: 0;
  color: #fff;
  font-size: 14px;
  text-align: center;
}

.image-modal__close {
  position: fixed;
  top: 18px;
  right: 18px;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.resume-reading {
  --resume-accent: var(--chapter-accent);
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 45;
  width: max-content;
  max-width: calc(100vw - 44px);
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--resume-accent) 22%, var(--line));
  border-radius: 8px;
  background: rgba(255, 253, 250, .96);
  box-shadow: 0 18px 48px rgba(38, 38, 38, .14);
}

.resume-reading p {
  margin: 0 0 10px;
  color: #262626;
  font-size: 15px;
  line-height: 1.55;
  font-weight: 760;
  text-align: center;
  white-space: nowrap;
}

.resume-reading__actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.resume-reading button {
  min-width: 0;
  height: 38px;
  padding: 0 13px;
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.resume-reading__primary {
  border: 1px solid var(--resume-accent);
  background: var(--resume-accent);
  color: #fffdfa;
}

.resume-reading__secondary {
  border: 1px solid var(--line);
  background: #fffdfa;
  color: #57534e;
}

@media (max-width: 820px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .reader-header {
    position: absolute;
    top: var(--reader-header-top, 0);
    transform: translateY(-105%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  body.reader-ui-visible .reader-header,
  .reader-header:focus-within {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .reader-content {
    width: min(calc(100% - 36px), 690px);
    max-width: 100%;
  }

  .book-cover,
  .back-cover {
    width: 100vw;
    max-width: none;
    margin-right: calc(50% - 50vw);
    margin-left: calc(50% - 50vw);
  }

  @supports (width: 100svw) {
    .book-cover,
    .back-cover {
      width: 100svw;
      margin-right: calc(50% - 50svw);
      margin-left: calc(50% - 50svw);
    }
  }

  .book-cover {
    min-height: 100vh;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
  }

  .book-cover__content,
  .back-cover__content {
    padding-right: max(20px, env(safe-area-inset-right));
    padding-left: max(20px, env(safe-area-inset-left));
  }

  @supports (height: 100svh) {
    .book-cover {
      min-height: 100svh;
      height: 100svh;
      max-height: 100svh;
    }
  }

  .book-cover__art,
  .back-cover__art {
    inset: 0;
  }

  .book-cover__art img,
  .back-cover__art img {
    object-position: center center;
  }

  .back-cover {
    min-height: 100vh;
    min-height: 100svh;
  }

  .chapter-cover {
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
    padding-right: 20px;
    padding-left: 20px;
  }

  .editorial-card {
    max-width: 100%;
    margin-right: 0;
    margin-left: 0;
  }

  table,
  .figure,
  .figure__button,
  .relation-diagram,
  .process-summary {
    max-width: 100%;
  }

  .figure {
    width: 100%;
    transform: none;
  }

  .relation-diagram {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .relation-node {
    min-width: 0;
    flex: 0 1 82px;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 17px;
    line-height: 1.88;
  }

  .reader-content {
    width: min(calc(100% - 36px), 720px);
  }

  .toc-drawer {
    width: min(94vw, 430px);
  }

  .resume-reading {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: auto;
    width: max-content;
    max-width: calc(100vw - 24px);
    padding: 12px 14px;
  }

  .resume-reading p {
    white-space: normal;
  }

  .chapter-cover {
    min-height: 76vh;
  }

  .book-cover h1,
  .chapter-cover h2 {
    word-break: keep-all;
  }

  .editorial-card {
    margin: 36px 0;
    padding: 24px 20px;
  }

  .question-list {
    grid-template-columns: 1fr;
  }

  .relation-diagram {
    gap: 8px;
  }

  .relation-node {
    min-width: 72px;
    padding: 10px 8px;
  }

  .relation-node strong {
    font-size: 20px;
  }

  .figure__button {
    max-height: 260px;
  }

  .figure {
    width: 100%;
    transform: none;
  }

  .prompt-card {
    padding: 24px 20px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 16mm 14mm;
  }

  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .reader-header,
  .toc-drawer,
  .toc-backdrop,
  .image-modal,
  .resume-reading {
    display: none !important;
  }

  body {
    color: #262626;
    background: #fffdfa;
    font-size: 11pt;
    line-height: 1.72;
    overflow: visible;
  }

  .reader-content {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .book-cover,
  .back-cover {
    min-height: 250mm;
    padding: 28mm 0;
    background:
      radial-gradient(circle at 30% 22%, rgba(124, 58, 237, .18), transparent 34%),
      linear-gradient(145deg, #fffdfa 0%, #f5f1ea 52%, #ede9fe 100%);
  }

  .book-cover__art,
  .back-cover__art {
    inset: 0;
    background:
      radial-gradient(circle at 30% 22%, rgba(124, 58, 237, .18), transparent 34%),
      linear-gradient(145deg, #fffdfa 0%, #f5f1ea 52%, #ede9fe 100%);
  }

  .book-cover__content,
  .back-cover__content {
    padding: 0;
  }

  .book-cover h1 {
    font-size: 48pt;
  }

  .book-cover__subtitle,
  .chapter-cover__subtitle {
    font-size: 15pt;
  }

  .scroll-cue,
  .chapter-cover__cue {
    display: none;
  }

  .intro,
  .author-page {
    padding: 0;
  }

  .book-toc {
    min-height: auto;
    padding: 18mm 0;
    break-before: page;
    break-after: page;
  }

  .book-toc__item {
    grid-template-columns: 15mm 1fr;
    padding: 5mm 0;
  }

  .book-cover,
  .chapter-cover {
    break-before: page;
    break-after: page;
  }

  .chapter {
    --chapter-accent: var(--accent);
  }

  .chapter-cover {
    min-height: 240mm;
    margin: 0;
    padding: 32mm 0;
    background: var(--chapter-bg);
    border: 0;
  }

  .chapter-cover__number {
    font-size: 68pt;
    opacity: .2;
  }

  .chapter-cover h2 {
    font-size: 38pt;
  }

  .chapter-body {
    padding-bottom: 0;
  }

  h2 {
    margin: 14mm 0 7mm;
    font-size: 22pt;
  }

  h3 {
    margin: 12mm 0 5mm;
    font-size: 17pt;
  }

  h4 {
    margin: 9mm 0 4mm;
    font-size: 14pt;
  }

  p {
    margin-bottom: 1em;
  }

  hr {
    margin: 12mm auto;
  }

  blockquote {
    margin: 9mm 0;
    padding-left: 7mm;
    border-left: 1.5pt solid var(--chapter-accent);
    background: transparent;
  }

  .editorial-card {
    margin: 10mm 0;
    padding: 8mm 9mm;
    background: var(--card-bg);
    border-radius: 2mm;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .editorial-card::before {
    height: 1.5pt;
  }

  .process-list,
  .question-list,
  .state-list,
  .compare-list {
    break-inside: avoid;
  }

  .question-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .process-list__number {
    background: #fffdfa;
  }

  table {
    margin: 9mm 0;
    page-break-inside: avoid;
  }

  th,
  td {
    padding: 4mm 2mm;
  }

  .figure {
    margin: 10mm 0;
    page-break-inside: avoid;
  }

  .figure__button {
    max-height: none;
    border: 1px solid #e7dfd3;
    cursor: default;
  }

  .figure__button::after {
    border: 1px dashed #cbd5e1;
  }

  figcaption {
    page-break-before: avoid;
  }

  .author-page {
    margin-top: 0;
    padding: 14mm 0;
    break-before: page;
  }

  .back-cover {
    break-before: page;
    break-after: auto;
  }

  .editorial-card,
  table,
  figure,
  h3,
  h4 {
    break-inside: avoid;
  }

  h3,
  h4 {
    break-after: avoid;
  }
}
