:root {
  --bg: #0a0d12;
  --bg-1: #11151c;
  --bg-2: #171d26;
  --bg-3: #1e2530;
  --line: rgba(200, 164, 92, 0.18);
  --line-2: rgba(255, 255, 255, 0.07);
  --gold: #c8a45c;
  --gold-soft: rgba(200, 164, 92, 0.12);
  --gold-dim: #8a6f3a;
  --text: #e9e5dc;
  --text-2: #99a1ab;
  --text-3: #6a7178;
  --danger: #c9756a;
  --serif: "Songti SC", "Noto Serif SC", "SimSun", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 12px 32px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f3ec;
    --bg-1: #fffdf8;
    --bg-2: #f0ece2;
    --bg-3: #e6e0d3;
    --line: rgba(140, 108, 48, 0.22);
    --line-2: rgba(0, 0, 0, 0.08);
    --gold: #8a6a24;
    --gold-soft: rgba(138, 106, 36, 0.1);
    --gold-dim: #a98a48;
    --text: #23201a;
    --text-2: #5f5a50;
    --text-3: #8b8478;
    --danger: #a8443c;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.6), 0 10px 28px rgba(90, 74, 40, 0.12);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(900px 420px at 50% -10%, rgba(200, 164, 92, 0.08), transparent 70%);
  padding-bottom: env(safe-area-inset-bottom);
}

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; }

/* ---------- 启动遮罩 ---------- */
.boot {
  position: fixed; inset: 0; background: var(--bg);
  display: grid; place-items: center; z-index: 90;
  transition: opacity .4s ease, visibility .4s;
}
.boot.gone { opacity: 0; visibility: hidden; }
.boot-mark {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--gold-dim);
  border-top-color: var(--gold);
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 头部 ---------- */
.site-head {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line-2);
  padding: calc(env(safe-area-inset-top) + 14px) 16px 0;
}
.head-inner {
  max-width: 980px; margin: 0 auto;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
}
.brand h1 {
  margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 500;
  letter-spacing: .18em; color: var(--text);
}
.brand p {
  margin: 2px 0 0; font-size: 11.5px; letter-spacing: .22em;
  color: var(--gold-dim);
}
.head-actions { display: flex; gap: 8px; padding-bottom: 6px; }
.ghost-btn {
  border: 1px solid var(--line); color: var(--gold);
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px;
  transition: background .2s, border-color .2s;
}
.ghost-btn:hover { background: var(--gold-soft); border-color: var(--gold-dim); }
.ghost-btn.wide { width: 100%; margin-top: 16px; padding: 11px; font-size: 14px; }

/* ---------- 搜索 ---------- */
.search-wrap {
  position: relative; max-width: 980px; margin: 14px auto 0;
}
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; fill: none; stroke: var(--text-3);
  stroke-width: 1.7; stroke-linecap: round; pointer-events: none;
}
#search {
  width: 100%; padding: 11px 40px 11px 40px;
  background: var(--bg-1); border: 1px solid var(--line-2);
  border-radius: 11px; color: var(--text); font-size: 14.5px;
  outline: none; transition: border-color .2s, background .2s;
  -webkit-appearance: none;
}
#search::placeholder { color: var(--text-3); }
#search:focus { border-color: var(--line); background: var(--bg-2); }
#search::-webkit-search-cancel-button { display: none; }
.clear-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border-radius: 50%;
  color: var(--text-3); font-size: 18px; line-height: 1;
}
.clear-btn:hover { background: var(--bg-3); color: var(--text); }

