/* ---------- detail ---------- */
.detail {
  height: 100vh;
  overflow: auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 24px 28px;
  position: relative;
  min-width: 0;
  opacity: 1;
  transition: opacity .18s ease, padding .24s ease, border-color .24s ease;
}
body.detail-closed .detail {
  overflow: hidden;
  padding-left: 0;
  padding-right: 0;
  border-left-color: transparent;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.detail-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 5;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.detail-close:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}
.detail-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text-soft);
  padding: 6px 11px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.detail-back:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}
.empty {
  color: var(--muted);
  display: grid;
  place-items: center;
  min-height: 70vh;
  font-family: var(--serif);
  font-size: 16px;
}
.detail h1 { font-family: var(--serif); font-size: 25px; font-weight: 600; line-height: 1.3; margin: 0 0 12px; letter-spacing: -0.01em; }
.detail .meta a { color: var(--accent); text-decoration: none; }
.detail .meta a:hover { text-decoration: underline; }
.detail-actions { display: flex; gap: 9px; margin: 16px 0; align-items: center; flex-wrap: wrap; }
.mark-read {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-soft);
}
.mark-read:disabled {
  background: #eef2f7;
  color: #64748b;
  cursor: default;
}

/* 5 星评分：点第 N 颗星直接落库，无需展开下拉再选 */
.rating-group { display: inline-flex; gap: 1px; align-items: center; }
.star-btn {
  border: 0;
  background: transparent;
  padding: 2px 2px;
  font-size: 21px;
  line-height: 1;
  color: var(--line);            /* 空星：浅灰 */
  border-radius: 6px;
  transition: color .1s, transform .05s;
}
.star-btn:hover { background: transparent; transform: scale(1.1); }
.star-btn.on { color: var(--star); }       /* 已评分：金色实星 */
.star-btn.hover { color: var(--star); }    /* 悬停预览：高亮到光标所在星 */

/* 私人笔记：默认折叠成右上角小胶囊，展开成浮层，不占正文空间 */
.note-fold { margin-left: auto; position: relative; }
.note-fold > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  background: var(--panel);
  white-space: nowrap;
  transition: border-color .12s, color .12s;
}
.note-fold > summary::-webkit-details-marker { display: none; }
.note-fold > summary::marker { content: ""; }
.note-fold > summary:hover { border-color: var(--accent); color: var(--text-soft); }
.note-fold.has-note > summary { color: var(--accent); border-color: var(--accent-soft); }
.note-fold.has-note > summary::after { content: " ●"; font-size: 8px; vertical-align: middle; }
.note-fold[open] > summary { border-color: var(--accent); color: var(--text); }
.note-fold[open] > textarea {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 6;
  width: min(380px, 78vw);
  min-height: 110px;
  margin: 0;
  box-shadow: var(--shadow);
}

