:root {
  /* 对齐 demo-web，强化高级质感 */
  --bg0: 245 245 247;
  --bg1: 242 242 247;
  --card: 255 255 255;
  --text: 29 29 31;
  --muted: 110 110 115;
  --line: 210 210 215;
  --brand: 0 113 227;
  --brand-hover: 0 102 204;
  --brand-soft: 232 244 255;
  --brand2: 41 151 255;
  --ok: 52 199 89;
  --warn: 255 159 10;
  --bad: 255 69 58;
  --radius: 18px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.04), 0 12px 40px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1), 0 24px 80px rgba(0, 0, 0, 0.12);
  --glass-bg: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.65);
  --surface-soft: rgba(255, 255, 255, 0.72);
  --surface-inset: rgba(0, 0, 0, 0.035);
  --table-head: rgba(250, 250, 252, 0.95);
  --row-hover: rgba(0, 113, 227, 0.028);
  --page-glow-1: rgba(0, 113, 227, 0.09);
  --page-glow-2: rgba(41, 151, 255, 0.07);
  --page-glow-3: rgba(0, 0, 0, 0.03);
  --toast-bg: rgba(29, 29, 31, 0.92);
  --backdrop: rgba(20, 22, 28, 0.38);
  --chip-ok-fg: #1f8a45;
  --chip-warn-fg: #b36b00;
}

html.theme-dark {
  color-scheme: dark;
  --bg0: 22 22 24;
  --bg1: 28 28 30;
  --card: 44 44 46;
  --text: 255 255 255;
  --muted: 174 174 178;
  --line: 58 58 60;
  --brand: 10 132 255;
  --brand-hover: 64 156 255;
  --brand-soft: 36 56 72;
  --brand2: 100 210 255;
  --ok: 48 209 88;
  --warn: 255 214 10;
  --bad: 255 82 82;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25), 0 4px 16px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 4px 18px rgba(0, 0, 0, 0.35), 0 16px 48px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.45), 0 28px 90px rgba(0, 0, 0, 0.4);
  --glass-bg: rgba(44, 44, 46, 0.78);
  --glass-border: rgba(255, 255, 255, 0.06);
  --surface-soft: rgba(36, 36, 38, 0.88);
  --surface-inset: rgba(255, 255, 255, 0.06);
  --table-head: rgba(36, 36, 38, 0.96);
  --row-hover: rgba(10, 132, 255, 0.1);
  --page-glow-1: rgba(10, 132, 255, 0.12);
  --page-glow-2: rgba(100, 210, 255, 0.06);
  --page-glow-3: rgba(0, 0, 0, 0.35);
  --toast-bg: rgba(44, 44, 46, 0.95);
  --backdrop: rgba(0, 0, 0, 0.55);
  --chip-ok-fg: #30d158;
  --chip-warn-fg: #ffd60a;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: rgb(var(--text));
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue",
    Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(900px 420px at 8% -8%, var(--page-glow-1), transparent 55%),
    radial-gradient(700px 380px at 96% 0%, var(--page-glow-2), transparent 50%),
    radial-gradient(600px 300px at 70% 100%, var(--page-glow-3), transparent 45%),
    rgb(var(--bg0));
  background-attachment: fixed;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: rgb(var(--brand)); text-decoration: none; }
a:hover { text-decoration: none; opacity: 0.85; }

* {
  scrollbar-width: thin;
  scrollbar-color: rgb(var(--muted) / 0.35) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb {
  background: rgb(var(--muted) / 0.35);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 32px 48px;
  gap: 18px;
  animation: page-in 0.55s var(--ease) both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.top-bar-dashboard {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
}
.top-bar-dashboard::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, rgb(var(--brand2)), rgb(var(--brand)));
  opacity: 0.9;
}

