:root {
  --paper: #f4ead6;
  --leaf: #fbf6ea;
  --ink: #1a1712;
  --ink-soft: #3a342c;
  --muted: #6a6258;
  --line: #d7cbb6;
  --gold: #b08a45;
  --gold-dim: #cbb48a;
  --cinnabar: #9c2b1d;
  --cinnabar-ink: #f6ecd8;
  --white: #fffdf7;
  --spine: #e6d7bb;
  --shadow: 0 10px 28px rgba(40, 32, 18, 0.07);
  --max: 920px;
  --serif: "Songti TC", "Songti SC", "Noto Serif TC", "Noto Serif SC", "Iowan Old Style", serif;
  --sans: "PingFang HK", "Hiragino Sans GB", "Noto Sans TC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: #e7dcc7; }
body {
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 8% -8%, rgba(176, 138, 69, 0.12), transparent 55%),
    radial-gradient(700px 380px at 100% 8%, rgba(156, 43, 29, 0.05), transparent 45%),
    radial-gradient(ellipse 80% 40% at 50% 100%, rgba(26, 23, 18, 0.06), transparent 60%),
    var(--paper);
}
img { max-width: 100%; }
a { color: var(--ink); }
.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 8px;
  top: 8px;
  z-index: 40;
  background: var(--white);
  padding: 8px 12px;
}

/* 冊頁外框：雙線 + 回紋角 */
.stage {
  display: flex;
  min-height: 100vh;
  width: min(1240px, calc(100% - 24px));
  margin: 12px auto;
  background: var(--leaf);
  border: 1px solid var(--ink);
  outline: 1px solid var(--gold-dim);
  outline-offset: 5px;
  box-shadow:
    inset 0 0 0 6px var(--leaf),
    inset 0 0 0 7px var(--gold-dim),
    var(--shadow);
  position: relative;
}
.stage::before,
.stage::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
  border: 2px solid var(--gold);
  z-index: 2;
}
.stage::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.stage::after { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }

/* 立軸 */
.axis {
  flex: none;
  width: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 28px 10px 24px;
  background:
    linear-gradient(180deg, #f3e6cc 0%, #efe2c4 40%, #e8d6b0 100%);
  border-right: 1px solid var(--ink);
  position: relative;
}
.axis::after {
  content: "";
  position: absolute;
  top: 0;
  right: 6px;
  width: 1px;
  height: 100%;
  background: var(--gold-dim);
}
.axis-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}
.axis-name {
  writing-mode: vertical-rl;
  font-family: var(--serif);
  font-size: 1.45rem;
  letter-spacing: 0.42em;
  font-weight: 600;
}
.axis-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.axis-nav a {
  writing-mode: vertical-rl;
  text-decoration: none;
  letter-spacing: 0.28em;
  font-size: 0.92rem;
  padding: 12px 8px;
  min-height: 84px;
  color: var(--ink-soft);
  border-left: 2px solid transparent;
}
.axis-nav a[aria-current="page"],
.axis-nav a:hover {
  color: var(--ink);
  border-left-color: var(--cinnabar);
}

.stamp {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--cinnabar);
  color: var(--cinnabar-ink);
  font-family: var(--serif);
  font-size: 1.05rem;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 2px var(--cinnabar-ink);
  outline: 1px solid var(--cinnabar);
  outline-offset: 2px;
  transform: rotate(-8deg);
}
.stamp-sm { width: 28px; height: 28px; font-size: 0.9rem; }
.stamp-float {
  position: absolute;
  margin-left: -8px;
  margin-top: 8px;
  width: 40px;
  height: 40px;
}

.langs a {
  text-decoration: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 0.85rem;
  border: 1px solid var(--cinnabar);
  color: var(--cinnabar);
  background: transparent;
}
.langs a.on {
  background: var(--cinnabar);
  color: var(--cinnabar-ink);
}
.langs-axis {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaf {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, transparent 0, transparent 70%, rgba(26, 23, 18, 0.03)),
    var(--leaf);
  position: relative;
}
.leaf::before,
.leaf::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
  border: 2px solid var(--gold);
  z-index: 2;
  bottom: 10px;
}
.leaf::before { left: 10px; border-right: 0; border-top: 0; }
.leaf::after { right: 10px; border-left: 0; border-top: 0; }

