:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --ink: #17201d;
  --muted: #66716c;
  --line: #dce3df;
  --green: #0d8065;
  --violet: #6650a4;
  --violet-soft: #ebe4fb;
  --violet-line: rgba(102, 80, 164, 0.28);
  --blue: #2457a6;
  --blue-soft: #dce8fb;
  --blue-line: rgba(36, 87, 166, 0.26);
  --paper: #fbfaf7;
  --shadow: 0 22px 60px rgba(24, 39, 33, 0.1);
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif CJK SC", "STSong",
    "SimSun", Georgia, serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

.shell {
  width: min(880px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 30px;
}

.shell.wide {
  width: min(1120px, calc(100% - 36px));
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
}

.topbar .brand .mark {
  width: 10px;
  height: 26px;
  flex: 0 0 10px;
  border-radius: 999px;
  background: var(--violet);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-weight: 700;
}

.topbar nav a:hover {
  color: var(--violet);
}

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

.hero {
  padding: 30px 32px 32px;
  margin-bottom: 26px;
  background:
    linear-gradient(135deg, rgba(102, 80, 164, 0.13), transparent 38%),
    linear-gradient(145deg, #ffffff 0%, #f1eefa 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--violet);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.hero h1 {
  margin-bottom: 14px;
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.15;
}

.hero .lead {
  max-width: 620px;
  margin-bottom: 0;
  color: #36423e;
  font-size: 18px;
}

/* ---------- 经文全文 ---------- */

.sutra-full {
  padding: 30px 34px;
  margin-bottom: 26px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sutra-full .kicker {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sutra-full .title {
  margin-bottom: 6px;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 700;
}

.sutra-full .byline {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 14px;
}

.sutra-full .body {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 2.05;
  text-align: justify;
}

/* ---------- 目录 ---------- */

.toc {
  margin-bottom: 26px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding: 0 2px;
}

.section-head h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.section-head .note {
  color: var(--muted);
  font-size: 13px;
}

.toc-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.toc-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease;
}

a.toc-item:hover {
  transform: translateY(-2px);
  border-color: var(--violet-line);
  box-shadow: 0 14px 34px rgba(102, 80, 164, 0.12);
}

.toc-num {
  flex: 0 0 34px;
  color: var(--violet);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.toc-text {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
}

.toc-meta {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- 分段页 ---------- */

.seg-head {
  padding: 26px 30px 28px;
  margin-bottom: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--violet);
  border-radius: 8px;
}

.seg-head .step {
  margin-bottom: 12px;
  color: var(--violet);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.seg-head .sutra-line {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(23px, 3vw, 31px);
  font-weight: 700;
  line-height: 1.75;
}

.seg-head .outline {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

/* ---------- 讲解卡片 ---------- */

.teaching {
  padding: 26px 30px 28px;
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.teaching.xuanhua {
  border-top: 3px solid var(--violet);
}

.teaching.huangnianzu {
  border-top: 3px solid var(--blue);
}

.teaching-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.teaching-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 23px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.xuanhua .tag {
  color: var(--violet);
  background: var(--violet-soft);
}

.huangnianzu .tag {
  color: var(--blue);
  background: var(--blue-soft);
}

.teaching-head .work {
  color: var(--muted);
  font-size: 13px;
}

.verse {
  padding: 22px 24px;
  margin-bottom: 22px;
  background: var(--paper);
  border: 1px solid var(--violet-line);
  border-radius: 8px;
}

.verse .verse-label {
  margin-bottom: 14px;
  color: var(--violet);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
}

.verse .couplets {
  display: grid;
  gap: 7px;
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.7;
  letter-spacing: 0.04em;
  text-align: center;
}

.verse .couplets .gap {
  height: 10px;
}

.prose p {
  margin: 0 0 17px;
  font-size: 16.5px;
  line-height: 1.95;
  text-align: justify;
}

.prose p:last-child {
  margin-bottom: 0;
}

.empty-note {
  margin: 0;
  padding: 18px 20px;
  color: var(--muted);
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.8;
}

/* ---------- 学习记录 ---------- */

.day-mark {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 30px 2px 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.day-mark::after {
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
  content: "";
}

.turn {
  padding: 22px 26px 24px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  scroll-margin-top: 18px;
}

.turn.ask {
  background: var(--paper);
  border-left: 4px solid var(--violet);
}

.turn-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.turn-who {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 26px;
  border-radius: 999px;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
}

.ask .turn-who {
  color: var(--violet);
  background: var(--violet-soft);
}

.reply .turn-who {
  color: var(--muted);
  background: #eef2f0;
}

.turn-seg {
  color: var(--muted);
  font-size: 12.5px;
}

.turn-seg a {
  color: var(--green);
  border-bottom: 1px solid rgba(13, 128, 101, 0.3);
}

.turn .prose hr {
  height: 1px;
  margin: 20px 0;
  border: 0;
  background: var(--line);
}

.turn .prose p.cut {
  padding: 9px 14px;
  margin: 16px 0;
  color: var(--muted);
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
}

.ask .prose p.cut {
  background: var(--surface);
}

.seg-study {
  margin: 16px 0 0;
  font-size: 14px;
  font-weight: 700;
}

.seg-study a {
  color: var(--green);
  border-bottom: 1px solid rgba(13, 128, 101, 0.35);
}

/* ---------- 出处 ---------- */

.attrib {
  padding: 20px 24px;
  margin-bottom: 22px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.85;
}

.attrib strong {
  color: var(--ink);
}

.attrib a {
  color: var(--green);
  border-bottom: 1px solid rgba(13, 128, 101, 0.35);
  word-break: break-all;
}

.attrib dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 14px;
  margin: 0;
}

.attrib dt {
  color: #8b958f;
  font-weight: 700;
  white-space: nowrap;
}

.attrib dd {
  margin: 0;
}

/* ---------- 段间导航 ---------- */

.seg-nav {
  display: flex;
  gap: 12px;
  margin-bottom: 26px;
}

.seg-nav a,
.seg-nav span {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  padding: 15px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.seg-nav span {
  opacity: 0.45;
}

.seg-nav .dir {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.seg-nav .what {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seg-nav .next {
  text-align: right;
}

.seg-nav a:hover {
  border-color: var(--violet-line);
}

/* ---------- 卡片（首页模块） ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 24px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.card.pending {
  border-style: dashed;
  background: #fcfcfb;
}

.card .card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.card h3 {
  margin-bottom: 9px;
  font-family: var(--serif);
  font-size: 21px;
  line-height: 1.35;
}

.card p {
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.card .card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 104px;
  min-height: 38px;
  margin-top: auto;
  padding: 0 15px;
  color: #ffffff;
  background: var(--violet);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 800;
}

.card .card-action.disabled {
  color: #69746f;
  background: #eef2f0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.live {
  color: var(--green);
  background: #d9f1e9;
}

.badge.reserve {
  color: var(--violet);
  background: var(--violet-soft);
}

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

.footer {
  width: min(880px, calc(100% - 36px));
  margin: 0 auto;
  padding: 22px 0 30px;
  border-top: 1px solid var(--line);
  color: #71807a;
  font-size: 13px;
  line-height: 1.9;
}

.footer .row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.footer a {
  color: var(--green);
}

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

@media (max-width: 760px) {
  .shell,
  .shell.wide,
  .footer {
    width: min(100% - 24px, 680px);
  }

  .shell {
    padding-top: 20px;
  }

  .hero,
  .sutra-full,
  .seg-head,
  .teaching {
    padding-left: 20px;
    padding-right: 20px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .toc-item {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .toc-meta {
    flex-basis: 100%;
    text-align: left;
  }

  .seg-nav {
    flex-direction: column;
  }

  .seg-nav .next {
    text-align: left;
  }

  .sutra-full .body {
    font-size: 17.5px;
    line-height: 1.95;
  }

  .prose p {
    font-size: 16px;
    line-height: 1.9;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a;
    --surface: #1c2124;
    --ink: #e6ebe8;
    --muted: #9aa5a0;
    --line: #2c3336;
    --paper: #1f2427;
    --violet: #b3a0e0;
    --violet-soft: rgba(179, 160, 224, 0.16);
    --violet-line: rgba(179, 160, 224, 0.34);
    --blue: #8fb5ef;
    --blue-soft: rgba(143, 181, 239, 0.16);
    --blue-line: rgba(143, 181, 239, 0.32);
    --green: #5cc4a5;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.4);
  }

  .hero {
    background:
      linear-gradient(135deg, rgba(179, 160, 224, 0.14), transparent 38%),
      linear-gradient(145deg, #1e2327 0%, #232232 100%);
  }

  .card.pending {
    background: #191e21;
  }

  .card .card-action.disabled {
    color: #9aa5a0;
    background: #262c30;
  }

  .badge.live {
    color: var(--green);
    background: rgba(92, 196, 165, 0.16);
  }

  .card .card-action {
    color: #14181a;
  }
}
