:root {
  --bg: #faf8f5; --fg: #2c2416; --accent: #7f5f10;
  --card-bg: #fff; --card-border: #e8e0d0;
  --muted: #6b604d; --tag-bg: #f0e8d8;
  --nav-bg: #f5f0e8; --hover-bg: #f0ead8;
  --cinnabar: #a83232; --jade: #2e6b5e; --jade-text: #2e6b5e; --paper: #f5efe0;
  --text-line: 2; --on-accent: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1812; --fg: #e8dcc8; --accent: #d4a830;
    --card-bg: #252218; --card-border: #3d3628;
    --muted: #b3a78f; --tag-bg: #3a3020;
    --nav-bg: #221f18; --hover-bg: #2e2a20;
    --on-accent: #1a1812; --cinnabar: #c84040; --jade: #2f7a69; --jade-text: #6dbfac; --paper: #201d16;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1812; --fg: #e8dcc8; --accent: #d4a830;
  --card-bg: #252218; --card-border: #3d3628;
  --muted: #b3a78f; --tag-bg: #3a3020;
  --nav-bg: #221f18; --hover-bg: #2e2a20;
  --on-accent: #1a1812; --cinnabar: #c84040; --jade: #2f7a69; --jade-text: #6dbfac; --paper: #201d16;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: "Noto Serif SC", "Source Han Serif CN", Georgia, serif;
  background: var(--bg); color: var(--fg);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 960px; margin: 0 auto; padding: 16px; width: 100%; }
main.container { flex: 1; }

.top-nav {
  background: var(--nav-bg); border-bottom: none;
  padding: 10px 16px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.top-nav::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(to right, transparent, var(--accent), transparent);
}
.top-nav .brand { font-size: 1.15em; font-weight: 700; color: var(--accent); white-space: nowrap; font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif; }
.brand-seal {
  display: inline-block; font-family: "Ma Shan Zheng", cursive;
  color: var(--cinnabar); border: 2px solid var(--cinnabar);
  padding: 1px 5px; margin-right: 4px; font-size: 1.1em;
  line-height: 1.2; transform: rotate(-2deg); letter-spacing: 0.1em;
}
.top-nav .nav-links { display: flex; gap: 12px; flex: 1; flex-wrap: wrap; }
.top-nav .nav-links a { color: var(--muted); font-size: 0.9em; }
.top-nav .nav-links a:hover { color: var(--accent); text-decoration: none; }
#lang-toggle, #theme-toggle {
  background: none; border: 1px solid var(--card-border); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; font-size: 1em; color: var(--muted);
}
#lang-toggle { font-size: 0.85em; font-family: "Noto Serif SC", serif; }

.breadcrumb { padding: 8px 16px; font-size: 0.85em; color: var(--muted); max-width: 960px; margin: 0 auto; width: 100%; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 4px; }

.hero {
  text-align: center; padding: 56px 0 36px; position: relative;
  background:
    radial-gradient(ellipse at 15% 80%, rgba(139,105,20,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 20%, rgba(139,105,20,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(139,105,20,0.02) 0%, transparent 60%);
}
.hero h1 {
  font-size: 3em; color: var(--accent); margin-bottom: 16px;
  font-family: "Ma Shan Zheng", cursive; letter-spacing: 0.15em; font-weight: 400;
}
.hero p { color: var(--muted); line-height: 1.8; font-size: 1.05em; }
.hero::after {
  content: '☯'; display: block; margin-top: 20px;
  font-size: 1.4em; color: var(--accent); opacity: 0.3;
}

.stats-bar { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 20px 0 32px; }
.stats-bar span {
  background: var(--tag-bg); padding: 6px 16px; border-radius: 20px;
  font-size: 0.85em; color: var(--muted); border: 1px solid var(--card-border);
}

.section-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin: 24px 0; }
.section-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 20px; transition: box-shadow 0.2s; border-left: 3px solid var(--cinnabar);
}
.section-card:hover { box-shadow: 0 4px 20px rgba(139,105,20,0.15); text-decoration: none; }
.section-card h2 { font-size: 1.2em; color: var(--accent); margin-bottom: 6px; font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif; }
.section-card .meta { font-size: 0.85em; color: var(--muted); margin-bottom: 10px; }
.section-card .sample { font-size: 0.88em; color: var(--fg); opacity: 0.8; line-height: 1.6; }

.sort-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.sort-bar button {
  padding: 4px 14px; border: 1px solid var(--card-border); border-radius: 16px;
  background: var(--card-bg); color: var(--muted); cursor: pointer; font-size: 0.85em; font-family: inherit;
}
.sort-bar button.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.text-list { margin: 20px 0; }
.text-item {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 12px 0; border-bottom: 1px solid var(--card-border); gap: 12px;
}
.text-item:last-child { border-bottom: none; }
.text-item .title { flex: 1; font-size: 1em; }
.text-item .info { font-size: 0.85em; color: var(--muted); white-space: nowrap; }

.text-header { margin-bottom: 24px; position: relative; }
.text-header h1 {
  font-size: 1.8em; color: var(--accent); margin-bottom: 8px;
  font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif;
}
.text-header::after {
  content: ''; display: block; width: 60px; height: 2px; margin-top: 12px;
  background: linear-gradient(to right, var(--cinnabar), transparent);
}
.text-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.9em; color: var(--muted); margin-bottom: 16px; }
.text-meta span { background: var(--tag-bg); padding: 4px 12px; border-radius: 16px; }

.toc { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 16px 20px; margin-bottom: 24px; }
.toc h2 { font-size: 1em; color: var(--accent); margin-bottom: 10px; }
.toc-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.toc-grid a {
  display: inline-block; padding: 4px 12px; background: var(--tag-bg);
  border-radius: 14px; font-size: 0.85em; color: var(--muted);
}
.toc-grid a:hover { background: var(--accent); color: var(--on-accent); text-decoration: none; }

.reading-controls {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 8px 10px;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px;
}
.reading-controls button {
  background: var(--tag-bg); border: 1px solid var(--card-border); border-radius: 6px;
  padding: 4px 10px; cursor: pointer; font-family: inherit; font-size: 0.85em;
  color: var(--muted); transition: background 0.15s, color 0.15s;
}
@media (max-width: 480px) {
  .reading-controls { gap: 4px; padding: 6px 8px; }
  .reading-controls button { padding: 4px 8px; font-size: 0.8em; }
  .reading-controls .sep { margin: 0 2px; }
}
.reading-controls button:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.reading-controls button.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.reading-controls .sep { width: 1px; height: 20px; background: var(--card-border); margin: 0 4px; }

/* 阅读进度条 */
.reading-bar {
  position: fixed; right: 20px; top: 60px; bottom: 20px; width: 4px;
  background: var(--card-border); border-radius: 2px; z-index: 90;
  cursor: pointer; opacity: 0.5; transition: opacity 0.2s, width 0.2s;
}
.reading-bar:hover { opacity: 1; width: 6px; }
.reading-bar::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: -10px; right: -10px;
}
.reading-bar-fill {
  width: 100%; background: var(--accent); border-radius: 2px;
  transition: height 0.1s linear; pointer-events: none;
}
.reading-bar-auto {
  position: absolute; right: -10px; width: 24px; height: 24px;
  border-radius: 50%; border: 1px solid var(--accent);
  background: var(--bg); color: var(--accent);
  font-size: 10px; line-height: 22px; text-align: center;
  cursor: pointer; z-index: 91; transition: background 0.2s, color 0.2s;
}
.reading-bar-auto.active {
  background: var(--accent); color: var(--bg);
}