/* 横批／窄屏牌匾 */
.plaque {
  border-bottom: 1px solid var(--ink);
  background:
    repeating-linear-gradient(90deg, transparent 0 10px, rgba(176, 138, 69, 0.18) 10px 12px) bottom / 100% 7px no-repeat,
    #f7efdc;
}
.plaque-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 28px 14px;
  flex-wrap: wrap;
}
.plaque-brand { display: none; text-decoration: none; align-items: center; gap: 10px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong {
  font-family: var(--serif);
  font-size: 1.1rem;
  letter-spacing: 0.18em;
}
.brand-text em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}
.plaque-motto {
  margin: 0 auto;
  font-family: var(--serif);
  letter-spacing: 0.55em;
  color: var(--gold);
  font-size: 0.82rem;
}
.nav, .langs-plaque { display: none; }
.nav-burger { display: none; cursor: pointer; padding: 10px; margin-left: auto; }
.nav-burger span,
.nav-burger span:before,
.nav-burger span:after {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--ink);
  position: relative;
}
.nav-burger span:before,
.nav-burger span:after { content: ""; position: absolute; left: 0; }
.nav-burger span:before { top: -6px; }
.nav-burger span:after { top: 6px; }

main { flex: 1; }
.section, .prose, .hall, .colophon .inner {
  width: min(var(--max), calc(100% - 48px));
  margin: 0 auto;
}

/* 中堂 */
.hall {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 8px 18px;
  align-items: stretch;
  padding: 48px 0 28px;
  position: relative;
}
.hall::after {
  content: "";
  grid-column: 1 / -1;
  height: 72px;
  margin-top: 8px;
  background:
    radial-gradient(ellipse 42% 90% at 22% 100%, rgba(26, 23, 18, 0.16), transparent 70%),
    radial-gradient(ellipse 36% 80% at 48% 110%, rgba(26, 23, 18, 0.12), transparent 70%),
    radial-gradient(ellipse 48% 100% at 78% 100%, rgba(26, 23, 18, 0.18), transparent 72%);
  opacity: 0.55;
  pointer-events: none;
}
.couplet {
  writing-mode: vertical-rl;
  font-family: var(--serif);
  letter-spacing: 0.42em;
  font-size: 1rem;
  color: var(--ink-soft);
  margin: 12px 0 0;
  padding: 8px 0;
  border-left: 1px solid var(--gold-dim);
  border-right: 1px solid var(--gold-dim);
  align-self: center;
  min-height: 11em;
}
.hall-centre { text-align: center; padding: 8px 8px 0; }
.kicker {
  letter-spacing: 0.42em;
  color: var(--gold);
  font-size: 0.78rem;
  margin: 0 0 14px;
  font-family: var(--serif);
}
h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.35;
}
.hall h1 {
  font-size: clamp(2.4rem, 8vw, 4.2rem);
  margin: 0 0 14px;
  letter-spacing: 0.28em;
  position: relative;
  display: inline-block;
}
.lede { color: var(--muted); margin: 0 0 16px; letter-spacing: 0.12em; }
.hero-bio { max-width: 36rem; margin: 0 auto 26px; color: var(--muted); }
.hero-cta, .hero-cta .btn { margin: 6px; }

.btn {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--ink);
  padding: 10px 22px;
  min-height: 44px;
  line-height: 24px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  letter-spacing: 0.16em;
  box-shadow: 2px 2px 0 var(--gold-dim);
}
.btn.gold { background: var(--ink); color: var(--leaf); border-color: var(--ink); }
.btn.ghost { background: var(--leaf); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.section { padding: 8px 0 56px; }
.section.narrow { max-width: 560px; }
.sec-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 22px;
}
.sec-head h1, .sec-head h2 { margin: 0; }
.sec-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: var(--cinnabar);
  color: var(--cinnabar-ink);
  font-family: var(--serif);
  transform: rotate(-7deg);
  font-size: 0.95rem;
  flex: none;
}

