/* The Long Climb — flat, server-free reading edition */
:root {
  color-scheme: light;
  --bg: #f2efe6;
  --surface: #faf7ef;
  --surface-strong: #fffdf8;
  --text: #25261f;
  --muted: #6c6e61;
  --line: #d6d0c1;
  --accent: #7f4a32;
  --accent-soft: #efe0d3;
  --moss: #52634a;
  --system-bg: #171b15;
  --system-text: #e9eee4;
  --system-muted: #aebba7;
  --shadow: 0 18px 60px rgb(54 44 30 / 9%);
  --reader-scale: 1;
  --reader-width: 740px;
}
html[data-reader-size="0"]{--reader-scale:.92}html[data-reader-size="2"]{--reader-scale:1.1}html[data-reader-width="wide"]{--reader-width:860px}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11130f;
  --surface: #181b16;
  --surface-strong: #1d201a;
  --text: #e8e6dc;
  --muted: #a4a598;
  --line: #34372e;
  --accent: #d58b67;
  --accent-soft: #33251d;
  --moss: #9daf91;
  --system-bg: #090b08;
  --system-text: #edf2e9;
  --system-muted: #a8b5a1;
  --shadow: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #11130f;
    --surface: #181b16;
    --surface-strong: #1d201a;
    --text: #e8e6dc;
    --muted: #a4a598;
    --line: #34372e;
    --accent: #d58b67;
    --accent-soft: #33251d;
    --moss: #9daf91;
    --system-bg: #090b08;
    --system-text: #edf2e9;
    --system-muted: #a8b5a1;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 36rem),
    var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 2.1vw, 20px);
  line-height: 1.72;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-underline-offset: .22em; }
a:hover { color: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: .75rem;
  left: .75rem;
  transform: translateY(-200%);
  padding: .65rem .85rem;
  border-radius: .35rem;
  background: var(--text);
  color: var(--bg);
  font: 700 .78rem/1 system-ui, sans-serif;
}
.skip-link:focus { transform: none; }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  background: color-mix(in srgb, var(--bg) 91%, transparent);
  backdrop-filter: blur(15px);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.header-inner {
  width: min(1120px, calc(100% - 2rem));
  min-height: 3.8rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .68rem;
  text-decoration: none;
  font-size: .82rem;
  font-weight: 750;
  letter-spacing: .025em;
  white-space: nowrap;
}
.brand-mark {
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--moss);
  border-radius: 50%;
  color: var(--moss);
  font-family: ui-monospace, Consolas, monospace;
  font-size: .74rem;
  font-weight: 800;
}
.header-actions,
.site-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.site-nav a {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 650;
  text-decoration: none;
}
.site-nav a:hover { color: var(--text); }
.theme-picker select {
  max-width: 5.4rem;
  padding: .35rem .5rem;
  border: 1px solid var(--line);
  border-radius: .35rem;
  background: var(--surface);
  color: var(--text);
  font: 600 .68rem/1.2 system-ui, sans-serif;
}