.top-bar-eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: rgb(var(--muted));
}
.top-bar-title {
  margin: 4px 0 0;
  font-size: clamp(1.55rem, 2.6vw, 2rem);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: rgb(var(--text));
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid rgb(var(--line) / 0.85);
  background: rgb(var(--card) / 0.85);
  color: rgb(var(--muted));
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgb(var(--muted) / 0.55);
}
.chip.ok {
  background: rgb(var(--ok) / 0.12);
  border-color: rgb(var(--ok) / 0.28);
  color: var(--chip-ok-fg);
}
.chip.ok::before {
  background: rgb(var(--ok));
  box-shadow: 0 0 0 3px rgb(var(--ok) / 0.18);
}
.chip.bad {
  background: rgb(var(--bad) / 0.12);
  border-color: rgb(var(--bad) / 0.28);
  color: rgb(var(--bad));
}
.chip.bad::before {
  background: rgb(var(--bad));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  border: 1px solid rgb(var(--line) / 0.9);
  background: rgb(var(--card) / 0.92);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 560;
  letter-spacing: -0.01em;
  color: rgb(var(--text));
  transition: transform 0.18s var(--ease), background 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.btn:hover {
  background: rgb(var(--card));
  border-color: rgb(var(--line));
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary {
  border-color: transparent;
  background: linear-gradient(180deg, rgb(var(--brand2)) 0%, rgb(var(--brand)) 100%);
  color: #fff;
  box-shadow: 0 6px 18px rgb(var(--brand) / 0.28);
}
.btn-primary:hover {
  background: linear-gradient(180deg, rgb(var(--brand-hover)) 0%, rgb(var(--brand)) 100%);
  box-shadow: 0 8px 22px rgb(var(--brand) / 0.34);
  color: #fff;
}
.btn-danger {
  border-color: rgb(var(--bad) / 0.28);
  color: rgb(var(--bad));
  background: rgb(var(--card) / 0.9);
}
.btn-danger:hover { background: rgb(var(--bad) / 0.1); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 9px; }

.field {
  height: 38px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgb(var(--line) / 0.95);
  background: rgb(var(--card) / 0.92);
  padding: 0 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  color: rgb(var(--text));
}
.field:hover { border-color: rgb(var(--brand) / 0.4); }
.field:focus {
  border-color: rgb(var(--brand));
  box-shadow: 0 0 0 4px rgb(var(--brand) / 0.14);
  background: rgb(var(--card));
}
.field::placeholder { color: rgb(var(--muted) / 0.78); }
textarea.field { height: auto; padding: 10px 12px; resize: vertical; }
select.field { appearance: auto; }
select.field option { background: rgb(var(--card)); color: rgb(var(--text)); }

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

.side {
  padding: 16px;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}
.side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 0 2px 10px;
  border-bottom: 1px solid rgb(var(--line) / 0.55);
}
.side-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.tree { display: flex; flex-direction: column; gap: 3px; }
.tree-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 11px;
  padding: 9px 11px;
  color: rgb(var(--muted));
  font-size: 13.5px;
  transition: color 0.15s ease;
}
.tree-item:hover { color: rgb(var(--text)); }
.tree-item.l1 { color: rgb(var(--text)); font-weight: 560; }
.tree-row.active .tree-item { color: rgb(var(--brand)); font-weight: 650; }
.tree-item.l2 { padding-left: 22px; font-size: 13px; }

.tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 12px;
  transition: background 0.18s ease;
}
.tree-row:hover { background: var(--surface-inset); }
.tree-row.active {
  background: rgb(var(--brand-soft));
  box-shadow: inset 0 0 0 1px rgb(var(--brand) / 0.12);
}
.tree-row .tree-item { flex: 1; min-width: 0; }
.tree-row .tree-item:hover { background: transparent; }
.tree-actions {
  display: none;
  gap: 3px;
  padding-right: 5px;
  flex-shrink: 0;
}
.tree-row:hover .tree-actions,
.tree-row.active .tree-actions { display: inline-flex; }
.tree-actions .btn {
  padding: 3px 7px;
  font-size: 11px;
  min-width: 0;
  border-radius: 8px;
}

.main {
  padding: 18px 18px 20px;
  min-width: 0;
}

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

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-inset);
  padding: 4px;
  border-radius: 14px;
}
.tab {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  border-radius: 11px;
  color: rgb(var(--muted));
  font-size: 13.5px;
  font-weight: 550;
  transition: all 0.18s var(--ease);
}
.tab:hover { color: rgb(var(--text)); }
.tab.active {
  background: rgb(var(--card));
  color: rgb(var(--text));
  box-shadow: var(--shadow-sm);
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .field { width: auto; min-width: 200px; }

.meta-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: rgb(var(--muted));
  letter-spacing: -0.01em;
}

