:root {
  --paper: #f7f2ea;
  --paper-deep: #eee4d4;
  --ink: #201b16;
  --muted: #746b61;
  --line: rgba(46, 37, 28, 0.16);
  --accent: #8c3f2b;
  --olive: #586246;
  --sky: #4f7288;
  --button-bg: rgba(255, 250, 240, 0.58);
  --button-bg-hover: rgba(255, 250, 240, 0.86);
  --button-line: rgba(80, 61, 44, 0.28);
  --button-shadow: 0 10px 26px rgba(47, 35, 24, 0.08);
  --divider-ink: rgba(32, 27, 22, 0.72);
  --divider-cutout: var(--paper);
  --reader-width: 740px;
  --body-size: 18px;
  --paragraph-indent: 0;
  --reader-font: var(--reader-font-songti);
  --reader-font-songti: "Songti SC", "STSongti-SC-Regular", "STSong", "Songti TC", serif;
  --reader-font-heiti: "PingFang SC", "Hiragino Sans GB", "Heiti SC", "STHeiti", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: only light;
  filter: none !important;
  forced-color-adjust: none;
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior: none;
  overscroll-behavior-x: none;
  scroll-behavior: smooth;
  width: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  color-scheme: only light;
  filter: none !important;
  forced-color-adjust: none;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
  overscroll-behavior: none;
  overscroll-behavior-x: none;
  position: relative;
  width: 100%;
}

.site-header,
.settings-card,
.download-options,
.hero,
.hero-image,
.hero-copy,
.reader-shell,
.toc-panel,
.reader,
.reader-content,
.swatch {
  forced-color-adjust: none;
}

body.theme-ivory {
  --paper: #fbf7ee;
  --paper-deep: #f1eadc;
  --ink: #211c16;
  --muted: #766c5f;
  --line: rgba(46, 37, 28, 0.14);
}

body.theme-mist {
  --paper: #f1f2ee;
  --paper-deep: #e4e6df;
  --ink: #22231f;
  --muted: #686d64;
  --line: rgba(40, 43, 37, 0.14);
}

body.theme-night {
  --paper: #171512;
  --paper-deep: #211d18;
  --ink: #eee4d6;
  --muted: #b9ab9a;
  --line: rgba(238, 228, 214, 0.14);
  --button-bg: rgba(255, 244, 226, 0.08);
  --button-bg-hover: rgba(255, 244, 226, 0.14);
  --button-line: rgba(238, 228, 214, 0.2);
  --button-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
  --accent: #d19677;
  --sky: #9bb7c4;
  --divider-ink: rgba(238, 228, 214, 0.72);
  --divider-cutout: var(--paper);
}

body.reader-font-songti {
  --reader-font: var(--reader-font-songti);
}

body.reader-font-heiti {
  --reader-font: var(--reader-font-heiti);
}

body.reader-no-indent {
  --paragraph-indent: 0;
}

body.reader-indent {
  --paragraph-indent: 2em;
}

a {
  color: inherit;
}

.site-header {
  align-items: center;
  backdrop-filter: blur(18px);
  background: rgba(247, 242, 234, 0.86);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 78px;
  justify-content: space-between;
  left: 0;
  padding: 0 clamp(24px, 5vw, 72px);
  position: sticky;
  right: 0;
  top: 0;
  z-index: 20;
}

body.theme-night .site-header {
  background: rgba(23, 21, 18, 0.92);
  border-bottom-color: rgba(238, 228, 214, 0.16);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
}

.brand {
  display: grid;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.08;
  text-decoration: none;
}

.brand span:first-child {
  font-size: 21px;
}

body.theme-night .brand span:first-child {
  color: #f1e8dc;
}

