@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Noto+Serif+JP:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --paper: #f2f4f2;
  --paper-deep: #e7ecec;
  --ink: #17232d;
  --navy: #071426;
  --blue: #234766;
  --slate: #6a7d89;
  --line: rgba(39, 68, 88, .18);
  --gold: #a98224;
  --red: #a74644;
  --serif: "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --mono: "DM Mono", "Consolas", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--serif); }
a { color: inherit; }
.skip-link { position: fixed; top: -4rem; left: 1rem; z-index: 100; padding: .7rem 1rem; background: white; }
.skip-link:focus { top: 1rem; }
.reading-progress { position: fixed; inset: 0 0 auto; z-index: 50; height: 3px; background: rgba(32, 68, 95, .15); }
.reading-progress span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--blue), var(--gold)); will-change: width; }
.reader-header { position: relative; min-height: 300px; display: flex; flex-direction: column; overflow: hidden; padding: 1.2rem clamp(1.2rem, 5vw, 5rem) 2rem; background: var(--navy); color: #dfeaf0; }
.reader-header::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 80% 30%, rgba(56, 103, 142, .46), transparent 30%), repeating-linear-gradient(135deg, transparent 0 26px, rgba(133, 174, 203, .025) 27px 28px); }
.reader-header::after { content: ""; position: absolute; top: -15%; right: 20%; width: 1px; height: 115%; transform: rotate(12deg); background: linear-gradient(transparent, #b9d6e8, transparent); box-shadow: 0 0 40px rgba(112, 169, 208, .45); }
.reader-nav { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.reader-nav a { text-decoration: none; }
.back-link { display: flex; align-items: center; gap: .8rem; font-size: .76rem; letter-spacing: .12em; }
.back-link span { color: #7fa0b7; }
.site-name { color: #91aabc; font: 300 .62rem var(--mono); letter-spacing: .1em; text-align: right; }
.episode-hero { position: relative; z-index: 2; width: min(780px, 100%); margin: auto auto 0; }
.episode-label { display: flex; align-items: center; gap: 1rem; margin: 0 0 1rem; color: #90aabd; font: 300 .62rem var(--mono); letter-spacing: .2em; }
.episode-label::before { content: ""; width: 2.5rem; height: 1px; background: var(--gold); }
.episode-hero h1 { margin: 0; color: #f4f7f8; font-size: clamp(2.1rem, 4.5vw, 3.6rem); font-weight: 500; line-height: 1.4; letter-spacing: .08em; }
.episode-hero > p:last-child { margin: 1rem 0 0; color: #9fb2c0; }
.episode-hero strong { color: #d9bd73; font-weight: 500; }

.reader-shell { position: relative; }
.reader-status { width: min(720px, calc(100% - 2.5rem)); min-height: 50vh; margin: 0 auto; padding: 7rem 0; color: var(--slate); text-align: center; letter-spacing: .1em; }
.reader-status.is-error { color: var(--red); }
.reader-status code { display: block; margin-top: 1rem; font: .75rem var(--mono); }
.reader-content { width: min(660px, calc(100% - 2.5rem)); margin: 0 auto; padding: clamp(5rem, 11vw, 9rem) 0; font-size: 1.1rem; line-height: 2; letter-spacing: .02em; }
.reader-content > :first-child { margin-top: 0; }
.reader-content p { margin: 0 0 1.45em; }
.reader-content h1, .reader-content h2, .reader-content h3 { color: #102434; font-weight: 600; line-height: 1.55; }
.reader-content h1 { position: relative; margin: 6.5rem 0 3.5rem; padding: 2rem 0 1.6rem; border-block: 1px solid var(--line); font-size: clamp(1.8rem, 5vw, 2.8rem); letter-spacing: .1em; }
.reader-content h1::before { content: "CHAPTER"; display: block; margin-bottom: .7rem; color: var(--gold); font: 400 .55rem var(--mono); letter-spacing: .22em; }
.reader-content h2 { margin: 4rem 0 2rem; font-size: 1.6rem; }
.reader-content h3 { margin: 3rem 0 1.5rem; font-size: 1.3rem; }
.reader-content hr { width: 52px; height: 1px; margin: 4.5rem auto; border: 0; background: #8da0aa; }
.reader-content strong { font-weight: 700; }
.world-log { position: relative; margin: 3.5rem 0; padding: 1.7rem 1.8rem 1.7rem 2.4rem; border: 1px solid rgba(46, 91, 122, .22); border-left: 2px solid #436f8d; background: linear-gradient(115deg, rgba(211, 223, 228, .52), rgba(225, 232, 233, .22)); color: #33566d; font: 400 .78rem/2 var(--mono); letter-spacing: .04em; box-shadow: 0 18px 55px rgba(28, 52, 70, .06); }
.world-log::before { content: "OBSERVATION"; position: absolute; top: -1.05rem; left: 1.2rem; padding: 0 .65rem; background: var(--paper); color: #78909e; font: 300 .5rem var(--mono); letter-spacing: .18em; }
.world-log p { margin: 0; }
.world-log p + p { margin-top: .55rem; }
.world-log strong { color: var(--red); font-weight: 500; }
.reader-content.is-loaded + .reader-status { display: none; }

.chapter-nav { border-top: 1px solid var(--line); background: var(--paper-deep); }
.chapter-nav-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; width: min(980px, calc(100% - 2.5rem)); margin: 0 auto; }
.chapter-link { display: flex; flex-direction: column; justify-content: center; min-height: 150px; padding: 1.5rem; text-decoration: none; transition: background .2s ease; }
.chapter-link:hover, .chapter-link:focus-visible { background: rgba(255,255,255,.6); }
.chapter-link.next { text-align: right; }
.chapter-link small { color: var(--slate); font: 300 .55rem var(--mono); letter-spacing: .16em; }
.chapter-link strong { margin-top: .5rem; color: #17344a; font-weight: 500; }
.chapter-link.is-disabled { color: #9ba8ad; pointer-events: none; }
.chapter-link.is-disabled strong { color: #9ba8ad; }
.to-top { align-self: center; padding: .65rem 1.2rem; border-inline: 1px solid var(--line); color: #526b7a; font-size: .74rem; text-align: center; }
.reader-footer { padding: 2.6rem 1.2rem; background: var(--navy); color: #6e899d; text-align: center; font: 300 .56rem var(--mono); letter-spacing: .12em; }

@media (max-width: 640px) {
  .reader-header { min-height: 300px; padding-inline: 1.2rem; }
  .site-name { max-width: 150px; font-size: .53rem; }
  .episode-hero h1 { font-size: clamp(1.7rem, 7vw, 2.1rem); letter-spacing: .04em; }
  .reader-content { width: min(100% - 2.2rem, 660px); padding-block: 4.5rem; font-size: 1.05rem; line-height: 2; }
  .reader-content h1 { margin-top: 5rem; font-size: 1.7rem; }
  .world-log { margin-inline: -.35rem; padding: 1.5rem 1.2rem 1.5rem 1.4rem; font-size: .7rem; overflow-wrap: anywhere; }
  .chapter-nav-inner { grid-template-columns: 1fr 1fr; width: 100%; }
  .chapter-link { min-height: 130px; padding: 1.2rem; }
  .to-top { grid-column: 1 / -1; grid-row: 2; border: 0; border-top: 1px solid var(--line); padding: 1rem; }
}

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