/* ============================================================
   红楼梦 · 戏曲录
   暗色 · 简约 · 宋楷
   ============================================================ */

:root {
  --bg:        #0b0a09;
  --bg-soft:   #100e0c;
  --panel:     #131110;
  --line:      rgba(201, 168, 106, 0.14);
  --line-soft: rgba(255, 255, 255, 0.055);
  --line-hot:  rgba(180, 64, 47, 0.45);

  --text:      #e7dfd2;
  --text-dim:  #b3a897;
  --text-faint:#8a8073;

  --red:       #b4402f;
  --red-soft:  rgba(180, 64, 47, 0.13);
  --gold:      #c8a96b;

  --serif: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", "STSong", "SimSun", serif;
  --kai:   "Kaiti SC", "STKaiti", "KaiTi", "楷体", "SimSun", serif;
  --sans:  "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;

  --maxw: 1280px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1100px 740px at 82% -12%, rgba(140, 68, 44, 0.09), transparent 62%),
    radial-gradient(900px 620px at -8% 104%, rgba(110, 88, 50, 0.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(180, 64, 47, 0.35); color: #fff4e8; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- 页头 ---------- */

.site-head {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid var(--line);
}

.head-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 18px; min-width: 0; }
.brand-text { min-width: 0; }

.seal {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  position: relative;
  color: #dcc3a9;
  font-family: var(--kai);
  font-size: 28px;
  line-height: 1;
  border: 1.5px solid var(--red);
  transform: rotate(-2deg);
  box-shadow: 0 0 26px rgba(180, 64, 47, 0.12);
}
.seal::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(180, 64, 47, 0.4);
}

h1 {
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: #f0e7d8;
}

.sub {
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: 0.12em;
  color: var(--text-faint);
}

.head-actions { display: flex; align-items: center; gap: 18px; }

.head-note {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--text-faint);
}

.ghost-btn {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--line);
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.25s, color 0.25s, background 0.25s;
}
.ghost-btn:hover {
  border-color: var(--line-hot);
  color: #ecd8b6;
  background: rgba(180, 64, 47, 0.07);
}

/* ---------- 序 ---------- */

.preface {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 50px 40px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 70px;
  align-items: start;
}

.preface-main { max-width: 760px; }

.preface-main p {
  font-size: 15px;
  line-height: 2.15;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-align: justify;
}
.preface-main p + p { margin-top: 12px; }

.preface-side {
  border-left: 1px solid var(--line);
  padding-left: 26px;
}

.stat { display: flex; align-items: baseline; gap: 8px; }
.stat-num {
  font-size: 40px;
  line-height: 1;
  color: #e5d3b4;
  letter-spacing: 0.06em;
  font-weight: 400;
}
.stat-label {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--text-faint);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-top: 10px;
}
.stat-row + .stat-row { margin-top: 6px; }
.stat-v { color: var(--text-dim); }

.side-note {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

/* ---------- 主体布局 ---------- */

.layout {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 34px 40px 90px;
  display: grid;
  grid-template-columns: 322px minmax(0, 1fr);
  gap: 58px;
  align-items: start;
}

/* ---------- 侧栏 ---------- */

.sidebar {
  position: sticky;
  top: 22px;
  max-height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 4px;
}

.tools {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-wrap { flex: 0 0 auto; }

.search {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-family: var(--serif);
  font-size: 13.5px;
  letter-spacing: 0.06em;
  padding: 9px 2px 10px;
  outline: none;
  transition: border-color 0.25s;
  -webkit-appearance: none;
}
.search::placeholder { color: var(--text-faint); letter-spacing: 0.08em; }
.search:focus { border-bottom-color: var(--line-hot); }
.search::-webkit-search-cancel-button { -webkit-appearance: none; }

.count {
  margin-top: 7px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--text-faint);
  min-height: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 0 0 auto;
}

.chip {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.chip:hover { color: var(--text); border-color: rgba(201, 168, 106, 0.32); }
.chip.on {
  color: #e8c3ae;
  border-color: var(--line-hot);
  background: var(--red-soft);
}

.list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 6px 20px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 168, 106, 0.2) transparent;
}
.list::-webkit-scrollbar { width: 5px; }
.list::-webkit-scrollbar-thumb {
  background: rgba(201, 168, 106, 0.18);
  border-radius: 4px;
}
.list::-webkit-scrollbar-track { background: transparent; }

.group { margin-top: 22px; }
.group:first-child { margin-top: 6px; }