/* 卷轴模式 */
.text-body.vertical-scroll { position: relative; }
.text-body.vertical-scroll .juan-text {
  writing-mode: vertical-rl;
  white-space: normal;
  height: calc(100vh - 160px);
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 24px 16px;
  line-height: 2.4;
  letter-spacing: 0.1em;
  font-size: 1.05em;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: inset -20px 0 16px -16px rgba(0,0,0,0.06), inset 20px 0 16px -16px rgba(0,0,0,0.06);
}
.text-body.vertical-scroll .juan-text::-webkit-scrollbar { display: none; }
.text-body.vertical-scroll .juan-text { scrollbar-width: none; }
.text-body.vertical-scroll .juan-section h2 { writing-mode: horizontal-tb; }
.text-body.vertical-scroll .juan-section { position: relative; }
.scroll-bar {
  position: absolute; bottom: 2px; left: 8px; right: 8px; height: 4px;
  background: rgba(128,128,128,0.2); border-radius: 2px; cursor: pointer; z-index: 10;
}
.scroll-bar-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width 0.1s linear; pointer-events: none;
}
.scroll-bar-auto {
  position: absolute; top: 8px; right: 0; width: 24px; height: 24px;
  border-radius: 50%; border: 1px solid var(--accent);
  background: var(--bg); color: var(--accent);
  font-size: 10px; line-height: 22px; text-align: center;
  cursor: pointer; z-index: 10; transition: background 0.2s, color 0.2s;
}
.scroll-bar-auto.active { background: var(--accent); color: var(--bg); }

/* 转经模式 */
.text-body.vertical-drum { position: relative; }
.drum-container {
  position: relative; width: 100%; height: calc(100vh - 200px);
  perspective: 1200px; perspective-origin: 50% 50%;
  overflow: hidden; cursor: grab;
}
.drum-cover-top {
  position: absolute; top: 0; left: 0; right: 0; height: 16px;
  background: linear-gradient(to bottom, var(--bg) 40%, transparent);
  z-index: 50; pointer-events: none;
}
.drum-cover-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; height: 16px;
  background: linear-gradient(to top, var(--bg) 40%, transparent);
  z-index: 50; pointer-events: none;
}
.drum-inner {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  transform-style: preserve-3d;
}
.drum-col {
  position: absolute; writing-mode: vertical-rl; white-space: normal;
  font-size: 1.15em; line-height: 1; letter-spacing: 0.12em;
  color: var(--fg); padding: 6px 0; width: 3em; max-width: 3em; line-height: 1.4; overflow: hidden;
}
.drum-container::before, .drum-container::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 80px;
  z-index: 10; pointer-events: none;
}
.drum-container::before { left: 0; background: linear-gradient(to right, var(--bg), transparent); }
.drum-container::after { right: 0; background: linear-gradient(to left, var(--bg), transparent); }
.drum-progress {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  color: var(--muted); font-size: 0.75em; z-index: 20;
}
.drum-bar {
  position: absolute; bottom: 30px; left: 60px; right: 60px;
  height: 3px; background: var(--card-border); border-radius: 2px;
  z-index: 20; cursor: pointer;
}
.drum-bar::before {
  content: ''; position: absolute; top: -8px; bottom: -8px; left: 0; right: 0;
}
.drum-bar-fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width 0.15s linear; pointer-events: none;
}
.drum-reset {
  position: absolute; top: 8px; right: 12px; z-index: 60;
  background: rgba(139,105,20,0.12); border: 1px solid rgba(139,105,20,0.25);
  color: var(--accent); font-size: 1.3em; width: 36px; height: 36px;
  border-radius: 50%; cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: background 0.2s;
}
.drum-reset:hover { background: rgba(139,105,20,0.25); }
.drum-auto {
  position: absolute; top: 8px; right: 56px; z-index: 60;
  background: rgba(139,105,20,0.12); border: 1px solid rgba(139,105,20,0.25);
  color: var(--accent); font-size: 0.85em; width: 36px; height: 36px;
  border-radius: 50%; cursor: pointer; display: flex; align-items: center;
  justify-content: center; transition: background 0.2s;
}
.drum-auto:hover { background: rgba(139,105,20,0.25); }
.drum-auto.active { background: rgba(139,105,20,0.3); border-color: var(--accent); }

/* 翻页模式 */
.text-body.vertical-flip { position: relative; }
.flip-container {
  position: relative; width: 100%; height: calc(100vh - 200px); overflow: hidden;
}
.flip-page {
  position: absolute; top: 0; bottom: 60px; width: 100%;
  display: flex; justify-content: center; padding: 24px;
  transition: transform 0.9s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 0.9s cubic-bezier(0.25, 0.1, 0.25, 1);
  will-change: transform, opacity;
}
.flip-page.current { transform: translateX(0) scale(1); opacity: 1; }
.flip-page.prev { transform: translateX(-100%) scale(0.95); opacity: 0; }
.flip-page.next { transform: translateX(100%) scale(0.95); opacity: 0; }
.flip-page-inner {
  writing-mode: vertical-rl; white-space: normal; height: 100%;
  font-size: 1.2em; line-height: 2.6; letter-spacing: 0.12em;
  overflow: hidden; max-width: 100%;
}
.flip-page-num {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  color: var(--muted); font-size: 0.8em;
}
.flip-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(139,105,20,0.12); border: 1px solid rgba(139,105,20,0.25);
  color: var(--accent); font-size: 1.5em; padding: 16px 12px;
  cursor: pointer; border-radius: 8px; z-index: 10; transition: background 0.2s;
}
.flip-nav:hover { background: rgba(139,105,20,0.25); }
.flip-nav.left { left: 8px; }
.flip-nav.right { right: 8px; }
.flip-nav:disabled { opacity: 0.2; cursor: default; }
.flip-progress {
  position: absolute; bottom: 8px; left: 24px; right: 24px;
  display: flex; gap: 3px; z-index: 10;
}
.flip-dot {
  flex: 1; height: 3px; background: var(--card-border); border-radius: 2px;
  cursor: pointer; transition: background 0.3s;
}
.flip-dot.active { background: var(--accent); }
.flip-auto {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px;
  border-radius: 50%; border: 1px solid var(--accent);
  background: var(--bg); color: var(--accent);
  font-size: 13px; line-height: 34px; text-align: center;
  cursor: pointer; z-index: 60; transition: background 0.2s, color 0.2s;
}
.flip-auto.active { background: var(--accent); color: var(--bg); }

.juan-section { margin-bottom: 32px; }
.juan-section h2 { font-size: 1.2em; color: var(--accent); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--card-border); }
.juan-text { line-height: 2; font-size: 0.95em; white-space: pre-wrap; transition: font-size 0.15s; }