.data-table-shell {
  overflow: auto;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid rgb(var(--line) / 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 13px 14px;
  border-bottom: 1px solid rgb(var(--line) / 0.55);
  text-align: left;
  vertical-align: top;
}
th.col-embed,
td.col-embed {
  text-align: center;
  vertical-align: top;
}
td.col-embed .badge {
  margin-inline: auto;
}
th.col-auth,
td.col-auth {
  text-align: center;
  vertical-align: top;
  white-space: nowrap;
}
.auth-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2em;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 620;
  background: rgb(var(--brand) / 0.1);
  border: 1px solid rgb(var(--brand) / 0.22);
  color: rgb(var(--brand));
}
.auth-level.lv-5 { background: rgb(var(--ok) / 0.12); border-color: rgb(var(--ok) / 0.28); color: var(--chip-ok-fg); }
.auth-level.lv-1,
.auth-level.lv-2 { opacity: 0.85; }
th {
  background: var(--table-head);
  font-weight: 620;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: rgb(var(--muted));
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody tr {
  transition: background 0.15s ease;
}
tbody tr:hover { background: var(--row-hover); }
tr:last-child td { border-bottom: 0; }
.empty {
  text-align: center;
  color: rgb(var(--muted));
  padding: 48px 20px !important;
  font-size: 14px;
}

.doc-title {
  font-weight: 620;
  color: rgb(var(--text));
  letter-spacing: -0.015em;
  max-width: 8em; /* 约 8 个汉字宽度后换行 */
  line-height: 1.45;
  word-break: break-all;
  overflow-wrap: anywhere;
}
.doc-sub {
  color: rgb(var(--muted));
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.45;
  max-width: 10em; /* 约 10 个汉字宽 */
  word-break: break-all;
  overflow-wrap: anywhere;
}
.doc-sub.is-expandable {
  cursor: pointer;
  user-select: none;
}
.doc-sub.is-expandable:hover {
  color: rgb(var(--text));
}
.doc-sub.is-expanded {
  max-width: 28em;
}
.doc-sub .doc-sub-more {
  color: rgb(var(--brand));
  margin-left: 2px;
  font-weight: 560;
}
.ops {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  gap: 5px;
  justify-content: start;
}
td.ops-cell {
  /* 保持 table-cell，避免 flex 直接挂在 td 上导致行底边错位 */
  width: 1%;
  vertical-align: top;
  white-space: normal;
  padding-left: 8px;
  padding-right: 10px;
}
td.ops-cell .btn-sm {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 8px;
  line-height: 1.25;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 560;
  border: 1px solid rgb(var(--line) / 0.8);
  background: var(--surface-inset);
  color: rgb(var(--muted));
}
.badge.ready {
  background: rgb(var(--ok) / 0.12);
  border-color: rgb(var(--ok) / 0.28);
  color: var(--chip-ok-fg);
}
.badge.failed,
.badge.keyword_only,
.badge.pending {
  background: rgb(var(--warn) / 0.12);
  border-color: rgb(var(--warn) / 0.28);
  color: var(--chip-warn-fg);
}

.hidden { display: none !important; }

.search-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.qa-block {
  margin-top: 14px;
}
.ask-row {
  align-items: stretch;
}
.ask-row textarea.field {
  height: auto;
  min-height: 64px;
  resize: vertical;
}
.ask-row .btn {
  align-self: flex-end;
  min-width: 88px;
}
.ask-answer {
  margin-top: 4px;
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid rgb(var(--line) / 0.55);
  background: rgb(var(--card) / 0.72);
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.65;
  color: rgb(var(--text));
  min-height: 72px;
}
.ask-answer.muted { color: rgb(var(--muted)); }
.ask-meta {
  margin: 10px 0 6px;
  font-size: 12px;
  color: rgb(var(--muted));
}
.card-block {
  padding: 16px 16px 14px;
  border-radius: 16px !important;
  background: var(--surface-soft) !important;
  border: 1px solid rgb(var(--line) / 0.5) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}
.section-heading {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.muted { color: rgb(var(--muted)); font-size: 12.5px; }
.row { display: flex; gap: 8px; margin: 12px 0; }
.row .field { flex: 1; height: 38px; }

.result-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: none;
  overflow: visible;
  padding-right: 0;
}
.search-grid .result-list {
  max-height: min(48vh, 520px);
  overflow: auto;
  padding-right: 4px;
  margin-top: 2px;
}
.qa-block .result-list {
  max-height: none;
  overflow: visible;
}
.result-item {
  border-radius: 14px;
  padding: 14px 16px 16px;
  background: rgb(var(--card) / 0.88);
  border: 1px solid rgb(var(--line) / 0.55);
  transition: box-shadow 0.2s ease, transform 0.2s var(--ease);
  overflow: hidden;
}
.result-item:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.result-item h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -0.02em;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.result-item .src {
  font-size: 12px;
  color: rgb(var(--muted));
  margin-bottom: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.result-item pre,
.result-item .chunk-body {
  margin: 0;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.75;
  color: rgb(var(--text) / 0.92);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.result-item pre {
  white-space: pre-wrap;
}
.result-item .chunk-body {
  white-space: normal;
}
.result-item .chunk-body p {
  margin: 0 0 0.7em;
}
.result-item .chunk-body p:last-child {
  margin-bottom: 0;
}

.result-item .cite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px;
}
.cite-hit-list {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}
.cite-hit-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-inset);
  border: 1px solid rgb(var(--line) / 0.45);
}
.cite-hit-snippet {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: rgb(var(--text));
}
.cite-hit-detail {
  margin-top: 8px;
  font-size: 12px;
  color: rgb(var(--muted));
}
.cite-hit-detail summary {
  cursor: pointer;
  user-select: none;
}
.cite-hit-detail[open] summary {
  margin-bottom: 8px;
}