.group-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 0 4px 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 5px;
}
.group-ch {
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--gold);
  opacity: 0.85;
}
.group-label {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.play-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  padding: 9px 10px 9px 12px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: background 0.22s, border-color 0.22s;
}
.play-item:hover { background: rgba(255, 255, 255, 0.024); }

.play-item .num {
  flex: 0 0 17px;
  padding-top: 4px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.play-item .body { min-width: 0; }

.play-item .t {
  display: block;
  font-size: 14.5px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  line-height: 1.5;
  transition: color 0.2s;
}

.play-item .s {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-item.on {
  border-left-color: var(--red);
  background: linear-gradient(90deg, rgba(180, 64, 47, 0.11), rgba(180, 64, 47, 0.015) 78%, transparent);
}
.play-item.on .t { color: #f2e8d8; }
.play-item.on .num { color: var(--red); }

.empty {
  padding: 26px 12px;
  font-size: 12.5px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}

/* ---------- 详情 ---------- */

.detail {
  min-height: 62vh;
  scroll-margin-top: 18px;
}

.mobile-bar,
.back-bottom { display: none; }

.detail-inner { animation: rise 0.4s ease both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}

.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--gold);
}
.kicker .sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--red);
  flex: 0 0 auto;
}
.kicker .part { color: var(--text-faint); }
.kicker .is-xushu {
  color: #cf8a73;
  border: 1px solid rgba(180, 64, 47, 0.32);
  padding: 2px 7px;
  border-radius: 2px;
  font-size: 9px;
  letter-spacing: 0.14em;
}

.detail-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 26px;
  flex-wrap: wrap;
  margin: 16px 0 4px;
}

.detail-head h2 {
  font-size: 43px;
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: 0.07em;
  color: #f4ead9;
}
.detail-head h2.long {
  font-size: 30px;
  line-height: 1.4;
  letter-spacing: 0.04em;
}

.detail-head .alt {
  padding-bottom: 9px;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  text-align: right;
}

.tagrow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 18px 0 34px;
}

.tag {
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: #cbb79a;
  border: 1px solid rgba(200, 168, 106, 0.19);
  padding: 4px 10px;
  border-radius: 2px;
}

.block { margin: 34px 0; }

.label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.3em;
  color: var(--gold);
  white-space: nowrap;
}
.label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.chapter-box {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.017), rgba(255, 255, 255, 0.006));
  padding: 20px 24px 22px;
}

.chapter-name {
  font-size: 14.5px;
  letter-spacing: 0.09em;
  color: #ddcdb2;
  line-height: 1.7;
  margin-bottom: 10px;
}
.chapter-name .ch {
  color: var(--red);
  margin-right: 8px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.16em;
  vertical-align: 2px;
}

.summary {
  font-size: 13.8px;
  line-height: 2.1;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-align: justify;
}

.quote {
  font-family: var(--kai);
  font-size: 19px;
  line-height: 2.08;
  letter-spacing: 0.035em;
  color: #ddd3c0;
  padding: 2px 0 2px 22px;
  border-left: 2px solid var(--red);
  white-space: pre-line;
}

.quote-src {
  margin-top: 12px;
  padding-left: 24px;
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--text-faint);
}

.quote-note {
  margin-top: 8px;
  padding-left: 24px;
  font-size: 11.5px;
  line-height: 1.85;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.annotation {
  border: 1px dashed rgba(200, 168, 106, 0.24);
  background: rgba(200, 168, 106, 0.028);
  padding: 17px 22px;
}
.annotation p {
  font-family: var(--kai);
  font-size: 16px;
  line-height: 1.95;
  color: #d2c3a8;
}
.annotation .from {
  margin-top: 9px;
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--text-faint);
}

.fate p {
  font-size: 14.8px;
  line-height: 2.18;
  color: #cec6b7;
  letter-spacing: 0.018em;
  text-align: justify;
}
.fate p + p { margin-top: 17px; }

.fate em {
  font-style: normal;
  color: #ecd9b9;
  border-bottom: 1px solid rgba(180, 64, 47, 0.55);
  padding-bottom: 1px;
}

/* ---------- 翻页 ---------- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 52px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.pager button {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 0;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: opacity 0.2s;
}
.pager button.next { text-align: right; align-items: flex-end; }
.pager button:hover .pg-title { color: var(--gold); }

.pg-dir {
  font-family: var(--sans);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: var(--text-faint);
}
.pg-title {
  font-size: 14px;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  transition: color 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* ---------- 页脚 ---------- */

