:root {
  --cream: #FBF6E9;
  --paper: #FFF9EE;
  --ink: #3D2A14;
  --accent: #8B6914;
  --soft: #6B4420;
  --green: #7A9B4A;
  --green-dark: #5A7A32;
  --leaf: #E8F0C8;
  --gold: #F5E6C0;
  --card: #FFF8E7;
  --shadow: rgba(80, 55, 20, 0.14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Noto Sans CJK SC", "Noto Sans SC", "PingFang SC",
    "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: linear-gradient(180deg, var(--leaf) 0%, var(--gold) 42%, var(--cream) 100%);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100vh;
}

a { color: var(--soft); }

/* —— Library home —— */
.site-header {
  text-align: center;
  padding: 28px 16px 12px;
}

.site-header .logo {
  display: inline-block;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--green-dark);
  background: rgba(255, 248, 231, 0.85);
  border: 1px solid rgba(122, 155, 74, 0.35);
  border-radius: 999px;
  padding: 6px 16px;
  margin-bottom: 14px;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  color: var(--soft);
}

.site-header p {
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 1.05rem;
}

.library {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 64px;
}

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

.book-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(139, 105, 20, 0.18);
  box-shadow: 0 8px 24px var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.book-card:hover,
.book-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(80, 55, 20, 0.2);
  outline: none;
}

.book-card .thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #F0E8D0;
}

.book-card .info {
  padding: 14px 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.book-card .title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--soft);
  font-weight: 700;
}

.book-card .subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--accent);
}

.book-card .meta {
  margin-top: auto;
  padding-top: 10px;
  font-size: 0.82rem;
  color: #8a7350;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--leaf);
  color: var(--green-dark);
  font-size: 0.75rem;
}

.site-footer {
  text-align: center;
  padding: 8px 16px 36px;
  color: #8a7350;
  font-size: 0.85rem;
}

/* —— Reader —— */
.reader-body {
  background: #1a140c;
  color: #f5ecd8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.reader-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(20, 14, 8, 0.92);
  border-bottom: 1px solid rgba(245, 230, 192, 0.12);
  position: sticky;
  top: 0;
  z-index: 10;
}

.reader-top a.back {
  color: #f5e6c0;
  text-decoration: none;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 248, 231, 0.08);
  border: 1px solid rgba(245, 230, 192, 0.2);
  white-space: nowrap;
}

.reader-top a.back:hover { background: rgba(255, 248, 231, 0.16); }

.reader-top .book-title {
  margin: 0;
  font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  text-align: center;
  flex: 1;
  color: #fbf6e9;
}

.reader-top .page-indicator {
  font-size: 0.9rem;
  color: #d4c4a0;
  min-width: 4.5em;
  text-align: right;
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  position: relative;
  min-height: 0;
}

.stage img {
  max-width: 100%;
  max-height: calc(100vh - 140px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
  background: #2a2014;
  user-select: none;
  -webkit-user-drag: none;
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 12px 16px 20px;
  background: rgba(20, 14, 8, 0.92);
  border-top: 1px solid rgba(245, 230, 192, 0.12);
}

.controls button {
  appearance: none;
  border: 1px solid rgba(245, 230, 192, 0.28);
  background: linear-gradient(180deg, #7A9B4A, #5A7A32);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  min-width: 110px;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.controls button:hover:not(:disabled) { filter: brightness(1.08); }
.controls button:active:not(:disabled) { transform: scale(0.97); }
.controls button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: #4a4030;
}

.hint {
  text-align: center;
  font-size: 0.78rem;
  color: #9a8a6a;
  padding: 0 12px 14px;
  background: rgba(20, 14, 8, 0.92);
}

@media (max-width: 560px) {
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .controls button { padding: 12px 18px; min-width: 90px; font-size: 1rem; }
  .stage img { max-height: calc(100vh - 160px); }
  .reader-top .book-title { display: none; }
}
