* {
  box-sizing: border-box;
}

:root {
  --rail-width: 56px;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

html {
  scroll-behavior: smooth;
  scroll-snap-type: y mandatory;
}

body {
  overflow-y: auto;
  overscroll-behavior-y: contain;
  color: #2b2a28;
  background: #f0eee6;
  font-family: 'EB Garamond', 'Alegreya', 'Iowan Old Style', serif;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.09;
  z-index: 1;
  background-image: radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.24) 1px, transparent 0);
  background-size: 4px 4px;
}

.rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail-width);
  z-index: 24;
  border-right: 1px solid rgba(35, 30, 24, 0.12);
  background: rgba(245, 242, 235, 0.86);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}

.rail-mark {
  margin-top: 2px;
  font: 600 0.68rem/1 'Cinzel', serif;
  letter-spacing: 0.14em;
  color: rgba(42, 36, 30, 0.58);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  align-items: center;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.rail-nav::-webkit-scrollbar {
  display: none;
}

.rail-link {
  width: 100%;
  text-align: center;
  text-decoration: none;
  font: 600 0.58rem/1.2 'IBM Plex Sans', sans-serif;
  letter-spacing: 0.06em;
  color: rgba(32, 30, 27, 0.28);
  padding: 2px 0;
  transition: color 160ms ease;
  flex-shrink: 0;
}

.rail-link.active {
  color: rgba(24, 22, 20, 0.95);
  font-weight: 700;
}

.rail-link.rail-section {
  font: 600 0.62rem/1 'Cinzel', serif;
  letter-spacing: 0.1em;
  color: rgba(32, 30, 27, 0.52);
  padding: 6px 0 4px;
  margin-top: 4px;
}

.rail-link.rail-section.active {
  color: rgba(24, 22, 20, 0.95);
}

.meta {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 20;
  font: 600 0.86rem/1 'Cinzel', serif;
  letter-spacing: 0.05em;
  color: rgba(28, 24, 20, 0.72);
  display: flex;
  align-items: center;
  gap: 14px;
}

.meta__random {
  all: unset;
  cursor: pointer;
  font: 600 0.68rem/1 'IBM Plex Sans', sans-serif;
  letter-spacing: 0.06em;
  color: rgba(28, 24, 20, 0.72);
  border: 1px solid rgba(35, 30, 24, 0.15);
  border-radius: 14px;
  padding: 5px 12px;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.meta__random:hover {
  color: rgba(90, 60, 30, 0.85);
  border-color: rgba(90, 60, 30, 0.5);
  background: rgba(90, 60, 30, 0.08);
}

.meta__btn {
  all: unset;
  cursor: pointer;
  font: 600 0.86rem/1 'Cinzel', serif;
  letter-spacing: 0.05em;
  color: rgba(28, 24, 20, 0.72);
  transition: color 160ms ease;
  font-variant-numeric: tabular-nums;
  min-width: 7.5ch;
  text-align: right;
}

.meta__btn:hover {
  color: rgba(90, 60, 30, 0.85);
}

/* ── Page Picker Overlay ── */

.page-picker {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(240, 238, 230, 0.96);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  overflow-y: auto;
}

.page-picker.open {
  opacity: 1;
  pointer-events: auto;
}

.page-picker__header {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-picker__title {
  font: 600 0.72rem/1 'IBM Plex Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(28, 24, 20, 0.72);
}

.page-picker__close {
  all: unset;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  color: rgba(28, 24, 20, 0.72);
  padding: 4px 8px;
  transition: color 160ms ease;
}

.page-picker__close:hover {
  color: rgba(28, 24, 20, 0.95);
}

.page-picker__grid {
  width: 100%;
  max-width: 480px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  margin-bottom: 24px;
}

.page-picker__cell {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 6px;
  font: 600 0.68rem/1 'IBM Plex Sans', sans-serif;
  letter-spacing: 0.04em;
  color: rgba(28, 24, 20, 0.72);
  background: rgba(35, 30, 24, 0.04);
  transition: background 160ms ease, color 160ms ease;
}

.page-picker__cell:hover {
  background: rgba(90, 60, 30, 0.15);
  color: rgba(28, 24, 20, 0.95);
}

.page-picker__cell.active {
  background: rgba(90, 60, 30, 0.75);
  color: #fff;
}

.page-picker__cell--label {
  aspect-ratio: auto;
  padding: 8px 6px;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  grid-column: span 2;
}

.page-picker__cell--section {
  background: transparent;
  font-family: 'Cinzel', serif;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: rgba(42, 36, 30, 0.52);
  grid-column: 1 / -1;
  aspect-ratio: auto;
  padding: 12px 0 4px;
  justify-content: flex-start;
  cursor: default;
}

.page-picker__cell--section:hover {
  background: transparent;
  color: rgba(42, 36, 30, 0.52);
}

.page-picker__random {
  all: unset;
  cursor: pointer;
  font: 600 0.72rem/1 'IBM Plex Sans', sans-serif;
  letter-spacing: 0.08em;
  color: rgba(28, 24, 20, 0.72);
  border: 1px solid rgba(35, 30, 24, 0.15);
  border-radius: 20px;
  padding: 10px 20px;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.page-picker__random:hover {
  color: rgba(90, 60, 30, 0.85);
  border-color: rgba(90, 60, 30, 0.5);
  background: rgba(90, 60, 30, 0.08);
}

.reader {
  position: relative;
  z-index: 2;
}

.page {
  min-height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  padding: 64px 28px 54px;
  margin-left: var(--rail-width);
}

.page-grid {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(240px, 400px) minmax(300px, 1fr);
  gap: clamp(26px, 5vw, 100px);
  align-items: center;
}

.art-col {
  margin: 0;
  width: min(400px, 100%);
  aspect-ratio: 1 / 1;
  background: #eceae1;
  box-shadow: 0 10px 24px rgba(22, 18, 14, 0.07);
  overflow: hidden;
}

.art-col canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.art-static {
  width: 100%;
  height: 100%;
  background: #eceae1;
}

.art-cover {
  background-image:
    radial-gradient(circle at 50% 50%, rgba(30, 30, 30, 0.7) 0 2px, transparent 2px),
    radial-gradient(circle at 50% 50%, transparent 0 26%, rgba(40, 40, 40, 0.3) 26% 27%, transparent 27%),
    radial-gradient(circle at 50% 50%, transparent 0 42%, rgba(40, 40, 40, 0.25) 42% 43%, transparent 43%);
}

.art-intro {
  background-image: repeating-linear-gradient(
    0deg,
    rgba(40, 40, 40, 0.08) 0 1px,
    transparent 1px 14px
  );
}

.art-framework {
  background-image:
    radial-gradient(circle at 28% 50%, rgba(40, 40, 40, 0.35) 0 2px, transparent 2px),
    radial-gradient(circle at 50% 50%, rgba(40, 40, 40, 0.35) 0 2px, transparent 2px),
    radial-gradient(circle at 72% 50%, rgba(40, 40, 40, 0.35) 0 2px, transparent 2px),
    linear-gradient(rgba(40, 40, 40, 0.12), rgba(40, 40, 40, 0.12));
  background-size: 100% 100%, 100% 100%, 100% 100%, 60% 1px;
  background-position: center, center, center, center;
  background-repeat: no-repeat;
}

.art-read {
  background-image:
    repeating-radial-gradient(circle at 50% 50%, rgba(40, 40, 40, 0.14) 0 1px, transparent 1px 16px),
    linear-gradient(0deg, transparent 0 48%, rgba(40, 40, 40, 0.07) 48% 52%, transparent 52% 100%);
}

.art-interlude {
  background-image:
    radial-gradient(circle at 50% 50%, transparent 0 20%, rgba(40, 40, 40, 0.13) 20% 21%, transparent 21%),
    radial-gradient(circle at 50% 50%, transparent 0 38%, rgba(40, 40, 40, 0.12) 38% 39%, transparent 39%),
    radial-gradient(circle at 50% 50%, transparent 0 56%, rgba(40, 40, 40, 0.11) 56% 57%, transparent 57%);
}

.art-postscript {
  background-image:
    repeating-linear-gradient(45deg, rgba(40, 40, 40, 0.08) 0 1px, transparent 1px 12px),
    linear-gradient(135deg, transparent 0 45%, rgba(40, 40, 40, 0.14) 45% 55%, transparent 55%);
}

.art-sources {
  background-image:
    repeating-linear-gradient(0deg, rgba(40, 40, 40, 0.1) 0 1px, transparent 1px 18px),
    repeating-linear-gradient(90deg, rgba(40, 40, 40, 0.06) 0 1px, transparent 1px 18px);
}

.art-credits {
  background-image:
    radial-gradient(circle at 50% 50%, rgba(40, 40, 40, 0.18) 0 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, transparent 0 24%, rgba(40, 40, 40, 0.18) 24% 25%, transparent 25%),
    linear-gradient(rgba(40, 40, 40, 0.1), rgba(40, 40, 40, 0.1));
  background-size: 100% 100%, 100% 100%, 1px 62%;
  background-position: center, center, center;
  background-repeat: no-repeat;
}

.text-col {
  font-size: clamp(1.2rem, 1.8vw, 1.7rem);
  line-height: 1.52;
  color: rgba(33, 30, 28, 0.93);
}

.text-wrap {
  display: grid;
  grid-template-columns: 24px minmax(260px, 34ch);
  gap: 20px;
}

.inline-num {
  margin-top: 3px;
  font-family: 'Cinzel', serif;
  font-size: 1.03rem;
  color: rgba(30, 26, 22, 0.92);
}

.discipline-label {
  display: block;
  font: 500 0.58rem/1 'IBM Plex Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 0.9rem;
  color: rgba(42, 36, 30, 0.38);
}

.discipline-label--judgement { color: rgba(90, 60, 30, 0.45); }
.discipline-label--desire { color: rgba(60, 60, 90, 0.45); }
.discipline-label--action { color: rgba(40, 80, 50, 0.45); }

.page--book-divider .page-grid {
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 0;
}

.page--book-divider .text-col {
  text-align: center;
  width: 100%;
}

.page--book-divider .book-num {
  display: block;
  font: 600 0.65rem/1 'IBM Plex Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(42, 36, 30, 0.4);
  margin-bottom: 1rem;
}

.page--book-divider .book-title {
  font: italic 400 clamp(1.6rem, 2.8vw, 2.6rem)/1.2 'EB Garamond', serif;
  color: rgba(36, 33, 29, 0.88);
}

.text-body p {
  margin: 0 0 10px;
  text-wrap: normal;
}

.text-body p:last-child {
  margin-bottom: 0;
}

.text-body .lead {
  font: italic 400 clamp(1.35rem, 2.2vw, 2.1rem) / 1.2 'EB Garamond', serif;
  color: rgba(36, 33, 29, 0.9);
  margin-bottom: 1.2rem;
}

.page--text-only .page-grid {
  grid-template-columns: 1fr;
  justify-items: stretch;
  gap: 0;
}

.page--text-only .text-col {
  width: min(100%, 760px);
  max-width: none;
  margin: 0 auto;
  font-size: clamp(1.14rem, 1.7vw, 1.58rem);
  line-height: 1.48;
  text-align: left;
}

.page--text-only .text-wrap {
  display: block;
  width: min(100%, 42ch);
  margin: 0 auto;
  gap: 0;
}

.page--text-only .inline-num {
  display: none;
}

.page--text-only .signature {
  margin-top: 0.8rem;
  font-style: italic;
}

.page--title .inline-num {
  opacity: 0;
}

.page--title .text-col {
  width: 100%;
  max-width: 100%;
  font-family: 'IBM Plex Sans', sans-serif;
  text-align: center;
}

.page--title .text-wrap {
  display: block;
  width: 100%;
}

.page--title .cover-body {
  display: grid;
  justify-items: center;
  gap: 0;
}

.page--title .text-body .kicker {
  margin-bottom: 1.4rem;
  font: 600 0.7rem/1.25 'IBM Plex Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(29, 27, 24, 0.72);
}

.page--title .text-body .title-stack {
  margin: 0 0 1rem;
  font-family: 'Cinzel', serif;
  font-weight: 400;
  font-size: clamp(2.8rem, 8.5vw, 6.8rem);
  line-height: 1.03;
  letter-spacing: 0.17em;
  text-indent: 0;
  color: rgba(20, 20, 20, 0.96);
}

.page--title .text-body .subtitle {
  margin: 0.2rem 0 1.8rem;
  font: italic 400 clamp(1.35rem, 2.2vw, 2.55rem) / 1.2 'EB Garamond', serif;
  color: rgba(36, 33, 29, 0.9);
}

.cover-mark {
  position: relative;
  width: clamp(170px, 20vw, 250px);
  aspect-ratio: 1 / 1;
  margin: 0.3rem 0 1.8rem;
  background: transparent;
}

.cover-mark .ring {
  position: absolute;
  border: 3px solid rgba(40, 40, 40, 0.74);
  border-radius: 50%;
}

.cover-mark .ring-a {
  width: 44%;
  height: 44%;
  top: 38%;
  left: 22%;
}

.cover-mark .ring-b {
  width: 58%;
  height: 58%;
  top: 10%;
  left: 22%;
}

.cover-mark .ring-c {
  width: 58%;
  height: 58%;
  top: 34%;
  left: 22%;
}

.page--title .cover-credit {
  margin-top: 0.2rem;
  font: 500 clamp(0.95rem, 1.3vw, 1.35rem) / 1.4 'EB Garamond', serif;
  color: rgba(41, 37, 33, 0.84);
}

.book-mark {
  position: fixed;
  left: calc(50% + var(--rail-width) / 2);
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 10;
  font: 500 0.78rem/1 'IBM Plex Sans', sans-serif;
  letter-spacing: 0.11em;
  color: rgba(44, 39, 35, 0.33);
  pointer-events: none;
}

@media (max-width: 980px) {
  .page {
    padding: 74px 18px 66px;
  }

  .page-grid {
    grid-template-columns: 1fr;
    gap: 24px;
    justify-items: center;
  }

  .text-wrap {
    grid-template-columns: 20px minmax(230px, 34ch);
    gap: 12px;
  }

  .text-col {
    font-size: clamp(0.98rem, 2.9vw, 1.25rem);
  }

  .page--text-only .text-col {
    font-size: clamp(1.04rem, 2.9vw, 1.34rem);
  }

  .page--title .text-body .title-stack {
    font-size: clamp(2.1rem, 10.8vw, 4.6rem);
    letter-spacing: 0.14em;
    text-indent: 0;
  }

  .page--title .text-body .subtitle {
    font-size: clamp(1.1rem, 5.8vw, 1.75rem);
  }

  .cover-mark {
    width: clamp(150px, 40vw, 220px);
  }
}

@media (max-width: 680px) {
  :root {
    --rail-width: 0px;
  }

  .rail {
    display: none;
  }

  .meta {
    right: 10px;
    top: 12px;
  }

  .meta__random {
    font-size: 0.62rem;
    padding: 4px 10px;
  }

  .meta__btn {
    font-size: 0.74rem;
  }

  .page {
    padding: 48px 24px 48px;
  }

  .page--title .text-body .title-stack {
    font-size: clamp(2rem, 12vw, 3.4rem);
    letter-spacing: 0.1em;
  }

  .page--title .text-body .subtitle {
    font-size: clamp(1rem, 5vw, 1.5rem);
  }

  .page--title .text-body .kicker {
    font-size: 0.6rem;
  }

  .page--title .cover-credit {
    font-size: clamp(0.85rem, 3.5vw, 1.1rem);
  }

  .cover-mark {
    width: clamp(120px, 35vw, 180px);
  }

  .text-col {
    font-size: clamp(1rem, 4.2vw, 1.2rem);
  }

  .page--text-only .text-col {
    font-size: clamp(1.05rem, 4.5vw, 1.3rem);
  }

  .text-wrap {
    grid-template-columns: 16px 1fr;
    gap: 10px;
  }

  .page-grid {
    gap: 20px;
  }

  .art-col {
    width: 100%;
    max-width: 320px;
  }

  .book-mark {
    font-size: 0.62rem;
    bottom: 10px;
    left: 50%;
  }

  .text-body .lead {
    font-size: clamp(1.15rem, 4.5vw, 1.5rem);
  }
}

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

  * {
    animation: none !important;
    transition-duration: 1ms !important;
  }
}