.site-foot {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
}
.foot-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 30px 40px 46px;
}
.foot-inner p {
  font-size: 11.5px;
  line-height: 1.95;
  color: var(--text-faint);
  letter-spacing: 0.02em;
  max-width: 780px;
}
.foot-src { margin-top: 8px; opacity: 0.72; }

.pwa-note { display: none; }

.noscript {
  padding: 20px 40px;
  color: var(--red);
  font-size: 14px;
}

/* ---------- 焦点 ---------- */

:focus-visible {
  outline: 1px solid rgba(200, 168, 106, 0.6);
  outline-offset: 3px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 1080px) {
  .layout { grid-template-columns: 290px minmax(0, 1fr); gap: 40px; }
  .preface { gap: 44px; }
}

@media (max-width: 900px) {
  .head-inner { padding: 20px 22px; }
  .head-note { display: none; }

  .preface {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 28px 22px 2px;
  }
  .preface-main p { font-size: 14px; line-height: 2; }
  .preface-main p + p { display: none; }
  .preface-side { display: none; }

  .layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 10px 22px 60px;
  }
  .sidebar {
    position: static;
    max-height: none;
    padding-right: 0;
    gap: 0;
  }

  /* 搜索与筛选项吸顶 */
  .tools {
    position: sticky;
    top: 0;
    z-index: 25;
    gap: 10px;
    margin: 0 -22px;
    padding: 12px 22px 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .search { font-size: 16px; padding: 8px 2px 10px; }
  .count { display: none; }
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 0 -22px;
    padding: 2px 22px 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .filters::-webkit-scrollbar { display: none; }
  .chip {
    flex: 0 0 auto;
    padding: 8px 13px;
    font-size: 11px;
  }

  /* 桌面端的侧栏内滚动改为整页滚动 */
  .list {
    max-height: none;
    overflow: visible;
    padding: 0;
    border-bottom: 0;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .group:first-child { margin-top: 14px; }
  .play-item { padding: 13px 10px 13px 12px; }
  .play-item .body { flex: 1 1 auto; }
  .play-item::after {
    content: "›";
    align-self: center;
    padding-left: 6px;
    font-size: 17px;
    line-height: 1;
    color: var(--text-faint);
  }

  /* 手机端：目录 / 详情 分屏 */
  body:not(.view-detail) .detail { display: none; }
  body.view-detail .site-head,
  body.view-detail .preface,
  body.view-detail .sidebar { display: none; }
  body.view-detail .layout { padding-top: 0; }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    margin: 0 -22px 20px;
    padding: 10px 22px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .back-btn {
    flex: 0 0 auto;
    padding: 9px 14px;
    font-family: var(--sans);
    font-size: 12px;
    letter-spacing: 0.08em;
    color: var(--gold);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 2px;
    cursor: pointer;
  }
  .back-btn:active { background: rgba(201, 168, 106, 0.08); }
  .bar-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: var(--text-dim);
  }

  .detail { min-height: 0; scroll-margin-top: 0; }
  .detail-head h2 { font-size: 32px; }
  .detail-head h2.long { font-size: 23px; line-height: 1.5; }
  .detail-head .alt { text-align: left; padding-bottom: 2px; }
  .quote { font-size: 17.5px; padding-left: 16px; }
  .quote-src, .quote-note { padding-left: 18px; }
  .fate p { font-size: 14.5px; }

  .back-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 26px;
    padding: 14px;
    font-family: var(--sans);
    font-size: 12px;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 2px;
    cursor: pointer;
  }

  .foot-inner { padding: 24px 22px 40px; }
  .pwa-note {
    display: block;
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px dashed rgba(200, 168, 106, 0.22);
    font-size: 11.5px;
    line-height: 1.8;
    letter-spacing: 0.02em;
    color: var(--text-faint);
  }
}

@media (max-width: 540px) {
  .head-inner { flex-wrap: wrap; row-gap: 14px; }
  .head-actions { margin-left: auto; }
  .detail-head { display: block; }
  .detail-head .alt { margin-top: 10px; padding-bottom: 0; text-align: left; }
}

@media (max-width: 480px) {
  h1 { font-size: 18px; letter-spacing: 0.14em; }
  .sub { font-size: 10.5px; letter-spacing: 0.08em; }
  .seal { width: 44px; height: 44px; font-size: 23px; }
  .brand { gap: 13px; }
  .ghost-btn { padding: 7px 10px; font-size: 10px; }
  .detail-head h2 { font-size: 27px; }
  .chapter-box { padding: 16px 17px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .detail-inner { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
