:root {
  --fg: #1a1a1a;
  --fg-soft: #555;
  --fg-mute: #999;
  --bg: #ffffff;
  --rule: #e8e8e8;
  --max: 680px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Noto Serif TC", Georgia, "Times New Roman", serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  font-size: 18px;
  line-height: 1.9;
}

a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

a:hover {
  border-bottom-color: var(--fg);
}

/* ---------- Layout ---------- */

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 96px 32px 120px;
}

@media (max-width: 640px) {
  .wrap {
    padding: 64px 24px 96px;
  }
  body {
    font-size: 17px;
    line-height: 1.85;
  }
}

/* ---------- Home ---------- */

.home-header {
  text-align: center;
  margin-bottom: 96px;
}

.home-title {
  font-size: 42px;
  font-weight: 500;
  letter-spacing: 0.08em;
  margin: 0 0 16px;
  line-height: 1.3;
}

.home-subtitle {
  font-size: 13px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 0;
}

.home-divider {
  width: 32px;
  height: 1px;
  background: var(--fg);
  margin: 40px auto 0;
  border: 0;
}

.toc {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
}

.toc li:first-child {
  border-top: 1px solid var(--rule);
}

.toc a {
  display: flex;
  align-items: baseline;
  gap: 24px;
  color: var(--fg);
}

.toc a:hover {
  border-bottom-color: transparent;
}

.toc a:hover .toc-title {
  border-bottom: 1px solid var(--fg);
}

.toc-num {
  flex: 0 0 auto;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-mute);
  min-width: 88px;
}

.toc-title {
  flex: 1;
  font-size: 17px;
}

/* ---------- Chapter ---------- */

.chap-header {
  text-align: center;
  margin-bottom: 72px;
}

.chap-num {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 0 0 12px;
}

.chap-title {
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.06em;
  margin: 0;
  line-height: 1.4;
}

.chap-divider {
  width: 32px;
  height: 1px;
  background: var(--fg);
  margin: 32px auto 0;
  border: 0;
}

.chap-body p {
  margin: 0 0 1.4em;
  text-align: justify;
  text-justify: inter-ideograph;
}

.chap-body hr {
  width: 48px;
  height: 1px;
  background: var(--fg-mute);
  border: 0;
  margin: 56px auto;
}

.chap-body blockquote {
  margin: 1.8em 0;
  padding: 0 0 0 24px;
  border-left: 2px solid var(--rule);
  color: var(--fg-soft);
  font-style: italic;
}

.chap-body blockquote p {
  margin: 0 0 0.8em;
}

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

.chap-body strong {
  font-weight: 600;
}

.chap-body em {
  font-style: italic;
}

/* ---------- Chapter nav ---------- */

.chap-nav {
  margin-top: 96px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--fg-soft);
}

.chap-nav a {
  color: var(--fg);
}

.chap-nav .prev,
.chap-nav .next {
  flex: 1 1 0;
}

.chap-nav .prev {
  text-align: left;
}

.chap-nav .home {
  flex: 0 0 auto;
  text-align: center;
}

.chap-nav .next {
  text-align: right;
}

.chap-nav .disabled {
  color: var(--fg-mute);
  opacity: 0.35;
}

/* ---------- Top nav (back-to-library + breadcrumb) ---------- */

.top-nav {
  margin-bottom: 64px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--fg-soft);
  text-align: center;
}

.top-nav a {
  color: var(--fg-soft);
}

.top-nav a:hover {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.top-nav-sep {
  margin: 0 10px;
  color: var(--fg-mute);
}

@media (max-width: 640px) {
  .top-nav {
    margin-bottom: 48px;
  }
}

/* ---------- Library (root) ---------- */

.library-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 96px 32px 120px;
}

@media (max-width: 640px) {
  .library-wrap {
    padding: 64px 24px 96px;
  }
}

.library-header {
  text-align: center;
  margin-bottom: 96px;
}

@media (max-width: 640px) {
  .library-header {
    margin-bottom: 64px;
  }
}

.library-title {
  font-size: 42px;
  font-weight: 500;
  letter-spacing: 0.08em;
  margin: 0 0 16px;
  line-height: 1.3;
}

.library-subtitle {
  font-size: 13px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 0;
}

.library-divider {
  width: 32px;
  height: 1px;
  background: var(--fg);
  margin: 40px auto 0;
  border: 0;
}

.book-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 56px 40px;
}

@media (max-width: 640px) {
  .book-list {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 48px 24px;
  }
}

.book-card {
  margin: 0;
}

.book-card a {
  display: block;
  color: var(--fg);
  border-bottom: none;
}

.book-card a:hover {
  border-bottom-color: transparent;
}

.book-cover {
  aspect-ratio: 2 / 3;
  background: #f6f6f6;
  margin-bottom: 24px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rule);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.book-card a:hover .book-cover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-cover-placeholder {
  padding: 32px 20px;
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f0 100%);
  position: relative;
}

.book-cover-placeholder::before,
.book-cover-placeholder::after {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  height: 1px;
  background: var(--fg);
  opacity: 0.2;
}

.book-cover-placeholder::before {
  top: 20%;
}

.book-cover-placeholder::after {
  bottom: 20%;
}

.book-cover-placeholder .placeholder-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-align: center;
  color: var(--fg);
  line-height: 1.5;
  writing-mode: horizontal-tb;
}

@media (max-width: 640px) {
  .book-cover-placeholder .placeholder-title {
    font-size: 18px;
  }
}

.book-meta {
  text-align: center;
}

.book-title {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.06em;
  margin: 0 0 8px;
  line-height: 1.4;
  transition: border-color 0.15s ease;
  display: inline-block;
  border-bottom: 1px solid transparent;
}

.book-card a:hover .book-title {
  border-bottom-color: var(--fg);
}

.book-subtitle {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin: 0 0 14px;
  line-height: 1.5;
}

.book-chapters {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--fg-soft);
  margin: 0;
}
