:root {
  color-scheme: light;
  --paper: #f5f1ea;
  --paper-soft: #faf8f4;
  --ink: #292826;
  --muted: #76716a;
  --line: rgba(48, 45, 41, 0.16);
  --accent: #7b8882;
  --accent-soft: #dce2de;
  --serif: "Noto Serif TC", "Source Han Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; }

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--paper);
}

.protected-page,
.protected-page * {
  -webkit-user-select: none;
  user-select: none;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}

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

a:focus-visible {
  outline: 2px solid #52645d;
  outline-offset: 4px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.site-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 2rem, 70rem);
  height: 4.5rem;
  margin-inline: auto;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.wordmark i { width: 1.25rem; height: 1px; background: var(--line); }

.site-header nav { display: flex; gap: 1rem; }
.site-header nav a { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.05em; }

.home-page { background: #e9e6e0; }

.home-shell {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  padding: max(1.25rem, env(safe-area-inset-top)) 1rem max(1.25rem, env(safe-area-inset-bottom));
}

.home-cover {
  display: grid;
  align-items: center;
  width: min(100%, 61rem);
  margin: auto;
}

.cover-frame {
  position: relative;
  width: min(84vw, 25rem);
  margin-inline: auto;
  background: #d8d4cd;
  box-shadow: 0 1.5rem 4rem rgba(45, 42, 38, 0.14);
}

.cover-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.home-intro {
  padding: 2.1rem 0.5rem 1rem;
  text-align: center;
}

.home-intro h1 {
  margin: 0.5rem 0 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 10vw, 3.5rem);
  font-weight: 500;
  letter-spacing: 0.12em;
}

.edition { margin: 0.65rem 0 0; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; }
.edition span { margin-left: 0.25rem; }

.home-actions {
  display: grid;
  gap: 0.7rem;
  width: min(100%, 22rem);
  margin: 1.8rem auto 0;
}

.primary-button,
.quiet-button,
.continue-button {
  display: grid;
  min-height: 3.25rem;
  place-items: center;
  border: 1px solid var(--ink);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
}

