/* 书籍百科（baike）插件样式 — bk- 前缀（核心 .card/.btn/.chip 提供基础外观） */

.bk-page {
  display: grid;
  gap: 16px;
}

/* ---------- 列表页（一体化主卡：标题 / 搜索 / 分类 / 内容同卡，避免卡片碎片化） ---------- */

.bk-list {
  padding: 0; /* 卡片内边距清零，头区与内容区自主排布 */
}

.bk-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 20px 14px;
}

.bk-list-titlewrap {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.bk-list-title {
  margin: 0;
  font-family: var(--serif, inherit);
  font-size: 20px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 8px;
}

.bk-list-sub {
  font-size: 13px;
  opacity: .6;
}

.bk-list-search {
  display: flex;
  gap: 8px;
  padding: 0 20px;
}

.bk-list-search input {
  flex: 1;
  min-width: 0;
}

.bk-list-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 16px;
}

.bk-chip.on {
  background: var(--ac);
  border-color: var(--ac);
  color: #fff;
}

/* 内容区：与头区浅线分隔，网格沉入卡内 */
.bk-list-body {
  border-top: 1px solid var(--border, rgba(127, 127, 127, .18));
  padding: 18px 20px 8px;
}

.bk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
}

.bk-entry {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
  background: rgba(127, 127, 127, .05);
  border: 1px solid rgba(127, 127, 127, .14);
  border-radius: var(--radius, 8px);
  transition: transform .15s ease, border-color .15s ease;
}

.bk-entry:hover {
  transform: translateY(-2px);
  border-color: var(--ac);
}

.bk-cover {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--radius, 8px);
}

.bk-cover-empty {
  border: 1px dashed currentColor;
  opacity: .55;
}

.bk-entry-title {
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bk-entry-author {
  font-size: 12px;
  opacity: .65;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 详情页：词条头 ---------- */

.bk-hero {
  display: flex;
  gap: 24px;
  padding: 22px 26px;
}

.bk-hero-cover {
  flex: 0 0 150px;
  width: 150px;
  height: auto;
  align-self: flex-start;
}

/* 无封面占位（通用）：3:4 虚线卡 + 图标居中——尺寸由宿主列宽类（bk-hero-cover / bk-book-cover）提供，
   不复用 bk-cover-empty（那套自身无比例无居中，脱离列表页 bk-cover 基类即塌陷） */
.bk-cover-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 4;
  border: 1px dashed currentColor;
  border-radius: var(--radius, 8px);
  opacity: .55;
  box-sizing: border-box;
}

.bk-hero-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bk-hero-titlebar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.bk-hero-title {
  margin: 0;
  font-family: var(--serif, inherit);
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: .01em;
}

/* 「词条」徽标：百科身份标识 */
.bk-badge {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--ac);
  color: #fff;
  transform: translateY(-2px);
}

.bk-hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bk-chip-tag {
  opacity: .85;
}

/* 信息条：行内紧凑排布（作者 · 浏览 · 更新） */
.bk-hero-facts {
  display: flex;
  flex-wrap: wrap;
  column-gap: 22px;
  row-gap: 4px;
  margin: 0;
  font-size: 13px;
}

.bk-hero-facts > div {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.bk-hero-facts dt {
  opacity: .55;
  flex: 0 0 auto;
}

.bk-hero-facts dd {
  margin: 0;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 摘要块：词条摘录气质（左侧赤陶竖线） */
.bk-hero-abstract {
  margin: 2px 0 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--ac);
  font-size: 14px;
  line-height: 1.75;
}

.bk-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.bk-hero-note {
  margin: 0;
  font-size: 12px;
  opacity: .7;
}

.bk-block-title {
  margin: 0 0 12px;
  font-family: var(--serif, inherit);
  font-size: 16px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- 详情页：正文 + 侧栏双栏 ---------- */

.bk-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.bk-article {
  padding: 6px 28px 18px;
}

/* 分节：编号标题 + 节间分隔线（单卡容器内排全部节，百科词条式） */
.bk-sec {
  scroll-margin-top: 76px; /* 锚点跳转避让顶栏 */
  padding-top: 18px;
}

.bk-sec + .bk-sec {
  margin-top: 6px;
  border-top: 1px solid rgba(127, 127, 127, .15);
}

.bk-sec-title {
  margin: 0 0 12px;
  font-family: var(--serif, inherit);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 10px;
}

.bk-sec-num {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--ac);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
}

.bk-section-body {
  font-size: 14px;
  line-height: 1.8;
}

.bk-article-empty {
  margin: 0;
  padding: 28px 0;
  text-align: center;
  font-size: 14px;
  opacity: .65;
}

.bk-article-foot {
  margin: 18px 0 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(127, 127, 127, .15);
  font-size: 12px;
  opacity: .65;
}

.bk-last-edit-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 8px 12px;
  border-radius: var(--radius-s, 6px);
  background: rgba(127, 127, 127, .08);
  font-size: 13px;
}