.interp-seg { display: block; }
.interp-popup {
  position: fixed; z-index: 60; display: none;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 8px 6px; white-space: nowrap;
}
@media (max-width: 480px) {
  .interp-popup { padding: 10px 12px; }
  .interp-popup button { padding: 6px 16px; font-size: 0.9em; }
}
.interp-popup::after {
  content: ''; position: absolute; left: 50%; bottom: -6px;
  transform: translateX(-50%); border: 6px solid transparent;
  border-top-color: var(--card-border); border-bottom: none;
}
.interp-popup button {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 0.82em; color: var(--jade-text); padding: 4px 12px;
  border-radius: 4px; transition: background 0.15s;
}
.interp-popup button:hover { background: var(--jade-light); }
.interp-block {
  max-height: 0; overflow: hidden; padding: 0 16px; margin: 0 0 4px;
  background: var(--paper); border-left: 3px solid var(--jade);
  border-radius: 0 6px 6px 0; font-size: 0.88em; line-height: 1.9;
  color: var(--fg); opacity: 0.92; white-space: normal;
  transition: max-height 0.6s ease, padding 0.5s ease, margin 0.5s ease;
}
.interp-block.open, .show-interp .interp-block {
  max-height: 2000px; padding: 12px 16px; margin: 8px 0 20px;
}
.show-interp .interp-block.collapsed {
  max-height: 0; padding: 0 16px; margin: 0;
}
.text-body.vertical-scroll .interp-block,
.text-body.vertical-scroll .interp-seg::after,
.text-body.vertical-drum .interp-block,
.text-body.vertical-drum .interp-seg::after,
.text-body.vertical-flip .interp-block,
.text-body.vertical-flip .interp-seg::after { display: none !important; }
.text-body.vertical-scroll .interp-seg,
.text-body.vertical-drum .interp-seg,
.text-body.vertical-flip .interp-seg { cursor: default; }
.interp-block .interp-label {
  display: block; font-size: 0.75em; color: var(--jade-text); font-weight: 700;
  margin-bottom: 4px; letter-spacing: 0.05em;
}
.interp-close {
  display: block; margin: 8px auto 0; padding: 4px 16px;
  background: none; border: 1px solid var(--jade); border-radius: 4px;
  color: var(--jade-text); font-size: 0.75em; cursor: pointer;
  font-family: inherit; opacity: 0.7; transition: opacity 0.2s;
}
.interp-close:hover { opacity: 1; }
.interp-toggle {
  padding: 6px 14px; border: 1px solid var(--jade); border-radius: 6px;
  background: transparent; color: var(--jade-text); cursor: pointer;
  font-family: inherit; font-size: 0.85em; transition: all 0.2s;
}
.interp-toggle:hover, .interp-toggle.active {
  background: var(--jade); color: #fff; border-color: var(--jade);
}

.interp-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--jade); color: #fff; padding: 10px 24px;
  border-radius: 20px; font-size: 0.88em; z-index: 90;
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.2); cursor: pointer;
}
.interp-toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto;
}

/* 拼音注音 */
.py-ruby { position: relative; }
.py-ruby rt { font-size: 0.5em; color: var(--jade-text); letter-spacing: -0.02em; }
.py-popup {
  position: fixed; z-index: 80; display: none;
  background: var(--card-bg); border: 1px solid var(--jade);
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 8px 14px; text-align: center; transform: translateX(-50%) translateY(-100%);
  min-width: 80px;
}
.py-popup::after {
  content: ''; position: absolute; left: 50%; bottom: -6px;
  transform: translateX(-50%); border: 6px solid transparent;
  border-top-color: var(--jade); border-bottom: none;
}
.py-popup-char { font-size: 1.6em; color: var(--accent); }
.py-popup-pinyin { font-size: 0.95em; color: var(--jade-text); font-weight: 700; margin: 2px 0; }
.py-popup-def { font-size: 0.8em; color: var(--muted); line-height: 1.4; }
.pinyin-toggle {
  padding: 6px 14px; border: 1px solid var(--jade); border-radius: 6px;
  background: transparent; color: var(--jade-text); cursor: pointer;
  font-family: inherit; font-size: 0.85em; transition: all 0.2s;
}
.pinyin-toggle:hover, .pinyin-toggle.active {
  background: var(--jade); color: #fff; border-color: var(--jade);
}

.juan-nav { display: flex; justify-content: space-between; padding: 20px 0; border-top: 1px solid var(--card-border); margin-top: 24px; }
.juan-nav a { color: var(--accent); }