.primary-button { background: var(--ink); color: var(--paper-soft); }
.quiet-button { border-color: var(--line); }
.continue-button { border: 0; color: #53645e; font-size: 0.78rem; }
.continue-button[hidden] { display: none; }

.home-credit {
  margin-top: 2rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.68rem;
  line-height: 1.8;
  letter-spacing: 0.03em;
}

.home-credit p { margin: 0; }

.page-shell { width: min(100% - 2rem, 45rem); margin-inline: auto; }

.page-heading { padding: 4.5rem 0 3rem; }
.page-heading h1 { margin: 0.55rem 0 1rem; font-family: var(--serif); font-size: clamp(2rem, 9vw, 3.4rem); font-weight: 500; letter-spacing: 0.08em; }
.page-heading > p:last-child { max-width: 34rem; margin: 0; color: var(--muted); font-family: var(--serif); font-size: 0.95rem; line-height: 1.9; }

.catalog-section { padding: 0 0 4.5rem; }
.catalog-section + .catalog-section { padding-top: 3.5rem; border-top: 1px solid var(--line); }

.section-heading {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.85rem;
  margin-bottom: 1.3rem;
}

.section-heading span { color: var(--accent); font-family: var(--serif); font-size: 0.72rem; }
.section-heading h2 { margin: 0; font-family: var(--serif); font-size: 1.45rem; font-weight: 500; letter-spacing: 0.1em; }
.section-heading small { color: var(--muted); font-size: 0.7rem; }

.chapter-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.chapter-list li { border-bottom: 1px solid var(--line); }
.chapter-list a {
  display: grid;
  grid-template-columns: 4.2rem 1fr auto;
  align-items: center;
  min-height: 4.5rem;
  gap: 0.65rem;
  padding: 0.75rem 0.2rem;
}

.chapter-code { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.06em; }
.chapter-name { min-width: 0; font-family: var(--serif); font-size: 1rem; line-height: 1.5; }
.chapter-arrow { color: var(--accent); }

.site-footer {
  display: flex;
  justify-content: space-between;
  width: min(100% - 2rem, 70rem);
  margin-inline: auto;
  padding: 1.6rem 0 max(1.6rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
}

.about-shell { padding-bottom: 5rem; }
.about-card { padding: 2rem 1.4rem; border: 1px solid var(--line); background: rgba(255,255,255,0.28); }
.about-kicker { margin: 0; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; }
.about-card h2 { margin: 0.5rem 0 2.5rem; font-family: var(--serif); font-size: 2rem; font-weight: 500; letter-spacing: 0.1em; }
.about-card dl { margin: 0; }
.about-card dl div { display: grid; gap: 0.4rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.about-card dt { color: var(--muted); font-size: 0.72rem; }
.about-card dd { margin: 0; font-family: var(--serif); font-size: 1rem; }
.text-link { display: inline-block; margin-top: 2rem; color: #53645e; font-size: 0.82rem; }

.reader-page {
  position: relative;
  isolation: isolate;
  background: var(--paper-soft);
}

.reader-page::before {
  content: "";
  position: fixed;
  z-index: -2;
  inset: 0;
  background-image: var(--scene-image);
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: saturate(0.72) contrast(0.96) brightness(1.04);
  opacity: 0.72;
  pointer-events: none;
}

.reader-page::after {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(250, 248, 244, 0.24) 0%,
    rgba(250, 248, 244, 0.34) 38%,
    rgba(250, 248, 244, 0.48) 100%
  );
  pointer-events: none;
}

.reading-progress { position: fixed; z-index: 100; top: 0; left: 0; width: 100%; height: 2px; background: rgba(123,136,130,0.12); }
.reading-progress span { display: block; width: 100%; height: 100%; transform: scaleX(0); transform-origin: left; background: #71817a; }

.reader-shell { width: min(100% - 2rem, 42rem); margin-inline: auto; }
.chapter-heading { padding: 4.5rem 0 2.5rem; text-align: center; }
.back-link { display: inline-block; margin-bottom: 3.5rem; color: var(--muted); font-size: 0.74rem; letter-spacing: 0.04em; }
.chapter-section { margin: 0; color: var(--accent); font-size: 0.7rem; letter-spacing: 0.18em; }
.chapter-number { margin: 1rem 0 0; color: var(--muted); font-size: 0.76rem; letter-spacing: 0.08em; }
.chapter-heading h1 { margin: 0.6rem 0 0; font-family: var(--serif); font-size: clamp(1.7rem, 8vw, 2.8rem); font-weight: 500; line-height: 1.45; letter-spacing: 0.06em; }

.chapter-illustration { width: min(100%, 34rem); margin: 0 auto 4.5rem; }
.chapter-illustration img { width: 100%; box-shadow: 0 1rem 3rem rgba(39,37,34,0.09); }
.chapter-illustration figcaption { margin-top: 0.65rem; color: var(--muted); text-align: right; font-size: 0.6rem; letter-spacing: 0.12em; text-transform: uppercase; }

.prose {
  position: relative;
  margin-inline: -0.45rem;
  padding: clamp(1.1rem, 4vw, 2.35rem);
  font-family: var(--serif);
  font-size: clamp(1.075rem, 4.6vw, 1.19rem);
  line-height: 2.05;
  letter-spacing: 0.025em;
  overflow-wrap: anywhere;
  background: rgba(250, 248, 244, 0.93);
  box-shadow: 0 1.25rem 4rem rgba(58, 53, 47, 0.14);
}

.prose p { margin: 0 0 1.45em; }
.prose strong { font-weight: 700; }
.prose em { font-style: italic; }
.prose hr { width: 2.5rem; margin: 3.8rem auto; border: 0; border-top: 1px solid rgba(48,45,41,0.35); }
.prose blockquote { margin: 1.8rem 0; padding: 0.1rem 0 0.1rem 1.15rem; border-left: 1px solid var(--accent); color: #4f5552; }
.prose blockquote p { margin-bottom: 0.9em; }
.prose blockquote p:last-child { margin-bottom: 0; }

.chapter-footer { padding: 5rem 0 max(4rem, env(safe-area-inset-bottom)); }
.chapter-footer > p { margin: 0 0 2rem; color: var(--muted); text-align: center; font-family: var(--serif); font-size: 0.75rem; letter-spacing: 0.04em; }
.chapter-footer > p span { margin-inline: 0.25rem; }
.chapter-navigation { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.chapter-nav-link { display: flex; min-width: 0; min-height: 5.5rem; flex-direction: column; justify-content: center; padding: 0.9rem; border: 1px solid var(--line); }
.chapter-nav-link.next { align-items: flex-end; text-align: right; }
.chapter-nav-link span { margin-bottom: 0.4rem; color: var(--muted); font-size: 0.65rem; }
.chapter-nav-link strong { max-width: 100%; font-family: var(--serif); font-size: 0.78rem; font-weight: 500; line-height: 1.55; }
.back-to-catalog { display: grid; min-height: 3.4rem; margin-top: 0.75rem; place-items: center; color: var(--muted); font-size: 0.74rem; }

@media (max-width: 47.999rem) {
  .prose {
    background: linear-gradient(
      to bottom,
      rgba(250, 248, 244, 0.84) 0%,
      rgba(250, 248, 244, 0.78) 5rem,
      rgba(250, 248, 244, 0.78) calc(100% - 9rem),
      rgba(250, 248, 244, 0.66) 100%
    );
  }
}

@media (hover: hover) {
  .chapter-list a,
  .primary-button,
  .quiet-button,
  .chapter-nav-link,
  .site-header a { transition: opacity 180ms ease, background-color 180ms ease; }
  .chapter-list a:hover { background: rgba(255,255,255,0.34); }
  .primary-button:hover,
  .quiet-button:hover,
  .chapter-nav-link:hover,
  .site-header a:hover { opacity: 0.66; }
}

@media (min-width: 48rem) {
  .home-cover { grid-template-columns: minmax(18rem, 25rem) 1fr; gap: 5rem; }
  .home-intro { padding: 0; text-align: left; }
  .home-actions { margin-left: 0; }
  .home-credit { text-align: right; }
  .about-card { padding: 3rem; }
  .about-card dl div { grid-template-columns: 1fr 1fr; align-items: baseline; }
}

@media (max-width: 22rem) {
  .site-header { width: min(100% - 1.25rem, 70rem); }
  .site-header nav { gap: 0.65rem; }
  .wordmark span:last-child { display: none; }
  .reader-shell,
  .page-shell { width: min(100% - 1.25rem, 45rem); }
  .chapter-navigation { grid-template-columns: 1fr; }
  .chapter-nav-spacer { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
