/* 寻典 — 极简样式（v1，先求清晰）。后续可整体替换。 */
* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: #2c3338;
  background: #f7f8fa;
  height: 100vh;
}

body { display: flex; flex-direction: column; }

main {
  flex: 1;
  overflow-y: auto;
  padding: 18px 28px;
}

/* —— 顶栏 —— */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 28px;
  background: #fff;
  border-bottom: 1px solid #e1e4e8;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 28px; height: 28px;
  display: block; flex-shrink: 0;
}
.brand .title { font-size: 18px; font-weight: 600; color: #1a3a6b; }
.brand .subtitle { font-size: 12px; color: #888; }

.tabs { display: flex; gap: 4px; }
.tab-btn {
  border: none; background: transparent; padding: 8px 16px;
  font-size: 14px; cursor: pointer; color: #555;
  border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: #1a3a6b; }
.tab-btn.active { color: #1a3a6b; border-bottom-color: #1a3a6b; font-weight: 600; }

.btn-icon {
  border: none; background: transparent; cursor: pointer;
  font-size: 20px; padding: 4px 10px; color: #666;
  border-radius: 4px;
}
.btn-icon:hover { background: #eef; color: #1a3a6b; }

/* 长操作期间的视觉反馈 */
button:disabled {
  cursor: not-allowed !important;
  opacity: 0.55;
}
body.is-busy {
  cursor: progress;
}
button.busy { pointer-events: none; }

/* 设置模态框里的滑块 */
.settings-row { margin-bottom: 14px; }
.settings-row label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.settings-row .desc { font-size: 12px; color: #888; margin-bottom: 4px; }
.settings-row input[type=range] { width: 100%; }
.settings-row .value-display {
  display: inline-block; min-width: 50px; padding: 2px 8px;
  background: #eef6ff; color: #1a3a6b; font-weight: 600;
  border-radius: 3px; font-size: 13px; margin-left: 8px;
}
.settings-section {
  margin-top: 18px; padding-top: 14px; border-top: 1px dashed #ddd;
}
.settings-section h4 {
  margin: 0 0 8px; font-size: 14px; color: #1a3a6b;
}
.about-table { font-size: 13px; line-height: 1.7; }
.about-table .key { color: #888; display: inline-block; min-width: 100px; }

/* —— 面板 —— */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.panel-header h2 {
  margin: 0; font-size: 18px; font-weight: 600; color: #1a3a6b;
}

.hint { color: #777; font-size: 13px; margin: 4px 0 16px; }

/* —— 按钮 —— */
.btn-primary, .btn-secondary {
  border: none; padding: 8px 16px; border-radius: 5px;
  font-size: 14px; cursor: pointer;
  transition: background 0.12s;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #9ab; cursor: not-allowed; }
.btn-secondary { background: #fff; color: #2563eb; border: 1px solid #2563eb; }
.btn-secondary:hover { background: #eff6ff; }
.btn-tiny {
  background: transparent; border: 1px solid #ccc; color: #555;
  padding: 3px 8px; font-size: 12px; border-radius: 4px; cursor: pointer;
  margin-left: 4px;
}
.btn-tiny:hover { background: #eef; border-color: #2563eb; color: #2563eb; }

/* —— 书架 —— */
.book-list { display: flex; flex-direction: column; gap: 10px; }
.book-card {
  background: #fff; border: 1px solid #e1e4e8; border-radius: 8px;
  padding: 14px 18px;
  display: flex; flex-direction: row; align-items: flex-start; gap: 8px;
}
.book-card .card-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.book-card .info { flex: 1; }
.book-card .title { font-size: 15px; font-weight: 600; color: #222; }
.book-card .meta { font-size: 13px; color: #666; margin-top: 4px; }
.book-card .stat { font-size: 12px; color: #888; margin-top: 6px; }

/* 卡片底部 actions 行：水平排列，与信息区用细线分隔 */
.book-card .actions {
  display: flex; flex-direction: row; gap: 6px;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid #f0f2f5;
  align-items: center;
}
.book-card .actions .btn-tiny {
  font-size: 12px;
  padding: 4px 10px;
}
/* "移除"按钮自动靠右，并和前面留一段空隙避免误点 */
.book-card .actions [data-act="remove"] {
  margin-left: auto;
  color: #c0392b !important;
  border-color: #f0c4be !important;
}
.book-card .actions [data-act="remove"]:hover {
  background: #fef2f2 !important;
  border-color: #c0392b !important;
}

.status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; margin-left: 6px;
}
.status-badge.ok      { background: #d1fae5; color: #065f46; }
.status-badge.warn    { background: #fef3c7; color: #92400e; }
.status-badge.error   { background: #fee2e2; color: #991b1b; }
.status-badge.pending { background: #e5e7eb; color: #4b5563; }

.empty-state {
  text-align: center; color: #555; padding: 30px 20px;
}
.empty-state .empty-emoji {
  font-size: 56px; margin-bottom: 12px; opacity: 0.7;
}
.empty-state h3 {
  margin: 0 0 12px; font-size: 18px; color: #1a3a6b; font-weight: 600;
}
.empty-state p { margin: 6px 0; line-height: 1.6; }

/* 欢迎卡片（书架空时） */
.welcome-card {
  background: #fff; border: 1px solid #e1e4e8; border-radius: 12px;
  padding: 40px 36px; max-width: 560px; margin: 16px auto;
  text-align: left; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.welcome-card .welcome-icon {
  font-size: 48px; text-align: center; opacity: 0.85;
  margin-bottom: 8px;
}
.welcome-card h3 {
  text-align: center; font-size: 22px; color: #1a3a6b; font-weight: 600;
  margin: 8px 0 4px;
}
.welcome-card .welcome-tagline {
  text-align: center; color: #555; font-size: 14px; margin: 0 0 24px;
}
.welcome-card .welcome-steps {
  margin: 16px 0 24px; padding-left: 24px;
  font-size: 14px; line-height: 2; color: #333;
}
.welcome-card .welcome-steps li { margin-bottom: 4px; }
.welcome-card .btn-large {
  display: block; margin: 16px auto 12px;
  padding: 12px 32px; font-size: 15px;
}
.welcome-card .welcome-note {
  text-align: center; color: #999; font-size: 11px;
  margin: 16px 0 0;
}
.welcome-card .welcome-note code {
  background: #f4f5f7; padding: 1px 6px; border-radius: 3px;
  font-family: "Consolas", monospace; color: #555;
}

/* —— 文档扫描 / 单句查询 共享 —— */
.upload-zone {
  text-align: center; padding: 30px; background: #fff;
  border: 2px dashed #ccd; border-radius: 8px; margin-bottom: 16px;
}
.upload-zone.dragover { border-color: #2563eb; background: #eef6ff; }
.upload-zone p { margin: 6px 0; color: #666; }
.upload-zone .meta { font-size: 12px; color: #888; margin-top: 8px; }

.summary {
  padding: 10px 14px; background: #eff6ff; border-radius: 6px;
  font-size: 13px; color: #1e40af; margin-bottom: 12px;
}

.result-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.result-card {
  background: #fff; border: 1px solid #e1e4e8; border-radius: 8px;
  padding: 14px 18px;
}
.result-card .header {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; margin-bottom: 8px;
}
.result-card .quote {
  font-size: 15px; color: #222; margin-bottom: 10px;
  background: #fafafa; padding: 8px 12px; border-left: 3px solid #2563eb;
}
.result-card .citation {
  font-family: "Cambria", "SimSun", serif; font-size: 13px;
  color: #444; padding: 6px 0;
}
.result-card .ctx-label {
  font-size: 12px; color: #888; margin-top: 6px;
}
.result-card .ctx-text { font-size: 13px; color: #555; }
.result-card .snippet {
  font-size: 13px; background: #fafafa; padding: 8px 12px;
  border-radius: 4px; margin-top: 6px; line-height: 1.6;
}
.result-card .snippet .highlight {
  background: #fef3c7; padding: 0 2px; border-radius: 2px;
}
.result-card .scores {
  font-size: 11px; color: #888; margin: 4px 0;
}
.result-card .actions {
  display: flex; gap: 8px; margin-top: 10px;
}

.alt-cands {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed #ddd;
}
.alt-cands .alt-title { font-size: 12px; color: #888; margin-bottom: 6px; }
.alt-cand-card {
  background: #f9fafb; border-left: 2px solid #aaa;
  padding: 8px 12px; margin-bottom: 6px; border-radius: 4px;
}

.bottom-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding-top: 12px; border-top: 1px solid #e1e4e8;
}

.lookup-form {
  background: #fff; padding: 16px; border-radius: 8px;
  border: 1px solid #e1e4e8; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.lookup-form label { font-size: 13px; color: #555; font-weight: 500; }
.lookup-form .required { color: #c0392b; }
.lookup-form textarea, .lookup-form input {
  width: 100%; padding: 8px 32px 8px 10px;
  font-family: inherit; font-size: 14px;
  border: 1px solid #ccc; border-radius: 4px; outline: none;
}
.lookup-form textarea:focus, .lookup-form input:focus { border-color: #2563eb; }
.lookup-form button { align-self: flex-start; margin-top: 4px; }

.input-with-clear { position: relative; }
.input-clear-btn {
  position: absolute; top: 6px; right: 6px;
  border: none; background: transparent; cursor: pointer;
  color: #aaa; font-size: 14px; line-height: 1;
  padding: 4px 8px; border-radius: 3px;
  display: none;
}
.input-clear-btn:hover { background: #eee; color: #555; }
.input-with-clear.has-value .input-clear-btn { display: block; }
.lookup-header {
  margin-bottom: 8px; padding: 6px 10px;
  background: #f4f5f7; border-radius: 4px; font-size: 13px;
}

/* —— 状态栏 —— */
.status-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 16px; background: #2c3338; color: #fff;
  font-size: 12px; flex-shrink: 0;
}
.progress {
  flex: 1; height: 6px; background: rgba(255,255,255,0.2);
  border-radius: 3px; overflow: hidden;
}
#progress-fill {
  display: block; height: 100%; width: 0; background: #4ade80;
  transition: width 0.2s;
}

/* —— 模态框 —— */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff; min-width: 420px; max-width: 600px; max-height: 80vh;
  border-radius: 8px; overflow: hidden; display: flex; flex-direction: column;
}
.modal-header {
  background: #1a3a6b; color: #fff;
  padding: 10px 16px; font-weight: 600;
}
.modal-body {
  padding: 16px; overflow-y: auto; flex: 1;
}
.modal-body label { display: block; margin: 8px 0 4px; font-size: 13px; color: #555; }
.modal-body input {
  width: 100%; padding: 8px 10px; font-size: 14px;
  border: 1px solid #ccc; border-radius: 4px;
}
.modal-footer {
  padding: 10px 16px; background: #f4f5f7;
  display: flex; justify-content: flex-end; gap: 8px;
}

.hidden { display: none !important; }

/* —— 解析进度模态 —— */
.parse-modal { min-width: 520px; max-width: 720px; }
.parse-summary {
  font-size: 14px; font-weight: 600; color: #1a3a6b;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid #eee;
}
.parse-list { display: flex; flex-direction: column; gap: 6px; }
.parse-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 4px;
  background: #fafafa; font-size: 13px;
}
.parse-row.in-progress { background: #eff6ff; }
.parse-row.done { background: #f0fdf4; }
.parse-row.cancelled { background: #fef3f2; }
.parse-row.failed { background: #fef2f2; }
.parse-row .parse-icon {
  width: 20px; text-align: center; flex-shrink: 0;
}
.parse-row .parse-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: #333;
}
.parse-row .parse-progress-bar {
  width: 120px; height: 6px; background: #e1e8f0;
  border-radius: 3px; overflow: hidden; flex-shrink: 0;
}
.parse-row .parse-progress-fill {
  height: 100%; background: #2563eb; transition: width 0.2s;
}
.parse-row.done .parse-progress-fill { background: #1e823b; }
.parse-row.cancelled .parse-progress-fill { background: #b78612; }
.parse-row.failed .parse-progress-fill { background: #c0392b; }
.parse-row .parse-pages {
  font-size: 11px; color: #666; min-width: 70px;
  text-align: right; flex-shrink: 0;
}

/* —— 拖拽 —— */
.book-card[draggable="true"] {
  cursor: grab;
}
.book-card[draggable="true"]:active {
  cursor: grabbing;
}
.book-card.dragging {
  opacity: 0.5;
}
/* 拖到文件夹上时高亮目标整片区域 */
.folder-section.drop-target {
  outline: 2px dashed #2563eb;
  outline-offset: 1px;
  background: #eff6ff66;
  border-radius: 6px;
}
.folder-section.drop-target .folder-header {
  background: #c7dbf3;
}

/* —— 文件夹分组 —— */
.folder-section {
  margin-bottom: 12px;
}
.folder-header {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; background: #f0f4f8;
  border-radius: 6px; cursor: pointer;
  user-select: none;
  border-left: 3px solid #2563eb;
}
.folder-header:hover { background: #e6eef7; }
.folder-header .folder-arrow {
  font-size: 11px; color: #888; width: 14px;
  transition: transform 0.15s;
  display: inline-block;
}
.folder-section.collapsed .folder-header .folder-arrow {
  transform: rotate(-90deg);
}
.folder-header .folder-icon { font-size: 16px; }
.folder-header .folder-name {
  font-weight: 600; color: #1a3a6b; font-size: 14px;
}
.folder-header .folder-count {
  font-size: 12px; color: #888;
}
.folder-header .folder-actions {
  margin-left: auto; display: flex; gap: 4px;
}
.folder-header .folder-actions .btn-tiny {
  padding: 2px 8px; font-size: 11px;
}
.folder-section.ungrouped .folder-header {
  border-left-color: #aaa; background: #f7f7f7;
}
.folder-section.ungrouped .folder-name {
  color: #555; font-weight: 500;
}
.folder-body {
  padding-left: 14px; padding-top: 6px;
  display: flex; flex-direction: column; gap: 6px;
}
.folder-section.collapsed .folder-body { display: none; }
.folder-empty-msg {
  font-size: 12px; color: #999; padding: 6px 14px;
  font-style: italic;
}

/* —— 查找范围卡片（扫描/查询页） —— */
.scope-card {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: #f0f4f8;
  border-radius: 6px; margin-bottom: 12px;
  border-left: 3px solid #2563eb;
}
.scope-card .scope-label { font-size: 13px; color: #555; }
.scope-card .scope-summary {
  flex: 1; font-size: 13px; color: #1a3a6b; font-weight: 500;
}

/* —— 范围选择模态：复刻书架页的文件夹外观 —— */

/* 修 modal-body 里的 input width:100% 把 checkbox 也撑大的 bug */
.modal-body input[type="checkbox"],
.modal-body input[type="radio"] {
  width: auto !important;
  padding: 0;
}

/* 半选状态（indeterminate）的视觉提示：浅蓝边框 */
.modal-body input[type="checkbox"]:indeterminate {
  background: #c7dbf3;
  border: 2px solid #2563eb;
}

.scope-tree { font-size: 13px; }

/* "全部书架" 顶部一项 */
.scope-all-row {
  background: #eff6ff;
  border: 1px solid #c7dbf3;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  user-select: none;
}
.scope-all-row label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; font-weight: 600; color: #1a3a6b;
  font-size: 14px;
}

/* 每个文件夹 section（仿书架页 .folder-section） */
.scope-folder-section {
  margin-bottom: 8px;
  border-radius: 6px;
  overflow: hidden;
}

.scope-folder-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: #f0f4f8;
  border-left: 3px solid #2563eb;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}
.scope-folder-header:hover { background: #e6eef7; }
.scope-folder-header .folder-arrow {
  font-size: 11px; color: #888; width: 12px;
  transition: transform 0.15s;
  display: inline-block;
}
.scope-folder-section.collapsed .folder-arrow {
  transform: rotate(-90deg);
}
.scope-folder-header .folder-icon { font-size: 15px; }
.scope-folder-header .folder-name {
  font-weight: 600; color: #1a3a6b; flex: 1;
}
.scope-folder-header .folder-count {
  font-size: 12px; color: #888;
}
.scope-folder-section.ungrouped .scope-folder-header {
  border-left-color: #aaa; background: #f7f7f7;
}
.scope-folder-section.ungrouped .folder-name {
  color: #555; font-weight: 500;
}

.scope-folder-body {
  padding: 4px 0 4px 28px;
  display: flex; flex-direction: column; gap: 2px;
}
.scope-folder-section.collapsed .scope-folder-body { display: none; }

.scope-book-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
}
.scope-book-row:hover { background: #f4f5f7; }
.scope-book-row .book-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 范围模态稍宽，免得长书名被挤 */
.modal.scope-modal {
  min-width: 560px;
  max-width: 760px;
}

/* —— 多选模式 —— */
.multiselect-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  background: #eff6ff; border: 1px solid #c7dbf3;
  padding: 8px 14px; border-radius: 6px; margin-bottom: 12px;
}
.multiselect-toolbar .ms-count { font-size: 13px; color: #1a3a6b; }
.multiselect-toolbar .ms-actions { display: flex; gap: 6px; }
.btn-tiny-danger { color: #c0392b !important; border-color: #c0392b !important; }
.btn-tiny-danger:hover { background: #fef2f2 !important; }

.book-card .ms-checkbox {
  margin-right: 12px; transform: scale(1.3); cursor: pointer;
  flex-shrink: 0; align-self: center;
}
.book-card.ms-selected {
  border-color: #2563eb; background: #f5f9ff;
  box-shadow: 0 0 0 1px #2563eb inset;
}
body.multiselect-active .book-card { cursor: pointer; }
body.multiselect-active .book-card .actions { display: none; }

/* —— 工具样式 —— */
.dim { color: #888; }
.cross-page-tag {
  background: #fef3c7; color: #92400e; padding: 1px 6px;
  border-radius: 3px; font-size: 11px; font-weight: 600;
}
