:root {
  --bg: #faf8f3;
  --bg-soft: #f1ede4;
  --fg: #1a1a1a;
  --fg-soft: #555;
  --rule: #e3ddd0;
  --accent: #8a5a2b;
  --accent-cool: #46635d;
  --max: 50rem;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: "Literata", Charter, "Iowan Old Style", "Georgia", serif;
  font-size: 20px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern", "liga", "onum";
  padding-bottom: 6rem;
}

body.home-view {
  padding-bottom: 3rem;
}

header.site {
  border-bottom: 1px solid var(--rule);
  padding: 0.9rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: rgba(250, 248, 243, 0.9);
  z-index: 5;
  backdrop-filter: saturate(140%) blur(6px);
}

header.site .brand {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--fg-soft);
  text-decoration: none;
  white-space: nowrap;
}

header.site .brand:hover { color: var(--fg); }

header.site nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex-wrap: wrap;
}

header.site button,
header.site a.btn {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--fg-soft);
  background: transparent;
  border: 1px solid var(--rule);
  padding: 0.35rem 0.68rem;
  border-radius: 0.25rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

header.site button:hover,
header.site a.btn:hover {
  color: var(--fg);
  border-color: var(--fg-soft);
}

header.site a.primary-nav {
  color: var(--fg);
  border-color: #cfc5b6;
  background: rgba(255, 255, 255, 0.28);
}

header.site a.tongatron-btn {
  color: var(--accent-cool);
  border-color: transparent;
  padding-right: 0.55rem;
}

header.site a.tongatron-btn:hover {
  border-color: #c8d0ca;
  color: #243f3a;
}

.reading-position {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.74rem;
  color: var(--accent-cool);
  line-height: 1.2;
  padding: 0.35rem 0.18rem;
  white-space: nowrap;
  text-transform: uppercase;
}

.mobile-label { display: none; }
.external-mark { margin-left: 0.25rem; }

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1.2rem 4rem;
}

main h1 {
  font-weight: 600;
  font-size: 2.1rem;
  line-height: 1.15;
  margin: 1.5rem 0 0.3rem;
  letter-spacing: 0;
}

main h1.book-title {
  font-size: 2.6rem;
  margin-top: 2.2rem;
  margin-bottom: 0.4rem;
}

.home-editorial {
  padding-top: clamp(1.8rem, 4vw, 3.2rem);
}

.home-kicker {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.74rem;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--accent-cool);
  margin-bottom: 1.2rem;
}

.home-lead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(9rem, 12rem);
  gap: 2rem;
  align-items: start;
  padding: 0.4rem 0 2.2rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--rule);
}

.home-copy {
  max-width: 34rem;
}

.home-copy .book-title {
  margin-top: 0;
  margin-bottom: 0.7rem;
  max-width: 12ch;
}

.home-deck {
  font-size: 1.12rem;
  line-height: 1.7;
  color: var(--fg);
  margin-bottom: 1.5rem;
}

.home-cover {
  margin: 0;
}

.home-cover img {
  width: 100%;
  max-width: 12rem;
  display: block;
  border-radius: 0.2rem;
  box-shadow: 0 1rem 2.2rem rgba(26, 26, 26, 0.11);
  border: 1px solid var(--rule);
}

.home-body {
  max-width: 38rem;
}

.home-body p + p {
  text-indent: 1.2em;
}

.home-body hr + blockquote p,
.home-body blockquote p + p {
  text-indent: 0;
}

.hero-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0.64rem 0.88rem;
  border-radius: 0.2rem;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.26);
  color: var(--fg-soft);
  text-decoration: none;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0;
  text-transform: uppercase;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.cta-primary {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

.cta-btn:hover {
  border-color: var(--fg);
  color: var(--fg);
  background: rgba(255, 255, 255, 0.45);
}

.cta-primary:hover {
  background: var(--accent-cool);
  border-color: var(--accent-cool);
  color: #fff;
}

.inline-download {
  color: var(--accent);
  text-decoration: none;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.84rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.inline-download:hover {
  color: var(--fg);
}

.hero-note {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.74rem;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--fg-soft);
}

.support-action {
  display: flex;
  align-items: center;
  min-height: 2.6rem;
  margin-top: 1rem;
}

.support-action:empty {
  display: none;
}

.home-editorial h1 + p,
.home-editorial p:first-of-type {
  text-indent: 0;
}

main .subtitle {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--fg-soft);
  letter-spacing: 0;
  text-transform: uppercase;
  margin-bottom: 2.2rem;
}