.reader-main {
  width: min(var(--reader-width), calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(3.5rem, 9vw, 7rem) 0 6rem;
}
.chapter-header {
  position: relative;
  margin: 0 0 clamp(3.2rem, 8vw, 5.5rem);
  padding-bottom: 2.2rem;
  border-bottom: 1px solid var(--line);
}
.chapter-header::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 5rem;
  height: 2px;
  background: var(--accent);
}
.chapter-label,
.chapter-meta,
.eyebrow {
  color: var(--muted);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.chapter-label { margin: 0 0 1rem; }
.chapter-header h1,
.book-hero h1 {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: clamp(2.45rem, 8.5vw, 4.9rem);
  line-height: .98;
  letter-spacing: -.055em;
  text-wrap: balance;
}
.chapter-meta { margin: 1.2rem 0 0; letter-spacing: .08em; }
.chapter-description {
  max-width: 37rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: .86rem;
  line-height: 1.55;
}

.prose { font-size:calc(1em * var(--reader-scale)); }
.prose p { margin: 0 0 1.42em; }
.prose em { font-style: italic; }
.prose strong { font-weight: 700; }
.prose hr {
  width: 4.2rem;
  height: 1px;
  margin: 3.6rem auto;
  border: 0;
  background: var(--line);
}
.prose h2,
.prose h3 {
  margin: 2.7em 0 .8em;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.2;
}
.prose blockquote {
  margin: 2rem 0;
  padding: .1rem 0 .1rem 1.3rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.prose blockquote p { margin: 0; }
.code-block,
.system-message pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
}
.system-message {
  position: relative;
  margin: 2.6rem 0;
  padding: 1.2rem 1.25rem 1.3rem;
  overflow: hidden;
  border: 1px solid #3a4638;
  border-radius: .55rem;
  background: var(--system-bg);
  color: var(--system-text);
  box-shadow: var(--shadow);
  font: .78rem/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.system-message::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: #79906f;
}
.system-label {
  display: block;
  margin-bottom: .75rem;
  color: var(--system-muted);
  font-size: .63rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.chapter-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.chapter-nav a {
  display: flex;
  flex-direction: column;
  gap: .28rem;
  min-width: 0;
  padding: .9rem 0;
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.35;
  text-decoration: none;
}
.chapter-nav a:last-child { align-items: flex-end; text-align: right; }
.chapter-nav .direction {
  color: var(--muted);
  font-size: .63rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.index-main {
  width: min(1040px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(3.5rem, 9vw, 7rem) 0 6rem;
}
.book-hero {
  max-width: 760px;
  margin-bottom: clamp(4.5rem, 11vw, 8rem);
}
.eyebrow { margin: 0 0 1rem; color: var(--accent); }
.book-hero h1 { font-size: clamp(3.6rem, 13vw, 8.4rem); }
.tagline {
  margin: .9rem 0 0;
  color: var(--moss);
  font: 700 clamp(1rem, 2.7vw, 1.35rem)/1.25 system-ui, sans-serif;
  letter-spacing: .015em;
}
.book-description {
  max-width: 43rem;
  margin: 2rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.18rem);
  line-height: 1.65;
}
.book-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem 2.5rem;
  margin: 2rem 0 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.book-stats div { display: flex; flex-direction: column; gap: .2rem; }
.book-stats dt {
  color: var(--muted);
  font-size: .62rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.book-stats dd { margin: 0; font-size: .84rem; font-weight: 650; }
.start-reading {
  display: inline-flex;
  margin-top: 2.4rem;
  padding: .75rem 1rem;
  border: 1px solid var(--accent);
  border-radius: .35rem;
  color: var(--accent);
  font: 750 .75rem/1 system-ui, sans-serif;
  text-decoration: none;
}
.start-reading:hover { background: var(--accent); color: var(--surface-strong); }
.reading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 2.4rem;
}
.reading-actions .start-reading { margin-top: 0; }
.start-reading.secondary { border-color: var(--line); color: var(--muted); }
.start-reading.secondary:hover { border-color: var(--accent); color: var(--surface-strong); }

.full-book-toc {
  margin: 0 0 5rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.full-book-toc summary {
  cursor: pointer;
  color: var(--accent);
  font-size: .76rem;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.full-book-toc ol {
  columns: 2;
  gap: 2rem;
  margin: 1rem 0 0;
  padding-left: 1.4rem;
}
.full-book-toc li { break-inside: avoid; margin: 0 0 .45rem; color: var(--muted); }
.full-book-toc a { font-size: .76rem; text-decoration: none; }
.full-book-toc a span { color: var(--muted); font-size: .65rem; }
.collected-chapter {
  scroll-margin-top: 5rem;
  margin-top: 7rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.collected-chapter-header { margin-bottom: 3rem; }
.collected-chapter-header h2 {
  margin: 0;
  font: 760 clamp(2rem, 7vw, 3.5rem)/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -.045em;
  text-wrap: balance;
}
.back-to-book-top {
  display: inline-block;
  margin-top: 2rem;
  color: var(--muted);
  font: 700 .67rem/1 system-ui, sans-serif;
  letter-spacing: .06em;
  text-decoration: none;
  text-transform: uppercase;
}
.back-to-book-top:hover { color: var(--accent); }

.contents { max-width: 920px; }
.contents-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2.8rem;
  padding-bottom: .9rem;
  border-bottom: 2px solid var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.contents-heading p { margin: 0; font-size: 1.2rem; font-weight: 780; }
.contents-heading span { color: var(--muted); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; }
.part-section {
  display: grid;
  grid-template-columns: minmax(180px, .72fr) minmax(0, 1.5fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  margin: 0 0 4.4rem;
}
.part-header { padding-top: .9rem; }
.part-header p {
  margin: 0 0 .35rem;
  color: var(--accent);
  font: 750 .61rem/1 system-ui, sans-serif;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.part-header h2 {
  margin: 0;
  font: 760 1.1rem/1.2 system-ui, sans-serif;
  letter-spacing: -.02em;
}
.part-header span {
  display: block;
  margin-top: .75rem;
  color: var(--muted);
  font: .72rem/1.5 system-ui, sans-serif;
}
.contents-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.contents-list li { border-bottom: 1px solid var(--line); }
.contents-list a {
  display: grid;
  grid-template-columns: 6.2rem minmax(0, 1fr) 3.5rem;
  gap: 1rem;
  align-items: baseline;
  padding: .9rem 0;
  text-decoration: none;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.contents-list a:hover .chapter-title { color: var(--accent); }
.chapter-number,
.reading-time { color: var(--muted); font-size: .64rem; }
.chapter-number { font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.chapter-title { font-size: .88rem; font-weight: 690; line-height: 1.35; }
.reading-time { text-align: right; white-space: nowrap; }

.story-footer {
  padding: 2.4rem 1rem 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  font: 650 .64rem/1.4 system-ui, sans-serif;
  letter-spacing: .08em;
  text-transform: uppercase;
}

@media (max-width: 720px) {
  .header-inner { width: min(100% - 1.25rem, 1120px); }
  .header-actions { gap: .55rem; }
  .site-nav { gap: .7rem; }
  .site-nav a:not(:nth-child(2)) { display: none; }
  .part-section { grid-template-columns: 1fr; gap: .8rem; }
  .part-header span { max-width: 34rem; }
}

@media (max-width: 520px) {
  .brand > span:last-child { display: none; }
  .reader-main,
  .index-main { width: min(100% - 1.5rem, 1040px); }
  .chapter-header h1 { font-size: clamp(2.25rem, 13vw, 3.4rem); }
  .system-message { margin-inline: -.2rem; padding: 1rem; font-size: .7rem; }
  .contents-list a { grid-template-columns: 1fr auto; gap: .25rem .75rem; }
  .chapter-number { grid-column: 1; }
  .chapter-title { grid-column: 1; }
  .reading-time { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .chapter-nav { gap: .7rem; }
  .full-book-toc ol { columns: 1; }
}

@media print {
  .site-header,
  .skip-link,
  .full-book-toc,
  .back-to-book-top,
  .story-footer { display: none; }
  .reader-main { width: 100%; padding: 0; }
  .collected-chapter { break-before: page; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  :root,
  :root[data-theme="dark"] {
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --text: #000;
    --muted: #444;
    --line: #bbb;
  }
  .site-header,
  .chapter-nav,
  .story-footer { display: none; }
  body { background: #fff; font-size: 12pt; }
  .reader-main { width: auto; padding: 0; }
  .system-message { border-color: #555; box-shadow: none; }
}

.reader-tools{display:inline-flex;gap:.18rem;padding:.18rem;border:1px solid var(--line);border-radius:.4rem}.reader-tools button{min-width:2rem;min-height:2rem;padding:.25rem;border:0;border-radius:.25rem;background:transparent;color:var(--muted);cursor:pointer;font:750 .68rem/1 system-ui,sans-serif}.reader-tools button:hover{background:var(--accent-soft);color:var(--text)}.contents-list a.last-read{position:relative;color:var(--accent)}.contents-list a.last-read::after{position:absolute;right:0;top:.3rem;content:"Continue";font:750 .52rem/1 system-ui,sans-serif;letter-spacing:.08em;text-transform:uppercase}@media(max-width:720px){.reader-tools{order:3}}