.content { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 16px; display: grid; gap: 14px; }
.section-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.section-block.major { border-color: var(--accent-soft); }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  background: var(--sidebar);
  border-bottom: 1px solid var(--line);
}
.section-block.major .section-head { background: var(--accent-tint); }
.section-head span { font-weight: 700; font-size: 13px; }
.section-head small { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
/* 维度小节旁一键收藏：靠右、低调，hover/已收藏才点亮 */
.section-fav {
  margin-left: auto;
  align-self: center;
  flex: none;
  padding: 2px 9px;
  font-size: 11px;
  line-height: 1.7;
  white-space: nowrap;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.section-fav:hover { color: var(--accent); border-color: var(--accent); }
.section-fav.saved { color: var(--accent); border-color: var(--accent); background: var(--accent-tint); cursor: default; }
.section-fav:disabled { opacity: .65; }
/* 快捷提问 chips：卡级一行 + 问答弹窗里复用同一套常见问题 */
.quick-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0; }
.quick-ask-lead { font-size: 11px; color: var(--muted); margin-right: 2px; }
.quick-ask-chip {
  padding: 3px 11px;
  font-size: 12px;
  color: var(--text-soft);
  background: var(--sidebar);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.quick-ask-chip:hover { color: var(--accent); border-color: var(--accent); }
.quick-ask:empty { display: none; }
.section-body { padding: 12px 14px; color: var(--text-soft); }
.section-body p { margin: 0 0 10px; }
.section-body p:last-child { margin-bottom: 0; }
.section-body ul { margin: 0; padding-left: 20px; }
.section-body li { margin: 6px 0; }
.orange-highlight {
  color: #b45309;
  background: rgba(245, 158, 11, 0.16);
  border-radius: 4px;
  padding: 0 3px;
  font-weight: 700;
}

/* 原文配图：本地化下载的关键图，卡片内呈现 */
.card-media { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0; }
.card-media-img {
  max-width: 100%;
  max-height: 420px;
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--sidebar);
  cursor: zoom-in;
  object-fit: contain;
  touch-action: manipulation;
}
.card-media-img:hover,
.card-media-img:focus-visible { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 2px; }

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 56px 18px 18px;
  background: rgba(20, 16, 12, .82);
}
.image-lightbox.hidden { display: none; }
.image-lightbox-img {
  max-width: min(96vw, 1280px);
  max-height: calc(100dvh - 86px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  cursor: zoom-out;
  box-shadow: var(--shadow);
}
.image-lightbox-close {
  position: fixed;
  top: 12px;
  right: 12px;
  min-width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.image-lightbox-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 多图轮播：一屏一张，横滑/箭头/圆点切换 */
.card-carousel { position: relative; margin: 8px 0; }
.cc-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}
.cc-track::-webkit-scrollbar { display: none; }
.cc-track .card-media-img {
  flex: 0 0 100%;
  width: 100%;
  scroll-snap-align: center;
  border-radius: var(--radius);
  margin: 0;
}
.cc-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.45); color: #fff;
  font-size: 20px; line-height: 1; cursor: pointer; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
}
.card-carousel:hover .cc-nav { opacity: 1; }
.cc-nav:hover { background: var(--accent); border-color: var(--accent); }
.cc-prev { left: 8px; }
.cc-next { right: 8px; }
.cc-count {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 12px;
}
.cc-dots { display: flex; justify-content: center; gap: 6px; margin-top: 8px; }
.cc-dot {
  width: 7px; height: 7px; padding: 0; border-radius: 50%;
  border: none; background: var(--line); cursor: pointer; transition: background 0.15s;
}
.cc-dot.active { background: var(--accent); }
@media (hover: none) { .cc-nav { display: none; } }   /* 触屏只用横滑+圆点 */

.annotation-panel { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 16px; }
.annotation-panel h3 { margin: 0 0 12px; font-family: var(--serif); font-size: 16px; font-weight: 600; }
.empty-asset { color: var(--muted); }
.annotation {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--sidebar);
}
.annotation-kind { color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.annotation blockquote, #fragmentQuote, #askQuote {
  margin: 0 0 9px;
  padding-left: 11px;
  border-left: 3px solid var(--accent);
  color: var(--text-soft);
}
.annotation p { margin: 0 0 8px; }
.annotation p:last-child { margin-bottom: 0; }
.annotation-note ol, .annotation-note ul, .ask-turn-content ol, .ask-turn-content ul {
  margin: 6px 0 10px;
  padding-left: 22px;
}
.annotation-note li, .ask-turn-content li { margin: 5px 0; }
.annotation-note code, .ask-turn-content code, .section-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--accent-tint);
  color: var(--text);
  font-size: 0.92em;
}
.code-block {
  margin: 10px 0 12px;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sidebar);
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.55;
}
.code-block code {
  padding: 0;
  background: transparent;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
}
.mermaid-block {
  margin: 10px 0 14px;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.mermaid-block svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}
.question { margin: 8px 0; color: var(--accent); font-weight: 600; }

.llm-answer {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: var(--sidebar);
  color: var(--text-soft);
}
.llm-answer.hidden { display: none; }
.ask-turn {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.ask-turn:first-child { padding-top: 0; }
.ask-turn:last-child { border-bottom: 0; padding-bottom: 0; }
.ask-turn.user { color: var(--accent); }
.ask-turn-content p { margin: 0 0 8px; }
.ask-turn-content p:last-child { margin-bottom: 0; }