.brand span:last-child {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

body.theme-night .brand span:last-child {
  color: rgba(238, 228, 214, 0.68);
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 16px;
}

.top-actions > a {
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  padding: 8px 11px;
  text-decoration: none;
  transition: background 160ms ease, color 160ms ease;
}

.top-actions > a:hover {
  background: rgba(140, 63, 43, 0.08);
  color: var(--accent);
}

.top-tool-button,
.toc-toggle-button {
  align-items: center;
  background: var(--button-bg);
  border: 1px solid var(--button-line);
  border-radius: 999px;
  box-shadow: var(--button-shadow);
  color: #44382f;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 15px;
  min-height: 40px;
  justify-content: center;
  padding: 9px 16px;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

body.theme-night .top-tool-button,
body.theme-night .toc-toggle-button,
body.theme-night .download-menu summary,
body.theme-night .secondary-link,
body.theme-night .chapter-nav button {
  color: var(--ink);
}

body.theme-night .top-tool-button,
body.theme-night .toc-toggle-button {
  background: rgba(238, 228, 214, 0.1);
  border-color: rgba(238, 228, 214, 0.18);
}

.top-tool-button:hover,
.toc-toggle-button:hover {
  background: var(--button-bg-hover);
  border-color: rgba(140, 63, 43, 0.32);
  transform: translateY(-1px);
}

body.theme-night .top-tool-button:hover,
body.theme-night .toc-toggle-button:hover {
  background: rgba(238, 228, 214, 0.16);
  border-color: rgba(238, 228, 214, 0.28);
  color: #fff6e9;
}

.toc-toggle-button {
  display: none;
}

.settings-panel {
  position: fixed;
  right: clamp(16px, 4vw, 54px);
  top: 92px;
  width: min(380px, calc(100vw - 32px));
  z-index: 50;
}

.settings-card {
  background: rgba(255, 250, 240, 0.96);
  border: 1px solid rgba(80, 61, 44, 0.18);
  border-radius: 14px;
  box-shadow: 0 22px 54px rgba(47, 35, 24, 0.16);
  color: #352b23;
  padding: 18px;
}

body.theme-night .settings-card {
  background: rgba(33, 29, 24, 0.98);
  color: var(--ink);
}

.settings-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
}

.settings-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.settings-head p,
.setting-group p,
.setting-group label {
  margin: 0;
}

.settings-head p {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.16em;
}

.settings-close {
  display: block;
}

.settings-reset {
  display: block;
}

.progress-toast {
  background: rgba(58, 45, 36, 0.92);
  border: 1px solid rgba(255, 250, 240, 0.16);
  border-radius: 999px;
  bottom: max(24px, env(safe-area-inset-bottom));
  box-shadow: 0 16px 38px rgba(47, 35, 24, 0.18);
  color: #f7f2ea;
  font-size: 14px;
  left: 50%;
  padding: 11px 18px;
  position: fixed;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 60;
}

body.theme-night .progress-toast {
  background: rgba(238, 228, 214, 0.92);
  color: #171512;
}

.setting-group {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.setting-group label,
.setting-group p,
.toggle-row span {
  color: var(--muted);
  font-size: 14px;
}

.setting-group output {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-left: 5px;
}

.setting-group input[type="range"] {
  accent-color: var(--accent);
  width: 100%;
}

.swatch-row,
.segmented-control {
  display: flex;
  gap: 8px;
}

.swatch {
  border: 1px solid var(--button-line);
  border-radius: 999px;
  cursor: pointer;
  height: 34px;
  padding: 0;
  position: relative;
  width: 34px;
}

.swatch[data-theme="paper"] {
  background: #f7f2ea !important;
  background-color: #f7f2ea !important;
}

.swatch[data-theme="ivory"] {
  background: #fbf7ee !important;
  background-color: #fbf7ee !important;
}

.swatch[data-theme="mist"] {
  background: #f1f2ee !important;
  background-color: #f1f2ee !important;
}

.swatch[data-theme="night"] {
  background: #171512 !important;
  background-color: #171512 !important;
}

.swatch.is-active::after {
  border: 1px solid var(--accent);
  border-radius: 999px;
  bottom: -5px;
  content: "";
  left: -5px;
  position: absolute;
  right: -5px;
  top: -5px;
}

.segmented-control {
  background: rgba(80, 61, 44, 0.07);
  border: 1px solid var(--button-line);
  border-radius: 999px;
  padding: 3px;
}

.segmented-control button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  flex: 1;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
}

.segmented-control button.is-active {
  background: #3a2d24;
  color: #f7f2ea;
}

body.theme-night .segmented-control button.is-active {
  background: #eee4d6;
  color: #171512;
}

.toggle-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 16px;
}

