/* ============ 书房(Study) ============ */
/* 三栏工作台:左 一棵树的侧边栏 · 中 当前文档 · 右 书房助手;没有顶栏,
   右上角一个悬浮工具栏。复用全局 tokens/components 与 nav-*/vibe-* 类。 */

.bk {
  position: fixed;
  inset: 0;
  background: var(--canvas);
  z-index: 5;
}
.bk-body {
  position: absolute;
  inset: 0;
  display: flex;
  gap: var(--inset);
  padding: var(--inset);
}
.bk-nav,
.bk-side {
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--r-2xl);
  overflow: hidden;
  background: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-highlight), 0 0 0 0.5px var(--glass-edge), var(--shadow-2);
}
.bk-nav {
  width: var(--studio-nav-w);
  animation: slide-in-left var(--d-slow) var(--spring);
}
.bk-side {
  width: var(--studio-side-w);
  position: relative;
  animation: slide-in-right var(--d-slow) var(--spring);
}
.bk-side-close {
  position: absolute;
  z-index: 3;
  top: 10px;
  right: 10px;
}
.bk-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-2xl);
  overflow: hidden;
  background: var(--bg-elevated);
  box-shadow: var(--glass-highlight), 0 0 0 0.5px var(--glass-edge), var(--shadow-1);
}
.bk-error {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--canvas);
}
/* 收起后的左缘展开手柄(与画布 nav-expander 同款) */
.bk-expander {
  position: absolute;
  z-index: 25;
  left: var(--inset);
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  color: var(--label-2);
  cursor: pointer;
  transition: color var(--d-fast);
}
.bk-expander:hover {
  color: var(--label);
  box-shadow: var(--glass-highlight), 0 0 0 0.5px var(--glass-edge), var(--shadow-2);
}
/* 右上角悬浮工具栏:保存灯 + 侧栏开关 + 助手开关;助手面板打开时让到它左侧 */
.bk-float {
  position: absolute;
  z-index: 30;
  top: calc(var(--inset) + 8px);
  right: calc(var(--inset) + 8px);
  display: flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 6px 0 12px;
  border-radius: var(--r-full);
  transition: right var(--d-slow) var(--spring);
}
.bk.side-open .bk-float {
  right: calc(var(--inset) * 2 + var(--studio-side-w) + 8px);
}
.bk-top-sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--separator);
}
.bk-top-ico {
  color: var(--tint-text, var(--brand));
}

