:root {
  color-scheme: dark;
  --bg: #081014;
  --bg-top: #0d1b20;
  --surface: rgba(14, 23, 29, 0.84);
  --surface-strong: rgba(12, 19, 24, 0.96);
  --surface-soft: rgba(22, 35, 42, 0.76);
  --border: rgba(214, 177, 107, 0.18);
  --border-strong: rgba(214, 177, 107, 0.28);
  --text: #f5efde;
  --text-muted: #b6c2be;
  --accent: #d6b16b;
  --accent-strong: #f1cb83;
  --accent-soft: rgba(214, 177, 107, 0.12);
  --secondary: #7cc6bb;
  --secondary-soft: rgba(124, 198, 187, 0.14);
  --shadow: 0 24px 64px rgba(0, 0, 0, 0.36);
  --font-body: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-ui: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  --font-code: "SFMono-Regular", "SF Mono", Consolas, "Liberation Mono", monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3ebdd;
  --bg-top: #efe5d5;
  --surface: rgba(255, 252, 246, 0.84);
  --surface-strong: rgba(255, 250, 242, 0.94);
  --surface-soft: rgba(255, 246, 232, 0.7);
  --border: rgba(132, 99, 42, 0.18);
  --border-strong: rgba(132, 99, 42, 0.3);
  --text: #241f18;
  --text-muted: #635847;
  --accent: #9c6a1b;
  --accent-strong: #8b4f00;
  --accent-soft: rgba(156, 106, 27, 0.12);
  --secondary: #2f7b75;
  --secondary-soft: rgba(47, 123, 117, 0.1);
  --shadow: 0 20px 56px rgba(77, 58, 25, 0.15);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124, 198, 187, 0.12), transparent 34%),
    radial-gradient(circle at top right, rgba(214, 177, 107, 0.16), transparent 32%),
    linear-gradient(180deg, var(--bg-top), var(--bg));
  font-family: var(--font-body);
  text-rendering: optimizeLegibility;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 24rem;
  height: 24rem;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(70px);
  opacity: 0.55;
  z-index: -1;
}

body::before {
  top: -8rem;
  right: -7rem;
  background: rgba(214, 177, 107, 0.18);
}

body::after {
  bottom: -10rem;
  left: -8rem;
  background: rgba(124, 198, 187, 0.16);
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at top left, rgba(156, 106, 27, 0.08), transparent 34%),
    radial-gradient(circle at top right, rgba(47, 123, 117, 0.08), transparent 32%),
    linear-gradient(180deg, #eee4d6, #e8dece 38%, #e2d7c5 100%);
}

:root[data-theme="light"] body::before,
:root[data-theme="light"] body::after {
  opacity: 0.36;
}

:root[data-theme="light"] body::before {
  background: rgba(156, 106, 27, 0.12);
}

:root[data-theme="light"] body::after {
  background: rgba(47, 123, 117, 0.1);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 18px;
}

code,
pre {
  font-family: var(--font-code);
}

::selection {
  background: rgba(214, 177, 107, 0.28);
}

.skip-link {
  position: absolute;
  top: -3rem;
  left: 1rem;
  z-index: 30;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text);
  font-family: var(--font-ui);
}

.skip-link:focus {
  top: 1rem;
}

.site-shell,
.reader-shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 4rem;
}

.page--home .site-shell {
  position: relative;
  isolation: isolate;
}

.page--reader .reader-shell {
  position: relative;
  isolation: isolate;
}

.page--home .site-shell::before {
  content: "";
  position: fixed;
  inset: -3rem;
  background:
    linear-gradient(180deg, rgba(8, 16, 20, 0.48) 0%, rgba(8, 16, 20, 0.62) 36%, rgba(8, 16, 20, 0.8) 100%),
    radial-gradient(circle at 22% 12%, rgba(214, 177, 107, 0.14), transparent 24%),
    radial-gradient(circle at 82% 18%, rgba(124, 198, 187, 0.14), transparent 28%),
    url("./cover.png") 52% 10% / 112% auto no-repeat;
  filter: blur(12px) saturate(0.98) contrast(1.02) brightness(0.98);
  transform: scale(1.05);
  transform-origin: center top;
  opacity: 0.44;
  pointer-events: none;
  z-index: -2;
}