.toggle-row input {
  appearance: none;
  background: rgba(80, 61, 44, 0.1);
  border: 1px solid var(--button-line);
  border-radius: 999px;
  accent-color: var(--accent);
  cursor: pointer;
  height: 24px;
  position: relative;
  transition: background 160ms ease, border-color 160ms ease;
  width: 42px;
}

.toggle-row input::after {
  background: #f8f1e6;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(47, 35, 24, 0.18);
  content: "";
  height: 18px;
  left: 2px;
  position: absolute;
  top: 2px;
  transition: transform 160ms ease;
  width: 18px;
}

.toggle-row input:checked {
  background: #8c3f2b;
  border-color: rgba(140, 63, 43, 0.4);
}

.toggle-row input:not(:checked)::after {
  background: #b8ad9f;
  box-shadow: none;
}

.toggle-row input:checked::after {
  transform: translateX(18px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  min-height: calc(100svh - 78px);
}

.hero-image {
  background:
    linear-gradient(rgba(32, 27, 22, 0.08), rgba(32, 27, 22, 0.16)),
    url("assets/hero-kenya.webp");
  background-position: center;
  background-size: cover;
  min-height: 520px;
}

.hero-copy {
  align-self: center;
  padding: clamp(44px, 8vw, 112px);
}

.eyebrow,
.section-heading p,
.reader-kicker {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.18em;
  margin: 0 0 14px;
}

h1,
h2,
h3 {
  font-family: "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  font-weight: 500;
  letter-spacing: 0;
}

.hero h1 {
  font-size: clamp(54px, 8vw, 112px);
  line-height: 0.95;
  margin: 0;
  transform: translateX(-0.1em);
}

.subtitle {
  color: var(--sky);
  font-family: Georgia, serif;
  font-size: clamp(22px, 3vw, 38px);
  margin: 20px 0 34px;
}

.lede {
  color: var(--ink);
  font-family: var(--reader-font);
  font-size: 21px;
  line-height: 1.9;
  max-width: 620px;
}

.hero-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 56px;
}

