:root {
  color-scheme: light;
  --font-hei: "SimHei", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  --font-kai: "KaiTi", "STKaiti", "Kaiti SC", "SimKai", "KaiTi_GB2312", serif;
  --font-ui: var(--font-hei);
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --text: #1c2521;
  --muted: #66736d;
  --line: #d9e0dc;
  --primary: #2f6f5e;
  --primary-dark: #245548;
  --accent: #8f4a3d;
  --focus: #d19a38;
  --shadow: 0 16px 40px rgba(28, 37, 33, 0.08);
}

:root[data-font="hei"] {
  --font-ui: var(--font-hei);
}

:root[data-font="kai"] {
  --font-ui: var(--font-kai);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.service-ok {
  color: #bce2ce;
  font-weight: 700;
}

.service-warn {
  color: #f1d39a;
  font-weight: 700;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.reader-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

.reader-layout.is-sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.reader-sidebar-stack[hidden] {
  display: none;
}

.reader-main {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

.reader-combined-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  padding-bottom: 12px;
  min-height: 0;
  overflow: hidden;
}

.reader-compare {
  --reader-compare-column-gap: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px var(--reader-compare-column-gap);
  width: 100%;
  min-height: 0;
}

/* 标题栏固定在各自列的第一行，不随折叠状态移动 */
.reader-original-heading {
  grid-area: 1 / 1;
}

.reader-text-heading {
  grid-area: 1 / 2;
}

.reader-annotation-heading {
  grid-area: 1 / 3;
}

.reader-original-panel {
  grid-area: 2 / 1;
}

.reader-text-panel {
  grid-area: 2 / 2;
}

.reader-annotation-panel {
  grid-area: 2 / 3;
}

/* 折叠某侧时，整理文本栏的边缘扩展到原侧栏边缘 */
.reader-compare.is-original-collapsed .reader-text-panel {
  grid-column: 1 / 3;
}

.reader-compare.is-annotation-collapsed .reader-text-panel {
  grid-column: 2 / 4;
}

.reader-compare.is-original-collapsed.is-annotation-collapsed .reader-text-panel {
  grid-column: 1 / -1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.form-panel {
  display: grid;
  gap: 14px;
}

.form-panel > .section-heading {
  margin-bottom: 0;
}

/* 文件选择：原生控件只保留功能（不显示「未选择任何文件」原生提示），外观全部自绘。
   只有绿色按钮是可点的 label，虚线外框不响应点击/悬停，且只框住待合并文件列表。 */
.file-picker-field {
  min-width: 0;
  position: relative;
  display: grid;
  gap: 8px;
}

.file-picker {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2px 8px;
  border: 1px dashed #cdd8d2;
  border-radius: 8px;
  background: #f8fbf9;
}

/* 没有待合并文件时不留空框。 */
.file-picker:not(:has(.file-upload-row)) {
  display: none;
}

.file-picker-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

.file-picker-field input:focus,
.file-picker-field input:focus-visible {
  outline: none;
}

.file-picker-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.file-picker-button:hover {
  background: var(--primary-dark);
}

/* 键盘聚焦到隐藏的原生控件时才给按钮画焦点环（鼠标点开不画），外框始终原样。 */
.file-picker-field:has(input:focus-visible) .file-picker-button {
  box-shadow: 0 0 0 3px rgba(209, 154, 56, 0.28);
}

.file-picker-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-picker-name {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-picker-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 32px;
}

.file-picker-hint {
  color: var(--muted);
  font-size: 12px;
}

.upload-file-list {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.file-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 1px 0;
  border-top: 1px solid var(--line);
}

.file-upload-row:first-child {
  border-top: 0;
}

.file-upload-drag {
  flex: 0 0 auto;
  padding: 2px 3px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: grab;
}

.file-upload-drag:active {
  cursor: grabbing;
}

.file-upload-row.is-dragging {
  opacity: .5;
}

.file-upload-row.is-drop-target {
  background: #e8f1ed;
}

.file-upload-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  margin-left: auto;
}

.file-upload-remove {
  border: 0;
  background: transparent;
  color: #c43838;
  padding: 2px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.file-upload-status {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 24px;
  flex: 0 0 96px;
  font-size: 13px;
}

/* 叠在进度条上，不改变行高与布局；与「上传失败」同一配色。 */
.file-upload-duplicate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

.file-upload-meter {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
}

.file-upload-meter progress {
  appearance: none;
  display: block;
  width: 100%;
  /* 高度容纳 13px 的同名提示文字，提示整体落在进度条内。 */
  height: 16px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: #e0e9e4;
  accent-color: var(--primary);
}

.file-upload-meter progress::-webkit-progress-bar {
  border-radius: 999px;
  background: #e0e9e4;
}

.file-upload-meter progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--primary);
}

.file-upload-meter progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--primary);
}

.file-upload-failed, .registration-error, .file-upload-duplicate, .file-upload-existing {
  color: #c43838;
}

.registration-error:empty {
  display: none;
}

#document-form button:disabled {
  opacity: .5;
  cursor: default;
}

.file-picker-field:has(#file-input:disabled) .file-picker-button {
  opacity: .5;
  cursor: default;
}

