:root {
  color-scheme: dark;
  --bg: #060706;
  --ink: #f2efe7;
  --soft: rgba(242, 239, 231, 0.78);
  --muted: rgba(242, 239, 231, 0.58);
  --line: rgba(242, 239, 231, 0.16);
  --gold: #d7bd75;
  --green: #6fd0a2;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(111, 208, 162, 0.14), transparent 28rem),
    radial-gradient(circle at 82% 12%, rgba(215, 189, 117, 0.1), transparent 26rem),
    linear-gradient(180deg, #060706 0%, #10100d 52%, #060706 100%);
  color: var(--ink);
  font-family: var(--sans);
}

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

.reader-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(0.85rem, env(safe-area-inset-top)) clamp(1rem, 4vw, 2rem) 0.85rem;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 7, 6, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
}

.brand img {
  filter: invert(1);
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.35rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.reader-shell {
  display: grid;
  gap: 1.4rem;
  width: min(100%, 76rem);
  margin: 0 auto;
  padding: 1rem clamp(1rem, 4vw, 2rem) 6rem;
}

.chapter-nav {
  position: sticky;
  top: 4.2rem;
  z-index: 2;
  overflow-x: auto;
  margin: 0 -1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(242, 239, 231, 0.1);
  background: rgba(6, 7, 6, 0.82);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.chapter-nav p,
.eyebrow {
  margin: 0 0 0.65rem;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.chapter-nav div {
  display: flex;
  gap: 0.65rem;
}

.chapter-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  max-width: 18rem;
  min-height: 2.35rem;
  padding: 0 0.8rem;
  border: 1px solid rgba(242, 239, 231, 0.12);
  border-radius: 999px;
  background: rgba(242, 239, 231, 0.045);
  color: var(--soft);
  font-family: var(--mono);
  font-size: 0.68rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-nav span {
  color: var(--gold);
}

.essay-copy {
  width: min(100%, 45rem);
}

h1 {
  margin: 0;
  font-size: clamp(3rem, 15vw, 7.2rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.subtitle,
.chapter-subtitle {
  margin: 0.75rem 0 0;
  color: var(--gold);
  font-family: var(--mono);
  font-size: clamp(0.82rem, 2.7vw, 1rem);
  letter-spacing: 0.08em;
  line-height: 1.45;
}

.essay-chapter {
  scroll-margin-top: 8rem;
  padding: 2.2rem 0;
  border-top: 1px solid var(--line);
}

.essay-chapter:first-of-type {
  margin-top: 2rem;
}

.essay-chapter h2 {
  max-width: 39rem;
  margin: 0;
  font-size: clamp(1.8rem, 7vw, 3.5rem);
  line-height: 1;
}

.essay-chapter p {
  margin: 1rem 0 0;
  color: var(--soft);
  font-size: clamp(1rem, 2.6vw, 1.18rem);
  line-height: 1.72;
}

@media (min-width: 860px) {
  .reader-shell {
    grid-template-columns: 17rem minmax(0, 1fr);
    align-items: start;
    padding-top: 2rem;
  }

  .chapter-nav {
    top: 5.2rem;
    overflow-x: visible;
    margin: 0;
    padding: 0;
    border-bottom: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .chapter-nav div {
    display: grid;
    gap: 0.45rem;
  }

  .chapter-nav a {
    width: 100%;
    border-radius: 0;
  }
}

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