/* 待审核提示（编辑页：提交人视角；词条页：管理员视角） */
.bk-pend-bar {
  border-left: 3px solid #c9a227;
}

/* 基础字段锁定提示（绑定书单库的词条编辑页：灰蓝左线，区别于琥珀的待审条） */
.bk-lock-bar {
  border-left: 3px solid rgba(90, 130, 180, .8);
  background: rgba(90, 130, 180, .08);
}

.bk-pend-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border-left: 3px solid #c9a227;
  font-size: 14px;
}

/* 状态 chip：待审核（琥珀）/ 已驳回（灰） */
.bk-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.7;
  vertical-align: middle;
}

.bk-chip-pend {
  background: rgba(201, 162, 39, .15);
  color: #a8841f;
}

.bk-chip-off {
  background: rgba(127, 127, 127, .15);
  color: inherit;
  opacity: .75;
}

.bk-last-edit-bar a,
.bk-last-editor {
  font-weight: 600;
  color: var(--ac);
  text-decoration: none;
}

.bk-last-edit-bar a:hover,
.bk-last-editor:hover {
  text-decoration: underline;
}

.bk-article-foot a {
  color: var(--ac);
  text-decoration: none;
}

.bk-article-sep {
  margin: 0 6px;
}

/* 侧栏：目录 / 收录卡 / 相关词条（粘性跟随） */
.bk-aside {
  position: sticky;
  top: 76px; /* 与 .bk-sec 的 scroll-margin-top 同口径：避让吸顶导航 */
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.bk-toc {
  padding: 14px 16px;
}

.bk-toc-head {
  font-size: 13px;
  font-weight: 700;
  opacity: .6;
  letter-spacing: .1em;
  margin-bottom: 8px;
}

.bk-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bk-toc-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-s, 6px);
  text-decoration: none;
  color: inherit;
  font-size: 13px;
  line-height: 1.5;
}

.bk-toc-list a:hover {
  background: rgba(127, 127, 127, .1);
}

.bk-toc-list em {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  color: var(--ac);
  min-width: 14px;
  text-align: center;
}

.bk-book,
.bk-related {
  padding: 16px;
}

.bk-book-row {
  display: flex;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.bk-book-cover {
  flex: 0 0 90px;
  width: 90px;
  height: auto;
}

.bk-book-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bk-book-title {
  font-family: var(--serif, inherit);
  font-size: 15px;
  font-weight: 600;
}

.bk-book-intro,
.bk-tc-intro {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  opacity: .75;
}

.bk-book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  opacity: .75;
}

/* 数据项：图标与数字留呼吸空隙（gap 5px），弱化图标存在感 */
.bk-mi {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.bk-mi svg {
  flex: 0 0 auto;
  opacity: .55;
}

.bk-related-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bk-related-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  text-decoration: none;
  color: inherit;
  font-size: 14px;
}

.bk-related-list em {
  font-style: normal;
  font-size: 12px;
  opacity: .6;
  flex: 0 0 auto;
}

/* ---------- 表单页 ---------- */

.bk-pick,
.bk-form,
.bk-err {
  padding: 16px 20px;
}

.bk-pick-tip,
.bk-picked {
  margin: 0 0 12px;
  font-size: 13px;
  opacity: .8;
}

.bk-pick-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bk-pick-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(127, 127, 127, .25);
}

.bk-pick-list li a {
  text-decoration: none;
  font-weight: 600;
}

.bk-pick-list li span {
  font-size: 12px;
  opacity: .6;
  flex: 0 0 auto;
}

.bk-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bk-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.bk-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.bk-label {
  font-size: 13px;
  font-weight: 600;
  opacity: .85;
}

.bk-input {
  width: 100%;
  box-sizing: border-box;
}

.bk-bind-tip {
  font-size: 12px;
  opacity: .65;
}

/* 分节槽位：右上角删除按钮（JS 可用时显示），主体字段区避让按钮位 */
.bk-sec-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 44px 12px 12px;
  border: 1px dashed rgba(127, 127, 127, .35);
  border-radius: var(--radius, 8px);
}

.bk-sec-limit {
  margin-left: auto;
  font-size: 12px;
  font-weight: normal;
  opacity: .55;
}

/* 增删按钮 / Markdown 工具栏默认隐藏（无 JS 退化），脚本就绪后 html.bk-js-on 显示 */
.bk-sec-del,
.bk-sec-add,
.bk-sec-tools {
  display: none;
}