.fulu-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 600px) { .fulu-grid { grid-template-columns: 1fr 1fr; } }
.fulu-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 20px; display: block; transition: box-shadow 0.2s;
}
.fulu-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); text-decoration: none; }
.fulu-card h3 { font-size: 1.05em; color: var(--accent); margin-bottom: 4px; }
.fulu-card .meta { font-size: 0.8em; color: var(--muted); margin-bottom: 8px; }
.fulu-card .preview { font-size: 0.88em; line-height: 1.8; color: var(--fg); opacity: 0.85; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.cat-tag { font-size: 0.75em; padding: 2px 10px; border-radius: 12px; color: #fff; display: inline-block; }
.cat-tag[data-cat="符箓"] { background: #b8860b; }
.cat-tag[data-cat="神咒"] { background: #8b0000; }
.cat-tag[data-cat="寶籙"] { background: #2e8b57; }
.cat-tag[data-cat="心印"] { background: #4169e1; }

.fulu-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 32px; }
@media (min-width: 600px) { .fulu-gallery { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .fulu-gallery { grid-template-columns: repeat(4, 1fr); } }
.fulu-classic-group { margin-bottom: 32px; }
.fulu-classic-title {
  font-size: 1.1em; color: var(--accent); margin: 0 0 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--card-border);
  display: flex; align-items: baseline; gap: 8px;
}
.fulu-classic-title .count { font-size: 0.75em; color: var(--muted); font-weight: normal; }
.fulu-filter-label { font-size: 0.8em; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.fulu-gallery-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.fulu-gallery-filters button {
  padding: 5px 14px; border: 1px solid var(--card-border); border-radius: 20px;
  background: var(--card-bg); color: var(--muted); cursor: pointer; font-size: 0.85em; font-family: inherit;
}
.fulu-gallery-filters button.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.fulu-category-filters { margin-bottom: 12px; }
.fulu-category-filters button.active { background: #6a5acd; border-color: #6a5acd; }
.fulu-tag-filters { margin-bottom: 24px; }
.fulu-tag-filters button.active { background: #b8860b; border-color: #b8860b; }
.fulu-img-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 8px; cursor: pointer; transition: box-shadow 0.2s, transform 0.2s; overflow: hidden;
}
.fulu-img-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-2px); }
.fulu-img-card img { width: 100%; height: auto; display: block; border-radius: 6px; background: #f5f0e8; }
[data-theme="dark"] .fulu-img-card img { background: #2a2520; }
.fulu-img-card .fulu-img-title { font-size: 0.78em; color: var(--fg); text-align: center; padding: 6px 4px 2px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fulu-img-card { position: relative; }
.source-badge { position: absolute; top: 12px; right: 12px; font-size: 0.65em; padding: 2px 6px; border-radius: 8px; color: #fff; }
.source-lingyan { background: #8b4513; }
.tag-badge {
  position: absolute; top: 12px; left: 12px; font-size: 0.6em;
  padding: 1px 6px; border-radius: 6px; color: #fff; opacity: 0.9;
  background: #b8860b; pointer-events: none;
}
.cat-badge {
  position: absolute; bottom: 32px; left: 12px; font-size: 0.6em;
  padding: 1px 6px; border-radius: 6px; color: #fff; opacity: 0.9;
  pointer-events: none;
}
.cat-镇宅安家 { background: #8b5e3c; }
.cat-驱邪除魔 { background: #c0392b; }
.cat-治病祛疾 { background: #27ae60; }
.cat-修真炼丹 { background: #8e44ad; }
.cat-召神通灵 { background: #2980b9; }
.cat-祈福求财 { background: #b8860b; }
.cat-天文星象 { background: #34495e; }
.cat-婚姻爱情 { background: #e84393; }
.cat-军事兵法 { background: #922b21; }
.cat-法印符篆 { background: #7f8c8d; }
.cat-其他 { background: var(--muted); }
.fulu-lightbox {
  display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.88);
  align-items: flex-start; justify-content: center; padding: 24px; cursor: pointer;
  overflow-y: auto;
}
.fulu-lightbox.active { display: flex; }
.fulu-lightbox .lb-content { display: flex; flex-direction: column; align-items: center; cursor: default; max-width: 95vw; }
.fulu-lightbox img { max-width: 90vw; max-height: 75vh; object-fit: contain; border-radius: 8px; background: #fff; margin-top: 40px; }
.fulu-lightbox .lb-title { color: #fff; font-size: 1.05em; text-align: center; margin-top: 12px; }
.fulu-lightbox .lb-close { position: fixed; top: 16px; right: 24px; color: #fff; font-size: 2em; cursor: pointer; line-height: 1; z-index: 10000; }
.fulu-lightbox .lb-items {
  background: rgba(255,255,255,0.08); border-radius: 10px; padding: 12px 16px;
  margin-top: 12px; max-width: 700px; width: 90vw;
}
.lb-items-title { color: var(--accent); font-size: 0.9em; margin-bottom: 8px; font-weight: bold; }
.lb-item { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.08); flex-wrap: wrap; }
.lb-item:last-child { border-bottom: none; }
.lb-item-type { font-size: 0.7em; padding: 1px 6px; border-radius: 8px; background: #b8860b; color: #fff; white-space: nowrap; }
.lb-item-type.tag-天文图 { background: #4169e1; }
.lb-item-type.tag-法印 { background: #8b0000; }
.lb-item-type.tag-卦象 { background: #6a5acd; }
.lb-item-type.tag-神像 { background: #2e8b57; }
.lb-item-type.tag-器物 { background: #8b4513; }
.lb-item-name { color: #fff; font-size: 0.9em; }
.lb-item-desc { color: rgba(255,255,255,0.6); font-size: 0.8em; width: 100%; margin-left: 0; }
.fulu-tab-bar { display: flex; gap: 0; margin-bottom: 24px; border-bottom: 2px solid var(--card-border); }
.fulu-tab { padding: 10px 24px; cursor: pointer; font-size: 1em; border: none; background: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.fulu-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.cat-tag[data-cat="陰符"] { background: #6a5acd; }

.fulu-search-box { margin-bottom: 16px; }
.fulu-search-box input {
  width: 100%; padding: 10px 16px; border: 1px solid var(--card-border); border-radius: 8px;
  background: var(--card-bg); color: var(--fg); font-size: 1em; font-family: inherit;
  box-sizing: border-box;
}
.fulu-search-box input:focus { outline: none; border-color: var(--accent); }
.fulu-img-card { display: block; text-decoration: none; color: inherit; }

.fulu-detail-page { max-width: 720px; margin: 0 auto; }
.fulu-detail-image { text-align: center; margin-bottom: 24px; }
.fulu-detail-image img { max-width: 100%; max-height: 70vh; object-fit: contain; border-radius: 8px; background: #f5f0e8; }
[data-theme="dark"] .fulu-detail-image img { background: #2a2520; }
.fulu-detail-info { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 20px; margin-bottom: 24px; }
.fulu-detail-info h1 { font-size: 1.4em; margin-bottom: 16px; color: var(--accent); }
.fulu-detail-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--card-border); font-size: 0.95em; line-height: 1.6; }
.fulu-detail-row:last-child { border-bottom: none; }
.fulu-detail-row .label { flex-shrink: 0; width: 80px; color: var(--muted); font-weight: 600; }
.fulu-detail-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.fulu-nav-link { font-size: 0.9em; color: var(--accent); text-decoration: none; }
.fulu-nav-link:hover { text-decoration: underline; }
.fulu-nav-link.prev { text-align: left; }
.fulu-nav-link.next { text-align: right; }
.fulu-nav-link.center { text-align: center; }

/* Charm explanation block */
.fulu-explanation {
  margin: 24px 0; padding: 20px 24px;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px;
  border-left: 3px solid var(--cinnabar, #a83232);
}
.fulu-explanation h2 {
  font-size: 1.1em; color: var(--accent); margin: 0 0 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--card-border);
}
.expl-source { font-size: 0.85em; color: var(--muted); margin-bottom: 10px; }
.expl-incantation {
  margin: 12px 0; padding: 12px 16px;
  background: var(--tag-bg); border-radius: 8px;
  font-size: 0.95em; line-height: 2; color: var(--fg);
  border: none; font-style: normal;
}
.expl-text { font-size: 0.92em; line-height: 1.9; color: var(--fg); margin: 12px 0; }
.expl-credit { font-size: 0.78em; color: var(--muted); text-align: right; margin-top: 8px; }

/* Incantation cards */
.incantation-list { display: flex; flex-direction: column; gap: 16px; }
.incantation-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 20px; border-left: 3px solid var(--cinnabar, #a83232);
}
.incantation-header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.incantation-header h3 { font-size: 1.1em; color: var(--accent); margin: 0; }
.expl-classic { font-size: 0.8em; color: var(--muted); }
.expl-cat { font-size: 0.72em; padding: 2px 8px; border-radius: 10px; background: var(--tag-bg); color: var(--muted); }
.expl-tag-badge { font-size: 0.72em; padding: 2px 8px; border-radius: 10px; background: #b8860b; color: #fff; margin-left: 4px; }
.incantation-text {
  margin: 10px 0; padding: 12px 16px;
  background: var(--tag-bg); border-radius: 8px;
  font-size: 0.95em; line-height: 2; color: var(--fg);
  border: none; font-style: normal;
}
.incantation-expl { font-size: 0.9em; line-height: 1.8; color: var(--fg); opacity: 0.9; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filters button {
  padding: 6px 16px; border: 1px solid var(--card-border); border-radius: 20px;
  background: var(--card-bg); color: var(--muted); cursor: pointer; font-size: 0.9em; font-family: inherit;
}
.filters button.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.search-box { display: flex; gap: 8px; margin: 24px 0; }
.search-box input {
  flex: 1; padding: 12px 16px; font-size: 1em;
  border: 1px solid var(--card-border); border-radius: 8px;
  background: var(--card-bg); color: var(--fg); font-family: inherit;
}
.search-box input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.search-box button {
  padding: 12px 24px; border: none; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-size: 1em;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.result-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 16px; margin-bottom: 12px;
}
.result-card h3 { font-size: 1em; color: var(--accent); margin-bottom: 4px; }
.result-card .meta { font-size: 0.8em; color: var(--muted); margin-bottom: 8px; }
.result-card .text { font-size: 0.92em; line-height: 1.7; }
.result-card mark { background: #fff3d0; color: var(--fg); padding: 0 2px; border-radius: 2px; }
.loading { text-align: center; padding: 40px; color: var(--muted); }

.about-content { line-height: 2; }
.about-content h2 { color: var(--accent); margin: 24px 0 12px; font-size: 1.3em; }
.about-content p { margin-bottom: 16px; }
.about-content ul { margin: 0 0 16px 24px; }
.about-content li { margin-bottom: 6px; }

.chat-area {
  display: flex; flex-direction: column; gap: 12px;
  max-height: 60vh; overflow-y: auto; padding: 16px 0;
  min-height: 200px;
}
.msg {
  max-width: 85%; padding: 12px 16px; border-radius: 12px;
  line-height: 1.8; font-size: 0.95em; word-break: break-word;
}
.msg.user {
  align-self: flex-end; background: var(--accent); color: var(--on-accent);
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start; background: var(--card-bg);
  border: 1px solid var(--card-border); border-bottom-left-radius: 4px;
}
.msg .ref {
  color: var(--accent); text-decoration: underline;
  text-decoration-style: dotted;
}
.msg .ref:hover { text-decoration-style: solid; }
.msg .error { color: #c0392b; }
.msg .typing { color: var(--muted); display: inline-flex; align-items: center; gap: 2px; }
.msg .typing::after {
  content: ''; display: inline-flex; gap: 4px; margin-left: 4px;
}
.typing-dots { display: inline-flex; gap: 4px; margin-left: 6px; }
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: dot-bounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
  0%,80%,100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}
.msg .cursor { color: var(--accent); animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

.ask-bar {
  display: flex; gap: 8px; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--card-border);
}
.ask-bar textarea {
  flex: 1; padding: 10px 14px; font-size: 1em;
  border: 1px solid var(--card-border); border-radius: 8px;
  background: var(--card-bg); color: var(--fg); font-family: inherit;
  resize: none; overflow: hidden; min-height: 44px; max-height: 120px;
  line-height: 1.6;
}
.ask-bar textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.ask-bar button {
  padding: 10px 20px; border: none; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-size: 1em;
  cursor: pointer; font-family: inherit; white-space: nowrap; align-self: flex-end;
}
.ask-bar button:hover { opacity: 0.9; }

.ask-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.ask-header-actions { display: flex; gap: 8px; }
.ask-header-actions button {
  background: var(--tag-bg); border: 1px solid var(--card-border); border-radius: 6px;
  padding: 4px 10px; cursor: pointer; font-size: 0.85em; color: var(--muted);
  font-family: inherit;
}
.ask-header-actions button:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.settings-panel {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px;
  padding: 16px; margin-bottom: 16px;
}
.settings-panel label { display: block; margin-bottom: 6px; font-size: 0.9em; color: var(--muted); }
.settings-panel select, .settings-panel input[type="password"] {
  width: 100%; padding: 8px 12px; font-size: 0.95em;
  border: 1px solid var(--card-border); border-radius: 6px;
  background: var(--bg); color: var(--fg); font-family: inherit;
  margin-bottom: 12px;
}
.settings-panel select:focus, .settings-panel input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.settings-panel .settings-row { display: flex; gap: 12px; align-items: flex-end; }
.settings-panel .settings-row > div { flex: 1; }
.settings-panel .save-btn {
  padding: 8px 20px; border: none; border-radius: 6px;
  background: var(--accent); color: var(--on-accent); cursor: pointer; font-family: inherit; font-size: 0.9em;
}

.ask-note {
  text-align: center; font-size: 0.82em; color: var(--muted);
  margin-top: 8px; line-height: 1.6;
}

footer {
  text-align: center; padding: 32px 16px; color: var(--muted);
  font-size: 0.85em; margin-top: 40px; position: relative;
}
footer::before {
  content: ''; display: block; height: 1px; margin-bottom: 24px;
  background: linear-gradient(to right, transparent, var(--accent), transparent);
}
footer a { color: var(--accent); }
.footer-dao {
  font-size: 2em; color: var(--accent); opacity: 0.25; margin-bottom: 8px;
}
.footer-quote {
  font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  font-size: 0.9em; color: var(--muted); opacity: 0.6;
  margin-bottom: 12px; letter-spacing: 0.1em;
}

.user-status {
  font-size: 0.8em; color: var(--muted); white-space: nowrap;
}
.user-status a { color: var(--accent); font-size: 0.9em; }

.auth-modal {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.auth-modal .modal-content {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 28px; max-width: 400px; width: 100%;
  position: relative;
}
.auth-modal h3 { color: var(--accent); margin-bottom: 8px; font-size: 1.2em; }
.auth-modal p { color: var(--muted); font-size: 0.9em; margin-bottom: 16px; line-height: 1.6; }
.auth-modal input[type="email"],
.auth-modal input[type="text"] {
  width: 100%; padding: 10px 14px; font-size: 1em;
  border: 1px solid var(--card-border); border-radius: 8px;
  background: var(--bg); color: var(--fg); font-family: inherit;
  margin-bottom: 12px;
}
.auth-modal input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.auth-modal .auth-submit {
  width: 100%; padding: 10px; border: none; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-size: 1em;
  cursor: pointer; font-family: inherit;
}
.auth-modal .auth-submit:hover { opacity: 0.9; }
.auth-modal .auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.auth-modal .close {
  position: absolute; top: 12px; right: 16px;
  background: none; border: none; font-size: 1.4em;
  color: var(--muted); cursor: pointer; line-height: 1;
}
.auth-modal .close:hover { color: var(--fg); }
.auth-modal .auth-error { color: #c0392b; font-size: 0.85em; margin-top: 8px; }
.auth-modal .auth-step2 { display: none; }
.auth-modal .auth-step2.active { display: block; }

.topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin: 24px 0; }
@media (min-width: 768px) { .topic-grid { grid-template-columns: repeat(4, 1fr); } }
.topic-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px;
  padding: 20px; text-align: center; transition: box-shadow 0.2s; display: block;
}
.topic-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); text-decoration: none; }
.topic-icon { font-size: 2em; display: block; margin-bottom: 8px; }
.topic-card h2 { font-size: 1.05em; color: var(--accent); margin-bottom: 4px; }
.topic-card .meta { font-size: 0.82em; color: var(--muted); margin-bottom: 6px; }
.topic-card .sample { font-size: 0.82em; color: var(--fg); opacity: 0.7; line-height: 1.5; }

@media (max-width: 600px) {
  .hero h1 { font-size: 1.6em; }
  .section-grid { grid-template-columns: 1fr; }
  .text-item { flex-direction: column; gap: 4px; }
  .top-nav .nav-links { gap: 8px; }
  .fulu-tab-bar { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .fulu-tab-bar::-webkit-scrollbar { display: none; }
  .fulu-tab { padding: 8px 14px; font-size: 0.85em; white-space: nowrap; flex-shrink: 0; }
  .fulu-gallery-filters, .fulu-category-filters, .fulu-tag-filters { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 4px; }
  .fulu-gallery-filters::-webkit-scrollbar, .fulu-category-filters::-webkit-scrollbar, .fulu-tag-filters::-webkit-scrollbar { display: none; }
  .fulu-gallery-filters button, .fulu-category-filters button, .fulu-tag-filters button { flex-shrink: 0; white-space: nowrap; }
  .scan-detail-item { flex-wrap: wrap; }
  .scan-detail-item .lb-item-name { min-width: auto; }
  .incantation-card { padding: 12px; }
  .incantation-header { flex-wrap: wrap; }
  .incantation-text { font-size: 0.88em; }
}

/* Scan gallery */
.scan-gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
@media (min-width: 600px) { .scan-gallery { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .scan-gallery { grid-template-columns: repeat(4, 1fr); } }
.scan-card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px;
  overflow: hidden; cursor: pointer; transition: box-shadow 0.2s, transform 0.2s;
  text-decoration: none; color: inherit; display: block;
}
.scan-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-2px); }
.scan-card img { width: 100%; height: 200px; object-fit: cover; object-position: top; display: block; background: #f5f0e8; }
[data-theme="dark"] .scan-card img { background: #2a2520; }
@media (min-width: 600px) { .scan-card img { height: 260px; } }
.scan-card-info { padding: 8px 10px; }
.scan-card-page { font-size: 0.85em; color: var(--accent); margin-bottom: 4px; }
.scan-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.scan-tag {
  font-size: 0.7em; background: var(--tag-bg); color: var(--muted);
  padding: 1px 6px; border-radius: 8px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}
.scan-tag.scan-more { background: var(--accent); color: var(--on-accent); }

/* Scan detail page */
.scan-detail-page { max-width: 800px; margin: 0 auto; }
.scan-detail-image { margin-bottom: 24px; }
.scan-detail-image img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--card-border); }
.scan-detail-info { margin-bottom: 24px; }
.scan-detail-info h1 { font-size: 1.5em; color: var(--accent); margin-bottom: 12px; }
.scan-detail-items { display: flex; flex-direction: column; gap: 8px; }
.scan-detail-item {
  display: flex; align-items: baseline; gap: 8px; padding: 8px 12px;
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 8px;
}
.scan-detail-item .lb-item-name { font-weight: 600; min-width: 120px; }
.scan-detail-item .lb-item-desc { color: var(--muted); font-size: 0.9em; }

/* Scan lightbox */
#scan-lightbox {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.9); padding: 16px; cursor: pointer; overflow-y: auto;
}
#scan-lightbox.active { display: flex; align-items: flex-start; justify-content: center; }
#scan-lightbox .lb-close { position: fixed; top: 16px; right: 24px; color: #fff; font-size: 2em; cursor: pointer; z-index: 10000; }
#scan-lightbox .lb-content {
  max-width: 1200px; width: 100%; display: flex; flex-direction: column; align-items: center;
  gap: 16px; padding-top: 24px; cursor: default;
}
#scan-lightbox .lb-content img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: 8px; background: #fff; }
#scan-lightbox .lb-title { color: #fff; font-size: 1.1em; text-align: center; }
#scan-lightbox .lb-items {
  background: rgba(255,255,255,0.08); border-radius: 10px; padding: 16px; width: 100%; max-width: 600px;
}
.lb-items-title { color: var(--accent); font-size: 0.95em; margin-bottom: 10px; font-weight: bold; }
.lb-item { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,0.08); flex-wrap: wrap; }
.lb-item:last-child { border-bottom: none; }
.lb-item-type {
  font-size: 0.7em; padding: 1px 8px; border-radius: 8px; white-space: nowrap;
  background: #b8860b; color: #fff;
}
.lb-item-type.tag-天文图 { background: #4169e1; }
.lb-item-type.tag-法印 { background: #8b0000; }
.lb-item-type.tag-卦象 { background: #6a5acd; }
.lb-item-type.tag-神像 { background: #2e8b57; }
.lb-item-type.tag-器物 { background: #8b4513; }
.lb-item-name { color: #fff; font-size: 0.9em; }
.lb-item-desc { color: rgba(255,255,255,0.5); font-size: 0.78em; width: 100%; padding-left: 60px; }

/* Feedback widget */
#feedback-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  background: var(--accent); color: var(--on-accent); border: none; border-radius: 24px;
  padding: 10px 20px; font-size: 0.9em; cursor: pointer;
  font-family: inherit; box-shadow: 0 2px 12px rgba(0,0,0,0.2);
  transition: opacity 0.2s;
}
#feedback-btn:hover { opacity: 0.9; }
#feedback-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5); align-items: center; justify-content: center;
}
#feedback-overlay.active { display: flex; }
#feedback-modal {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 12px; padding: 24px; width: 90%; max-width: 460px;
  position: relative; font-family: inherit; color: var(--fg);
}
#feedback-modal h3 { color: var(--accent); margin-bottom: 4px; font-size: 1.1em; }
#feedback-modal p { color: var(--muted); font-size: 0.85em; margin-bottom: 16px; }
#feedback-modal .fb-close {
  position: absolute; top: 12px; right: 16px; background: none; border: none;
  font-size: 1.4em; cursor: pointer; color: var(--muted); line-height: 1;
}
.fb-cats { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.fb-cats button {
  padding: 6px 14px; border: 1px solid var(--card-border); border-radius: 16px;
  background: var(--card-bg); color: var(--muted); cursor: pointer;
  font-size: 0.85em; font-family: inherit; transition: all 0.15s;
}
.fb-cats button.active {
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
}
#fb-content {
  width: 100%; padding: 10px 12px; border: 1px solid var(--card-border);
  border-radius: 8px; background: var(--bg); color: var(--fg);
  font-family: inherit; font-size: 0.92em; resize: vertical; min-height: 80px;
}
#fb-content:focus { outline: 2px solid var(--accent); border-color: transparent; }
.fb-char-count { text-align: right; font-size: 0.78em; color: var(--muted); margin: 2px 0 8px; }
#fb-email {
  width: 100%; padding: 8px 12px; border: 1px solid var(--card-border);
  border-radius: 8px; background: var(--bg); color: var(--fg);
  font-family: inherit; font-size: 0.9em; margin-bottom: 12px;
}
#fb-email:focus { outline: 2px solid var(--accent); border-color: transparent; }
#fb-submit {
  width: 100%; padding: 10px; border: none; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-size: 0.95em;
  cursor: pointer; font-family: inherit;
}
#fb-submit:hover { opacity: 0.9; }
#fb-submit:disabled { opacity: 0.5; cursor: not-allowed; }
#fb-msg { text-align: center; font-size: 0.85em; margin-top: 8px; min-height: 1.2em; }
@media (max-width: 600px) {
  #feedback-btn { bottom: 16px; right: 16px; padding: 8px 16px; font-size: 0.85em; }
  #feedback-modal { padding: 18px; }
}

/* interpretation markup (rendered from Markdown at build time) */
.interp-block p { margin: 0 0 0.55em; }
.interp-block p.interp-h { margin-top: 0.4em; }
.interp-block hr { border: 0; border-top: 1px solid var(--card-border); margin: 0.7em 0; }
.interp-block ul.interp-list { margin: 0 0 0.55em 1.2em; padding: 0; }
.interp-block blockquote.interp-quote { margin: 0 0 0.55em; padding-left: 10px; border-left: 2px solid var(--card-border); opacity: 0.9; }
.interp-block table.interp-table { border-collapse: collapse; margin: 0.4em 0 0.7em; font-size: 0.95em; display: block; overflow-x: auto; }
.interp-block table.interp-table th, .interp-block table.interp-table td { border: 1px solid var(--card-border); padding: 3px 8px; vertical-align: top; }
.interp-note { margin: 8px 0 14px; padding: 8px 12px; background: var(--paper); border-left: 3px solid var(--jade); font-size: 0.88em; line-height: 1.7; opacity: 0.92; }
.interp-gap { margin: 6px 0 14px; padding: 6px 12px; border-left: 3px solid var(--line, #c9c3b3); font-size: 0.85em; line-height: 1.7; opacity: 0.75; font-style: italic; }
.juan-text h2.chap-h { white-space: normal; font-size: 1.1em; color: var(--accent); margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--card-border); }
.text-body.vertical-scroll h2.chap-h, .text-body.vertical-drum h2.chap-h, .text-body.vertical-flip h2.chap-h { border-bottom: 0; margin: 0 0 0 12px; font-size: 1em; }

/* core classics: 导读 / 版本说明 / 相关链接 (2026-10-19) */
.core-guide, .core-edition, .core-related { margin: 8px 0 16px; padding: 10px 14px; background: var(--paper); border-left: 3px solid var(--jade); font-size: 0.92em; line-height: 1.85; }
.core-guide h2, .core-edition h2, .core-related h2 { font-size: 1.1em; margin: 0 0 6px; }
.core-guide h3, .core-edition h3 { font-size: 1em; margin: 12px 0 2px; }
.core-guide p, .core-edition p { margin: 0 0 8px; }
.core-edition ul, .core-related ul { margin: 0 0 6px; padding-left: 1.2em; }
.core-related { margin-top: 24px; }
.core-lead { margin: 8px 0 8px; padding: 0 2px; font-size: 1em; line-height: 1.9; color: var(--text, inherit); }
.core-edition code { font-size: 0.95em; }
@media (max-width: 600px) { .core-guide, .core-edition, .core-related { padding: 8px 10px; font-size: 0.9em; } }
.core-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 12px 0 28px; }
.core-card h3 { font-size: 1.05em; color: var(--accent); margin-bottom: 6px; font-family: "ZCOOL XiaoWei", "Noto Serif SC", serif; }

/* 2026-10-21: #feedback-btn etc. */
#feedback-btn { color: var(--on-accent); }

/* ---- 2026-10-21 GEO/UX ---- */
:root { --nav-h: 64px; }
html { scroll-padding-top: calc(var(--nav-h) + 12px); }
@media (max-width: 600px) { :root { --nav-h: 112px; } }
#text-body, .juan-section h2[id], .interp-seg[id], .interp-block[id], .text-header, .toc, .core-related { scroll-margin-top: calc(var(--nav-h) + 12px); }
body { padding-bottom: 56px; }

/* start reading / correction row */
.start-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 8px 0 14px; }
.start-read { display: inline-block; padding: 8px 22px; border-radius: 22px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 1em; }
.start-read:hover { text-decoration: none; opacity: 0.9; }
.fix-link { font-size: 0.85em; color: var(--muted); text-decoration: underline; cursor: pointer; }
.src-attrib { margin: 20px 0 8px; padding-top: 10px; border-top: 1px solid var(--card-border); font-size: 0.85em; color: var(--muted); line-height: 1.8; }

/* collapsed guide / edition (content stays in the static HTML) */
details.core-guide > summary, details.core-edition > summary { cursor: pointer; font-size: 1.1em; font-weight: 700; color: var(--accent); }
details.core-guide[open] > summary, details.core-edition[open] > summary { margin-bottom: 6px; }
details.core-guide > summary:focus-visible, details.core-edition > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* source text vs interpretation */
.src-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82em; color: var(--muted); margin: 0 0 8px; }
.src-legend .lg::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.src-legend .lg-src::before { border-left: 3px solid var(--accent); background: var(--tag-bg); }
.src-legend .lg-interp::before { border-left: 3px solid var(--jade); background: var(--paper); }
.interp-seg { border-left: 3px solid var(--accent); padding-left: 10px; margin: 6px 0; }
.seg-link { color: var(--muted); font-size: 0.75em; margin-right: 6px; opacity: 0.8; }
.seg-link::before { content: '¶'; }
.seg-link:hover { opacity: 1; text-decoration: none; }
.interp-seg:target { background: var(--tag-bg); }
.text-body[class*="vertical-"] .seg-link { display: none; }
.text-body[class*="vertical-"] .interp-seg { border-left: 0; padding-left: 0; margin: 0; }
.interp-fix { display: inline-block; margin-top: 6px; font-size: 0.75em; }

/* reading-mode help */
.mode-help { flex-basis: 100%; font-size: 0.82em; color: var(--muted); }
.mode-help summary { cursor: pointer; display: inline-block; padding: 2px 4px; }
.mode-help ul { margin: 4px 0 2px 1.2em; line-height: 1.7; }

/* home search + count note */
.home-search { display: flex; gap: 8px; max-width: 560px; margin: 16px auto 0; }
.home-search input { flex: 1; padding: 11px 16px; font-size: 1em; border: 1px solid var(--card-border); border-radius: 8px; background: var(--card-bg); color: var(--fg); font-family: inherit; }
.home-search input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.home-search button { padding: 11px 22px; border: none; border-radius: 8px; background: var(--accent); color: var(--on-accent); font-size: 1em; cursor: pointer; font-family: inherit; }
.stats-note { max-width: 720px; margin: -16px auto 28px; text-align: center; font-size: 0.82em; line-height: 1.7; color: var(--muted); }

/* search results */
.search-summary { font-size: 0.9em; color: var(--muted); margin: 0 0 8px; }
.search-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.search-chips button { padding: 3px 12px; border: 1px solid var(--card-border); border-radius: 14px; background: var(--card-bg); color: var(--muted); cursor: pointer; font-family: inherit; font-size: 0.82em; }
.search-chips button.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* methodology (about) */
.about-content details { margin: 8px 0; }
.about-content table { border-collapse: collapse; margin: 8px 0 14px; font-size: 0.92em; }
.about-content th, .about-content td { border: 1px solid var(--card-border); padding: 4px 10px; text-align: left; vertical-align: top; }

/* avoid overlap of the fixed reading bar / feedback button with content on narrow viewports */
@media (max-width: 1100px) {
  .reading-bar { right: 3px; }
  .reading-bar::before { left: -6px; right: -6px; }
  .reading-bar-auto { display: none; }
}
@media (max-width: 600px) { #feedback-btn { padding: 8px 14px; } }

/* ---- 2026-10-23 GEO trust / citation blocks (in-body, muted) ---- */
.trust-block { margin: 10px 0 14px; padding: 8px 12px; border-top: 1px solid var(--card-border); border-bottom: 1px solid var(--card-border); font-size: 0.82em; line-height: 1.75; color: var(--muted); }
.trust-block p { margin: 0 0 4px; }
.trust-block a { color: var(--muted); text-decoration: underline; }
.trust-block time { white-space: nowrap; }
.trust-block details { margin-top: 2px; }
.trust-block summary, .cite-block summary { cursor: pointer; }
.trust-block ul, .cite-block ul { margin: 4px 0 4px 1.2em; padding: 0; }
.trust-block li, .cite-block li { margin-bottom: 2px; }
.cite-block { margin: 8px 0 14px; padding: 6px 12px; background: var(--paper); border-left: 3px solid var(--card-border); font-size: 0.82em; line-height: 1.75; color: var(--muted); overflow-wrap: anywhere; }
.cite-block a { color: var(--muted); text-decoration: underline; }
.cite-block .cite-fmt { display: block; margin-top: 2px; padding: 4px 8px; background: var(--card-bg); border: 1px dashed var(--card-border); border-radius: 4px; color: var(--fg); user-select: all; }
.answer-lead { margin: 8px 0 10px; padding: 0 2px; font-size: 1em; line-height: 1.9; }
.home-trust { max-width: 760px; margin: 0 auto 22px; text-align: left; }
.search-hint { max-width: 560px; margin: 8px auto 0; font-size: 0.82em; line-height: 1.7; color: var(--muted); text-align: center; }
.search-hint a { color: var(--muted); text-decoration: underline; }
.about-content table.ai-table { border-collapse: collapse; margin: 6px 0 12px; }
.about-content table.ai-table th, .about-content table.ai-table td { border: 1px solid var(--card-border); padding: 3px 10px; text-align: left; }
.about-content .cite-fmt { display: block; padding: 4px 8px; background: var(--paper); border: 1px dashed var(--card-border); border-radius: 4px; overflow-wrap: anywhere; }
.text-item .info { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.text-item { flex-wrap: wrap; }

/* ---- 2026-11-01 识典风格阅读 UX pilot (only KR5a0001 / KR5c0003) ----
   All selectors are gated by body.pilot-reader or #text-body[data-pilot-ux]. */
.text-badges { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 10px; vertical-align: middle; }
.text-badge {
  font-family: "Noto Serif SC", "Source Han Serif CN", serif;
  font-size: 0.42em; font-weight: 400; line-height: 1.5; letter-spacing: 0.03em;
  color: var(--jade-text); background: var(--paper);
  border: 1px solid var(--card-border); border-radius: 999px; padding: 1px 9px;
  vertical-align: middle; white-space: nowrap;
}
body.pilot-reader main.container { max-width: 1420px; }
.pilot-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 26px; align-items: start; }
.pilot-layout.toc-collapsed { grid-template-columns: 64px minmax(0, 1fr); }
.pilot-main { min-width: 0; }
.reader-toc {
  position: sticky; top: calc(var(--nav-h) + 14px);
  max-height: calc(100vh - var(--nav-h) - 28px); overflow: auto;
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 8px; padding: 10px 10px 12px; font-size: 0.86em;
  scrollbar-width: thin;
}
.reader-toc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.reader-toc-head span { font-weight: 700; color: var(--accent); letter-spacing: 0.08em; }
.reader-toc-toggle {
  background: none; border: 1px solid var(--card-border); border-radius: 4px;
  color: var(--muted); font-family: inherit; font-size: 0.78em;
  padding: 1px 6px; cursor: pointer;
}
.reader-toc-toggle:hover { color: var(--accent); border-color: var(--accent); }
.pilot-layout.toc-collapsed .reader-toc-body,
.pilot-layout.toc-collapsed .reader-toc-head span { display: none; }
.pilot-layout.toc-collapsed .reader-toc-head { justify-content: center; margin-bottom: 0; }
.toc-juan-block { margin: 1px 0; }
.toc-juan {
  display: block; padding: 3px 7px; border-radius: 4px;
  color: var(--muted); line-height: 1.7;
}
.toc-juan:hover { background: var(--tag-bg); color: var(--accent); text-decoration: none; }
.toc-juan.current { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.toc-segs { margin: 3px 0 8px 8px; padding-left: 7px; border-left: 1px solid var(--card-border); }
.toc-segs a {
  display: block; padding: 2px 5px; border-radius: 3px;
  color: var(--muted); font-size: 0.9em; line-height: 1.55;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toc-segs a:hover { background: var(--tag-bg); text-decoration: none; }
.toc-segs a.current { background: var(--tag-bg); color: var(--accent); font-weight: 700; }
@media (min-width: 1001px) {
  body.pilot-reader .pilot-main > .toc { display: none; }
}
@media (max-width: 1000px) {
  body.pilot-reader main.container { max-width: 960px; }
  .pilot-layout, .pilot-layout.toc-collapsed { display: block; }
  .reader-toc {
    position: fixed; left: 12px; right: 12px; top: calc(var(--nav-h) + 8px);
    max-height: calc(100vh - var(--nav-h) - 24px); z-index: 85;
    transform: translateY(-130%); opacity: 0; pointer-events: none;
    transition: transform 0.25s ease, opacity 0.2s ease;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  }
  .reader-toc.open { transform: none; opacity: 1; pointer-events: auto; }
  .reader-toc-overlay {
    position: fixed; inset: 0; z-index: 84; display: none;
    background: rgba(0, 0, 0, 0.38);
  }
  .reader-toc-overlay.open { display: block; }
  .pilot-toc-open { display: inline-block !important; }
}
.pilot-toc-open { display: none; }

/* HFL page markers (only rendered in pilot books) */
.hfl-page {
  display: inline-block; font-family: "Noto Serif SC", serif;
  font-size: 0.68em; line-height: 1.6; color: var(--muted);
  background: var(--tag-bg); border: 1px solid var(--card-border);
  border-radius: 3px; padding: 0 4px; margin: 0 2px;
  vertical-align: baseline; white-space: nowrap; opacity: 0.8;
}

/* paragraph-level side-by-side source / interpretation (wide screens, horizontal mode only) */
@media (min-width: 1001px) {
  .text-body.pilot-split:not([class*="vertical-"]) .cmp-row {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 26px; padding: 13px 0 15px;
    border-top: 1px solid var(--card-border);
  }
  .text-body.pilot-split:not([class*="vertical-"]) .cmp-src { min-width: 0; }
  .text-body.pilot-split:not([class*="vertical-"]) .cmp-int {
    min-width: 0; border-left: 2px solid var(--jade); padding-left: 18px;
  }
  .text-body.pilot-split .cmp-src .interp-seg { margin: 0; }
  .text-body.pilot-split .cmp-int .interp-block,
  .text-body.pilot-split.show-interp .cmp-int .interp-block,
  .text-body.pilot-split .cmp-int .interp-block.collapsed {
    display: block; max-height: none; overflow: visible;
    padding: 0; margin: 0; border-left: 0; background: transparent;
    opacity: 1; font-size: 0.9em; line-height: 1.95;
  }
  .text-body.pilot-split .cmp-int .interp-block .interp-label { margin-bottom: 5px; }
  .text-body.pilot-split .cmp-int .interp-block .interp-close { display: none; }
  .text-body.pilot-split .cmp-int .interp-gap { margin: 0; border-left: 0; padding: 0; }
}
@media (max-width: 1000px) {
  .text-body.pilot-split .cmp-row { display: block; }
}
.text-body[class*="vertical-"] .cmp-row,
.text-body[class*="vertical-"] .cmp-src,
.text-body[class*="vertical-"] .cmp-int,
.text-body[class*="vertical-"] .cmp-full { display: contents; }