/* ---------- 筛选 chips ---------- */
.chip-row {
  max-width: 980px; margin: 12px auto 0;
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 12px; scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip-row--sub { padding-bottom: 10px; margin-top: 0; }
.chip {
  flex: 0 0 auto;
  padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent;
  color: var(--text-2); font-size: 13px; white-space: nowrap;
  transition: all .18s;
}
.chip:hover { color: var(--text); border-color: var(--line); }
.chip[aria-pressed="true"] {
  background: var(--gold-soft); border-color: var(--gold-dim);
  color: var(--gold);
}
.chip--tag { font-size: 12px; padding: 4px 11px; }

/* ---------- 列表 ---------- */
.grid {
  max-width: 980px; margin: 0 auto;
  padding: 8px 16px 40px;
  display: grid; gap: 12px;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 620px) { .grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (min-width: 940px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  cursor: pointer;
  transition: transform .22s ease, border-color .22s, background .22s;
  display: flex; flex-direction: column; gap: 9px;
  min-height: 132px;
  min-width: 0;
  animation: rise .34s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.card:hover { border-color: var(--line); background: var(--bg-2); transform: translateY(-2px); }
.card:active { transform: scale(.995); }

.card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kind {
  font-size: 10.5px; letter-spacing: .1em; padding: 2px 7px;
  border-radius: 4px; border: 1px solid currentColor; opacity: .85;
  flex: 0 0 auto;
}
.kind--article { color: var(--gold-dim); }
.kind--audio { color: #6fa8a0; }
.kind--video { color: #a08aa8; }
@media (prefers-color-scheme: light) {
  .kind--audio { color: #2f6f68; }
  .kind--video { color: #6b4f76; }
}
.card-cat {
  font-size: 11.5px; color: var(--text-3); letter-spacing: .04em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}

.card h3 {
  margin: 0; font-family: var(--serif); font-size: 17px; font-weight: 500;
  line-height: 1.45; letter-spacing: .02em; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card p {
  margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  flex: 1;
}
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11.5px; color: var(--text-3); gap: 8px;
  min-width: 0;
}
.card-tags { display: flex; gap: 5px; overflow: hidden; min-width: 0; flex: 1 1 auto; }
.card-tags span {
  font-size: 10.5px; color: var(--text-3); border: 1px solid var(--line-2);
  padding: 1px 6px; border-radius: 4px; white-space: nowrap; flex: 0 0 auto;
}
.card-time { white-space: nowrap; font-variant-numeric: tabular-nums; flex: 0 0 auto; }

mark { background: rgba(200, 164, 92, 0.28); color: inherit; border-radius: 2px; padding: 0 1px; }

.empty {
  max-width: 980px; margin: 40px auto; padding: 0 16px;
  text-align: center; color: var(--text-3); font-size: 13.5px;
}

/* ---------- 底部 ---------- */
.site-foot {
  max-width: 980px; margin: 0 auto;
  padding: 0 16px calc(28px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 11.5px; color: var(--text-3); letter-spacing: .05em;
}

/* ---------- 播放条 ---------- */
.player-bar {
  position: fixed; left: 10px; right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--bg-2) 94%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  border-radius: 13px; padding: 9px 10px;
  box-shadow: var(--shadow);
  animation: rise .3s ease both;
}
.pb-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  background: var(--gold-soft); border: 1px solid var(--line);
  display: grid; place-items: center;
}
.pb-btn svg { width: 17px; height: 17px; fill: var(--gold); }
.pb-btn .ico-pause { display: none; }
.player-bar.playing .pb-btn .ico-play { display: none; }
.player-bar.playing .pb-btn .ico-pause { display: block; }
.pb-main { flex: 1; min-width: 0; cursor: pointer; }
.pb-title {
  font-size: 12.5px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px;
}
.pb-progress { height: 2px; background: var(--line-2); border-radius: 2px; overflow: hidden; }
.pb-progress-fill { height: 100%; width: 0; background: var(--gold); transition: width .25s linear; }
.pb-time { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.pb-close { color: var(--text-3); font-size: 20px; padding: 0 4px; line-height: 1; }

/* ---------- 详情 ---------- */
.detail {
  position: fixed; inset: 0; z-index: 70;
  width: 100%;
  background: var(--bg);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  animation: slidein .28s cubic-bezier(.22,.7,.3,1) both;
}
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.detail-top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.back-btn {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--gold); font-size: 14px;
}
.back-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.detail-body {
  max-width: 660px; margin: 0 auto;
  width: 100%;
  padding: 6px 20px calc(120px + env(safe-area-inset-bottom));
  box-sizing: border-box;
  overflow-wrap: break-word;
}
.d-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.d-title {
  font-family: var(--serif); font-size: 25px; font-weight: 500;
  line-height: 1.42; margin: 0 0 8px; letter-spacing: .02em;
}
.d-sub {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-3); margin-bottom: 18px;
}
.d-caution {
  border-left: 2px solid var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  padding: 10px 14px; border-radius: 0 8px 8px 0;
  font-size: 13px; color: var(--text-2); margin: 0 0 20px;
}
.d-caution strong { color: var(--danger); font-weight: 500; }

.player-box {
  background: var(--bg-1); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 16px; margin-bottom: 22px;
}
.player-box video {
  width: 100%; border-radius: 10px; display: block; background: #000;
  aspect-ratio: 16 / 9;
}
.player-box .p-label { font-size: 12px; color: var(--gold-dim); margin-bottom: 10px; letter-spacing: .06em; }
.p-controls { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.p-play {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto;
  background: var(--gold-soft); border: 1px solid var(--line);
  display: grid; place-items: center;
}
.p-play svg { width: 19px; height: 19px; fill: var(--gold); }
.p-play .p-ico-pause { display: none; }
.player-box.playing .p-play .p-ico-play { display: none; }
.player-box.playing .p-play .p-ico-pause { display: block; }
.p-track { flex: 1; }
.p-seek {
  -webkit-appearance: none; appearance: none; width: 100%; height: 18px;
  background: transparent; cursor: pointer;
}
.p-seek::-webkit-slider-runnable-track { height: 3px; background: var(--bg-3); border-radius: 3px; }
.p-seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--gold); margin-top: -4.5px;
}
.p-seek::-moz-range-track { height: 3px; background: var(--bg-3); border-radius: 3px; }
.p-seek::-moz-range-thumb { width: 12px; height: 12px; border: none; border-radius: 50%; background: var(--gold); }
.p-times {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.p-rate {
  flex: 0 0 auto; font-size: 12px; color: var(--text-2);
  border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 9px;
  font-variant-numeric: tabular-nums;
}
.p-rate:hover { border-color: var(--line); color: var(--gold); }
.p-missing {
  font-size: 12.5px; color: var(--text-3); text-align: center; padding: 18px 0 4px;
}

/* ---------- 正文排版 ---------- */
.prose { font-size: 15.5px; line-height: 1.95; color: var(--text); }
.prose h2 {
  font-family: var(--serif); font-size: 19px; font-weight: 500;
  margin: 32px 0 12px; letter-spacing: .04em;
  padding-left: 11px; border-left: 2px solid var(--gold-dim);
}
.prose h3 { font-size: 16px; font-weight: 500; margin: 22px 0 8px; color: var(--text); }
.prose p { margin: 0 0 15px; }
.prose ul, .prose ol { margin: 0 0 15px; padding-left: 1.3em; }
.prose li { margin-bottom: 6px; }
.prose strong { font-weight: 500; color: var(--gold); }
.prose code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: .88em; background: var(--bg-2); padding: 1px 5px;
  border-radius: 4px; border: 1px solid var(--line-2);
}
.prose blockquote {
  margin: 18px 0; padding: 12px 16px;
  background: var(--bg-1); border-left: 2px solid var(--gold-dim);
  border-radius: 0 8px 8px 0; color: var(--text-2); font-size: 14.5px;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { border: none; border-top: 1px solid var(--line-2); margin: 28px 0; }
/* 图片：掌诀图多为透明底黑字，必须给白底，否则在深色主题上看不见 */
.prose figure.fig { margin: 20px 0; }
.prose figure.fig img {
  display: block; width: 100%; height: auto;
  border-radius: 10px; border: 1px solid var(--line-2);
  background: #fff; padding: 8px;
}
.prose table {
  width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13.5px;
  display: block; overflow-x: auto;
}
.prose th, .prose td {
  border: 1px solid var(--line-2); padding: 8px 11px; text-align: left;
  white-space: nowrap;
}
.prose th { background: var(--bg-2); font-weight: 500; color: var(--gold); }
.prose a { color: var(--gold); text-decoration: none; border-bottom: 1px solid var(--line); }

/* ---------- 说明面板 ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0, 0, 0, .55);
  display: grid; place-items: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.sheet-card {
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 18px; padding: 24px; max-width: 420px; width: 100%;
  box-shadow: var(--shadow);
}
.sheet-card h2 { margin: 0 0 12px; font-family: var(--serif); font-size: 19px; font-weight: 500; }
.sheet-card h3 { margin: 20px 0 6px; font-size: 13.5px; font-weight: 500; color: var(--gold); }
.sheet-card p { margin: 0 0 8px; font-size: 13.5px; color: var(--text-2); line-height: 1.75; }
kbd {
  font-family: inherit; font-size: 11.5px; border: 1px solid var(--line-2);
  border-radius: 4px; padding: 1px 6px; background: var(--bg-2); color: var(--text-2);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