main h2 { font-weight: 600; font-size: 1.4rem; margin: 2.2rem 0 0.6rem; }
main h3 { font-weight: 600; font-size: 1.15rem; margin: 1.8rem 0 0.4rem; font-style: italic; color: var(--fg-soft); }
main p { margin: 0 0 1.1rem; hyphens: auto; }
main p + p { text-indent: 1.2em; }
main p:first-of-type,
main h1 + p,
main h2 + p,
main h3 + p,
main hr + p { text-indent: 0; }
main em { font-style: italic; }
main strong { font-weight: 600; }

main blockquote {
  margin: 1.2rem 0;
  padding: 0.1rem 1rem;
  border-left: 2px solid var(--accent);
  color: var(--fg-soft);
  font-style: italic;
}

main blockquote p { text-indent: 0 !important; }

main hr {
  border: none;
  text-align: center;
  margin: 2rem 0;
  color: var(--fg-soft);
}

main hr::before {
  content: "✻   ✻   ✻";
  letter-spacing: 0;
  font-size: 0.8rem;
}

main ul,
main ol { padding-left: 1.4rem; }

main li { margin-bottom: 0.3rem; }

.toc {
  list-style: none;
  padding: 0;
  margin: 1.4rem 0 0;
  border-top: 1px solid var(--rule);
}

.toc li {
  margin: 0;
  border-bottom: 1px solid var(--rule);
}

.toc a {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 0.95rem 0.2rem;
  color: var(--fg);
  text-decoration: none;
  transition: color 160ms ease, padding-left 160ms ease;
}

.toc a:hover {
  color: var(--accent);
  padding-left: 0.45rem;
}

.toc .num {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--accent-cool);
  min-width: 1.6rem;
  font-variant-numeric: tabular-nums;
}

.toc .title { flex: 1; font-size: 1.1rem; }

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.85rem;
}

.chapter-nav a {
  color: var(--fg-soft);
  text-decoration: none;
  max-width: 45%;
  display: block;
}

.chapter-nav a:hover { color: var(--accent); }

.chapter-nav .label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--fg-soft);
  margin-bottom: 0.2rem;
}

.chapter-nav .name { color: var(--fg); }
.chapter-nav .next { text-align: right; margin-left: auto; }

.loading {
  color: var(--fg-soft);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.9rem;
  text-align: center;
  padding: 3rem 1rem;
}

footer.site {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2rem 1.2rem 3rem;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--fg-soft);
  text-align: center;
  border-top: 1px solid var(--rule);
}

footer.site p { margin: 0; }

footer.site a {
  color: var(--fg-soft);
  text-underline-offset: 0.18em;
}

footer.site a:hover { color: var(--fg); }

@media (max-width: 480px) {
  body { font-size: 18.5px; line-height: 1.65; }
  main { padding: 1.2rem 1.1rem 4rem; }
  main h1.book-title { font-size: 2rem; }
  main h1 { font-size: 1.65rem; }
}

@media (max-width: 560px) {
  header.site {
    padding: 0.75rem 1rem;
    align-items: flex-start;
  }

  header.site .brand {
    max-width: 10.5rem;
    white-space: normal;
  }

  header.site nav {
    gap: 0.3rem;
  }

  header.site button,
  header.site a.btn {
    font-size: 0.72rem;
    padding: 0.32rem 0.5rem;
  }

  .reading-position {
    font-size: 0.7rem;
    padding: 0.32rem 0.1rem;
  }

  .desktop-label { display: none; }
  .mobile-label { display: inline; }
}

@media (max-width: 760px) {
  .home-lead {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .home-cover {
    order: -1;
  }

  .home-cover img {
    max-width: 8.5rem;
  }
}

@media (min-width: 900px) {
  body { font-size: 22px; line-height: 1.72; }
  main { padding: 2.4rem 2.4rem 5rem; }
  main h1.book-title { font-size: 3rem; }
  main h1 { font-size: 2.4rem; }
}