.info-field {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.info-field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.info-field-heading span:last-child {
  font-weight: 400;
  white-space: nowrap;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.metadata-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.meta-line,
.result-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.auth-bar { display:inline-flex; align-items:center; gap:0; }
.auth-bar .auth-actions { display:inline-flex; align-items:center; gap:0; }
.auth-bar .auth-user { margin-right:12px; color:var(--muted); font-size:13px; font-weight:700; white-space:nowrap; max-width:200px; overflow:hidden; text-overflow:ellipsis; }
.auth-bar .auth-user.hidden { display:none; }
.auth-modal { position:fixed; inset:0; background:rgba(15,23,42,.38); display:grid; place-items:center; z-index:20; }
.auth-modal.hidden { display:none; }
.auth-card { width:min(360px, calc(100vw - 32px)); background:#fff; padding:24px; border-radius:8px; box-shadow:0 16px 48px rgba(15,23,42,.2); display:grid; gap:12px; }
.auth-card input { padding:10px 12px; border:1px solid #cbd5e1; border-radius:4px; }
.auth-card p { color:#b42318; min-height:20px; margin:0; }

.reader-sidebar-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* 左侧整栏：顶部三个面板开关 + 下方卡片区。
   卡片高度按内容自适应；内容超出可视高度时只滚动卡片区，按钮保持可见。 */
.reader-sidebar-shell {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  padding: 8px;
  overflow: hidden;
}

.reader-sidebar-tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.reader-sidebar-tab {
  min-height: 32px;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.reader-sidebar-tab:hover {
  border-color: #bac7c0;
  background: var(--surface-2);
  color: var(--text);
}

/* 展开状态绿底白字、收起状态白底灰字，按钮状态一眼可分 */
.reader-sidebar-tab[aria-expanded="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.reader-sidebar-tab[aria-expanded="true"]:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.reader-sidebar-cards {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.reader-sidebar-card {
  flex: 0 0 auto;
  min-width: 0;
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.reader-sidebar-card[hidden] {
  display: none;
}

.reader-sidebar-cards-empty {
  margin: 0;
  padding: 18px 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.reader-sidebar-cards-empty[hidden] {
  display: none;
}

/* 进度块整块隐藏（未打开文献）时给出占位说明，避免出现空白卡片 */
.reader-card-empty {
  display: none;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

#reader-stream-progress.hidden + .reader-card-empty {
  display: block;
}

.reader-progress-panel {
  min-width: 0;
  min-height: 0;
}

/* 状态文字为空时不占高度 */
.reader-detail-card > .inline-status:empty {
  display: none;
}

.reader-search-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.reader-search-panel .section-heading { margin-bottom: 0; }
.reader-search-form { display: flex; gap: 8px; }
/* 放大镜 + 输入框同处一个描边框内：边框、圆角、焦点环都画在容器上，
   内层 input 去边框去背景，避免出现「框中框」 */
.reader-search-field {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.15s ease;
}
.reader-search-field:hover { border-color: #bac7c0; }
/* 焦点环画在容器上（与全局 input:focus 的三黄色描边一致），内层 input 不画 */
.reader-search-field:focus-within { border-color: var(--focus); outline: 3px solid rgba(209, 154, 56, 0.28); outline-offset: 2px; }
.reader-search-icon { flex: 0 0 auto; width: 15px; height: 15px; }
.reader-search-field:focus-within .reader-search-icon { color: var(--primary); }
.reader-search-field input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
}
.reader-search-field input:focus,
.reader-search-field input:focus-visible { outline: none; }
/* 保留浏览器自带的搜索清除按钮（输入非空时出现），只把它的边距压掉 */
.reader-search-field input::-webkit-search-cancel-button { margin-right: 0; }
.reader-search-form button { flex-shrink: 0; min-height: 30px; padding: 4px 14px; font-size: 14px; }
.reader-search-status { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.reader-search-status { max-height: 100px; overflow: auto; flex-shrink: 0; }
/* 只有「未找到匹配项。」一种情况，其余时候为空；空时整行退出布局，
   否则它仍会占掉 .reader-search-panel 的两个 flex gap（10px×2） */
.reader-search-status:empty { display: none; }
.reader-search-filters { display: flex; flex-wrap: wrap; gap: 8px 10px; padding: 0; margin: 0; border: 0; }
.reader-search-filters label { display: flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 400; white-space: nowrap; }
.reader-search-filters [data-reader-search-count] { color: var(--muted); font-variant-numeric: tabular-nums; }
/* 嵌入检索失败：计数格显示「失败」（替代数字），悬停 title 给出原因 */
.reader-search-filters [data-reader-search-count].is-failed { color: var(--red); }
/* 类别筛选 + 页码筛选同一行；页码筛选 flex-basis 为 0，所以优先被压缩而不是换行
   （行宽不够时两个页码输入框等比变窄，最低 24px），只有类别筛选自己都放不下时才换行 */
.reader-search-filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; }
.reader-search-filter-row .reader-search-filters { flex: 0 0 auto; }
.reader-search-filter-row .reader-search-page-range { flex: 1 1 0; min-width: 0; }
/* 按页码筛选：第 [起始]-[终止] 页；两个框留空 = 不限页码 */
.reader-search-page-range { display: flex; align-items: center; gap: 2px; padding: 0; margin: 0; border: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.reader-search-page-range input { flex: 0 1 54px; width: 54px; min-width: 20px; padding: 3px 4px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--text); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
/* 去掉数字框的上下箭头，保持行内紧凑 */
.reader-search-page-range input::-webkit-outer-spin-button,
.reader-search-page-range input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.reader-search-page-range input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
/* 三个匹配层级各自的颜色：筛选标签文字与结果表序号列共用。
   注意别用紫色（#7152a3 是本面板的「选中」色：复选框 accent-color、选中行底色/色条、正文当前高亮），
   否则嵌入匹配和选中态会混淆 */
.reader-search-level-exact { color: #2f6f5e; }
.reader-search-level-partial { color: #b27a42; }
.reader-search-level-semantic { color: #2f6d9e; }
.reader-search-panel input[type="checkbox"] { flex: none; width: 14px; height: 14px; margin: 0; padding: 0; accent-color: #7152a3; }
/* 检索结果表：序号 / 匹配文本 / 位置 三列。序号与位置只放数字，列宽压到最小，
   把剩余宽度都留给「匹配文本」列（列宽必须写死：每行是独立的 grid，用 max-content 会各行不齐） */
.reader-search-results-head,
.reader-search-result {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: start;
}

.reader-search-col-center { text-align: center; }

/* 表头随结果列表吸顶（同处一个滚动容器，列宽/滚动条都不会错位） */
.reader-search-results-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0 9px 5px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  border-bottom: 1px solid var(--line);
}

/* 卡片高度随内容自适应；结果列表单独限高并在内部滚动，避免一张卡片占满整栏 */
.reader-search-results { flex: 0 1 auto; max-height: min(50vh, 420px); overflow: auto; margin: 0; padding: 0; list-style: none; }
.reader-search-result-row + .reader-search-result-row { border-top: 1px solid var(--line); }
.reader-search-result { width: 100%; padding: 6px 9px; text-align: left; border: 0; background: transparent; color: var(--text); font-size: 12px; line-height: 1.5; }
.reader-search-result:hover, .reader-search-result:focus-visible { background: #faf7fe; }
.reader-search-result.is-active { background: #f3edfc; box-shadow: inset 2px 0 0 #7152a3; }
.reader-search-result-index { font-variant-numeric: tabular-nums; }
.reader-search-result-text { overflow-wrap: anywhere; white-space: pre-wrap; }
.reader-search-result-page { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 首项|末项 、 上一项|下一项 两个按钮组 + 标注；三个块两端对齐、间距平分 */
.reader-search-action-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
/* 组合样式：组内两个按钮首尾相连、共用中间那条边线 */
.reader-search-nav-group { display: flex; align-items: stretch; }
.reader-search-nav-group .reader-search-nav-button:first-child { border-radius: 6px 0 0 6px; }
.reader-search-nav-group .reader-search-nav-button:last-child { border-radius: 0 6px 6px 0; }
.reader-search-nav-group .reader-search-nav-button + .reader-search-nav-button { margin-left: -1px; }
.reader-search-nav-button {
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
}
.reader-search-nav-button:hover:not(:disabled) { border-color: #bac7c0; background: var(--surface-2); }
.reader-search-nav-button:disabled { opacity: 0.45; cursor: not-allowed; }

/* 「标注全部筛选结果」开关按钮：未启用白底描边，启用绿底白字 */
.reader-search-mark-button {
  min-height: 30px;
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.reader-search-mark-button:hover:not(:disabled) {
  border-color: #bac7c0;
  background: var(--surface-2);
}

.reader-search-mark-button[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.reader-search-mark-button[aria-pressed="true"]:hover:not(:disabled) {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

/* 无筛选结果时与 首项/末项/上一项/下一项 同步禁用 */
.reader-search-mark-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
mark.reader-search-highlight { background: #e8d9fa; color: inherit; padding: 0; border-radius: 2px; }
mark.reader-search-highlight.is-current { background: #c9adf0; box-shadow: inset 0 -2px #7152a3; }

#reader-document-detail {
  margin: 0;
}

/* 复合选择器提升优先级：文件更靠后的 .section-heading 同为单类优先级，
   不加前缀时其 16px 会覆盖这里的值，标题与内容间距偏大 */
.section-heading.reader-detail-heading {
  margin-bottom: 4px;
}

.reader-detail-heading h3 {
  font-size: 14px;
}

/* 无操作按钮时不占高度 */
.reader-detail-actions:empty {
  display: none;
}

.reader-detail-actions .reader-detail-registration-status {
  color: var(--primary);
  white-space: nowrap;
}

.reader-detail-actions,
.conversation-prompt-actions,
.conversation-answer-actions,
.conversation-edit-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 信息栏编辑态：输入框完全不可见，外观与只读文字行一致（相同的字号/行高/左边缘），
   只保留光标与文字本身。不加底色、不加边框、hover/focus 都不改变外观，
   因此切换编辑态时行高与整个面板高度都不变。 */
#reader-document-detail .reader-detail-input {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: normal;
  caret-color: var(--primary);
}

#reader-document-detail .reader-detail-input:hover,
#reader-document-detail .reader-detail-input:focus,
#reader-document-detail .reader-detail-input:focus-visible {
  outline: none;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#reader-document-detail > div {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  font-size: 13px;
}

/* 末行不画分隔线，也不留 8px 下内边距——否则「文献信息」框底部视觉留白
   会比另外两栏多 8px（卡片内边距 20px + 末行 8px）*/
#reader-document-detail > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

#reader-document-detail .metadata-pair-row {
  grid-template-columns: 62px minmax(0, 1fr) 62px minmax(0, 1fr);
  column-gap: 8px;
}

#reader-document-detail dt {
  color: var(--muted);
  font-weight: 700;
  /* 标题两端对齐：2～4 字的标签都撑满标签列（文字少的自动拉开间距），左右边缘对齐 */
  text-align: justify;
  text-align-last: justify;
  white-space: nowrap;
}

#reader-document-detail dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

#reader-document-detail .reader-visibility-row {
  align-items: center;
}

.reader-visibility-options {
  /* 两个选项各占一半宽度（各自左对齐），使「私密」「公开」后的空白一致 */
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-items: start;
  align-items: center;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
}

.reader-visibility-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.3;
  cursor: pointer;
}

.reader-visibility-option input {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  accent-color: var(--primary);
}

.reader-visibility-option.is-disabled {
  cursor: default;
  opacity: 0.62;
}

.reader-stream-status {
  margin-top: 12px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfdfc;
  color: var(--text);
  padding: 10px 11px;
  font-weight: 400;
}

.processing-mode-field {
  display: grid;
  gap: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.processing-mode-field legend {
  margin-bottom: 7px;
  padding: 0;
}

.processing-mode-options {
  display: grid;
  /* 「大串小并」里带着页数输入框，给第一列多一点宽度 */
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

/* 用 label 前缀提升优先级，避免被全局 label { display: grid } 撑成竖排 */
label.processing-mode-option {
  position: relative;
  display: flex;
  margin: 0;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

/* 只隐藏单选按钮本身，别影响选项内部的数字输入框 */
.processing-mode-option > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.processing-mode-option > span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  text-align: center;
  white-space: nowrap;
  transition: border-color 140ms ease, background 140ms ease,
    color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

/* 两行选项：上行标题、下行参数；圆点在左侧与两行整体垂直居中 */
.processing-mode-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.25;
}

.processing-mode-text > strong {
  font-size: 14px;
  font-weight: 600;
}

.processing-mode-text > small {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* 常驻的圆形指示器，选中时填充，避免文字左右跳动 */
.processing-mode-option > span::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: #fff;
  transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.processing-mode-option:hover > span {
  border-color: var(--primary);
  background: #f2f7f5;
}

.processing-mode-option:hover > span::before {
  border-color: var(--primary);
}

.processing-mode-option:active > span {
  transform: translateY(1px);
}

.processing-mode-option input:checked + span {
  border-color: var(--primary);
  background: var(--surface-2);
  color: var(--primary-dark);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.processing-mode-option input:checked + span::before {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 3px #fff;
}

.processing-mode-option input:focus-visible + span {
  outline: 3px solid rgba(209, 154, 56, 0.28);
  outline-offset: 2px;
}

/* 每部分页数：缩在「大串小并」选项里，只有选中该项才可编辑 */
.processing-chunk-size {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  margin-left: 2px;
  font-weight: 700;
  line-height: 1;
}

.processing-chunk-size em {
  font-style: normal;
  opacity: 0.7;
}

.processing-chunk-size input {
  width: 2.4em;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.processing-chunk-size input::-webkit-outer-spin-button,
.processing-chunk-size input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 选中「大串小并」后才有输入框的样子 */
.processing-mode-option > input:checked + span .processing-chunk-size input {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

/* 没选中时就是普通文字，且点击落到整个选项上 */
.processing-chunk-size input:disabled {
  color: inherit;
  -webkit-text-fill-color: currentColor;
  opacity: 0.75;
  pointer-events: none;
}

/* 窄屏改竖排，避免「大串小并 3 页」被挤成单字竖排 */
@media (max-width: 520px) {
  .processing-mode-options {
    grid-template-columns: 1fr;
  }
}

textarea {
  resize: vertical;
  min-height: 360px;
  line-height: 1.7;
}

input:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(209, 154, 56, 0.28);
  outline-offset: 2px;
  border-color: var(--focus);
}

/* 首页底栏输入框无边框，避免聚焦时出现额外焦点框。 */
.smart-input-box textarea:focus,
.smart-input-box textarea:focus-visible {
  outline: none;
  border-color: transparent;
}

.primary-button,
.secondary-button {
  min-height: 38px;
  border-radius: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.secondary-button:hover {
  border-color: #bac7c0;
  background: #e3ebe7;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading h3,
.form-panel h3 {
  margin: 0;
  font-size: 18px;
}

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

.document-list,
.result-list {
  display: grid;
  gap: 10px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.result-item h4 {
  margin: 0 0 6px;
  font-size: 16px;
}

.text-layer {
  gap: 8px;
}

.reader-original-viewer img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.reader-original-viewer {
  display: grid;
  min-height: 0;
  height: 100%;
  place-items: start center;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
  padding: 12px;
}

.reader-nav-row {
  display: flex;
  gap: 12px;
  align-items: end;
}

.reader-nav-row {
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
}

.reader-nav-row {
  justify-content: center;
  padding-top: 14px;
}

.reader-page-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.reader-page-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-width: 138px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.reader-page-jump input {
  width: 48px;
  min-height: 30px;
  padding: 2px 6px;
  border-radius: 6px;
  text-align: center;
}

.reader-page-jump span {
  white-space: nowrap;
}

.empty-state {
  border: 1px dashed #bac7c0;
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.inline-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 38px;
}

/* 进度卡片的外框由 .reader-sidebar-card 提供，这里只负责内部排列 */
.progress-stack {
  display: grid;
  gap: 8px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e6ebe6;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #3e8f76);
  transition: width 0.3s ease;
}

.reader-original-panel,
.reader-text-panel,
.reader-annotation-panel {
  min-height: 0;
  overflow: hidden;
}

.reader-original-panel,
.reader-annotation-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

.reader-text-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

/* 标题栏与内容栏之间的间距由网格行间距控制 */
.reader-compare > .section-heading {
  margin-bottom: 0;
}

.reader-text-heading {
  min-height: 28px;
  justify-content: space-between;
  text-align: left;
}

/* 与左右两栏的标题行保持同高，避免整理文本栏内容整体下移 */
.reader-text-heading .ghost-link {
  min-height: 28px;
  padding: 0 8px;
}

/* 标题栏（第一行）列间两条竖虚线，落在列间空隙正中并撑满行高 */
.reader-text-heading {
  position: relative;
}

.reader-text-heading::before,
.reader-text-heading::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed var(--line);
}

.reader-text-heading::before {
  left: calc(var(--reader-compare-column-gap) / -2);
}

.reader-text-heading::after {
  right: calc(var(--reader-compare-column-gap) / -2);
}

.reader-annotation-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  min-height: 28px;
}

.reader-original-heading {
  min-height: 28px;
  justify-content: flex-start;
}

.reader-original-heading .reader-panel-toggle {
  order: -1;
}

.reader-annotation-heading h3 {
  text-align: right;
}

.reader-annotation-heading .reader-panel-toggle {
  justify-self: end;
}

.reader-annotation-status {
  min-height: 20px;
}

.reader-panel-toggle.icon-button,
.icon-button,
.chat-title-edit,
.conversation-turn-action {
  display: inline-grid;
  place-items: center;
}

.reader-panel-toggle.icon-button {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--primary);
}

/* 侧栏折叠按钮：竖长胶囊（参考 VS Code）。中线压在阅览器面板的左边框线上
   （left = -宽度/2，即 -8.5px）；填充与描边比背景稍重，好在边框线上立起来 */
.reader-main .reader-sidebar-toggle.icon-button {
  position: absolute;
  top: 50%;
  left: -8.5px;
  z-index: 2;
  transform: translateY(-50%);
  width: 17px;
  height: 58px;
  flex: 0 0 auto;
  padding: 0;
  /* 图标比内容盒宽，必须 place-content 居中；只写 place-items 时它会贴左边缘 */
  place-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(28, 37, 33, 0.1);
}

/* 胶囊只有 17px 宽，用透明伪元素把可点区域向四周扩 7px */
.reader-main .reader-sidebar-toggle.icon-button::before {
  content: "";
  position: absolute;
  inset: -7px;
}

.reader-main .reader-sidebar-toggle.icon-button:hover {
  background: #e3ebe7;
  color: var(--primary-dark);
}

.reader-main .reader-sidebar-toggle svg {
  width: 19px;
  height: 19px;
}

/* 侧栏收起后分隔线消失，按钮贴到主区左边缘 */
.reader-layout.is-sidebar-collapsed .reader-sidebar-toggle.icon-button {
  left: 0;
}

.reader-panel-toggle.icon-button:hover {
  background: #e3ebe7;
  color: var(--primary-dark);
}

.reader-panel-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 160ms ease;
}

/* 折叠时只隐藏内容栏，标题栏与按钮保持原位 */
#reader-original-panel.reader-panel-collapsed,
#reader-annotation-panel.reader-panel-collapsed {
  display: none;
}

.reader-layout.is-sidebar-collapsed .reader-sidebar-toggle svg,
.reader-compare.is-original-collapsed .reader-original-heading .reader-panel-toggle svg,
.reader-compare.is-annotation-collapsed .reader-annotation-heading .reader-panel-toggle svg {
  transform: rotate(180deg);
}

.reader-annotation {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--text);
  padding: 18px;
  font: inherit;
  line-height: 1.85;
}

.reader-annotation:focus {
  border-color: var(--focus);
  outline: 2px solid color-mix(in srgb, var(--focus) 18%, transparent);
  outline-offset: 0;
}

.reader-annotation:disabled {
  background: #f8faf9;
  color: var(--muted);
}

.reader-text {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 18px;
  white-space: pre-wrap;
  line-height: 1.85;
}

.reader-original-viewer.is-empty,
.reader-text.is-empty {
  display: grid;
  place-items: center;
}

.reader-text.is-empty {
  white-space: normal;
}

/* 编辑态只换配色，内边距与只读态一致，避免进出编辑态时换行位置错位 */
.reader-text.is-editing {
  min-height: 220px;
  border-color: var(--focus);
  background: #fffdf7;
  outline: none;
}

.reader-empty-state,
.message-panel .result-empty {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(251, 253, 252, 0.96);
  color: var(--muted);
  box-shadow: 0 10px 24px rgba(42, 48, 44, 0.06);
  line-height: 1.7;
}

.reader-notes {
  margin-top: 12px;
  border-left: 3px solid var(--accent);
  background: #f8f4ef;
  color: var(--muted);
  padding: 10px 12px;
  white-space: pre-wrap;
  line-height: 1.7;
}

.hidden {
  display: none !important;
}

mark {
  background: #f5d996;
  color: #1c2521;
  padding: 0 2px;
}

@media (max-width: 900px) {
  .app-shell,
  .reader-layout,
  .reader-compare {
    grid-template-columns: 1fr;
  }

  .result-item,
  .reader-nav-row {
    align-items: stretch;
    flex-direction: column;
  }
}

:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef1ec;
  --text: #20241f;
  --muted: #747b74;
  --line: #dde2dc;
  --primary: #2d6b5c;
  --primary-dark: #1f5145;
  --red: #d84233;
  --gold: #b78b55;
  --blue: #5477d8;
  --ink: #161916;
  --shadow: 0 18px 44px rgba(32, 36, 31, 0.1);
  --book-shadow: 0 16px 26px rgba(32, 36, 31, 0.18);
}

html {
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(circle at 18% 8%, rgba(183, 139, 85, 0.12), transparent 26%),
    linear-gradient(180deg, #fafbf8 0%, var(--bg) 46%, #eef1ef 100%);
}

.app-shell {
  display: block;
  min-height: 100vh;
}

.main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 34px 24px 56px;
}

.reader-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.reader-topbar h2 {
  margin: 4px 0 0;
  font-size: 34px;
  line-height: 1;
  font-family: inherit;
  font-weight: 700;
}

.reader-title-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 0;
}

.reader-title-block h2,
.conversation-item strong,
.reference-document-option strong,
.reference-document-option span span,
.conversation-share-choice strong,
.conversation-share-choice span span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-title-block h2 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
  line-height: 1.2;
}

/* 标题仍贴顶，保证三栏标题顶端对齐；串行/并行那行在
   「标题下沿 → 下面进度条上沿」之间垂直居中 */
.progress-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
}

/* 左栏：标题 + 处理方式（串行 / 并行）两行；环固定在右上角。
   grid-template-rows: auto 1fr 让标题占 auto、方式占剩余空间并居中；
   margin-bottom: -8px 把这块居中区域向下延伸到下一行开始处
   （-8px 即 .progress-stack 的行间距），这样上下间距才真正相等 */
.progress-heading {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0;
  margin-bottom: -8px;
  min-width: 0;
}

.progress-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.progress-mode {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

/* 各阶段（环 / 进度条段）统一用色 */
.progress-ring-fill-variant { stroke: #6d8fbd; }
.progress-ring-fill-punctuation { stroke: #b27a42; }
.progress-ring-fill-proofreading { stroke: var(--accent); }

/* 四个阶段环固定在右上角（环内上排两字简称、下排页数） */
.progress-header-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

/* 环尺寸：必须给环项显式宽度——只写 flex-basis 时，父容器按 max-content 计算会退回 min-width，
   环会缩到 30px、环内文字被环线压住。显式 width 后 300px 侧栏下环为 52px，变窄按比例收缩不溢出 */
.progress-header-tools .progress-stage-ring-item {
  flex: 0 1 auto;
  width: 52px;
  min-width: 30px;
}

.progress-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 8px;
}

/* 总页数固定在进度条右侧（与条同行） */
.progress-total {
  color: var(--muted);
  font-size: 12px;
  line-height: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.progress-total b {
  color: var(--text);
  font-weight: 700;
}

/* 四阶段合并进度条：单条轨道，各阶段按流水线顺序分层叠加 */
.progress-track-main {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf2ef;
}

.progress-track-main .progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  height: 100%;
  border-radius: 0;
  transition: width 0.35s ease;
}

.progress-fill-ocr { z-index: 1; background: linear-gradient(90deg, var(--primary), #3e8f76); }
.progress-fill-variant { z-index: 2; background: #6d8fbd; }
.progress-fill-punctuation { z-index: 3; background: #b27a42; }
.progress-fill-proofreading { z-index: 4; background: linear-gradient(90deg, var(--accent), #c7775f); }

/* 环：SVG 铺满做底（z-index 0，不能被环线遮挡文字），环内文字居中竖排（简称 / 页数） */
.progress-ring {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 1px;
  width: 100%;
  aspect-ratio: 1 / 1;
}

.progress-ring svg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-track {
  fill: none;
  stroke: #e6ebe6;
  stroke-width: 4;
}

.progress-ring-fill {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease;
}

.progress-ring-fill-ocr {
  stroke: var(--primary);
}

/* 正在处理该页、但还没有实测进度：环保持空环，轨道呼吸表示「进行中」（不画假进度弧） */
.progress-stage-ring-item.is-active .progress-ring svg {
  animation: progress-ring-spin 1.4s linear infinite;
}

.progress-stage-ring-item.is-active .progress-ring-track {
  animation: progress-ring-pulse 1.2s ease-in-out infinite;
}

.progress-stage-ring-item.is-active .progress-ring-label {
  color: var(--primary);
}

@keyframes progress-ring-spin {
  from { transform: rotate(-90deg); }
  to { transform: rotate(270deg); }
}

@keyframes progress-ring-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-stage-ring-item.is-active .progress-ring svg {
    animation: none;
  }

  .progress-stage-ring-item.is-active .progress-ring-track {
    opacity: 0.55;
    animation: none;
  }
}

.progress-ring-label {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.progress-ring-count {
  position: relative;
  z-index: 1;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.reader-progress-area {
  display: block;
}

.reader-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.reader-actions .ghost-link:disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* .icon-text-button 的 display 规则在后面，必须用复合选择器才能隐藏。 */
.reader-actions .ghost-link.hidden {
  display: none;
}

.reader-topbar .ghost-link {
  color: #7b817b;
}

.icon-text-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.icon-text-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#edit-document:disabled {
  cursor: default;
  opacity: 0.55;
}

.eyebrow {
  margin: 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
}

.icon-button,
.ghost-link,
.chip-button,
.round-send {
  border: 0;
  color: var(--text);
}

.icon-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: transparent;
  font-size: 30px;
  line-height: 1;
}

.icon-button:hover,
.ghost-link:hover {
  background: rgba(32, 36, 31, 0.06);
}

.icon-button.subtle {
  width: 36px;
  height: 36px;
  color: var(--muted);
  font-size: 24px;
}

.ghost-link {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  background: transparent;
  color: #7b817b;
  font-weight: 700;
}

.shelf-stage {
  position: relative;
  padding-bottom: 26px;
}

.shelf-search {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.shelf-search:focus-within {
  border-color: var(--accent);
}

.shelf-search svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.shelf-search input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  font-size: 13px;
}

.shelf-search input:focus {
  outline: none;
}

.shelf-search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* × 清空按钮只在有输入时显示（JS 切 hidden），所以它不能比静态子元素高
   （svg 18px / input 行盒 19px），否则按钮一出现整行就从 37px 撑到 42px，
   下方内容整块下移。尺寸必须保持 ≤ 19px。 */
.shelf-search button {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.shelf-search button:hover {
  background: rgba(32, 36, 31, 0.06);
}

.shelf-search-empty {
  grid-column: 1 / -1;
}

.document-list[data-search-query]:not([data-search-query=""]) .book-card[data-document-id] {
  cursor: pointer;
  touch-action: auto;
}

.document-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  column-gap: clamp(26px, 4vw, 54px);
  row-gap: 48px;
}

.book-card {
  position: relative;
  min-width: 0;
}

.book-card[data-document-id] {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.book-card.dragging {
  z-index: 3;
  cursor: grabbing;
  opacity: 0.28;
  transform: scale(0.98);
}

.book-drag-preview {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  margin: 0;
  pointer-events: none;
  opacity: 0.94;
  filter: drop-shadow(0 18px 28px rgba(32, 36, 31, 0.24));
}

.document-list.is-reordering .book-card {
  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.document-drag-active,
.document-drag-active * {
  cursor: grabbing !important;
}

.book-card::after {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  bottom: -8px;
  z-index: -1;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(185, 180, 161, 0), rgba(185, 180, 161, 0.72), rgba(185, 180, 161, 0));
  filter: blur(6px);
}

.book-open {
  display: grid;
  width: 100%;
  gap: 12px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.book-cover {
  aspect-ratio: 0.72;
  width: 100%;
  min-height: 210px;
  border-radius: 6px 4px 4px 6px;
}

.book-cover {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 18px 16px;
  box-shadow: var(--book-shadow);
  color: #fff;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0 9px, transparent 9px),
    linear-gradient(145deg, #314f64, #c24732);
}

.book-cover.image-cover {
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.34) 0 9px, transparent 9px),
    linear-gradient(0deg, rgba(0, 0, 0, 0.58), rgba(0, 0, 0, 0.12) 48%, rgba(0, 0, 0, 0.34)),
    var(--cover-image);
  background-position: left top, center, center;
  background-repeat: no-repeat;
  background-size: auto, cover, cover;
  color: #fff;
}

.book-cover::before,
.book-cover::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.book-cover::before {
  inset: 0;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.22), transparent 35%),
    radial-gradient(circle at 80% 18%, rgba(255, 255, 255, 0.22), transparent 24%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.3), transparent 42%);
}

.book-cover::after {
  left: 16px;
  right: 16px;
  bottom: 18px;
  height: 1px;
  background: rgba(255, 255, 255, 0.36);
}

.cover-1 .book-cover {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0 9px, transparent 9px),
    linear-gradient(145deg, #e8e3d5, #7d9a72);
  color: #1f2b23;
}

.cover-2 .book-cover {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 9px, transparent 9px),
    linear-gradient(145deg, #141817, #bf2d22 62%, #f0d9b4);
}

.cover-3 .book-cover {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.16) 0 9px, transparent 9px),
    linear-gradient(145deg, #f0c328, #e75d2a 58%, #25364b);
}

.cover-4 .book-cover {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0 9px, transparent 9px),
    linear-gradient(145deg, #425d4e, #d6c4a4);
}

.cover-5 .book-cover {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0 9px, transparent 9px),
    linear-gradient(145deg, #2c4772, #8e3d43 60%, #d8a84c);
}

.book-title {
  position: relative;
  z-index: 1;
  display: -webkit-box;
  overflow: hidden;
  font-size: clamp(20px, 2.2vw, 32px);
  font-family: inherit;
  font-weight: 700;
  line-height: 1.12;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.book-author {
  position: relative;
  z-index: 1;
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-facts {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-top: auto;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 700;
}

.book-year,
.book-pages {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-pages {
  flex: 0 0 auto;
  text-align: right;
}

/* 下载副本正在后台重建索引：文献已可用，只提示进度，不遮封面也不拦进入阅读页 */
.book-card.is-preparing .book-pages {
  color: var(--primary);
}

.upload-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 1200;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 48px));
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.smart-dock {
  margin-top: 54px;
  padding-bottom: 10px;
}

.smart-input-box {
  display: grid;
  gap: 14px;
  min-height: 176px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(42, 48, 44, 0.09);
}

.reference-context {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.reference-trigger {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f9f7;
  color: #4f5b54;
  font-size: 13px;
  font-weight: 700;
}

.reference-trigger:hover {
  border-color: #b8c6be;
  background: #edf3ef;
}

.reference-trigger-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  place-items: center;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
}

.reference-chips {
  display: flex;
  min-width: 0;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.reference-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  min-height: 30px;
  padding: 4px 5px 4px 10px;
  border: 1px solid #c8d8cf;
  border-radius: 999px;
  background: #edf5f0;
  color: #315d4f;
  font-size: 12px;
}

.reference-chip > span,
.reference-chip > a {
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-chip > a:hover {
  text-decoration: underline;
}

.reference-chip button {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  line-height: 1;
}

.reference-chip button:hover {
  background: rgba(47, 111, 94, 0.12);
}

.reference-chip-warning {
  border-color: #e2bd77;
  background: #fff7e7;
  color: #8c5c13;
}

.attachment-chip {
  border-color: #c8d2ea;
  background: #f0f3fb;
  color: #425c93;
}

.attachment-chip-pending {
  border-style: dashed;
  color: #6d6f78;
}

.reference-scope-status {
  margin: -6px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.reference-scope-status.reference-scope-warning {
  color: #9a6217;
}

.smart-input-box textarea {
  min-height: 78px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  line-height: 1.6;
  resize: vertical;
}

.smart-input-box textarea::placeholder {
  color: #a1a8a3;
}

.smart-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 让会话来源与发送控件一起固定在右下角。 */
#open-reference-documents {
  margin-left: auto;
}

.chip-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #58615b;
  font-weight: 700;
}

.chip-button.active {
  border-color: #b9c9ff;
  background: #eef3ff;
  color: #3768f4;
}

.chip-button:not(.active):hover {
  background: #f1f4f1;
}

.chip-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.chip-button:disabled:hover {
  background: transparent;
}

.round-send {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  background: #aebdf7;
  color: #fff;
  font-size: 32px;
  line-height: 1;
}

.smart-results {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.citation-markers {
  white-space: nowrap;
}

.citation {
  margin-left: 3px;
  color: var(--primary);
  font-size: 12px;
  vertical-align: super;
  cursor: help;
}

a.citation {
  cursor: pointer;
  text-decoration: none;
}

a.citation:hover {
  text-decoration: underline;
}

.citation-missing {
  color: var(--muted);
  vertical-align: baseline;
}

.citation-conflict-mark {
  color: var(--red);
}

.citation-conflict {
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 4px;
  background: rgba(216, 66, 51, 0.14);
  color: var(--red);
  font-size: 12px;
  vertical-align: super;
  cursor: help;
}

.form-sheet,
.confirm-dialog,
.reference-dialog,
.settings-dialog,
.accounts-dialog,
.conversation-share-editor {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

.form-sheet {
  z-index: 20;
  padding: 22px;
  background: rgba(32, 36, 31, 0.28);
  backdrop-filter: blur(6px);
}

.confirm-dialog {
  z-index: 30;
  padding: 22px;
  background: rgba(32, 36, 31, 0.28);
  backdrop-filter: blur(6px);
}

.reference-dialog {
  z-index: 35;
  padding: 22px;
  background: rgba(32, 36, 31, 0.32);
  backdrop-filter: blur(6px);
}

.reference-dialog-card,
.confirm-card,
.settings-card,
.accounts-dialog-card,
.conversation-share-editor-card {
  border: 1px solid var(--line);
  background: var(--surface);
}

.reference-dialog-card {
  display: grid;
  grid-template-rows: auto auto minmax(180px, 1fr) auto;
  gap: 14px;
  width: min(680px, 100%);
  max-height: min(720px, calc(100vh - 44px));
  padding: 22px;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.reference-dialog-header,
.reference-dialog-footer,
.settings-header,
.settings-field,
.accounts-header,
.conversation-share-editor-head,
.conversation-share-editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reference-dialog-header,
.reference-dialog-footer {
  gap: 16px;
}

.reference-dialog-header {
  align-items: flex-start;
}

.reference-dialog-header h2,
.reference-dialog-header p {
  margin: 0;
}

.reference-dialog-header h2 {
  font-size: 21px;
}

.reference-dialog-header p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.5;
}

.reference-dialog-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
}

.reference-document-search {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
}

.reference-document-list {
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 180px;
  padding: 2px;
  overflow-y: auto;
}

.reference-document-option,
.conversation-share-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  cursor: pointer;
}

.reference-document-option {
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfb;
}

.reference-document-option:hover {
  border-color: #afc3b8;
  background: #f2f7f4;
}

.reference-document-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.reference-document-option > span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.reference-document-option span span,
.reference-dialog-footer,
.reference-document-empty {
  color: var(--muted);
  font-size: 13px;
}

.reference-document-empty {
  margin: 0;
  padding: 44px 12px;
  text-align: center;
}

.confirm-card {
  width: min(360px, 100%);
  padding: 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.confirm-card h2 {
  margin: 0;
  font-size: 20px;
}

.confirm-card p {
  margin: 12px 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.danger-button {
  min-height: 38px;
  border: 1px solid #c94437;
  border-radius: 6px;
  background: #c94437;
  color: #fff;
  padding: 8px 14px;
}

.danger-button:hover {
  background: #a83228;
}

.form-panel {
  width: min(680px, 100%);
  max-height: min(820px, calc(100vh - 44px));
  overflow: auto;
}

@media (max-width: 980px) {
  .document-list {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .reader-layout,
  .reader-compare {
    grid-template-columns: 1fr;
  }

  /* 窄屏单列：标题栏与内容栏按 标题-内容 顺序堆叠 */
  .reader-compare {
    grid-template-rows: auto;
  }

  .reader-compare > * {
    grid-area: auto;
  }

  .reader-compare.is-original-collapsed .reader-text-panel,
  .reader-compare.is-annotation-collapsed .reader-text-panel,
  .reader-compare.is-original-collapsed.is-annotation-collapsed .reader-text-panel {
    grid-column: auto;
  }

  .reader-original-heading {
    order: 1;
  }

  .reader-original-panel {
    order: 2;
  }

  .reader-text-heading {
    order: 3;
  }

  .reader-text-panel {
    order: 4;
  }

  .reader-annotation-heading {
    order: 5;
  }

  .reader-annotation-panel {
    order: 6;
  }

  .reader-sidebar-stack {
    height: auto;
  }

  /* 单列时没有左右分隔带，胶囊贴主区左边缘（否则 -13px 会被 .reader-layout 的 overflow 裁掉） */
  .reader-main .reader-sidebar-toggle.icon-button {
    left: 0;
  }

  #reader-view.active {
    overflow: auto;
  }

  .reader-layout,
  .reader-main,
  .reader-combined-panel,
  .reader-compare {
    min-height: auto;
  }

  .reader-original-viewer,
  .reader-text,
  .reader-annotation {
    min-height: 320px;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 22px 16px 40px;
  }

  .reader-topbar,
  .result-item,
  .reader-nav-row {
    align-items: stretch;
    flex-direction: column;
  }

  .smart-actions {
    align-self: stretch;
  }

  .reference-context {
    align-items: flex-start;
    flex-direction: column;
  }

  .reference-chips {
    width: 100%;
  }

  .reference-dialog {
    padding: 10px;
  }

  .reference-dialog-card {
    max-height: calc(100vh - 20px);
    padding: 16px;
  }

  .reference-dialog-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .reference-dialog-footer .confirm-actions {
    justify-content: stretch;
  }

  .reference-dialog-footer .confirm-actions button {
    flex: 1 1 0;
  }

  .document-list {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    column-gap: 22px;
    row-gap: 38px;
  }

  .book-cover {
    min-height: 184px;
  }

  .smart-input-box {
    border-radius: 20px;
    padding: 18px;
  }

  .round-send {
    margin-left: 0;
  }

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

html,
body {
  height: 100%;
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  overflow: hidden;
}

.main {
  width: 100%;
  height: 100vh;
  padding: 0;
  overflow: hidden;
}

#library-view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.home-statusbar,
.documents-topbar,
.reader-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  min-height: 68px;
  padding: 10px 18px;
  border: 1px solid rgba(221, 226, 220, 0.86);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 32px rgba(42, 48, 44, 0.08);
}

.service-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px 40px;
  min-width: 0;
  color: #69716a;
  font-size: 14px;
  white-space: nowrap;
}

/* 四个状态项都只占一行：标签 + 状态；所用模型只在悬停 title 里出现。 */
.service-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.service-item-version {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.status-title {
  min-width: 0;
  text-align: center;
}

/* 标题里要放文件夹层级：中间轨道随内容增长，但最多占 60%，避免把两侧压成 0 宽。 */
.documents-topbar {
  grid-template-columns: minmax(0, 1fr) fit-content(60%) minmax(0, 1fr);
}

/* 文献库页大标题：显示当前文件夹层级，过长就省略号。 */
.status-title .eyebrow {
  overflow: hidden;
  color: var(--text);
  font-size: 24px;
  font-family: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-topbar-actions {
  display: inline-flex;
  justify-self: end;
  align-items: center;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
}

.settings-button {
  color: #69716a;
}

.font-options {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid rgba(174, 184, 175, 0.78);
  border-radius: 8px;
  background: #f7faf6;
}

.font-option {
  min-width: 48px;
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #414842;
  padding: 3px 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.font-option[data-font-option="hei"] {
  font-family: var(--font-hei);
}

.font-option[data-font-option="kai"] {
  font-family: var(--font-kai);
}

.font-option.active,
.font-option:hover {
  background: #2f6f5e;
  color: #ffffff;
}

.settings-dialog {
  z-index: 20;
  padding: 16px;
  background: rgba(15, 23, 42, 0.38);
}

.settings-card {
  width: min(360px, 100%);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2);
  padding: 18px;
}

.settings-header,
.settings-field {
  gap: 16px;
}

.settings-header {
  margin-bottom: 18px;
}

.settings-field + .settings-field {
  margin-top: 14px;
}

.settings-header h2,
.settings-field-label {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.accounts-dialog {
  z-index: 25;
  grid-template-columns: minmax(0, 1fr);
  padding: 16px;
  background: rgba(15, 23, 42, 0.38);
}

.accounts-dialog-card {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 634px;
  min-width: 0;
  max-height: calc(100vh - 32px);
  overflow: hidden;
  padding: 18px;
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2);
}

.accounts-header {
  gap: 16px;
}

.accounts-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.accounts-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.accounts-toolbar-left {
  min-width: 0;
}

.accounts-search {
  width: min(260px, 100%);
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--text);
  font: inherit;
}

.accounts-search:focus,
.accounts-pagination .pagination-input:focus {
  outline: 3px solid rgba(209, 154, 56, 0.28);
  border-color: var(--focus);
}

.accounts-count {
  justify-self: end;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.accounts-pagination {
  display: flex;
  align-items: center;
  justify-self: center;
  gap: 8px;
  min-height: 30px;
}

.accounts-pagination .pagination-info {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.accounts-pagination .pagination-input {
  width: 48px;
  min-height: 30px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
}

.accounts-table-wrap {
  width: 100%;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.accounts-table {
  width: 100%;
  min-width: 592px;
  border-collapse: collapse;
  table-layout: fixed;
}

.accounts-table th,
.accounts-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e6ebe7;
  text-align: center;
  white-space: nowrap;
}

.accounts-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.accounts-table tbody tr:last-child td {
  border-bottom: 0;
}

.accounts-table tbody tr:hover td {
  background: #f7faf8;
}

.accounts-table .col-id {
  width: 56px;
  color: var(--muted);
}

.accounts-table .col-username {
  width: 142px;
  overflow: hidden;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
}

.accounts-table .col-role {
  width: 80px;
  padding-inline: 4px;
  text-align: center;
}

.accounts-table .col-created {
  width: 138px;
  color: var(--muted);
  font-size: 13px;
}

.accounts-table .col-actions {
  width: 176px;
  text-align: center;
}

.accounts-empty {
  padding: 42px 12px !important;
  color: var(--muted);
  text-align: center !important;
}

.account-tag {
  display: inline-block;
  min-width: 70px;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

.account-tag-admin {
  border-color: #ecd9b6;
  background: #fdf3e5;
  color: #a06a18;
}

.account-tag-user {
  border-color: #d3e3da;
  background: #eef3f0;
  color: #2d6b5c;
}

.accounts-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.accounts-btn {
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.accounts-btn:hover:not(:disabled) {
  border-color: #afc3b8;
  background: #f2f7f4;
}

/* 「设为普通用户 / 设为管理员」两种文案宽度对齐 */
.accounts-row .accounts-btn[data-act="role"] {
  min-width: calc(6em + 20px);
}

.accounts-btn:disabled {
  cursor: default;
  opacity: 0.45;
}

.accounts-btn-danger {
  border-color: #e3b7b2;
  color: #c0392b;
}

.accounts-btn-danger:hover:not(:disabled) {
  border-color: #c94437;
  background: #c94437;
  color: #fff;
}

.accounts-current {
  color: var(--muted);
  font-size: 13px;
}

.accounts-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: 60;
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 18px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: #20241f;
  box-shadow: 0 12px 32px rgba(32, 36, 31, 0.24);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.accounts-toast.toast-error {
  background: #c0392b;
}

@media (max-width: 620px) {
  .accounts-dialog {
    padding: 10px;
  }

  .accounts-dialog-card {
    max-height: calc(100vh - 20px);
    padding: 14px;
  }

  .accounts-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .accounts-toolbar-left {
    grid-column: 1 / -1;
    width: 100%;
  }

  .accounts-search {
    width: 100%;
  }

  .accounts-pagination {
    justify-self: start;
  }
}

.service-strip strong,
.service-strip b {
  display: inline-block;
  min-width: 60px;
  color: #414842;
  /* 四项的值列统一宽度且左对齐，标签到状态的间距才会一致。 */
  text-align: left;
}

.status-action {
  width: 52px;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid #aeb8af;
  border-radius: 6px;
  background: #f7faf6;
  color: #414842;
  font-size: 13px;
  font-weight: 700;
  line-height: 24px;
}

.status-action:disabled {
  cursor: wait;
  opacity: 0.72;
}

/* 版本项：状态文字与「更新」按钮占用同一宽度，两种状态切换时后面的项不会左右跳动。 */
.service-item-version > b {
  box-sizing: border-box;
  width: 60px;
  min-width: 60px;
  text-align: left;
}

.service-item-version > .status-action {
  box-sizing: border-box;
  width: 60px;
  min-width: 60px;
  text-align: center;
}

.home-board {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 330px;
  gap: 14px;
  min-height: 0;
  overflow: hidden;
}

.center-stack {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.home-sidebar,
.message-panel {
  min-height: 0;
  border: 1px solid rgba(221, 226, 220, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 34px rgba(42, 48, 44, 0.08);
}

.home-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-heading {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(221, 226, 220, 0.74);
}

.sidebar-heading h2 {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

/* 拼在图标题行右侧：先计数、再「展开」，两个都在这一行垂直居中。 */
.sidebar-shelf-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

/* 标题行的「重命名当前文件夹」按钮。 */
.shelf-rename-current {
  flex: 0 0 auto;
  padding: 2px 4px;
  font-size: 15px;
  line-height: 1;
}

/* 文献库页顶栏右侧：重命名按钮 + 计数。 */
.documents-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 10px;
  min-width: 0;
}

/* 标题里的文件夹层级：整条放不下时由 renderShelfTitle 折叠成「››最后一层」，这里只负责尾部省略。 */
#shelf-title {
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-count {
  display: inline;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}

.conversation-list {
  display: grid;
  flex: 1 1 auto;
  align-content: start;
  gap: 4px;
  min-height: 0;
  padding: 12px;
  overflow: auto;
}

.conversation-empty {
  display: grid;
  min-height: 100%;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
}

.conversation-date-heading {
  margin: 16px 8px 6px;
  color: #858d87;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.conversation-date-heading:first-child {
  margin-top: 4px;
}

.conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.conversation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 42px;
  padding: 8px 0 8px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.conversation-row:hover,
.conversation-row.active {
  border-color: #dfe5df;
  background: #f4f7f4;
}

.conversation-item strong {
  font-size: 14px;
  line-height: 1.35;
}

/* 只作用于标题行右侧的「对话类型」提示，别把按钮里的图标 span 也画成胶囊。 */
.message-head > span {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  background: #edf1ee;
  color: #646d66;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.conversation-mode {
  justify-self: end;
  padding: 2px 6px;
  border-radius: 999px;
  background: #edf1ee;
  color: #747d76;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
}

.conversation-delete {
  display: grid;
  width: 26px;
  height: 26px;
  justify-self: center;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #a0a8a2;
  font-size: 20px;
  line-height: 1;
}

.conversation-delete:hover {
  background: #f2e7e5;
  color: #c03d31;
}

.message-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(221, 226, 220, 0.74);
}

.message-head h2 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 22px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

/* 与书架标题行的「重命名当前文件夹」按钮（.ghost-link.shelf-rename-current）保持一致。 */
.chat-title-edit {
  flex: 0 0 auto;
  padding: 2px 4px;
  font-size: 15px;
  line-height: 1;
}

.chat-title-edit.hidden,
.chat-title-input.hidden {
  display: none;
}

.chat-title-edit:disabled,
.chat-title-edit:disabled:hover {
  background: transparent;
  color: #c6cbc6;
  cursor: default;
}

.chat-title-edit.editing {
  background: rgba(32, 36, 31, 0.09);
  color: #3f4a41;
}

.chat-title-edit .icon-check {
  display: none;
}

.chat-title-edit.editing .icon-pencil {
  display: none;
}

.chat-title-edit.editing .icon-check {
  display: inline;
}

.chat-title-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
}

.chat-title-input:focus {
  outline: none;
  border-color: #3d8052;
  box-shadow: 0 0 0 3px rgba(61, 128, 82, 0.12);
}

.message-scroll {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  padding: 18px;
  overflow-x: hidden;
  overflow-y: auto;
}

.message-panel .smart-results {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  margin-top: 0;
  min-height: 0;
}

.message-panel .result-list:empty:not(.empty-result-list) {
  display: none;
}

.message-panel .result-item {
  align-items: flex-start;
  background: rgba(251, 253, 252, 0.94);
}

.message-panel .result-list.empty-result-list {
  display: grid;
  height: 100%;
  min-height: 0;
  place-items: center;
}

.message-panel .result-list.conversation-history {
  display: flex;
  flex-direction: column;
  gap: 26px;
  align-self: start;
  min-width: 0;
}

.conversation-turn {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.conversation-question {
  display: grid;
  justify-items: end;
  gap: 4px;
  min-width: 0;
}

.conversation-prompt,
.conversation-share-page-prompt {
  max-width: 88%;
  background: var(--surface-2);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.conversation-prompt {
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px 0 14px 14px;
  line-height: 1.6;
}

.conversation-turn-action {
  width: 30px;
  height: 30px;
  padding: 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.conversation-turn-action svg {
  width: 18px;
  height: 18px;
}

.conversation-turn-action:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--primary);
}

.conversation-turn-action:disabled {
  cursor: default;
  opacity: 0.45;
}

.conversation-answer {
  display: grid;
  justify-self: start;
  width: fit-content;
  max-width: 88%;
  gap: 10px;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 0 14px 14px 14px;
  background: #f7eee8;
  overflow-wrap: anywhere;
}

.conversation-retrieval {
  min-width: 0;
  width: 100%;
}

.conversation-retrieval-title {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.conversation-retrieval summary {
  cursor: pointer;
  padding: 6px 0;
}

.conversation-retrieval-group {
  border-top: 1px solid var(--line);
  margin-top: 6px;
}

.conversation-retrieval-list {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.conversation-match-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.7;
}

.conversation-match-table th,
.conversation-match-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}

/* 分组之间由 .conversation-retrieval-group 的 border-top 分隔；末行若再带下边框，
   两个分组交界处会出现紧挨着的两条线。 */
.conversation-match-table tbody tr:last-child td {
  border-bottom: 0;
}

.conversation-match-table th {
  color: var(--muted);
  font-weight: 500;
}

.conversation-match-table th:first-child,
.conversation-match-table td:first-child {
  width: 3.5rem;
  text-align: center;
  color: var(--muted);
}

.conversation-match-table th:last-child,
.conversation-match-table td:last-child {
  width: 28%;
}

.conversation-match-table td:nth-child(2) {
  white-space: pre-wrap;
}

.conversation-match-row {
  cursor: pointer;
}

.conversation-match-row:hover,
.conversation-match-row:focus-within {
  background: var(--surface-2);
}

.conversation-match-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

@media (max-width: 600px) {
  .conversation-match-table th,
  .conversation-match-table td {
    padding: 7px 5px;
  }

  .conversation-match-table th:first-child,
  .conversation-match-table td:first-child {
    width: 2.75rem;
  }
}

.conversation-answer-text {
  margin: 0;
  line-height: 1.75;
  white-space: pre-wrap;
}

.conversation-turn-status,
.conversation-turn-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.conversation-turn-status[role="alert"] {
  color: var(--accent);
}

.conversation-prompt-editor {
  display: grid;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.conversation-prompt-editor textarea {
  min-height: 90px;
  max-height: 320px;
  padding: 10px 14px;
  line-height: 1.6;
}

.conversation-prompt-editor .meta-line {
  margin: 0;
}

.conversation-edit-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.library-sidebar .shelf-stage {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px 14px 16px;
  overflow-x: hidden;
  overflow-y: auto;
}

.library-sidebar .document-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 14px;
  row-gap: 24px;
}

.library-sidebar .book-cover {
  height: 160px;
  min-height: 0;
  aspect-ratio: auto;
}

.library-sidebar .book-title {
  font-size: 19px;
  -webkit-line-clamp: 4;
}

.library-sidebar .book-facts,
.library-sidebar .book-author {
  font-size: 11px;
}

.library-sidebar .book-card::after {
  bottom: -8px;
}

#library-view .smart-dock {
  margin-top: 0;
  padding-bottom: 0;
}

#library-view .smart-input-box {
  min-height: 124px;
  padding: 16px 18px;
  border-radius: 24px;
}

#library-view .smart-input-box textarea {
  height: 82px;
  min-height: 82px;
  max-height: 82px;
  font-size: 17px;
  overflow-y: auto;
  resize: none;
}

#library-view .chip-button {
  min-height: 36px;
}

#library-view .round-send {
  width: 44px;
  height: 44px;
  font-size: 26px;
}

#documents-view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.reader-topbar {
  margin-bottom: 0;
}

.documents-nav {
  min-width: 0;
}

#reader-back {
  justify-self: start;
}

.reader-title-block {
  justify-self: center;
}

.reader-actions {
  justify-self: end;
}

.documents-count {
  justify-self: end;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.documents-stage {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px 4px 40px;
}

.documents-stage .document-list {
  grid-template-columns: repeat(10, minmax(0, 142px));
  justify-content: space-between;
  column-gap: 14px;
  row-gap: 24px;
}

.documents-stage .book-cover {
  width: 100%;
  height: 160px;
  min-height: 0;
  aspect-ratio: auto;
}

.documents-stage .book-title {
  font-size: 19px;
  -webkit-line-clamp: 4;
}

.documents-stage .book-facts,
.documents-stage .book-author {
  font-size: 11px;
}

.documents-stage .book-card::after {
  bottom: -8px;
}

#reader-view.active {
  height: 100vh;
  padding: 28px;
  overflow: auto;
}

#reader-view.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

@media (max-width: 980px) {
  #library-view.active {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .home-statusbar {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .service-strip {
    grid-row: 2;
    justify-content: center;
    overflow-x: auto;
  }

  .status-title {
    grid-row: 1;
  }

  .home-topbar-actions {
    grid-row: 3;
    justify-self: center;
  }

  .home-board {
    grid-template-columns: 210px minmax(0, 1fr) 260px;
  }

  .library-sidebar .document-list {
    grid-template-columns: 1fr;
  }

  .documents-stage .document-list {
    grid-template-columns: repeat(auto-fill, 142px);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell,
  .main,
  #library-view.active,
  #documents-view.active,
  #reader-view.active {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  #library-view.active,
  #documents-view.active,
  #reader-view.active {
    display: grid;
    padding: 12px;
  }

  .home-statusbar,
  .documents-topbar,
  .reader-topbar,
  .home-board {
    grid-template-columns: 1fr;
  }

  #documents-view.active {
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    min-height: 0;
    overflow: hidden;
  }

  .documents-actions,
  .documents-count,
  .documents-nav {
    justify-self: center;
  }

  .home-sidebar,
  .message-panel {
    max-height: none;
  }

  .conversation-list,
  .message-scroll,
  .library-sidebar .shelf-stage {
    max-height: 42vh;
  }
}

/* 失败页：统一标题 + 两字阶段 chip（有失败页才显示） */
.processing-failed {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
}

/* 注意：.hidden 定义在本文件更早处，同优先级下会被上面的 display 覆盖，必须写成复合选择器 */
.processing-failed.hidden {
  display: none;
}

.processing-failed-title {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.processing-failed-pages { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 auto; min-width: 0; }
.processing-failed-page { padding: 3px 8px; border: 1px solid currentColor; border-radius: 5px; background: transparent; cursor: pointer; font-size: 12px; font-variant-numeric: tabular-nums; }
.processing-failed-page.is-ocr { color: var(--primary); }
.processing-failed-page.is-variant { color: #6d8fbd; }
.processing-failed-page.is-punctuation { color: #b27a42; }
.processing-failed-page.is-proofreading { color: var(--accent); }

.startup-error {
  position: fixed;
  inset: 20px;
  z-index: 1000;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
  font-weight: 700;
  text-align: center;
}

.conversation-row {
  grid-template-columns: minmax(0, 1fr) 32px 28px;
}

.conversation-share {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #7b877e;
  font-size: 12px;
  font-weight: 700;
}

.conversation-share:hover,
.conversation-share.active {
  background: #e3eee5;
  color: #34734a;
}

.conversation-share-editor {
  z-index: 100;
  padding: 16px;
  background: rgba(28, 37, 33, 0.34);
}

.conversation-share-editor-card {
  display: grid;
  gap: 12px;
  width: min(780px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  overflow-x: hidden;
  overflow-y: auto;
  padding: 22px;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(28, 37, 33, 0.2);
}

.conversation-share-editor.hidden,
.conversation-share-link.hidden {
  display: none;
}

.conversation-share-editor-head,
.conversation-share-editor-foot {
  gap: 12px;
}

.conversation-share-editor-head strong {
  color: var(--text);
  font-size: 14px;
}

.conversation-share-editor-foot {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.conversation-share-editor-head .confirm-actions {
  flex: 0 0 auto;
  align-items: center;
}

.conversation-share-create {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.conversation-share-create .conversation-share-link {
  flex: 1 1 auto;
}

/* 分享窗口中的按钮文字保持单行、不收缩。 */
.conversation-share-editor-card button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.conversation-share-editor-head #conversation-share-count {
  white-space: nowrap;
}

.conversation-share-selection {
  display: grid;
  gap: 7px;
  max-height: 300px;
  overflow-x: hidden;
  overflow-y: auto;
}

.conversation-share-choice {
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid #dfe7df;
  border-radius: 8px;
  background: #fff;
}

.conversation-share-choice.disabled {
  cursor: default;
  opacity: .58;
}

.conversation-share-choice input {
  margin: 0;
  accent-color: #3d8052;
}

/* 去掉复选框获得焦点时的黄色外框（来自全局 input:focus 规则）；选框本身已能说明选中状态。 */
.conversation-share-choice input:focus,
.conversation-share-choice input:focus-visible {
  outline: none;
}

.conversation-share-choice span {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.conversation-share-choice strong {
  font-size: 13px;
  font-weight: 700;
}

.conversation-share-choice span span {
  color: var(--muted);
  font-size: 12px;
}

.conversation-share-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: #edf5ee;
  color: #326e42;
  font-size: 12px;
}

.conversation-share-link a {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-share-link .secondary-button {
  flex: 0 0 auto;
  padding: 5px 9px;
}

.conversation-share-page {
  width: min(820px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.conversation-share-page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.conversation-share-page-head .eyebrow {
  flex: 0 0 auto;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.25;
}

.conversation-share-page-head h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.25;
  text-align: right;
  overflow-wrap: anywhere;
}

.conversation-share-page-status {
  margin: 18px 0;
  color: var(--muted);
  font-size: 14px;
}

.conversation-share-page-status:empty {
  display: none;
}

.conversation-share-page-turns {
  display: grid;
  gap: 28px;
  margin-top: 32px;
}

.conversation-share-page-turn {
  display: grid;
  gap: 12px;
}

.conversation-share-page-number {
  color: #708078;
  font-size: 12px;
  font-weight: 700;
}

.conversation-share-page-prompt {
  width: fit-content;
  margin: 0 0 0 auto;
  padding: 11px 15px;
  border-radius: 14px;
  line-height: 1.65;
}

.conversation-share-page-answer-wrap {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.conversation-share-page-answer,
.conversation-share-page-result-text {
  margin: 0;
  color: var(--text);
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.conversation-share-page-result {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.conversation-share-page-result:last-child {
  border-bottom: 0;
}

.conversation-share-page-result-title {
  margin: 0;
  color: var(--text);
  font-weight: 700;
}

.conversation-share-page-result-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.conversation-share-page-empty {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 720px) {
  .conversation-share-create {
    flex-wrap: wrap;
  }

  .conversation-share-page-head {
    flex-wrap: wrap;
  }
}

@media print {
  .conversation-share-page {
    width: auto;
    padding: 0;
  }

  .conversation-share-page-answer-wrap {
    box-shadow: none;
  }
}

.reader-image-frame {
  position: relative;
  width: fit-content;
  max-width: 100%;
  line-height: 0;
  border: 1px solid var(--line);
}

.reader-original-viewer .reader-image-frame img {
  display: block;
  border: 0;
}

.reader-image-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.reader-image-region {
  pointer-events: all;
  cursor: pointer;
  fill: transparent;
  stroke: transparent;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.reader-image-region.is-active,
.reader-image-region:focus-visible {
  fill: rgb(234 179 8 / 28%);
  stroke: #a66c08;
  outline: none;
}

.reader-sentence {
  border-radius: 3px;
}

.reader-sentence.is-active,
.reader-sentence:focus-visible {
  background: #f5e3a6;
  outline: 1px solid #b58421;
}

.reader-sentence.is-selected,
.reader-image-region.is-selected {
  outline: 2px solid #986811;
}

.retrieval-highlight {
  background: #ffe59a;
  color: inherit;
  border-radius: 2px;
  scroll-margin-block: 5rem;
}
.reader-evidence-status {
  padding: 0.75rem 1rem;
  border-inline-start: 3px solid #ba8a32;
  background: #fffbef;
  font-size: 0.9rem;
}
.reader-evidence-text {
  white-space: pre-wrap;
  max-height: 16rem;
  overflow-y: auto;
  line-height: 1.8;
}

@media (max-width: 980px) {
  .reader-layout { grid-template-rows: max-content max-content; overflow: auto; }
  /* 单列时整页滚动，卡片区不单独出滚动条 */
  .reader-sidebar-cards { overflow: visible; }
  .reader-search-results { max-height: 320px; }
  .reader-visual-catalog-items { max-height: 320px; }
  .reader-chapter-catalog-items { max-height: 320px; }
}

/* 共用的个人书架文件夹。 */
.book-card[data-shelf-key] {
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.shelf-name-actions button {
  padding: 7px 10px;
  border: 1px solid #dce2d9;
  border-radius: 9px;
  background: #fffdf8;
  color: #425044;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.folder-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 210px;
  aspect-ratio: 0.72;
  gap: 8px;
  padding: 18px 12px 12px;
  border: 1px solid #e8ddc5;
  border-radius: 10px;
  background: linear-gradient(145deg, #fffaf0, #f0e7d2);
  box-shadow: var(--book-shadow);
  color: #685537;
  text-align: center;
}
.folder-icon {
  position: relative;
  display: block;
  width: 86%;
  height: 78px;
  flex: 0 0 78px;
  margin-top: 8px;
  border: 1px solid #c9a364;
  border-radius: 4px 8px 8px 8px;
  background: linear-gradient(140deg, #e6cb91, #cda969);
  box-shadow: 0 5px 9px #70532920;
}
.folder-icon::before {
  position: absolute;
  content: "";
  width: 42%;
  height: 9px;
  top: -9px;
  left: -1px;
  border: 1px solid #c9a364;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: #e6cb91;
}
.folder-previews {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  height: 100%;
  padding: 7px;
  overflow: hidden;
}
.folder-mini-book {
  display: block;
  min-width: 0;
  overflow: hidden;
  padding: 4px;
  border-left: 3px solid #ffffff50;
  border-radius: 2px;
  background: #61766e;
  color: #fff;
  font-size: 9px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-mini-book:nth-child(2n) { background: #a47158; }
.folder-mini-book:nth-child(3n) { background: #6c7789; }
.folder-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.35;
}
.folder-count { color: #8b7b61; font-size: 11px; }
.folder-rename {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: #fffdf2d9;
  color: #76613e;
  font-size: 18px;
  cursor: pointer;
}
.folder-rename:hover { background: #fff; }

/* 文件夹卡片：打开按钮是覆盖整张卡片的透明层，名字行里只有名字和改名按钮。 */
.folder-card .folder-open {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  height: 100%;
}
/* 名字占满除按钮外的剩余宽度，改名按钮固定贴在这一行的末尾，各文件夹位置一致。 */
.folder-card .folder-name-row {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
/* 名字左对齐，占满除按钮外的剩余宽度；单行显示，放不下时省略号正好落在按钮前面。 */
.folder-card .folder-name {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.folder-card.shelf-drop-hover .folder-cover {
  outline: 3px solid #6e8c68;
  outline-offset: 2px;
  background: #e7eedb;
  box-shadow: 0 8px 24px #476a3c30;
}
.library-sidebar .folder-cover,
.documents-stage .folder-cover {
  height: 160px;
  min-height: 0;
  aspect-ratio: auto;
  gap: 6px;
  padding: 14px 10px 8px;
}
.library-sidebar .folder-icon,
.documents-stage .folder-icon { height: 68px; flex-basis: 68px; }
.library-sidebar .folder-name,
.documents-stage .folder-name { font-size: 13px; }

.shelf-name-dialog {
  width: min(380px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid #e0ddce;
  border-radius: 18px;
  background: #fffdf8;
  color: #354238;
  box-shadow: 0 24px 80px #172d2538;
}
.shelf-name-dialog::backdrop { background: #172d2566; }
.shelf-name-dialog form { display: grid; gap: 14px; }
.shelf-name-dialog h2 { margin: 0 0 6px; font-size: 20px; }
.shelf-name-dialog label { font-size: 13px; }
.shelf-name-dialog input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #cdd7c8;
  border-radius: 8px;
  background: #fff;
  font: inherit;
}
.shelf-name-actions { display: flex; justify-content: flex-end; gap: 8px; }
.shelf-name-actions button[type="submit"] { background: #425c47; color: #fff; }

/* 嵌套书架上固定的「新增文献 / 返回上一级」卡片。 */
.shelf-utility-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 210px;
  aspect-ratio: 0.72;
  gap: 10px;
  padding: 18px 12px;
  border: 1px solid #dfe4dc;
  border-radius: 10px;
  background: #f6f8f3;
  text-align: center;
  color: #526550;
  box-shadow: var(--book-shadow);
}
.shelf-utility-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  font-size: 48px;
  line-height: 1;
  color: #7c9175;
}
.shelf-utility-icon svg { width: 48px; height: 48px; }
.shelf-utility-cover small { color: var(--muted); font-size: 11px; }
/* 「新增文献」平静态沿用默认配色，只有拖拽变成「故纸堆」时才转为可删除的红调。 */
.shelf-add-card.trash-active .shelf-utility-cover {
  border: 1px dashed #c08d7b;
  background: #fcf7f4;
  color: #875d50;
}
.shelf-add-card.trash-active .shelf-utility-icon { color: #af8575; }
.shelf-add-card.trash-hover .shelf-utility-cover {
  outline: 3px solid #bc6c59;
  outline-offset: 2px;
  background: #f7dfd7;
}
/* 拖拽文件夹时「新建文件夹」变「解散文件夹」：绿调区分于红色的「故纸堆」，表示内容上移。 */
.shelf-create-card.dissolve-active .shelf-utility-cover {
  border: 1px dashed #a9bb9f;
  background: #f5f8f1;
  color: #4f6349;
}
.shelf-create-card.dissolve-active .shelf-utility-icon { color: #6e8c68; }
.shelf-create-card.dissolve-hover .shelf-utility-cover {
  outline: 3px solid #6e8c68;
  outline-offset: 2px;
  background: #e7eedb;
}
.shelf-parent-card.shelf-drop-hover .shelf-utility-cover {
  outline: 3px solid #6e8c68;
  outline-offset: 2px;
  background: #e7eedb;
}
/* 拖拽时「返回上一级」也进入可投放态（拖到它上面松手 = 内容移到上一层）。 */
.shelf-parent-card.move-active .shelf-utility-cover {
  border: 1px dashed #a9bb9f;
  background: #f5f8f1;
  color: #4f6349;
}
.shelf-parent-card.move-active .shelf-utility-icon { color: #6e8c68; }
.library-sidebar .shelf-utility-cover,
.documents-stage .shelf-utility-cover {
  height: 160px;
  min-height: 0;
  aspect-ratio: auto;
  gap: 8px;
  padding: 14px 10px;
}
.folder-mini-folder { background: #b48e47; border-color: #eed9aa; }

.folder-count {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 阅览器内嵌图、表、高亮与图目录。 */
.reader-content-text { white-space: pre-wrap; }
.reader-visual { position: relative; display: block; margin: 1.25rem 0; padding: .75rem; border: 1px solid var(--border-color, #ddd6c7); border-radius: .5rem; background: var(--panel-bg, #fffdf7); white-space: normal; }
.reader-visual > img { display: block; max-width: 100%; height: auto; margin: auto; }
.reader-visual.is-zoomable { cursor: zoom-in; }
.reader-visual-caption { margin: .6rem 0; white-space: pre-wrap; line-height: 1.6; color: var(--muted-color, #675f53); cursor: auto; }
.reader-visual-note { margin: .6rem 0; white-space: pre-wrap; line-height: 1.6; color: var(--muted-color, #675f53); font-size: .92em; cursor: auto; }
.reader-visual-caption:empty { display: none; }
.reader-visual-unavailable { color: #786f60; }
.reader-visual.is-active { outline: 2px solid #a57525; outline-offset: 2px; }
/* 图表内的题注属于正文文字：高亮与正文句子完全一致（逐行底色 + 细描边），而不是整块矩形。 */
.reader-visual-caption.is-active, .reader-visual-caption:focus-visible { outline: none; }
.reader-visual-caption.is-active .reader-visual-caption-text,
.reader-visual-caption:focus-visible .reader-visual-caption-text { background: #f5e3a6; outline: 1px solid #b58421; border-radius: 3px; }
.reader-visual.is-selected { box-shadow: 0 0 0 2px #b18c48; }
.reader-visual-caption.is-selected .reader-visual-caption-text { outline: 2px solid #986811; border-radius: 3px; }
.reader-image-frame { position: relative; }
.reader-visual-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.reader-visual-region { fill: transparent; stroke: transparent; stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: all; cursor: pointer; }
.reader-visual-region.is-active, .reader-visual-region:focus-visible { fill: rgb(197 146 50 / 22%); stroke: #ac7b25; outline: none; }
.reader-visual-region.is-selected { stroke: #8d631b; fill: rgb(197 146 50 / 14%); }
.reader-visual-dialog { width: min(96vw, 110rem); max-width: 96vw; max-height: 94vh; padding: 1rem; overflow: auto; border: 1px solid #bcb4a5; border-radius: .5rem; background: #fffdf7; color: #302b23; }
.reader-visual-dialog::backdrop { background: rgb(0 0 0 / 60%); }
.reader-visual-dialog .reader-visual { margin-top: .5rem; }
.reader-visual-dialog .reader-visual > img { max-width: none; max-height: none; cursor: default; }
.reader-visual-dialog-close { display: block; margin-left: auto; }
/* 图表目录卡片：外框与内边距由 .reader-sidebar-card 提供，内部对齐文内检索卡片 */
.reader-chapter-catalog { min-width: 0; }
.reader-chapter-catalog[hidden] { display: none; }
.reader-chapter-catalog-heading { margin-bottom: 8px; }
.reader-chapter-catalog-status { margin: 0 0 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.reader-chapter-catalog-status:empty { display: none; }
.reader-chapter-catalog-retry { min-height: 28px; padding: 3px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; }
.reader-chapter-catalog-retry:hover { border-color: #bac7c0; background: var(--surface-2); }
.reader-chapter-catalog-items { list-style: none; margin: 0; padding: 0; max-height: min(50vh, 420px); overflow-y: auto; }
.reader-chapter-catalog-row { display: flex; align-items: stretch; min-width: 0; }
.reader-chapter-catalog-toggle { flex: 0 0 auto; width: 18px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 11px; line-height: 1; cursor: pointer; }
.reader-chapter-catalog-toggle[aria-hidden="true"] { pointer-events: none; }
.reader-chapter-catalog-toggle:hover { color: var(--text); }
.reader-chapter-catalog-item { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 6px 9px; border: 0; border-radius: 0; background: transparent; color: var(--text); font-size: 12px; line-height: 1.5; text-align: left; cursor: pointer; }
.reader-chapter-catalog-row + .reader-chapter-catalog-row { border-top: 1px solid var(--line); }
.reader-chapter-catalog-item:hover, .reader-chapter-catalog-item:focus-visible { background: #faf7fe; }
.reader-chapter-catalog-item[aria-current="true"] { background: #f3edfc; box-shadow: inset 2px 0 0 #7152a3; }
.reader-chapter-catalog-title { min-width: 0; overflow-wrap: anywhere; }
.reader-chapter-catalog-item[data-level="1"] .reader-chapter-catalog-title { font-weight: 700; }
.reader-chapter-catalog-page { flex-shrink: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.reader-chapter-catalog :focus-visible { outline: 2px solid #a57525; outline-offset: 2px; }
/* 无句子索引时用文本节点定位章节标题，短暂标一下目标位置。 */
.is-outline-target { background: #f5e3a6; box-shadow: 0 0 0 2px #f5e3a6; border-radius: 2px; }

.reader-visual-catalog { min-width: 0; }
.reader-visual-catalog[hidden] { display: none; }
.reader-visual-catalog-heading { margin-bottom: 8px; }
.reader-visual-catalog-status { margin: 0 0 8px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.reader-visual-catalog-status:empty { display: none; }
.reader-visual-catalog-items { list-style: none; margin: 0; padding: 0; max-height: min(50vh, 420px); overflow-y: auto; }
.reader-visual-catalog-item { width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 6px 9px; border: 0; background: transparent; color: var(--text); font-size: 12px; line-height: 1.5; text-align: left; cursor: pointer; }
.reader-visual-catalog-items li + li .reader-visual-catalog-item { border-top: 1px solid var(--line); }
.reader-visual-catalog-item:hover, .reader-visual-catalog-item:focus-visible { background: #faf7fe; }
.reader-visual-catalog-item[aria-current="true"] { background: #f3edfc; box-shadow: inset 2px 0 0 #7152a3; }
.reader-visual-catalog-title { overflow-wrap: anywhere; }
.reader-visual-catalog-page { flex-shrink: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.reader-visual :focus-visible, .reader-visual-catalog :focus-visible { outline: 2px solid #a57525; outline-offset: 2px; }
.reader-visual-dialog-close {
  border: 1px solid #d2c8b6;
  border-radius: .4rem;
  background: #f8f6ef;
  color: #675f53;
  font: inherit;
  font-size: .85rem;
  line-height: 1.4;
  padding: .35rem .6rem;
  cursor: pointer;
}
.reader-visual-dialog-close:hover { background: #eee5d3; color: #302b23; }
.reader-visual-placement-status { margin: .5rem 0 0; color: #786f60; font-size: .85rem; }