.settings-block .settings-runtime {
  margin: 0 0 14px;
  font-size: 13px;
}
.settings-form {
  display: grid;
  gap: 14px;
}
.settings-form label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: rgb(var(--muted));
}
.settings-form label > span:first-child {
  color: rgb(var(--text));
  font-weight: 600;
}
.settings-field-hint {
  font-size: 12px;
  font-weight: 400;
}
.settings-form label.full {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: rgb(var(--muted));
}
.settings-form label.full span {
  color: rgb(var(--text));
  font-weight: 600;
}
.settings-subheading {
  margin: 6px 0 -4px;
  font-size: 13px;
  font-weight: 700;
  color: rgb(var(--text));
  padding-top: 4px;
  border-top: 1px solid rgb(var(--line) / 0.5);
}
.settings-prompt {
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.doc-viewer {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(16, 20, 24, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
  backdrop-filter: blur(8px);
}
.doc-viewer-panel {
  width: min(1080px, 100%);
  height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgb(var(--line) / 0.55);
  box-shadow: var(--shadow-lg);
}
.doc-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgb(var(--line) / 0.55);
}
.doc-viewer-eyebrow {
  font-size: 11px;
  color: rgb(var(--muted));
  margin-bottom: 2px;
}
.doc-viewer-head strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  word-break: break-all;
}
.doc-viewer-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-inset);
  color: rgb(var(--text));
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.doc-viewer-body {
  position: relative;
  flex: 1;
  min-height: 0;
  background: rgb(var(--bg0));
}
.doc-viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}
.doc-viewer-text {
  margin: 0;
  padding: 18px 20px;
  height: 100%;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SimSun", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  font-size: 15px;
  line-height: 1.75;
  color: rgb(var(--text));
}
.doc-viewer-loading,
.doc-viewer-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-size: 14px;
  color: rgb(var(--muted));
}
.doc-viewer-error { color: rgb(var(--bad)); }

.page-preview {
  margin: 0 0 12px;
  padding: 8px;
  border-radius: 12px;
  background: var(--surface-inset);
  border: 1px solid rgb(var(--line) / 0.55);
}
.page-preview img {
  display: block;
  width: 100%;
  max-width: 720px;
  height: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.page-preview figcaption {
  margin-top: 8px;
  font-size: 12px;
  color: rgb(var(--muted));
}

.modal {
  border: 0;
  padding: 0;
  width: min(640px, calc(100vw - 24px));
  border-radius: 20px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-lg);
  color: rgb(var(--text));
}
.modal::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(6px);
}
.modal form { display: flex; flex-direction: column; }
.modal header,
.modal footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
}
.modal header { border-bottom: 1px solid rgb(var(--line) / 0.65); }
.modal footer {
  border-top: 1px solid rgb(var(--line) / 0.65);
  gap: 8px;
  justify-content: flex-end;
}
.modal h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.icon {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: rgb(var(--muted));
  padding: 0 4px;
  border-radius: 8px;
}
.icon:hover { background: var(--surface-inset); color: rgb(var(--text)); }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px 18px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 550;
  color: rgb(var(--muted));
  letter-spacing: 0.01em;
}
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: rgb(var(--text));
  font-size: 13.5px;
  font-weight: 500;
}

.upload-dropzone {
  grid-column: 1 / -1;
  position: relative;
  border: 1.5px dashed rgb(var(--line) / 0.95);
  border-radius: 14px;
  background: var(--surface-inset);
  min-height: 118px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.upload-dropzone:hover,
.upload-dropzone:focus-visible {
  border-color: rgb(var(--brand) / 0.55);
  box-shadow: 0 0 0 3px rgb(var(--brand) / 0.12);
  outline: none;
}
.upload-dropzone.is-dragover {
  border-color: rgb(var(--brand));
  background: rgb(var(--brand) / 0.08);
  box-shadow: 0 0 0 3px rgb(var(--brand) / 0.16);
}
.upload-dropzone.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}
.upload-dropzone.has-file {
  border-style: solid;
  border-color: rgb(var(--brand) / 0.35);
}
.upload-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  z-index: 2;
}
.upload-dropzone-inner {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 118px;
  padding: 18px 16px;
  text-align: center;
}
.upload-dropzone-title {
  font-size: 14px;
  font-weight: 620;
  color: rgb(var(--text));
}
.upload-dropzone-hint {
  font-size: 12px;
  color: rgb(var(--muted));
  line-height: 1.45;
}
.upload-dropzone-file {
  margin-top: 4px;
  font-size: 12.5px;
  max-width: 100%;
  word-break: break-all;
}