.page--reader .reader-shell::before {
  content: "";
  position: fixed;
  inset: -3rem;
  background:
    linear-gradient(180deg, rgba(8, 16, 20, 0.58) 0%, rgba(8, 16, 20, 0.72) 38%, rgba(8, 16, 20, 0.86) 100%),
    radial-gradient(circle at 24% 12%, rgba(214, 177, 107, 0.12), transparent 24%),
    radial-gradient(circle at 80% 16%, rgba(124, 198, 187, 0.12), transparent 26%),
    url("./cover.png") 56% 8% / 114% auto no-repeat;
  filter: blur(14px) saturate(0.98) contrast(1.02) brightness(0.98);
  transform: scale(1.05);
  transform-origin: center top;
  opacity: 0.34;
  pointer-events: none;
  z-index: -2;
}

:root[data-theme="light"] .page--home .site-shell::before {
  background:
    linear-gradient(180deg, rgba(248, 241, 231, 0.34) 0%, rgba(241, 232, 219, 0.3) 38%, rgba(230, 219, 203, 0.46) 100%),
    radial-gradient(circle at 22% 12%, rgba(156, 106, 27, 0.09), transparent 24%),
    radial-gradient(circle at 82% 18%, rgba(47, 123, 117, 0.09), transparent 28%),
    url("./cover.png") 52% 10% / 112% auto no-repeat;
  filter: blur(11px) saturate(0.9) contrast(1) brightness(1);
  opacity: 0.46;
}

:root[data-theme="light"] .page--reader .reader-shell::before {
  background:
    linear-gradient(180deg, rgba(248, 241, 231, 0.42) 0%, rgba(240, 231, 218, 0.36) 38%, rgba(228, 217, 200, 0.5) 100%),
    radial-gradient(circle at 24% 12%, rgba(156, 106, 27, 0.08), transparent 24%),
    radial-gradient(circle at 80% 16%, rgba(47, 123, 117, 0.08), transparent 26%),
    url("./cover.png") 56% 8% / 114% auto no-repeat;
  filter: blur(12px) saturate(0.86) contrast(0.98) brightness(1);
  opacity: 0.32;
}

.reader-shell {
  width: min(900px, calc(100% - 1.5rem));
}

.topbar {
  position: sticky;
  top: 0.8rem;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  min-width: 0;
}

.brand-kicker {
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
}

.brand-title {
  display: block;
  max-width: 18rem;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: uppercase;
}

.topbar-actions,
.hero-stats,
.button-row,
.reader-meta,
.chapter-meta,
.chapter-actions,
.mobile-reader-nav {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  align-items: center;
}

.topbar-actions {
  margin-left: auto;
  gap: 0.6rem;
  flex-wrap: nowrap;
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.8rem;
  padding: 0.68rem 0.92rem;
  border: 1px solid rgba(214, 177, 107, 0.18);
  border-radius: 999px;
  background: rgba(11, 22, 28, 0.56);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1;
  text-transform: uppercase;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.topbar-link--stacked {
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  gap: 0.14rem;
  text-align: left;
}

.topbar-link__detail {
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.2;
}

:root[data-theme="light"] .topbar {
  background: rgba(255, 249, 242, 0.86);
  box-shadow:
    0 20px 40px rgba(90, 68, 31, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

:root[data-theme="light"] .topbar-link {
  border-color: rgba(156, 106, 27, 0.14);
  background: rgba(255, 244, 226, 0.86);
  color: #7f5312;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

:root[data-theme="light"] .topbar-link__detail {
  color: #866f4e;
}

.hero-card,
.reader-hero,
.chapter-card,
.chapter-body {
  border: 1px solid var(--border);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-card,
.reader-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(1.5rem, 5vw, 3rem);
  margin-top: 1.6rem;
}

.hero-card::after,
.reader-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(214, 177, 107, 0.08), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(124, 198, 187, 0.1), transparent 30%);
  pointer-events: none;
}

.hero-card--compact {
  max-width: 760px;
}

.hero-card--with-cover {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 360px);
  grid-template-areas:
    "intro cover"
    "meta cover"
    "actions cover";
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: center;
}

.hero-copy,
.hero-cover {
  position: relative;
  z-index: 1;
}

.hero-copy {
  max-width: 42rem;
}

.hero-copy--intro {
  grid-area: intro;
}

.hero-copy--actions {
  grid-area: actions;
}

.hero-copy--meta {
  grid-area: meta;
}

.hero-copy--meta .hero-stats {
  margin-top: 0;
}

.hero-copy--actions .button-row {
  margin-top: 0;
}

.eyebrow {
  position: relative;
  z-index: 1;
  margin: 0 0 1rem;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.hero-card h1,
.reader-title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 0.95;
}

.reader-title {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
}

.lede {
  position: relative;
  z-index: 1;
  max-width: 44rem;
  margin: 1.25rem 0 0;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.75;
}

.hero-stats,
.reader-meta {
  position: relative;
  z-index: 1;
  gap: 0.7rem;
  margin-top: 1.85rem;
}

.stat-chip,
.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.38rem 0.72rem;
  border: 1px solid rgba(214, 177, 107, 0.14);
  border-radius: 999px;
  background: rgba(18, 31, 37, 0.66);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

:root[data-theme="light"] .stat-chip,
:root[data-theme="light"] .meta-pill {
  background: rgba(255, 247, 236, 0.82);
  color: #6d5d45;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.2rem;
  margin-top: 0;
}

.library-section {
  margin-top: 2rem;
}

.section-heading {
  margin-bottom: 1.25rem;
  padding-inline: 0.15rem;
}

.section-heading h2 {
  margin: 0.3rem 0 0;
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  line-height: 0.98;
}

.section-copy {
  max-width: 34rem;
  margin: 0.75rem 0 0;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.7;
}

.chapter-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 100%;
  padding: 1.55rem;
  background:
    radial-gradient(circle at top right, rgba(124, 198, 187, 0.1), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 30%),
    var(--surface);
}