.bk-js-on .bk-sec-del,
.bk-js-on .bk-sec-add {
  display: inline-flex;
}

.bk-js-on .bk-sec-tools {
  display: flex;
}

.bk-sec-tools {
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.bk-tool {
  padding: 3px 10px;
  border: 1px solid rgba(127, 127, 127, .3);
  border-radius: var(--radius-s, 6px);
  background: transparent;
  color: inherit;
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
}

.bk-tool:hover {
  border-color: var(--ac);
  color: var(--ac);
}

.bk-sec-del {
  position: absolute;
  top: 10px;
  right: 10px;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(127, 127, 127, .12);
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.bk-sec-del:hover {
  background: var(--ac);
  color: #fff;
}

.bk-sec-add {
  align-self: flex-start;
}

/* 分节预览区：核心 /preview 端点 md_render 渲染（与发帖预览同管线），图片直接可见 */
.bk-sec-preview {
  padding: 12px 14px;
  border: 1px dashed rgba(127, 127, 127, .35);
  border-radius: var(--radius, 8px);
  background: rgba(127, 127, 127, .06);
}

.bk-form-actions {
  display: flex;
  gap: 10px;
}

.bk-err p {
  margin: 0;
  font-size: 14px;
}

/* ---------- 书页 / 帖页注入卡 ---------- */

.bk-thread-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
  padding: 14px 16px;
}

.bk-tc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.bk-tc-head .chip {
  margin-left: auto;
}

.bk-tc-title {
  font-family: var(--serif, inherit);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

.bk-tc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  opacity: .7;
}

.bk-tc-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

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

/* 平板及以下：双栏退化单栏，正文优先，侧栏沉底 */
@media (max-width: 1024px) {
  .bk-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .bk-aside {
    position: static;
  }

  .bk-toc-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .bk-toc-list a {
    padding: 4px 10px;
    background: rgba(127, 127, 127, .08);
  }
}

@media (max-width: 640px) {
  .bk-list-head {
    padding: 14px 16px 10px;
  }

  .bk-list-search {
    padding: 0 16px;
  }

  .bk-list-chips {
    padding: 10px 16px 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .bk-list-body {
    padding: 14px 16px 4px;
  }

  .bk-hero {
    flex-direction: column;
    gap: 16px;
    padding: 18px;
  }

  .bk-hero-cover {
    flex: 0 0 135px;
    width: 135px;
  }

  .bk-hero-title {
    font-size: 22px;
  }

  .bk-article {
    padding: 4px 16px 14px;
  }

  .bk-grid {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 10px;
  }

  .bk-book-row {
    flex-direction: column;
  }

  .bk-book-cover {
    flex: 0 0 120px;
    width: 90px;
  }
}

/* ---------- 词条统计 + 突出贡献榜（词条页侧栏卡） ---------- */

.bk-stats {
  padding: 16px;
}

.bk-stats-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}

.bk-stats-list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.bk-stats-list dt {
  flex: 0 0 auto;
  opacity: .55;
}

.bk-stats-list dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.bk-stats-list dd a,
.bk-hist-link {
  color: var(--ac);
  font-weight: 400;
  text-decoration: none;
}

.bk-stats-list dd a:hover,
.bk-hist-link:hover {
  text-decoration: underline;
}

.bk-stats-date {
  display: block;
  font-size: 12px;
  font-weight: normal;
  opacity: .6;
}

.bk-stats-top {
  margin-top: 16px;
}

.bk-top-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bk-top-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bk-top-list li a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.bk-top-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bk-top-list em {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 12px;
  opacity: .6;
}

/* ---------- 历史版本页（仅管理员） ---------- */

.bk-hist {
  padding: 16px;
}

.bk-hist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bk-hist-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  font-size: 13px;
}

.bk-hist-ops {
  display: flex;
  gap: 8px;
}

.bk-hist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bk-hist-table th,
.bk-hist-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(127, 127, 127, .15);
  text-align: left;
}

.bk-hist-table th {
  font-weight: 700;
  opacity: .6;
}

.bk-hist-view-link {
  color: var(--ac);
  text-decoration: none;
  white-space: nowrap;
}

/* 回滚按钮（仅管理员可见）：与「查看」并列，独立小表单 */
.bk-hist-rollback {
  display: inline-block;
  margin-left: 8px;
}

.bk-hist-rollback-btn {
  padding: 2px 10px;
  border: 1px solid rgba(127, 127, 127, .3);
  border-radius: var(--radius-s, 6px);
  background: transparent;
  color: inherit;
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
}

.bk-hist-rollback-btn:hover {
  border-color: var(--ac);
  color: var(--ac);
}