.form-error {
  grid-column: 1 / -1;
  margin-top: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgb(var(--bad) / 0.1);
  border: 1px solid rgb(var(--bad) / 0.28);
  color: rgb(var(--bad));
  font-size: 13px;
  line-height: 1.45;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--toast-bg);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  max-width: min(420px, calc(100vw - 32px));
  font-size: 13.5px;
  backdrop-filter: blur(10px);
  animation: toast-in 0.28s var(--ease);
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.upload-status {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid rgb(var(--line) / 0.7);
  background: var(--surface-inset);
}
.upload-status-title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 10px;
}
.upload-status-pct {
  margin-top: 6px;
  font-size: 12px;
  color: rgb(var(--muted));
}

.job-bar {
  height: 8px;
  border-radius: 999px;
  background: rgb(var(--line) / 0.55);
  overflow: hidden;
}
.job-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgb(var(--brand2)), rgb(var(--brand)));
  transition: width 0.25s var(--ease);
}
.job-bar-fill.indeterminate {
  width: 40% !important;
  animation: job-indeterminate 1.1s ease-in-out infinite;
}
@keyframes job-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}

.job-steps {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.job-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: rgb(var(--muted));
}
.job-steps li::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgb(var(--line));
  flex-shrink: 0;
}
.job-steps li.done {
  color: rgb(var(--text) / 0.88);
}
.job-steps li.done::before {
  background: rgb(var(--ok));
}
.job-steps li.active {
  color: rgb(var(--text));
  font-weight: 600;
}
.job-steps li.active::before {
  background: rgb(var(--brand));
  box-shadow: 0 0 0 3px rgb(var(--brand) / 0.2);
}
.job-steps li.error {
  color: rgb(var(--bad));
}
.job-steps li.error::before {
  background: rgb(var(--bad));
}

.job-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  width: min(360px, calc(100vw - 32px));
}
.job-panel-card {
  padding: 16px 16px 14px;
}
.job-title {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}
.job-pct {
  margin-top: 6px;
  font-size: 12px;
  color: rgb(var(--muted));
}

.badge.processing {
  background: rgb(var(--brand) / 0.12);
  border-color: rgb(var(--brand) / 0.28);
  color: rgb(var(--brand));
}
.badge.processing::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 1s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1); }
}

@media (max-width: 960px) {
  .app { padding: 16px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .search-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .top-bar-dashboard::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .app, .toast, .btn, .tab, .result-item, tbody tr { animation: none !important; transition: none !important; }
  .btn:hover, .result-item:hover { transform: none; }
  .job-bar-fill.indeterminate, .badge.processing::after { animation: none !important; }
}

/* 登录页样式已独立到 assets/login.css，由 login.html 单独引入 */

.chip.muted-chip {
  background: var(--surface-inset);
  color: rgb(var(--muted));
  border-color: transparent;
}

/* Document detail / chunks */
.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 16px;
  margin-bottom: 14px;
}
.detail-title-wrap { flex: 1; min-width: 180px; }
.detail-title {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.detail-meta { font-size: 13px; line-height: 1.4; }
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.col-idx { width: 48px; text-align: center; color: rgb(var(--muted)); }
.col-source,
.col-lock,
.col-vec {
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
}
.col-source {
  width: 5.5rem;
  min-width: 5.5rem;
}
.col-lock,
.col-vec {
  width: 3.25rem;
  min-width: 3.25rem;
}
.chunk-preview {
  font-size: 13px;
  line-height: 1.45;
  max-width: 42rem;
  white-space: normal;
  word-break: break-word;
}
.col-source .badge,
.badge.manual,
.badge.auto {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  word-break: keep-all;
  flex-wrap: nowrap;
  flex-shrink: 0;
  writing-mode: horizontal-tb;
}
.badge.manual {
  background: rgb(34 120 90 / 0.14);
  color: rgb(24 110 80);
}
.badge.auto {
  background: rgb(var(--muted) / 0.12);
  color: rgb(var(--muted));
}
.modal-wide { width: min(760px, calc(100vw - 24px)); }
.chunk-content {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}
button.linkish {
  border: 0;
  background: transparent;
  color: rgb(var(--accent));
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
button.linkish:hover { opacity: 0.85; }