.primary-link,
.secondary-link {
  align-items: center;
  border: 1px solid var(--button-line);
  border-radius: 999px;
  box-shadow: var(--button-shadow);
  display: inline-flex;
  font-size: 14px;
  justify-content: center;
  letter-spacing: 0.03em;
  min-height: 44px;
  min-width: 136px;
  padding: 11px 20px;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.hero-actions .primary-link {
  font-size: 16px;
  min-height: 54px;
  min-width: 168px;
  padding: 15px 28px;
}

.primary-link {
  background: #3a2d24;
  border-color: rgba(58, 45, 36, 0.88);
  color: #f7f2ea;
}

body.theme-night .primary-link {
  background: #eee4d6;
  border-color: rgba(238, 228, 214, 0.8);
  color: #171512;
}

.secondary-link {
  background: var(--button-bg);
  color: #44382f;
}

.primary-link:hover,
.secondary-link:hover {
  transform: translateY(-1px);
}

.primary-link:hover {
  background: #4a3527;
}

.secondary-link:hover {
  background: var(--button-bg-hover);
  border-color: rgba(140, 63, 43, 0.32);
  color: var(--accent);
}

.download-menu {
  position: relative;
}

.download-menu summary {
  align-items: center;
  border: 1px solid var(--button-line);
  border-radius: 999px;
  box-shadow: var(--button-shadow);
  color: #44382f;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  justify-content: center;
  list-style: none;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
  user-select: none;
}

.download-menu summary::-webkit-details-marker {
  display: none;
}

.download-menu summary::after {
  border-bottom: 1px solid currentColor;
  border-right: 1px solid currentColor;
  content: "";
  height: 6px;
  margin-top: -3px;
  transform: rotate(45deg);
  transition: transform 160ms ease;
  width: 6px;
}

.download-menu[open] summary::after {
  margin-top: 3px;
  transform: rotate(225deg);
}

.download-menu summary:hover {
  background: var(--button-bg-hover);
  border-color: rgba(140, 63, 43, 0.32);
  color: var(--accent);
  transform: translateY(-1px);
}

.download-options {
  background: rgba(255, 250, 240, 0.96);
  border: 1px solid rgba(80, 61, 44, 0.18);
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(47, 35, 24, 0.14);
  display: grid;
  gap: 2px;
  min-width: 168px;
  padding: 7px;
  position: absolute;
  top: calc(100% + 10px);
  z-index: 30;
}

body.theme-night .download-options {
  background: rgba(33, 29, 24, 0.98);
}

.download-options a {
  align-items: baseline;
  border-radius: 8px;
  color: var(--ink);
  display: flex;
  font-size: 14px;
  gap: 22px;
  justify-content: space-between;
  padding: 10px 12px;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease;
}

.download-options span {
  font-family: Georgia, serif;
  letter-spacing: 0.06em;
}

.download-options small {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.download-options a:hover {
  background: rgba(140, 63, 43, 0.09);
  color: var(--accent);
}

.top-download summary {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  font-size: 15px;
  min-height: 40px;
  padding: 9px 13px;
}

body.theme-night .top-download summary {
  background: rgba(238, 228, 214, 0.06);
  border-color: rgba(238, 228, 214, 0.12);
  color: rgba(238, 228, 214, 0.88);
}

body.theme-night .top-download summary:hover {
  background: rgba(238, 228, 214, 0.14);
  border-color: rgba(238, 228, 214, 0.24);
  color: #fff6e9;
}

.top-download .download-options {
  right: 0;
}

.hero-download summary {
  background: var(--button-bg);
  font-size: 16px;
  min-height: 54px;
  min-width: 172px;
  padding: 15px 26px;
}

.hero-download .download-options {
  left: 0;
}

.intro-band,
.downloads {
  border-top: 1px solid var(--line);
  padding: clamp(56px, 8vw, 104px) clamp(20px, 7vw, 96px);
}

.section-heading {
  margin: 0 auto 36px;
  max-width: 920px;
}

.section-heading h2 {
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.12;
  margin: 0;
}

.note-body {
  column-gap: 44px;
  columns: 2 360px;
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: 17px;
  line-height: 1.95;
  margin: 0 auto;
  max-width: 1100px;
}

.note-body h1 {
  display: none;
}

.note-body p {
  break-inside: avoid;
  margin: 0 0 1em;
  text-indent: 2em;
}

.reader-shell {
  align-items: stretch;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  min-height: 100svh;
}

body.reader-page .reader-shell {
  min-height: calc(100svh - 78px);
}

.toc-panel {
  background: color-mix(in srgb, var(--paper-deep) 84%, var(--paper) 16%);
  border-right: 1px solid var(--line);
  max-height: calc(100svh - 78px);
  overflow: auto;
  padding: 26px 14px;
  position: sticky;
  top: 78px;
}

body.theme-night .toc-panel {
  background: rgba(33, 29, 24, 0.96);
}

.toc-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 0 7px;
}

.toc-heading p {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.16em;
  margin: 0;
}

.text-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  display: none;
  font: inherit;
  padding: 8px 10px;
}

.toc-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #3b332b;
  cursor: pointer;
  display: block;
  font: inherit;
  font-size: 14px;
  margin: 2px 0;
  padding: 10px 11px;
  text-align: left;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
  width: 100%;
}

body.theme-night .toc-item {
  color: rgba(238, 228, 214, 0.84);
}

.toc-item.part {
  color: var(--accent);
  cursor: default;
  font-size: 12px;
  letter-spacing: 0.12em;
  margin-top: 14px;
  padding-bottom: 5px;
  padding-top: 14px;
}

