/* === 安全五点半 · 研讨会沉淀 =================================
   设计取向：与 books 同套语言（米白纸面 / 衬线正文 / 克制动效）
   主色改为紫色系（呼应研讨会卡片 cover_color）
   ============================================================ */

:root {
  --bg: #f4f0e6;
  --paper: #fbf7ec;
  --ink: #2b2a26;
  --ink-soft: #4e4b44;
  --muted: #8b8678;
  --accent: #7c3aed;            /* 研讨会紫 */
  --accent-soft: #a855f7;
  --accent-ink: #ffffff;
  --rule: #d9d2c2;
  --highlight: #fff3b8;
  --danger: #b3261e;
  --success: #2f7d4f;
  --shadow-sm: 0 1px 2px rgba(31, 28, 22, .08);
  --shadow-md: 0 8px 28px rgba(31, 28, 22, .12);
  --maxw: 1080px;
  --gap: 24px;
}

[data-theme="dark"] {
  --bg: #1a1326;
  --paper: #221a33;
  --ink: #ece4d2;
  --ink-soft: #c0b89f;
  --muted: #8c8472;
  --accent: #c084fc;
  --accent-soft: #d8b4fe;
  --accent-ink: #1a1326;
  --rule: #2e2444;
  --highlight: #574f1f;
  --danger: #ff8979;
  --success: #6dd49a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.78;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 36px; height: 36px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font-family: "Noto Sans SC", sans-serif; font-weight: 700;
}
.brand__title { font-size: 18px; font-weight: 600; }
.brand__title em { font-style: normal; font-weight: 400; opacity: .7; }
.brand__sep { margin: 0 6px; opacity: .35; }
.topbar__right { display: flex; gap: 10px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 13px; border: 1px solid var(--rule);
  background: var(--paper); color: var(--ink-soft);
}
.chip--user { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip__avatar { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; }

/* ===== layout ===== */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--gap);
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px;
  min-height: calc(100vh - 70px);
}

/* ===== rail ===== */
.rail {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 16px;
  height: fit-content;
  position: sticky; top: 84px;
  box-shadow: var(--shadow-sm);
}
.rail__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.rail__title { font-size: 16px; margin: 0; font-weight: 600; }
.iconbtn {
  border: 1px solid var(--rule); background: transparent;
  border-radius: 6px; padding: 4px 8px; cursor: pointer; color: var(--ink-soft);
  font-family: inherit;
}
.iconbtn:hover { background: var(--bg); }