/* ---------- 侧边栏(一棵树) ---------- */
.bk-tree {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.bk-side-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 10px 2px;
}
.bk-side-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  font: 650 13px/1 var(--font);
  color: var(--label);
  text-align: left;
  transition: background var(--d-fast);
}
.bk-side-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bk-side-title:hover,
.bk-side-title.is-on {
  background: var(--hover);
}
.bk-side-search {
  flex: none;
  padding: 6px 10px 4px;
}
.bk-tree-body {
  flex: 1;
  min-height: 0;
  padding: 0 8px 10px;
}
.bk-tree-foot {
  flex: none;
  padding: 6px 14px 10px;
  border-top: 0.5px solid var(--separator);
  font: var(--t-footnote);
}
.bk-sec {
  margin-top: 6px;
}
.bk-sec > .nav-list {
  margin-left: 14px;
}
.bk-vol {
  margin-top: 2px;
}
.bk-vol-head .nav-section-toggle {
  font-weight: 600;
  color: var(--label-2);
}
.bk-vol-head .nav-section-ico {
  color: var(--label-3);
}
.bk-row .nav-kind-ico {
  color: var(--label-3);
}
.bk-row.is-selected .nav-kind-ico {
  color: var(--brand);
}
.bk-role-dot {
  flex: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  font: 650 10px/1 var(--font);
  color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 62% 60%), hsl(calc(var(--h) + 40) 58% 44%));
}
/* 侧栏行:名称 + 内容缩略(第二行) */
.bk-row-sub {
  font: 400 10.5px/1.4 var(--font);
  color: var(--label-4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bk-ch-words {
  flex: none;
  font: 500 10.5px/1 var(--font);
}
.bk-ch-more {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: var(--label-4);
  opacity: 0;
  transition: opacity var(--d-fast), background var(--d-fast), color var(--d-fast);
}
.bk-row:hover .bk-ch-more,
.bk-ch-more:focus-visible {
  opacity: 1;
}
.bk-ch-more:hover {
  background: var(--hover);
  color: var(--label);
}
.bk-row.is-fresh {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  box-shadow: inset 0 0 0 0.5px color-mix(in srgb, var(--brand) 35%, transparent);
}
.bk-ch-fresh {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: te-save-pulse 1.1s ease-in-out infinite;
}
.bk-ch-add {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 2px;
  padding: 6px 8px;
  border-radius: var(--r-md);
  font: 500 12px/1 var(--font);
  color: var(--label-3);
  transition: background var(--d-fast), color var(--d-fast);
}
.bk-ch-add:hover {
  background: var(--hover);
  color: var(--label);
}
.bk-rename {
  flex: 1;
  min-width: 0;
  height: 26px;
  font-size: 12px;
}
.bk-tree-empty {
  padding: 26px 16px;
  font: var(--t-subhead);
  color: var(--label-3);
  text-align: center;
  line-height: 1.7;
}

/* ---------- 中栏文档页(正文 / 大纲 / 角色卡 / 设定卡 / 书籍信息) ---------- */
.bk-editor {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.bk-editor-empty {
  align-items: center;
  justify-content: center;
  display: flex;
}
.bk-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px;
  text-align: center;
}
.bk-empty-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  color: var(--tint-text, var(--brand));
  background: color-mix(in srgb, var(--tint-text, var(--brand)) 12%, transparent);
}
.bk-empty h3 {
  font: var(--t-title3);
}
.bk-empty p {
  max-width: 380px;
  font: var(--t-subhead);
  color: var(--label-2);
  line-height: 1.6;
}
.bk-editor-head {
  flex: none;
  padding: 14px 20px 0;
  /* 悬浮工具栏压在右上角,标题行右侧留出空位 */
  padding-right: 28px;
}
.bk-editor-eyebrow {
  font: var(--t-footnote);
}
.bk-editor-eyebrow .icon {
  vertical-align: -2px;
}
.bk-editor-titlerow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 2px 0 8px;
}
.bk-editor-title {
  font: 650 22px/1.3 var(--font-display, var(--font));
  color: var(--label);
  padding: 1px 6px;
  margin-left: -6px;
  border-radius: 8px;
  cursor: text;
  min-width: 60px;
}
.bk-editor-title:hover {
  background: var(--hover);
}
.bk-editor-title.is-static {
  cursor: default;
}
.bk-editor-title.is-static:hover {
  background: transparent;
}
.bk-title-input {
  font: 650 20px/1.3 var(--font);
  color: var(--label);
  height: 34px;
  padding: 0 6px;
  min-width: 200px;
  flex: 0 1 auto;
}
.bk-entry-name {
  flex: 1 1 240px;
  max-width: 420px;
  margin-left: -6px;
  border: 0;
  background: transparent;
  border-radius: 8px;
}
.bk-entry-name:hover {
  background: var(--hover);
}
.bk-entry-name:focus-visible {
  background: var(--fill-4);
  box-shadow: inset 0 0 0 1px var(--brand);
}
.bk-entry-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 0 10px;
}
.bk-entry-meta-sep {
  width: 1px;
  height: 16px;
  margin: 0 6px;
  background: var(--separator);
}
.bk-entry-meta-label {
  font: 650 11px/1 var(--font);
}
.bk-entry-role {
  width: 190px;
}
/* 定位徽标 + 弹层 */
.bk-role-pick-wrap {
  display: inline-flex;
}
.bk-role-pick {
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 9px;
}
.bk-role-pick-form {
  display: flex;
  padding: 6px 4px 2px;
  border-top: 0.5px solid var(--separator);
  margin-top: 4px;
}
.bk-role-pick-form .input {
  width: 100%;
}
/* 标签编辑器 */
.bk-tags-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
.bk-tag-text {
  font: inherit;
  color: inherit;
}
.bk-tag-edit {
  width: 64px;
  height: 16px;
  border: 0;
  background: transparent;
  font: 500 10.5px/1 var(--font);
  color: var(--label);
  border-bottom: 1px solid var(--brand);
}
.bk-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-wrap: wrap;
}
.bk-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--r-full);
  font: 500 12px/1 var(--font);
  color: var(--label-2);
  transition: background var(--d-fast), color var(--d-fast), box-shadow var(--d-fast);
}
.bk-action:hover {
  background: var(--fill-3);
  color: var(--label);
  box-shadow: inset 0 0 0 0.5px var(--separator);
}
.bk-action .icon {
  color: var(--brand);
}
.bk-action.is-danger .icon {
  color: var(--red);
}
.bk-action.is-danger:hover {
  color: var(--red);
}
/* 格式工具条沿用 te-toolbar,这里去掉顶部圆角让纸面贴合 */
.bk-toolbar.te-toolbar {
  height: 42px;
  margin: 0 20px;
  border: 0.5px solid var(--separator);
  border-radius: 12px 12px 0 0;
  border-bottom: 0;
  background: var(--fill-4);
}
.bk-paper {
  flex: 1;
  min-height: 0;
  margin: 0 20px 14px;
  padding: 18px 0 120px;
  border: 0.5px solid var(--separator);
  border-radius: 0 0 12px 12px;
  background: var(--bg-elevated);
}
.bk-info-paper {
  border-radius: 12px;
  padding: 20px 28px 40px;
}
.bk-info-paper .bk-info {
  padding: 0;
  max-width: 900px;
  margin: 0 auto;
}
.bk-editor-rt.rt-root {
  width: min(1040px, 100%);
  margin: 0 auto;
  max-height: none;
  overflow: visible;
  padding: 0 30px;
}
.bk-editor-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px 12px;
  border-top: 0.5px solid var(--separator);
}
.bk-foot-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border-radius: 9px;
  font: 500 11.5px/1 var(--font);
  color: var(--label-3);
  max-width: 180px;
  overflow: hidden;
  white-space: nowrap;
  transition: background var(--d-fast), color var(--d-fast);
}
.bk-foot-btn:hover:not(:disabled) {
  background: var(--hover);
  color: var(--label);
}
.bk-foot-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- 角色头像(条目页) ---------- */
.bk-role-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font: 650 16px/1 var(--font-display, var(--font));
  color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 62% 60%), hsl(calc(var(--h) + 40) 58% 44%));
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.18);
}