.chapter-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(140deg, rgba(214, 177, 107, 0.08), transparent 34%),
    radial-gradient(circle at 12% 0%, rgba(214, 177, 107, 0.08), transparent 24%);
  pointer-events: none;
}

.chapter-card__header,
.chapter-card__footer {
  position: relative;
  z-index: 1;
}

.chapter-card__header {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.chapter-card__footer {
  display: flex;
  flex-direction: column;
  gap: 0.95rem;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(214, 177, 107, 0.12);
}

.chapter-card .eyebrow {
  margin-bottom: 0;
}

.chapter-card h2 {
  margin: 0;
  font-size: clamp(1.95rem, 2.4vw, 2.45rem);
  line-height: 0.98;
}

.chapter-card__lede {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.98rem;
  line-height: 1.72;
}

.chapter-meta {
  gap: 0.65rem;
  margin-top: 0;
}

.chapter-card .button-row {
  margin-top: 0;
  padding-top: 0;
}

.button-row--hero {
  gap: 1rem 1.2rem;
  align-items: stretch;
}

.hero-cover {
  grid-area: cover;
  align-self: center;
  display: block;
  width: min(100%, 360px);
  margin-left: auto;
  padding: 0.9rem;
  border: 1px solid rgba(214, 177, 107, 0.24);
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 48%),
    rgba(7, 13, 17, 0.58);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.34);
  isolation: isolate;
  transform: rotate(2deg);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

:root[data-theme="light"] .hero-cover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent 48%),
    rgba(255, 246, 232, 0.82);
  box-shadow: 0 24px 56px rgba(77, 58, 25, 0.18);
}

.hero-cover::before {
  content: "";
  position: absolute;
  inset: 12% 8% -6%;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(214, 177, 107, 0.38), rgba(124, 198, 187, 0.26));
  filter: blur(26px);
  opacity: 0.48;
  z-index: 0;
}

.hero-cover__badge {
  position: absolute;
  top: 1.1rem;
  left: 1.1rem;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.72rem;
  border: 1px solid rgba(245, 239, 222, 0.16);
  border-radius: 999px;
  background: rgba(7, 13, 17, 0.78);
  color: #f5efde;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  z-index: 1;
}

:root[data-theme="light"] .hero-cover__badge {
  border-color: rgba(132, 99, 42, 0.18);
  background: rgba(255, 251, 244, 0.88);
  color: #6d5d45;
}

.hero-cover__image {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 1024 / 1536;
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid rgba(245, 239, 222, 0.08);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.28);
}

.hero-cover:hover,
.hero-cover:focus-visible {
  transform: translateY(-3px) rotate(1deg);
  border-color: var(--accent);
  box-shadow: 0 32px 84px rgba(0, 0, 0, 0.4);
  outline: none;
}

.button,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.7rem;
  padding: 0.72rem 0.98rem;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(214, 177, 107, 0.18), rgba(214, 177, 107, 0.08));
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    opacity 160ms ease;
  cursor: pointer;
}

