:root {
  --ink: #2d2926;
  --muted: #716a65;
  --brand: #81756e;
  --brand-dark: #5d524c;
  --gold: #b58b4b;
  --cream: #f6f1e9;
  --paper: #fffdf9;
  --line: #ded5ca;
  --shadow: 0 18px 50px rgba(54, 44, 37, .12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: #fbfaf7;
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  line-height: 1.65;
}
a { color: inherit; }
button, input { font: inherit; }
img { max-width: 100%; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 99; background: #fff; padding: 10px 16px; }
.skip-link:focus { top: 12px; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid rgba(129, 117, 110, .18);
  background: rgba(251, 250, 247, .94);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { width: 68px; height: 52px; object-fit: contain; mix-blend-mode: multiply; }
.brand span { display: grid; line-height: 1.25; }
.brand b { font-family: "Noto Serif TC", "PMingLiU", serif; font-size: 1.03rem; }
.brand small { color: var(--muted); letter-spacing: .04em; }
nav { display: flex; align-items: center; gap: 6px; }
nav a { padding: 9px 14px; border-radius: 99px; text-decoration: none; color: var(--muted); }
nav a:hover, nav a.active { background: #eee7df; color: var(--brand-dark); }
.menu-button { display: none; border: 0; background: transparent; font-size: 1.5rem; }

.hero {
  min-height: 72vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(290px, .72fr);
  align-items: center;
  gap: clamp(30px, 6vw, 96px);
  padding: clamp(54px, 8vw, 112px) clamp(22px, 7vw, 110px);
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 10%, rgba(181, 139, 75, .18), transparent 34%),
    linear-gradient(145deg, #f5f0e9 0%, #fbfaf7 55%, #eee7df 100%);
}
.eyebrow { color: var(--gold); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.hero h1, .page-heading h1, .article-heading h1 {
  margin: 12px 0 18px;
  font-family: "Noto Serif TC", "PMingLiU", serif;
  font-weight: 600;
  line-height: 1.2;
}
.hero h1 { font-size: clamp(2.5rem, 6vw, 5.2rem); }
.hero h1 span { display: block; color: var(--brand); font-size: .56em; margin-top: 8px; }
.hero p { max-width: 650px; color: var(--muted); font-size: 1.08rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 20px; border: 1px solid var(--brand); border-radius: 99px; text-decoration: none; }
.button.primary { color: #fff; background: var(--brand-dark); }
.cover-card { position: relative; justify-self: center; width: min(390px, 85%); }
.cover-card::before { content: ""; position: absolute; inset: 5% -8% -5% 8%; border-radius: 28px; background: rgba(129, 117, 110, .18); transform: rotate(4deg); }
.cover-card img { position: relative; display: block; border-radius: 8px; box-shadow: 0 28px 70px rgba(54, 44, 37, .28); }

.section { padding: clamp(58px, 8vw, 104px) clamp(20px, 6vw, 92px); }
.section.alt { background: var(--cream); }
.section-title { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 28px; }
.section-title h2 { margin: 0; font-family: "Noto Serif TC", "PMingLiU", serif; font-size: clamp(1.8rem, 3vw, 2.7rem); }
.section-title p { margin: 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; max-width: 780px; margin-top: -38px; position: relative; z-index: 2; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.stat { padding: 24px; text-align: center; background: var(--paper); }
.stat b { display: block; color: var(--brand-dark); font-family: Georgia, serif; font-size: 2rem; }
.stat span { color: var(--muted); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 22px; }
.article-card { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); text-decoration: none; transition: transform .2s, box-shadow .2s; }
.article-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.article-card .thumb { aspect-ratio: 4 / 3; overflow: hidden; background: #e9e3dc; }
.article-card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform .3s; }
.article-card:hover .thumb img { transform: scale(1.025); }
.card-body { display: grid; gap: 7px; padding: 18px; }
.tag { width: max-content; padding: 3px 9px; border-radius: 99px; background: #eee7df; color: var(--brand-dark); font-size: .8rem; }
.card-body h3 { margin: 2px 0; font-family: "Noto Serif TC", "PMingLiU", serif; font-size: 1.2rem; line-height: 1.35; }
.card-body p, .card-body small { margin: 0; color: var(--muted); }

.page-heading { padding: clamp(46px, 7vw, 82px) clamp(20px, 6vw, 92px) 34px; background: linear-gradient(140deg, #eee7df, #fbfaf7); }
.page-heading h1 { font-size: clamp(2.2rem, 5vw, 4rem); }
.page-heading p { max-width: 700px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.search { flex: 1 1 300px; min-height: 48px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filter { border: 1px solid var(--line); border-radius: 99px; padding: 8px 13px; background: #fff; color: var(--muted); cursor: pointer; }
.filter.active { background: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }
.result-count { color: var(--muted); margin: 0 0 20px; }

.article-heading { max-width: 1100px; margin: 0 auto; padding: clamp(50px, 8vw, 92px) 22px 28px; }
.article-heading h1 { font-size: clamp(2.1rem, 4.4vw, 4rem); }
.article-meta { display: flex; flex-wrap: wrap; gap: 9px 18px; color: var(--muted); }
.article-pages { display: grid; gap: 34px; max-width: 1080px; margin: 0 auto; padding: 18px 22px 70px; }
.scan-page { position: relative; margin: 0; }
.scan-page img { display: block; width: 100%; border: 1px solid #e2ddd7; border-radius: 10px; box-shadow: var(--shadow); cursor: zoom-in; }
.scan-page figcaption { margin-top: 8px; color: var(--muted); text-align: center; }
.article-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 1080px; margin: 0 auto 80px; padding: 0 22px; }
.article-nav a { padding: 18px; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; background: #fff; }
.article-nav a:last-child { text-align: right; }

.book-reader { max-width: 1080px; margin: 0 auto; padding: 34px 22px 84px; }
.book-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin: 0 0 24px; }
.book-controls:last-child { margin: 24px 0 0; }
.book-controls label { display: flex; align-items: center; gap: 9px; color: var(--muted); white-space: nowrap; }
.page-select { min-height: 42px; padding: 7px 32px 7px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; }
.book-turn { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 18px; border: 1px solid var(--brand); border-radius: 99px; color: var(--brand-dark); text-decoration: none; background: #fff; }
.book-turn:last-child { justify-self: end; }
.book-turn:hover { color: #fff; background: var(--brand-dark); }
.book-turn.disabled { color: #aaa29c; border-color: var(--line); background: #f3f0ec; cursor: not-allowed; }
.book-current { margin: 0; text-align: center; }
.book-current img { display: block; width: min(100%, 900px); margin: 0 auto; border: 1px solid #e2ddd7; border-radius: 10px; box-shadow: var(--shadow); cursor: zoom-in; }
.book-current figcaption { margin-top: 10px; color: var(--muted); }

dialog { width: min(95vw, 1200px); max-height: 94vh; border: 0; padding: 42px 12px 12px; background: #1d1b1a; border-radius: 12px; }
dialog::backdrop { background: rgba(19, 16, 14, .83); backdrop-filter: blur(4px); }
dialog img { display: block; max-height: calc(94vh - 60px); margin: auto; }
.dialog-close { position: absolute; top: 7px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.14); font-size: 1.5rem; cursor: pointer; }

footer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; padding: 34px clamp(20px, 6vw, 92px); color: #eee8e3; background: #3d3733; }
footer img { width: 72px; padding: 6px; border-radius: 8px; background: #fff; }
footer div { display: grid; }
footer span, footer small { color: #cfc6c0; }
footer a { color: #fff; }
.empty { padding: 50px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

@media (max-width: 760px) {
  .site-header { min-height: 68px; }
  .brand span { display: none; }
  .menu-button { display: block; }
  nav { display: none; position: absolute; top: 66px; left: 12px; right: 12px; padding: 10px; flex-direction: column; align-items: stretch; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
  nav.open { display: flex; }
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero-copy { order: 2; }
  .cover-card { order: 1; width: min(250px, 70%); }
  .stats { grid-template-columns: 1fr; margin-top: -20px; }
  .section-title { align-items: start; flex-direction: column; }
  .article-nav { grid-template-columns: 1fr; }
  .article-nav a:last-child { text-align: left; }
  .book-controls { grid-template-columns: 1fr 1fr; }
  .book-controls label { grid-column: 1 / -1; grid-row: 1; justify-content: center; }
  .book-turn { grid-row: 2; }
  footer { grid-template-columns: auto 1fr; }
  footer > a { grid-column: 1 / -1; }
}

@media print {
  .site-header, footer, .article-nav, .dialog-close { display: none; }
  .scan-page img { box-shadow: none; border: 0; break-after: page; }
}