.books {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 22px;
}
.book {
  display: grid;
  grid-template-columns: 16px 1fr;
  background: var(--white);
  border: 1px solid var(--ink-soft);
  text-decoration: none;
  min-height: 176px;
  box-shadow: var(--shadow);
}
.spine {
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0 18px,
      var(--ink) 18px 20px,
      transparent 20px 32px
    ),
    linear-gradient(90deg, #cbb892, var(--spine));
  border-right: 1px solid var(--line);
}
.book-body {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.book h3, .card h3 { margin: 0; font-size: 1.12rem; }
.tag {
  align-self: flex-start;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 2px 8px;
  font-family: var(--serif);
}
.price { font-size: 1.25rem; font-family: var(--serif); letter-spacing: 0.04em; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.card {
  background: var(--white);
  border: 1px solid var(--line);
  padding: 20px;
  text-decoration: none;
  box-shadow: var(--shadow);
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prose { padding: 40px 0 64px; }
.prose h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); }
.master-head { display: flex; gap: 22px; align-items: center; margin-bottom: 28px; flex-wrap: wrap; }
.avatar {
  width: 120px;
  height: 148px;
  border: 1px solid var(--ink);
  outline: 1px solid var(--gold-dim);
  outline-offset: 4px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.8rem;
  background:
    linear-gradient(#fffdf7, #f3ead4);
}
.gallery-ph {
  min-height: 148px;
  border: 1px dashed var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--white);
}
.videos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin: 8px 0 24px;
}
.video { margin: 0; }
.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink);
  border: 1px solid var(--ink);
  outline: 1px solid var(--gold-dim);
  outline-offset: 3px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.video-frame iframe {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.video figcaption {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding-top: 8px;
}
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 0.9rem; }
.form input, .form select, .form textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--ink-soft);
  background: var(--white);
  width: 100%;
  min-height: 44px;
  border-radius: 0;
}
.flash {
  background: var(--white);
  border: 1px solid var(--gold);
  padding: 10px 14px;
}
.flash.bad { border-color: var(--cinnabar); color: var(--cinnabar); }
.muted { color: var(--muted); font-size: 0.9rem; }
.locked { color: var(--muted); }

.colophon {
  border-top: 1px solid var(--ink);
  padding: 28px 0 36px;
  margin-top: auto;
  background: #f3ead8;
}
.colophon .inner { text-align: center; }
.foot-brand {
  font-family: var(--serif);
  letter-spacing: 0.28em;
  margin: 10px 0 8px;
}
.foot-links { display: flex; flex-wrap: wrap; gap: 12px 18px; justify-content: center; }
.foot-links a { color: var(--muted); }

body.admin {
  background: var(--paper);
}
.admin-head {
  border-bottom: 1px solid var(--ink);
  background: #f7efdc;
}
.admin-head .inner,
.admin-main {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}
.admin-head .inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  align-items: center;
}
.admin-head nav { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.admin-main { padding: 24px 0 64px; }
.inline { display: inline; }
.linkish { background: none; border: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--white); }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; font-size: 0.9rem; }
.stats { padding: 0; list-style: none; display: flex; gap: 24px; }

@media (max-width: 860px) {
  .stage {
    width: min(100% - 12px, 100%);
    margin: 6px auto;
    flex-direction: column;
    outline-offset: 3px;
  }
  .axis { display: none; }
  .plaque-brand { display: flex; }
  .plaque-motto { display: none; }
  .nav-burger { display: block; }
  .nav, .langs-plaque {
    display: none;
    width: 100%;
  }
  .nav-toggle:checked ~ .nav,
  .nav-toggle:checked ~ .langs-plaque {
    display: flex;
  }
  .nav {
    flex-direction: column;
    gap: 4px;
    padding: 4px 0 12px;
  }
  .nav a {
    text-decoration: none;
    padding: 10px 4px;
    min-height: 44px;
    display: flex;
    align-items: center;
    letter-spacing: 0.16em;
  }
  .langs-plaque { gap: 8px; padding-bottom: 12px; }
  .hall {
    grid-template-columns: 26px minmax(0, 1fr) 26px;
    gap: 4px 8px;
    padding: 28px 0 16px;
  }
  .couplet {
    font-size: 0.78rem;
    letter-spacing: 0.32em;
    min-height: 9em;
    padding: 0;
  }
  .section, .prose, .hall, .colophon .inner {
    width: min(var(--max), calc(100% - 28px));
  }
  .plaque-inner { padding: 6px 14px 12px; min-height: 52px; }
  .hall h1 { font-size: clamp(1.8rem, 11vw, 2.6rem); letter-spacing: 0.16em; }
  .stamp-float { width: 30px; height: 30px; font-size: 0.9rem; }
}

@media (max-width: 420px) {
  .books { grid-template-columns: 1fr; }
  .hero-cta .btn { display: block; margin: 8px 0; }
}