.theme-toggle {
  position: relative;
  flex: 0 0 auto;
  width: 2.9rem;
  min-width: 2.9rem;
  min-height: 2.9rem;
  padding: 0;
  border-color: rgba(124, 198, 187, 0.24);
  border-radius: 100%;
  background:
    radial-gradient(circle at 30% 30%, rgba(124, 198, 187, 0.22), transparent 52%),
    linear-gradient(180deg, rgba(14, 31, 37, 0.96), rgba(10, 21, 26, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 24px rgba(0, 0, 0, 0.22);
}

:root[data-theme="light"] .theme-toggle {
  border-color: rgba(156, 106, 27, 0.24);
  background:
    radial-gradient(circle at 30% 30%, rgba(214, 177, 107, 0.24), transparent 52%),
    linear-gradient(180deg, rgba(255, 249, 239, 0.96), rgba(247, 238, 223, 0.92));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    0 10px 24px rgba(77, 58, 25, 0.12);
}

.theme-toggle__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
}

.theme-toggle__glyph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.theme-toggle__glyph--sun {
  color: #c98b28;
  opacity: 0;
  transform: scale(0.7) rotate(-20deg);
}

.theme-toggle__glyph--moon {
  color: #f4ebd8;
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

:root[data-theme="light"] .theme-toggle__glyph--sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

:root[data-theme="light"] .theme-toggle__glyph--moon {
  opacity: 0;
  transform: scale(0.7) rotate(20deg);
}

.button--hero {
  min-width: min(12rem, 100%);
  min-height: 3.5rem;
}

.button--stacked {
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
  gap: 0.18rem;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
  text-align: left;
}

.button-label {
  line-height: 1;
}

.button-detail {
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-transform: uppercase;
}

.button:hover,
.theme-toggle:hover,
.topbar-link:hover,
.button:focus-visible,
.theme-toggle:focus-visible,
.topbar-link:focus-visible,
.back-link:focus-visible,
.chapter-body a:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
  outline: none;
}

.button--ghost {
  background: var(--surface-soft);
}

.button--disabled {
  cursor: not-allowed;
  opacity: 0.62;
  background: var(--surface-soft);
}

.progress-track {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  z-index: 25;
}

.progress-bar {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--secondary), var(--accent));
  box-shadow: 0 0 18px rgba(124, 198, 187, 0.5);
}

.reader-main {
  margin-top: 1.2rem;
}

.back-link {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--secondary);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chapter-pager {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-top: 1.1rem;
}

.hero-card .button-row,
.chapter-actions,
.reader-hero .chapter-pager {
  margin-top: 1.5rem;
}

.chapter-actions + .chapter-pager {
  margin-top: 0.8rem;
}

.chapter-body {
  padding: clamp(1.3rem, 5vw, 3rem);
}

.chapter-body p,
.chapter-body li,
.chapter-body blockquote {
  font-size: clamp(1.08rem, 1rem + 0.25vw, 1.2rem);
  line-height: 1.95;
}

.chapter-body p {
  margin: 0 0 1.35rem;
  color: rgba(245, 239, 222, 0.96);
}

.chapter-body > :last-child {
  margin-bottom: 0;
}

:root[data-theme="light"] .chapter-body p {
  color: rgba(36, 31, 24, 0.96);
}

.chapter-body p:first-of-type::first-letter {
  float: left;
  margin-right: 0.12em;
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 3.4em;
  line-height: 0.82;
}

.chapter-body h2,
.chapter-body h3,
.chapter-body h4,
.chapter-body h5,
.chapter-body h6 {
  margin: 2.3rem 0 0.9rem;
  font-family: var(--font-ui);
  line-height: 1.1;
}

.chapter-body ul,
.chapter-body ol {
  margin: 0 0 1.4rem;
  padding-left: 1.35rem;
}

.chapter-body li {
  margin: 0.45rem 0;
  color: var(--text);
}

.chapter-body strong {
  color: var(--accent-strong);
}