.toc-item.is-active {
  background: rgba(140, 63, 43, 0.08);
  border-color: rgba(140, 63, 43, 0.13);
  color: var(--accent);
}

.toc-item:not(.part):hover {
  background: var(--button-bg);
  border-color: var(--button-line);
  color: var(--accent);
}

.reader {
  margin: 0 auto;
  max-width: calc(var(--reader-width) + 96px);
  padding: clamp(34px, 7vw, 88px) 48px;
  position: relative;
  width: 100%;
}

.reader-toolbar {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 34px;
  padding-bottom: 28px;
}

.reader-toolbar h1,
.reader-toolbar h2 {
  font-size: clamp(32px, 4vw, 50px);
  line-height: 1.18;
  margin: 0;
}

.reader-controls {
  background: rgba(255, 250, 240, 0.42);
  border: 1px solid var(--button-line);
  border-radius: 999px;
  display: flex;
  flex: 0 0 auto;
  padding: 3px;
}

.reader-controls button {
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 13px;
  transition: background 140ms ease, color 140ms ease;
}

.reader-controls .is-active {
  background: #3a2d24;
  color: var(--paper);
}

.reader-content {
  font-family: var(--reader-font) !important;
  font-size: var(--body-size);
  line-height: 2.05;
  margin: 0 auto;
  max-width: var(--reader-width);
}

.reader-content-songti,
.reader-content-songti p {
  font-family: var(--reader-font-songti) !important;
}

.reader-content-heiti,
.reader-content-heiti p {
  font-family: var(--reader-font-heiti) !important;
}

.reader-content p {
  margin: 0 0 1.05em;
  text-indent: var(--paragraph-indent);
}

.reader-table-wrap {
  margin: 2.2em 0 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  width: 100%;
}

.reader-table {
  border-collapse: collapse;
  color: var(--ink);
  font-size: max(0.82em, 15px);
  line-height: 1.48;
  min-width: min(100%, 540px);
  table-layout: fixed;
  text-indent: 0;
  width: 100%;
}

.reader-table th,
.reader-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  vertical-align: middle;
}

.reader-table th {
  color: var(--muted);
  font-size: 0.78em;
  font-weight: 500;
  letter-spacing: 0;
}

.reader-table td:first-child {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  overflow-wrap: anywhere;
}

.reader-table td:last-child {
  color: var(--muted);
}

.animal-divider {
  align-items: center;
  color: var(--divider-ink);
  display: flex;
  gap: 18px;
  justify-content: center;
  margin: 2.8em auto 2.9em;
  max-width: 460px;
}

.animal-divider::before,
.animal-divider::after {
  background: linear-gradient(90deg, transparent, currentColor 22%, currentColor 78%, transparent);
  content: "";
  flex: 1;
  height: 1px;
  opacity: 0.34;
}

.animal-divider svg {
  display: block;
  flex: 0 0 auto;
  height: 46px;
  width: clamp(150px, 32vw, 230px);
}

.animal-divider .savanna-shape {
  opacity: 0.92;
}

.animal-divider .zebra-stripes {
  opacity: 0.86;
  stroke: var(--divider-cutout);
  stroke-linecap: round;
  stroke-width: 2.3;
}

.chapter-nav {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  margin-top: 54px;
  padding-top: 22px;
}

.chapter-nav button {
  background: var(--button-bg);
  border: 1px solid var(--button-line);
  border-radius: 999px;
  color: #44382f;
  cursor: pointer;
  font: inherit;
  min-width: 112px;
  padding: 11px 18px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.chapter-nav button:hover:not(:disabled) {
  background: var(--button-bg-hover);
  border-color: rgba(140, 63, 43, 0.32);
  color: var(--accent);
  transform: translateY(-1px);
}

.chapter-nav button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.45;
}

.download-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 auto;
  max-width: 920px;
}

.download-grid a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.38);
  min-height: 138px;
  padding: 22px;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.download-grid a:hover {
  background: rgba(255, 250, 240, 0.7);
  border-color: rgba(140, 63, 43, 0.24);
  box-shadow: var(--button-shadow);
  transform: translateY(-2px);
}