/* ---------- 书籍信息表单 ---------- */
.bk-info {
  flex: 1;
  min-height: 0;
  padding: 2px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bk-info-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--fill-4);
  box-shadow: inset 0 0 0 0.5px var(--separator);
}
.bk-info-cover {
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: var(--tint-text, var(--brand));
  background: color-mix(in srgb, var(--tint-text, var(--brand)) 14%, transparent);
}
.bk-info-cover .icon {
  width: 26px;
  height: 26px;
}
.bk-info-title {
  display: block;
  font: 600 15px/1.35 var(--font);
  color: var(--label);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bk-info-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bk-info-field .field-label {
  font: 650 11.5px/1 var(--font);
  color: var(--label-2);
}
.bk-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  border-radius: var(--r-md);
  background: var(--fill-4);
  box-shadow: inset 0 0 0 0.5px var(--separator);
}
.bk-tag-input {
  flex: 1;
  min-width: 88px;
  border: 0;
  background: transparent;
  font: var(--t-footnote);
  color: var(--label);
}
.bk-tag-input:focus-visible {
  box-shadow: none;
}
.bk-info-nums {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bk-info-hint {
  font: var(--t-footnote);
  margin-top: -6px;
}

/* ---------- 右栏变更卡 ---------- */
.bk-change {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-elevated);
  box-shadow: inset 0 0 0 0.5px var(--separator);
  font: var(--t-footnote);
  animation: pop-in var(--d) var(--spring);
}
.bk-change-ico {
  color: var(--green);
  margin-top: 1px;
}
.bk-change.is-undone .bk-change-ico {
  color: var(--label-4);
}
.bk-change-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bk-change-text strong {
  font: 600 12px/1.4 var(--font);
  color: var(--label);
}
.bk-change-text small {
  line-height: 1.45;
}
.bk-change.is-undone .bk-change-text strong {
  color: var(--label-3);
  text-decoration: line-through;
}
.bk-change-undo {
  flex: none;
  height: 22px;
  padding: 0 9px;
  border-radius: var(--r-full);
  font: 600 11px/1 var(--font);
  color: var(--brand);
  background: var(--brand-soft);
  transition: filter var(--d-fast);
}
.bk-change-undo:hover {
  filter: brightness(1.06);
}
.bk-change-state {
  flex: none;
  align-self: center;
  font: 500 11px/1 var(--font);
}

/* ---------- 列表页附加 ---------- */
.bk-card-kind {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-full);
  font: 500 10.5px/1 var(--font);
  color: var(--tint);
  background: color-mix(in srgb, var(--tint) 12%, transparent);
}
.bk-row-stat {
  font: 500 11px/1 var(--font);
  color: var(--label-3);
}
.bk-new-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bk-new-kind-desc {
  font: var(--t-footnote);
  margin-top: -4px;
}
.bk-new-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

/* ---------- 窄屏:左右栏覆盖 ---------- */
@media (max-width: 1100px) {
  .bk-nav,
  .bk-side {
    position: absolute;
    z-index: 30;
    top: var(--inset);
    bottom: var(--inset);
    box-shadow: var(--glass-highlight), 0 0 0 0.5px var(--glass-edge), var(--shadow-4);
  }
  .bk-nav {
    left: var(--inset);
  }
  .bk-side {
    right: var(--inset);
  }
  .bk.side-open .bk-float {
    right: calc(var(--inset) + 8px);
    top: auto;
    bottom: calc(var(--inset) + 8px);
  }
  .bk-paper,
  .bk-toolbar.te-toolbar {
    margin-left: 16px;
    margin-right: 16px;
  }
  .bk-editor-head,
  .bk-editor-foot {
    padding-left: 16px;
    padding-right: 16px;
  }
}