.chapter-body a {
  color: var(--secondary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.chapter-body blockquote {
  margin: 1.8rem 0;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 18px 18px 0;
  background: var(--accent-soft);
}

.chapter-body code {
  padding: 0.15rem 0.38rem;
  border-radius: 0.45rem;
  background: rgba(124, 198, 187, 0.12);
  font-size: 0.92em;
}

.chapter-body pre {
  overflow-x: auto;
  margin: 0 0 1.5rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(124, 198, 187, 0.2);
  border-radius: 20px;
  background: rgba(4, 10, 13, 0.78);
}

:root[data-theme="light"] .chapter-body pre {
  background: rgba(245, 240, 230, 0.96);
}

.chapter-body pre code {
  padding: 0;
  background: transparent;
}

.chapter-body hr {
  height: 1px;
  margin: 2rem 0;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.mobile-reader-nav {
  display: none;
}

@media (min-width: 721px) {
  .mobile-reader-nav {
    display: none;
  }
}

@media (max-width: 720px) {
  .site-shell,
  .reader-shell {
    width: min(100% - 1rem, 1100px);
    padding-top: 0.75rem;
  }

  .page--home .site-shell::before {
    inset: -2rem;
    background:
      linear-gradient(180deg, rgba(8, 16, 20, 0.5) 0%, rgba(8, 16, 20, 0.66) 40%, rgba(8, 16, 20, 0.84) 100%),
      radial-gradient(circle at 20% 12%, rgba(214, 177, 107, 0.12), transparent 24%),
      radial-gradient(circle at 82% 20%, rgba(124, 198, 187, 0.12), transparent 28%),
      url("./cover.png") 46% 8% / 126% auto no-repeat;
    filter: blur(10px) saturate(0.96) contrast(1.02) brightness(0.98);
    opacity: 0.42;
  }

  .page--reader .reader-shell::before {
    inset: -2rem;
    background:
      linear-gradient(180deg, rgba(8, 16, 20, 0.58) 0%, rgba(8, 16, 20, 0.72) 42%, rgba(8, 16, 20, 0.88) 100%),
      radial-gradient(circle at 24% 12%, rgba(214, 177, 107, 0.1), transparent 24%),
      radial-gradient(circle at 80% 18%, rgba(124, 198, 187, 0.1), transparent 26%),
      url("./cover.png") 50% 7% / 128% auto no-repeat;
    filter: blur(10px) saturate(0.96) contrast(1.02) brightness(0.98);
    opacity: 0.34;
  }

  :root[data-theme="light"] .page--home .site-shell::before {
    background:
      linear-gradient(180deg, rgba(248, 241, 231, 0.36) 0%, rgba(240, 231, 218, 0.32) 42%, rgba(227, 216, 199, 0.48) 100%),
      radial-gradient(circle at 20% 12%, rgba(156, 106, 27, 0.08), transparent 24%),
      radial-gradient(circle at 82% 20%, rgba(47, 123, 117, 0.08), transparent 28%),
      url("./cover.png") 46% 8% / 126% auto no-repeat;
    filter: blur(10px) saturate(0.86) contrast(0.98) brightness(1);
    opacity: 0.42;
  }

  :root[data-theme="light"] .page--reader .reader-shell::before {
    background:
      linear-gradient(180deg, rgba(248, 241, 231, 0.42) 0%, rgba(240, 231, 218, 0.36) 42%, rgba(228, 217, 200, 0.52) 100%),
      radial-gradient(circle at 24% 12%, rgba(156, 106, 27, 0.07), transparent 24%),
      radial-gradient(circle at 80% 18%, rgba(47, 123, 117, 0.07), transparent 26%),
      url("./cover.png") 50% 7% / 128% auto no-repeat;
    filter: blur(9px) saturate(0.82) contrast(0.98) brightness(1);
    opacity: 0.3;
  }

  .page--reader .reader-shell {
    padding-bottom: calc(5.8rem + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    border-radius: 16px;
    align-items: center;
    flex-direction: row;
    padding: 0.72rem 0.8rem;
  }

  .topbar-actions {
    width: auto;
  }

  .topbar-actions > :not(.theme-toggle) {
    flex: 0 0 auto;
  }

  .brand {
    max-width: min(11.5rem, calc(100% - 8rem));
  }

  .brand-kicker {
    font-size: 0.54rem;
  }

  .brand-title {
    max-width: 100%;
    font-size: 0.74rem;
    letter-spacing: 0.12em;
  }

  .topbar-link {
    min-height: 2.65rem;
    padding: 0.6rem 0.78rem;
    font-size: 0.68rem;
  }

  .topbar-link__detail {
    display: none;
  }

  .hero-card,
  .reader-hero,
  .chapter-body,
  .chapter-card {
    border-radius: 16px;
  }

  .library-section {
    margin-top: 1.5rem;
  }

  .section-heading {
    margin-bottom: 1rem;
  }

  .section-heading h2 {
    font-size: clamp(1.8rem, 8vw, 2.3rem);
  }

  .section-copy {
    max-width: 20rem;
    font-size: 0.94rem;
  }

  .hero-card--with-cover {
    grid-template-columns: 1fr;
    grid-template-areas:
      "intro"
      "meta"
      "actions";
    gap: 1rem;
  }

  .hero-card--with-cover::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
      linear-gradient(180deg, rgba(8, 16, 20, 0.24) 0%, rgba(8, 16, 20, 0.56) 38%, rgba(8, 16, 20, 0.88) 100%),
      radial-gradient(circle at 58% 24%, rgba(245, 239, 222, 0.04), transparent 22%),
      url("./cover.png") 8% 13% / 132% auto no-repeat;
    opacity: 0.34;
    filter: saturate(1.02) contrast(1.06);
    transform: scale(1.04);
    transform-origin: center top;
    pointer-events: none;
    z-index: 0;
  }

  :root[data-theme="light"] .hero-card--with-cover::before {
    background:
      linear-gradient(180deg, rgba(251, 245, 237, 0.8) 0%, rgba(246, 239, 229, 0.72) 40%, rgba(231, 220, 204, 0.84) 100%),
      radial-gradient(circle at 58% 24%, rgba(255, 255, 255, 0.18), transparent 22%),
      url("./cover.png") 8% 13% / 132% auto no-repeat;
    opacity: 0.68;
    filter: saturate(0.72) contrast(0.9) brightness(1.01);
  }

  .hero-copy {
    max-width: none;
  }

  .chapter-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .chapter-card {
    padding: 1.25rem;
  }

  .chapter-card__footer {
    padding-top: 0.85rem;
  }

  .chapter-card__lede {
    font-size: 0.95rem;
  }

  .hero-copy--meta {
    width: 100%;
  }

  .hero-copy--meta .hero-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.55rem;
    width: 100%;
    margin-top: 0.45rem;
  }

  .hero-copy--meta .stat-chip {
    max-width: 100%;
  }

  .hero-copy--actions {
    width: 100%;
    padding-top: 0.2rem;
  }

  .hero-copy--actions .button-row {
    margin-top: 0;
  }

  .hero-cover {
    display: none;
  }

  .button-row,
  .reader-meta,
  .chapter-actions {
    align-items: stretch;
  }

  .hero-card .button-row {
    margin-top: 0.85rem;
  }

  .button-row--hero {
    gap: 0.85rem;
  }

  .button-row > *,
  .chapter-actions > * {
    width: 100%;
  }

  .button--stacked {
    align-items: center;
    text-align: center;
  }

  .button,
  .theme-toggle {
    width: 100%;
  }

  .theme-toggle {
    width: 2.9rem;
  }

  .chapter-body {
    padding: 1.2rem;
    padding-top: 2rem;
  }

  .chapter-body p:first-of-type::first-letter {
    font-size: 2.8em;
  }

  .chapter-pager--desktop {
    display: none;
  }

  .page--reader .topbar--reader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    padding:
      calc(0.75rem + env(safe-area-inset-top, 0px))
      max(0.75rem, env(safe-area-inset-left, 0px))
      0.75rem
      max(0.75rem, env(safe-area-inset-right, 0px));
    border-top: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    transition:
      transform 220ms ease,
      opacity 220ms ease;
  }

  .page--reader.reader-touch-ui .topbar--reader {
    transform: translateY(calc(-100% - 1rem));
    opacity: 0;
    pointer-events: none;
  }

  .page--reader.reader-touch-ui.reader-controls-visible .topbar--reader {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .page--reader .mobile-reader-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 16;
    display: flex;
    flex-wrap: nowrap;
    padding:
      0.65rem
      max(0.75rem, env(safe-area-inset-right, 0px))
      calc(0.65rem + env(safe-area-inset-bottom, 0px))
      max(0.75rem, env(safe-area-inset-left, 0px));
    border: 1px solid var(--border);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
    background: var(--surface);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
    transition:
      transform 220ms ease,
      opacity 220ms ease;
  }

  .page--reader .mobile-reader-nav > * {
    flex: 1 1 50%;
  }

  .page--reader.reader-touch-ui .mobile-reader-nav {
    transform: translateY(calc(100% + 1rem));
    opacity: 0;
    pointer-events: none;
  }

  .page--reader.reader-touch-ui.reader-controls-visible .mobile-reader-nav {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
}