.download-grid span {
  display: block;
  font-family: Georgia, serif;
  font-size: 28px;
  margin-bottom: 18px;
}

.download-grid small {
  color: var(--muted);
  line-height: 1.7;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
  padding: 22px clamp(20px, 5vw, 72px);
  text-align: center;
}

.site-footer p {
  margin: 0;
}

body.reader-compact {
  --body-size: 17px;
}

body.reader-wide {
  --body-size: 19px;
}

@media (max-width: 860px) {
  .site-header {
    height: 64px;
    padding: 0 14px;
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions > a {
    display: none;
  }

  .top-tool-button,
  .toc-toggle-button,
  .top-download summary {
    font-size: 13px;
    min-height: 36px;
    padding: 7px 9px;
  }

  .brand span:first-child {
    font-size: 18px;
  }

  .brand span:last-child {
    font-size: 11px;
  }

  .toc-toggle-button {
    display: inline-flex;
  }

  .settings-panel {
    left: 12px;
    right: 12px;
    top: 74px;
    width: auto;
  }

  .settings-card {
    padding: 16px;
  }

  .hero {
    display: flex;
    flex-direction: column;
    min-height: calc(100svh - 64px);
  }

  .hero-image {
    min-height: 41svh;
  }

  .hero-copy {
    flex: 1;
    padding: 28px 20px max(30px, calc(env(safe-area-inset-bottom) + 24px));
  }

  .hero h1 {
    font-size: clamp(44px, 13vw, 54px);
  }

  .subtitle {
    font-size: 27px;
    margin: 14px 0 24px;
  }

  .lede {
    font-size: 18px;
    line-height: 1.74;
  }

  .hero-actions {
    display: grid;
    gap: 12px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    margin-top: clamp(42px, 7vh, 58px);
    padding-bottom: max(env(safe-area-inset-bottom), 10px);
    transform: translateY(clamp(-34px, -4.2vh, -18px));
  }

  .hero-actions .primary-link,
  .hero-download summary {
    font-size: 15px;
    min-height: 50px;
    min-width: 0;
    padding: 13px 14px;
    width: 100%;
  }

  .reader-shell {
    display: block;
    max-width: 100%;
    min-height: calc(100svh - 64px);
    overflow-x: clip;
  }

  .toc-panel {
    bottom: 0;
    box-shadow: none;
    left: max(-340px, -82vw);
    max-height: none;
    max-width: 340px;
    position: fixed;
    top: 0;
    transition: left 180ms ease;
    width: min(82vw, 340px);
    z-index: 40;
  }

  .toc-panel.is-open {
    box-shadow: 0 0 0 999px rgba(32, 27, 22, 0.28);
    left: 0;
  }

  .text-button {
    display: block;
  }

  .reader {
    max-width: 100%;
    overflow-x: clip;
    padding: 34px 20px 56px;
  }

  .reader-content {
    max-width: 100%;
    overflow-x: clip;
    width: 100%;
  }

  .reader-content p {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .reader-toolbar {
    display: block;
  }

  .note-body {
    columns: 1;
  }

  .download-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) and (max-height: 760px) {
  .hero-image {
    min-height: 39svh;
  }

  .hero-copy {
    padding-top: 22px;
  }

  .eyebrow,
  .section-heading p,
  .reader-kicker {
    margin-bottom: 10px;
  }

  .subtitle {
    margin-bottom: 18px;
  }

  .lede {
    line-height: 1.58;
  }

  .hero-actions {
    margin-top: 48px;
    transform: translateY(clamp(-32px, -4vh, -20px));
  }
}

@media print {
  .site-header,
  .toc-panel,
  .settings-panel,
  .chapter-nav,
  .downloads {
    display: none;
  }

  body {
    background: white;
  }

  .hero,
  .intro-band {
    display: none;
  }

  .reader-shell {
    border: 0;
    display: block;
  }

  .reader {
    max-width: none;
    padding: 0;
  }
}