.rail__list { list-style: none; margin: 0; padding: 0; }
.card-mini {
  display: flex; gap: 10px;
  padding: 10px; border-radius: 10px;
  color: inherit; text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.card-mini:hover { background: var(--bg); text-decoration: none; }
.card-mini[data-active="true"] {
  background: var(--bg);
  border-color: var(--accent-soft);
}
.card-mini__bar {
  width: 4px; min-width: 4px; border-radius: 2px;
  align-self: stretch;
}
.card-mini__body { flex: 1; min-width: 0; }
.card-mini__ep {
  font-size: 11px; margin: 0 0 4px;
  color: var(--accent); font-weight: 600;
  letter-spacing: 0.04em;
}
.card-mini__title {
  font-size: 14px; font-weight: 600; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-mini__sub {
  font-size: 12px; color: var(--muted); margin: 2px 0 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-mini__meta {
  font-size: 11px; color: var(--muted); margin: 6px 0 0;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg) 25%, var(--rule) 50%, var(--bg) 75%);
  background-size: 400% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.muted { color: var(--muted); font-size: 14px; }

/* ===== reader ===== */
.reader {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 32px 36px;
  box-shadow: var(--shadow-sm);
  min-height: 70vh;
}
.placeholder {
  text-align: center; padding: 80px 20px;
}
.placeholder__big { font-size: 18px; margin: 0 0 8px; }
.error { color: var(--danger); }

.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--rule);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* detail */
.detail__head {
  display: flex; gap: 24px;
  padding-bottom: 24px; margin-bottom: 24px;
  border-bottom: 1px solid var(--rule);
}
.detail__cover {
  width: 120px; height: 160px;
  border-radius: 8px;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}
.detail__ep {
  font-size: 13px; margin: 0 0 8px;
  color: var(--accent); font-weight: 600;
  letter-spacing: 0.06em;
}
.detail__title {
  font-size: 28px; font-weight: 700; margin: 0 0 8px;
  line-height: 1.3;
}
.detail__sub {
  font-size: 15px; color: var(--ink-soft); margin: 0 0 12px;
}
.detail__by {
  font-size: 13px; color: var(--muted); margin: 0 0 16px;
}
.detail__desc {
  font-size: 14px; color: var(--ink-soft);
  padding: 12px 14px;
  background: var(--bg);
  border-left: 3px solid var(--accent-soft);
  border-radius: 0 6px 6px 0;
}

/* CTA row（购买 / 回放 / 音频） */
.cta-row {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin: 0 0 28px;
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-size: 14px; font-family: inherit;
  border: 1px solid var(--rule);
  background: var(--paper); color: var(--ink);
  cursor: pointer; transition: all .15s;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn--primary {
  background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent); font-weight: 600;
}
.btn--primary:hover {
  background: var(--accent-soft); border-color: var(--accent-soft);
  filter: brightness(0.95);
}
.btn--accent {
  background: var(--accent); color: var(--accent-ink);
  border-color: var(--accent);
}
.btn--accent:hover { filter: brightness(0.95); }
.btn--ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* prose：渲染清洗后的 HTML */
.prose { font-size: 16px; line-height: 1.85; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  margin: 28px 0 14px; font-weight: 700; line-height: 1.4;
}
.prose h1 { font-size: 24px; }
.prose h2 { font-size: 20px; border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.prose h3 { font-size: 17px; }
.prose p { margin: 12px 0; }
.prose ul, .prose ol { padding-left: 24px; }
.prose li { margin: 6px 0; }
.prose blockquote {
  margin: 16px 0; padding: 12px 18px;
  border-left: 4px solid var(--accent-soft);
  background: var(--bg);
  color: var(--ink-soft);
  border-radius: 0 6px 6px 0;
}
.prose code {
  background: var(--bg); padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}
.prose pre {
  background: var(--bg); padding: 14px; border-radius: 8px;
  overflow-x: auto;
  border: 1px solid var(--rule);
}
.prose pre code { background: transparent; padding: 0; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose a { color: var(--accent); }
.prose a[href^="http"]:not([href*="i530.vip"]) {
  /* 外链视觉标记 */
}
.prose hr { border: none; border-top: 1px solid var(--rule); margin: 24px 0; }
.prose table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.prose th, .prose td { border: 1px solid var(--rule); padding: 8px 12px; text-align: left; }
.prose th { background: var(--bg); font-weight: 600; }

/* comments */
.comments { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--rule); }
.comments__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.comments__head h3 { margin: 0; font-size: 18px; }
.comments__count { color: var(--muted); font-size: 13px; }

.comments__form { margin-bottom: 24px; }
.comments__form textarea {
  width: 100%; min-height: 80px;
  padding: 10px 12px; border: 1px solid var(--rule);
  border-radius: 8px; background: var(--bg);
  color: var(--ink); font-family: inherit; font-size: 14px;
  resize: vertical;
}
.comments__form textarea:focus {
  outline: none; border-color: var(--accent);
}
.comments__form-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
}
.comments__hint { color: var(--muted); font-size: 12px; }

.comments__list { list-style: none; padding: 0; margin: 0; }
.comments__list li {
  padding: 14px 0;
  border-top: 1px dashed var(--rule);
}
.comments__meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); margin-bottom: 6px;
}
.comments__avatar {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover;
}
.comments__name { color: var(--ink); font-weight: 600; }
.comments__body { font-size: 14px; line-height: 1.7; white-space: pre-wrap; }

/* toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 8px;
  background: var(--ink); color: var(--paper);
  font-size: 14px;
  box-shadow: var(--shadow-md);
  z-index: 100;
}

/* ===== responsive ===== */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
  .rail { position: static; max-height: 240px; overflow-y: auto; }
  .reader { padding: 20px; }
  .detail__head { flex-direction: column; gap: 16px; }
  .detail__cover { width: 100%; height: 140px; }
  .detail__title { font-size: 22px; }
  .prose { font-size: 15px; }
}
