:root {
  --bg-a: #e5e5db;
  --bg-b: #c6d8d3;
  --bg-c: #d9d4cd;
  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --line: rgba(255, 255, 255, 0.74);
  --line-strong: rgba(91, 104, 101, 0.34);
  --line-mid: rgba(91, 104, 101, 0.26);
  --line-soft: rgba(91, 104, 101, 0.19);
  --line-dashed: rgba(91, 104, 101, 0.3);
  --text: #39403e;
  --muted: #66726f;
  --accent: #b3cde0;
  --success: #a7d8b9;
  --danger: #e4a0a0;
  --focus-ring: rgba(129, 183, 148, 0.82);
  --panel-inner: rgba(255, 255, 255, 0.64);
  --panel-inner-strong: rgba(255, 255, 255, 0.74);
  --shadow: 0 26px 56px rgba(71, 82, 79, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Manrope", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-a) 0%, var(--bg-b) 56%, var(--bg-c) 100%);
  overflow: hidden;
}

.bg-layer {
  position: fixed;
  inset: -14vh -14vw;
  pointer-events: none;
}

.bg-layer-1 {
  background:
    radial-gradient(38rem 26rem at 18% 18%, rgba(179, 205, 224, 0.32), transparent 74%),
    radial-gradient(44rem 30rem at 80% 26%, rgba(167, 216, 185, 0.24), transparent 72%);
  filter: blur(22px);
}

.bg-layer-2 {
  background:
    radial-gradient(36rem 24rem at 72% 74%, rgba(228, 160, 160, 0.16), transparent 78%),
    radial-gradient(28rem 18rem at 24% 76%, rgba(178, 204, 194, 0.2), transparent 72%);
  filter: blur(34px);
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image: radial-gradient(rgba(83, 95, 92, 0.24) 0.35px, transparent 0.35px);
  background-size: 3px 3px;
}

.workspace-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.glass-panel {
  border-radius: 26px;
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(20px) saturate(120%);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: clamp(24px, 2.8vw, 38px);
  letter-spacing: 0.01em;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status {
  max-width: 46%;
  padding: 11px 15px;
  border-radius: 999px;
  border: 1px solid rgba(129, 160, 176, 0.52);
  background: rgba(179, 205, 224, 0.26);
  color: #425c66;
  font-size: 12px;
  font-weight: 600;
}

.notebook-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(760px, 1fr) 300px;
  gap: 14px;
}

.sources-pane,
.center-pane,
.intelligence-hub {
  min-height: 0;
}

.sources-pane {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

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

.intelligence-hub {
  min-height: 0;
}

.form-bar-card,
.chat-card,
.hub-card {
  min-height: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hub-card {
  height: 100%;
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.upload-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.upload-row input[type="file"] {
  flex: 1 1 190px;
  min-width: 160px;
}

input,
textarea,
button {
  font: inherit;
}

textarea,
input[type="file"] {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line-mid);
  background: var(--panel-inner-strong);
  color: var(--text);
}


input[type="file"] {
  padding: 4px 6px;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  border: 1px solid var(--line-mid);
  border-radius: 999px;
  padding: 7px 12px;
  margin-right: 10px;
  color: #4d5956;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.92), rgba(233, 238, 235, 0.86));
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

input[type="file"]::file-selector-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 8px 16px rgba(86, 99, 95, 0.16);
}

input[type="file"]::-webkit-file-upload-button {
  border: 1px solid var(--line-mid);
  border-radius: 999px;
  padding: 7px 12px;
  margin-right: 10px;
  color: #4d5956;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.92), rgba(233, 238, 235, 0.86));
  cursor: pointer;
}
textarea {
  min-height: 90px;
  padding: 10px 12px;
  resize: vertical;
}

button {
  border: 1px solid var(--line-mid);
  border-radius: 999px;
  padding: 8px 13px;
  color: #4d5956;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.88), rgba(233, 238, 235, 0.84));
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 8px 16px rgba(86, 99, 95, 0.16);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.5;
  border-color: var(--line-soft);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.danger {
  border-color: rgba(186, 128, 128, 0.56);
  background: linear-gradient(140deg, rgba(253, 241, 241, 0.92), rgba(246, 223, 223, 0.86));
  color: #7f5050;
}

.meta-grid,
.kb-stats {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.meta-grid > div,
.kb-stats > div {
  border-radius: 14px;
  border: 1px solid var(--line-mid);
  background: var(--panel-inner);
  padding: 11px;
}

.meta-grid span,
.kb-stats span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.target-form-pill {
  border-radius: 12px;
  border: 1px solid var(--line-mid);
  background: var(--panel-inner-strong);
  padding: 7px 10px;
}

.target-form-pill.active {
  background: rgba(167, 216, 185, 0.5);
  border-color: rgba(129, 183, 148, 0.56);
}

.chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--line-mid);
  background: rgba(255, 255, 255, 0.5);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-message {
  max-width: 88%;
  border-radius: 14px;
  border: 1px solid var(--line-mid);
  background: var(--glass-strong);
  padding: 10px 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-user {
  margin-left: auto;
  background: rgba(179, 205, 224, 0.38);
  border-color: rgba(124, 155, 173, 0.45);
}

.chat-assistant {
  margin-right: auto;
}

.chat-system {
  margin: 0 auto;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.58);
}

.chat-structured {
  width: 100%;
  max-width: 100%;
}

.chat-summary {
  font-weight: 700;
  margin-bottom: 8px;
}

.chat-section {
  margin-top: 8px;
  border-top: 1px dashed var(--line-dashed);
  padding-top: 8px;
}

.chat-section-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.chat-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.ghost-mini {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid var(--line-mid);
  background: var(--panel-inner-strong);
}

.chat-fill-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-fill-item {
  border: 1px solid var(--line-mid);
  border-radius: 12px;
  background: var(--panel-inner-strong);
  padding: 8px;
}

.chat-fill-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chat-fill-value {
  margin-top: 5px;
  font-weight: 700;
}

.chat-fill-meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.chat-fill-actions {
  margin-top: 6px;
  display: flex;
  justify-content: flex-end;
}

.chat-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.chat-list li {
  margin-bottom: 4px;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.chat-input-row textarea {
  min-height: 68px;
}

.kb-list,
.candidate-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kb-list {
  flex: 1 1 44%;
}

.kb-preview-panel {
  flex: 1 1 56%;
  min-height: 260px;
  border-radius: 16px;
  border: 1px solid var(--line-mid);
  background: var(--panel-inner);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.kb-preview-panel .preview-body {
  height: 100%;
}

.kb-item,
.candidate-item,
.context-card,
.paragraph-card,
.table-card {
  border-radius: 16px;
  border: 1px solid var(--line-mid);
  background: var(--glass-strong);
}

.kb-item.active-preview {
  border-color: rgba(129, 183, 148, 0.56);
  background: rgba(167, 216, 185, 0.26);
}

.kb-item,
.candidate-item,
.context-card,
.paragraph-card {
  padding: 10px 12px;
}

.table-card {
  padding: 10px;
  margin-top: 10px;
}

.table-meta,
.context-meta,
.kb-meta,
.paragraph-card .label,
.candidate-item .meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.kb-item-head,
.candidate-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.kb-actions,
.inline-actions,
.candidate-item .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.kb-badge {
  border-radius: 999px;
  font-size: 11px;
  padding: 4px 9px;
  font-weight: 700;
}

.kb-indexed {
  background: rgba(167, 216, 185, 0.42);
  color: #4f7e63;
}

.kb-uploaded {
  background: rgba(216, 199, 167, 0.42);
  color: #886f46;
}

.kb-failed {
  background: rgba(228, 160, 160, 0.44);
  color: #8a5959;
}

.feedback-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memory-log {
  margin-top: 6px;
  min-height: 70px;
  max-height: 240px;
  overflow: auto;
  border: 1px dashed var(--line-dashed);
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.38);
}

.memory-item {
  padding: 7px 9px;
  border-radius: 10px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line-soft);
}

.empty-state {
  border: 1px dashed var(--line-dashed);
  border-radius: 16px;
  padding: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.42);
  display: grid;
  place-items: center;
  text-align: center;
}

.error {
  color: #8b4f4f;
  border-color: rgba(228, 160, 160, 0.54);
  background: rgba(228, 160, 160, 0.25);
}

.legacy-hidden {
  display: none !important;
}

@media (max-width: 1620px) {
  .notebook-layout {
    grid-template-columns: 280px minmax(620px, 1fr) 280px;
  }
}

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

  .workspace-shell {
    height: auto;
    min-height: 100vh;
  }

  .notebook-layout {
    grid-template-columns: 1fr;
  }

  .center-pane {
    grid-template-rows: auto minmax(420px, 1fr);
  }
}

@media (max-width: 860px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .status {
    max-width: 100%;
  }

  .meta-grid,
  .kb-stats,
  .chat-input-row {
    grid-template-columns: 1fr;
  }
}

.chat-head-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.hidden {
  display: none !important;
}

.docx-preview-panel {
  border-radius: 16px;
  border: 1px solid var(--line-mid);
  background: var(--panel-inner);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
  max-height: 340px;
}

.preview-meta {
  font-size: 12px;
  color: var(--muted);
}

.preview-body {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-body.empty-state {
  min-height: 120px;
}

.table-scroll {
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.7);
}

.doc-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.doc-table th,
.doc-table td {
  border: 1px solid var(--line-soft);
  padding: 7px 9px;
  vertical-align: top;
  font-size: 13px;
  line-height: 1.45;
}

.selectable {
  cursor: pointer;
  transition: background 0.12s ease;
}

.selectable:hover {
  background: rgba(179, 205, 224, 0.24);
}

.selectable.selected {
  background: rgba(167, 216, 185, 0.36);
  outline: 1px solid rgba(129, 183, 148, 0.46);
}

.header-cell {
  font-weight: 700;
  background: rgba(233, 238, 235, 0.8);
}

@media (max-width: 860px) {
  .chat-head-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .docx-preview-panel {
    max-height: 280px;
  }
}

.docx-interactive {
  cursor: pointer;
}

.docx-interactive:hover {
  background: rgba(179, 205, 224, 0.22);
}

.docx-dom-selected {
  outline: 2px solid rgba(129, 183, 148, 0.75);
  outline-offset: -1px;
  background: rgba(167, 216, 185, 0.24);
}

.docx-preview-panel .docx-wrapper,
.kb-preview-panel .docx-wrapper {
  background: transparent !important;
  padding: 4px 2px !important;
}

.docx-preview-panel .docx,
.kb-preview-panel .docx {
  color: var(--text);
}

.docx-preview-panel .docx table,
.kb-preview-panel .docx table {
  border-collapse: collapse;
}

.docx-preview-panel .docx td,
.docx-preview-panel .docx th,
.kb-preview-panel .docx td,
.kb-preview-panel .docx th {
  border: 1px solid var(--line-mid);
}


.chat-workbench {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  flex: 1;
}

.chat-main {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
}

.chat-card.with-preview .chat-workbench {
  grid-template-columns: minmax(360px, 1fr) minmax(480px, 0.95fr);
  align-items: stretch;
}

.chat-card.with-preview .docx-preview-panel {
  display: flex !important;
  min-height: 0;
  max-height: none;
  height: 100%;
}

.chat-card.with-preview .preview-body {
  height: 100%;
}

.docx-preview-panel {
  overflow: hidden;
}

@media (max-width: 1360px) {
  .chat-card.with-preview .chat-workbench {
    grid-template-columns: 1fr;
  }

  .chat-card.with-preview .docx-preview-panel {
    max-height: 360px;
  }
}


.chat-thinking-toggle {
  margin-top: 6px;
}

.chat-hidden-panel {
  margin-top: 6px;
  border: 1px solid var(--line-mid);
  border-radius: 12px;
  background: var(--panel-inner);
  padding: 8px;
}

.chat-thought-list {
  margin: 0;
  padding-left: 20px;
}

.chat-thought-list li {
  margin-bottom: 4px;
}

.chat-cited-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-cited-item {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.66);
  padding: 7px 8px;
}

.chat-cited-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.chat-cited-row > span {
  flex: 1;
}

.source-link-icon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line-mid);
  background: var(--panel-inner-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.source-link-icon svg {
  width: 14px;
  height: 14px;
  fill: #5b6662;
}

.source-link-icon.no-source {
  opacity: 0.62;
}

.chat-line-sources {
  margin-top: 6px;
  display: grid;
  gap: 6px;
}

.source-button-row {
  margin-top: 10px;
}

.chat-source-grid {
  display: grid;
  gap: 8px;
}

.chat-source-card {
  border: 1px solid var(--line-mid);
  border-radius: 10px;
  padding: 8px;
  background: var(--panel-inner-strong);
}

.chat-source-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.chat-source-snippet {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.chat-source-empty {
  border: 1px dashed var(--line-dashed);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  font-size: 12px;
  padding: 7px 9px;
}








button.is-loading {
  opacity: 0.72;
  pointer-events: none;
}

button.is-loading::after {
  content: ' ...';
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.glass-chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.56);
  border-radius: 999px;
  padding: 7px 9px;
}

.auth-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.auth-actions button {
  padding: 6px 10px;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(33, 39, 37, 0.35);
  backdrop-filter: blur(4px);
}

.auth-card {
  width: min(860px, 92vw);
  padding: 18px;
  border-radius: 20px;
}

.auth-card h2 {
  margin-bottom: 6px;
}

.auth-card p {
  margin-bottom: 12px;
  color: var(--muted);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.auth-form {
  border: 1px solid var(--line-mid);
  border-radius: 14px;
  background: var(--panel-inner-strong);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.auth-form h3 {
  font-size: 14px;
}

.auth-message {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.auth-message.error {
  color: #8b4f4f;
}

@media (max-width: 920px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-actions {
    width: 100%;
    flex-wrap: wrap;
  }
}



/* ===== Figma-style final polish: source preview + auth modal ===== */
.kb-item {
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.kb-item:hover {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.9);
  transform: translateY(-1px);
}

.kb-item h3 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 4px;
}

.kb-item p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.kb-actions button {
  padding: 6px 11px;
  font-size: 12px;
}

.kb-preview-panel {
  border-color: var(--line-strong);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.78), rgba(239, 244, 242, 0.66));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.kb-preview-panel .preview-meta {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  color: #586562;
}

.kb-preview-panel .preview-body {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: rgba(245, 249, 247, 0.76);
  padding: 8px;
}

.kb-preview-panel .preview-body.empty-state {
  display: grid;
  place-items: center;
}

.kb-preview-panel .docx-wrapper {
  background: linear-gradient(180deg, rgba(236, 241, 239, 0.82), rgba(245, 248, 247, 0.92)) !important;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 14px 10px !important;
}

.kb-preview-panel .docx section.docx,
.kb-preview-panel .docx-wrapper > section {
  margin-left: auto !important;
  margin-right: auto !important;
  margin-bottom: 16px !important;
  box-shadow: 0 12px 28px rgba(88, 101, 96, 0.16) !important;
}

.auth-modal {
  background: radial-gradient(circle at 20% 16%, rgba(183, 205, 218, 0.25), transparent 52%), rgba(26, 34, 32, 0.42);
  backdrop-filter: blur(10px);
}

.auth-card {
  width: min(980px, 94vw);
  padding: 0;
  border-radius: 24px;
  overflow: hidden;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(260px, 0.88fr) minmax(420px, 1.12fr);
  min-height: 460px;
}

.auth-hero {
  padding: 30px 26px;
  border-right: 1px solid var(--line-soft);
  background:
    linear-gradient(168deg, rgba(177, 204, 216, 0.24), rgba(158, 190, 180, 0.14)),
    rgba(252, 255, 254, 0.76);
}

.auth-eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  font-weight: 700;
  color: #6a7874;
}

.auth-hero h2 {
  font-size: clamp(24px, 2.1vw, 30px);
  margin-bottom: 10px;
}

.auth-hero p {
  margin: 0;
  line-height: 1.6;
  color: #5f6d69;
}

.auth-points {
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.auth-points li {
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  color: #4e5b58;
}

.auth-body {
  padding: 26px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  justify-content: center;
}

.auth-grid {
  gap: 14px;
}

.auth-form {
  padding: 14px;
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.auth-form h3 {
  font-size: 15px;
  margin-bottom: 2px;
}

.auth-form input {
  min-height: 40px;
}

.auth-form button {
  margin-top: 4px;
  width: 100%;
  font-weight: 700;
  border-color: rgba(108, 133, 126, 0.46);
  background: linear-gradient(145deg, rgba(242, 250, 247, 0.95), rgba(225, 238, 232, 0.9));
}

.auth-form button:hover {
  border-color: rgba(88, 117, 108, 0.66);
}

.auth-message {
  min-height: 28px;
  margin-top: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  padding: 6px 10px;
  display: flex;
  align-items: center;
}

.auth-message.error {
  border-color: rgba(188, 129, 129, 0.5);
  background: rgba(245, 225, 225, 0.62);
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    padding: 20px 20px 14px;
  }

  .auth-body {
    padding: 16px;
  }
}

/* ===== 20260328-ui3: compact header + unified auth + kb modal preview ===== */
.compact-topbar {
  padding: 11px 16px;
  border-radius: 20px;
}

.compact-topbar h1 {
  margin-top: 2px;
  font-size: clamp(18px, 1.5vw, 24px);
  letter-spacing: 0;
}

.compact-topbar .subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: #64716e;
}

.compact-topbar .eyebrow {
  font-size: 10px;
  letter-spacing: 0.16em;
}

.compact-topbar .status {
  padding: 8px 12px;
  font-size: 11px;
}

.kb-preview-hint {
  border: 1px dashed var(--line-dashed);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  color: #60716b;
  background: rgba(255, 255, 255, 0.52);
}

.kb-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(25, 33, 31, 0.42);
  backdrop-filter: blur(8px);
}

.kb-preview-dialog {
  width: min(1320px, 94vw);
  height: min(90vh, 940px);
  border-radius: 22px;
  padding: 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.kb-preview-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 8px 10px;
}

.kb-preview-title {
  font-size: 13px;
  font-weight: 700;
  color: #475653;
}

#kbDocumentPreview.preview-body {
  border: 1px solid var(--line-mid);
  border-radius: 16px;
  background: linear-gradient(165deg, rgba(247, 250, 249, 0.9), rgba(232, 239, 236, 0.74));
  padding: 12px;
  overflow: auto;
}

#kbDocumentPreview .docx-wrapper {
  background: rgba(240, 245, 243, 0.86) !important;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 18px 14px !important;
}

#kbDocumentPreview .docx-wrapper > section,
#kbDocumentPreview .docx section.docx {
  margin-left: auto !important;
  margin-right: auto !important;
  margin-bottom: 18px !important;
  box-shadow: 0 14px 30px rgba(78, 91, 86, 0.16) !important;
}

.auth-modal {
  background: rgba(27, 36, 34, 0.36);
  backdrop-filter: blur(9px);
}

.auth-modal .auth-card {
  width: min(760px, 92vw);
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(165deg, rgba(247, 251, 249, 0.82), rgba(232, 239, 236, 0.74));
}

.auth-head {
  margin-bottom: 12px;
}

.auth-head h2 {
  font-size: clamp(22px, 2vw, 28px);
  margin: 3px 0 6px;
}

.auth-head p {
  margin: 0;
  font-size: 13px;
  color: #5f6e69;
}

.auth-head .auth-eyebrow {
  margin: 0;
  text-transform: none;
  letter-spacing: 0.06em;
  font-size: 11px;
  color: #6b7a76;
}

.auth-modal .auth-grid {
  gap: 12px;
}

.auth-modal .auth-form {
  border-color: rgba(107, 123, 117, 0.32);
  background: rgba(255, 255, 255, 0.78);
  padding: 12px;
}

.auth-modal .auth-form h3 {
  margin-bottom: 4px;
  font-size: 14px;
}

.auth-modal .auth-form input {
  min-height: 38px;
}

.auth-modal .auth-form button {
  width: 100%;
  margin-top: 2px;
  font-weight: 700;
  border-color: rgba(103, 125, 116, 0.44);
  background: linear-gradient(145deg, rgba(239, 248, 244, 0.95), rgba(224, 237, 231, 0.9));
}

.auth-modal .auth-message {
  margin-top: 10px;
  min-height: 30px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.66);
  padding: 7px 10px;
  display: flex;
  align-items: center;
}

.auth-modal .auth-message.error {
  border-color: rgba(185, 132, 132, 0.48);
  background: rgba(244, 227, 227, 0.62);
}

@media (max-width: 980px) {
  .kb-preview-dialog {
    width: min(96vw, 1320px);
    height: min(92vh, 940px);
    border-radius: 16px;
  }

  .auth-modal .auth-card {
    width: min(94vw, 760px);
    padding: 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}







/* ===== 20260330-theme-white: 全局白色主视觉 + 对话精修 ===== */
:root {
  --bg-a: #ffffff;
  --bg-b: #f8fafc;
  --bg-c: #eef3f8;
  --glass: rgba(255, 255, 255, 0.9);
  --glass-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(34, 44, 62, 0.08);
  --line-strong: rgba(34, 44, 62, 0.18);
  --line-mid: rgba(34, 44, 62, 0.13);
  --line-soft: rgba(34, 44, 62, 0.08);
  --line-dashed: rgba(34, 44, 62, 0.18);
  --text: #182033;
  --muted: #5e687d;
  --accent: #d7e6ff;
  --focus-ring: rgba(97, 140, 255, 0.58);
  --panel-inner: rgba(255, 255, 255, 0.86);
  --panel-inner-strong: rgba(255, 255, 255, 0.94);
  --shadow: 0 18px 44px rgba(21, 29, 44, 0.08);
}

body {
  background: linear-gradient(145deg, var(--bg-a) 0%, var(--bg-b) 58%, var(--bg-c) 100%);
}

.bg-layer-1 {
  background:
    radial-gradient(34rem 24rem at 14% 10%, rgba(196, 214, 255, 0.28), transparent 74%),
    radial-gradient(36rem 26rem at 84% 18%, rgba(213, 234, 255, 0.2), transparent 76%);
  filter: blur(26px);
}

.bg-layer-2 {
  background:
    radial-gradient(34rem 22rem at 70% 82%, rgba(223, 236, 255, 0.16), transparent 78%),
    radial-gradient(24rem 16rem at 24% 76%, rgba(224, 238, 255, 0.18), transparent 72%);
  filter: blur(34px);
}

.bg-noise {
  opacity: 0.06;
  background-image: radial-gradient(rgba(80, 92, 120, 0.22) 0.32px, transparent 0.32px);
}

.glass-panel {
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(250, 252, 255, 0.86));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(14px) saturate(112%);
  -webkit-backdrop-filter: blur(14px) saturate(112%);
}

.status {
  border-color: rgba(79, 115, 188, 0.26);
  background: rgba(227, 238, 255, 0.86);
  color: #26436a;
}

.chat-card {
  background: linear-gradient(175deg, rgba(255, 255, 255, 0.94), rgba(249, 251, 255, 0.9));
}

.chat-messages {
  border: 1px solid rgba(34, 44, 62, 0.1);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(247, 250, 255, 0.92));
  padding: 14px 14px 12px;
  gap: 12px;
}

.chat-message {
  border-radius: 16px;
  border: 1px solid rgba(34, 44, 62, 0.1);
  background: rgba(255, 255, 255, 0.96);
  padding: 12px 14px;
  line-height: 1.65;
  box-shadow: 0 8px 18px rgba(24, 32, 51, 0.05);
}

.chat-user {
  background: linear-gradient(150deg, rgba(233, 241, 255, 0.96), rgba(222, 234, 255, 0.94));
  border-color: rgba(72, 111, 194, 0.22);
}

.chat-assistant {
  border-color: rgba(30, 44, 67, 0.12);
}

.chat-summary {
  font-weight: 700;
  font-size: 15px;
  color: #11192a;
  margin-bottom: 8px;
}

.chat-message strong,
.chat-list strong,
.chat-rich strong {
  font-weight: 800;
  color: #0f1730;
}

.chat-rich p {
  margin: 0 0 8px;
}

.chat-rich p:last-child {
  margin-bottom: 0;
}

.chat-section {
  margin-top: 10px;
  border-top: 1px dashed rgba(34, 44, 62, 0.16);
  padding-top: 10px;
}

.chat-section-title {
  color: #4f5b73;
  letter-spacing: 0.01em;
}

.chat-input-row {
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
}

.chat-input-row textarea {
  min-height: 72px;
  border-radius: 16px;
  border: 1px solid rgba(34, 44, 62, 0.14);
  background: rgba(255, 255, 255, 0.96);
  padding: 12px 14px;
  line-height: 1.5;
}

#sendChatBtn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 14px;
  border-color: rgba(66, 98, 168, 0.3);
  background: linear-gradient(150deg, rgba(236, 244, 255, 0.96), rgba(225, 236, 255, 0.92));
  color: #213d67;
  font-weight: 700;
}

#sendChatBtn.is-stop-mode {
  border-color: rgba(178, 74, 74, 0.34);
  background: linear-gradient(150deg, rgba(255, 240, 240, 0.98), rgba(255, 232, 232, 0.94));
  color: #8f2734;
}

#sendChatBtn.is-stop-mode:hover {
  border-color: rgba(178, 74, 74, 0.52);
  box-shadow: 0 6px 14px rgba(148, 58, 72, 0.14);
}

.ghost-mini {
  border-radius: 999px;
  border: 1px solid rgba(34, 44, 62, 0.14);
  background: rgba(255, 255, 255, 0.94);
  color: #4b5670;
}

.chat-hidden-panel,
.chat-source-card,
.chat-cited-item {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(34, 44, 62, 0.12);
}

.source-link-icon {
  border-color: rgba(34, 44, 62, 0.14);
  background: rgba(255, 255, 255, 0.96);
}

.source-link-icon svg {
  fill: #44506a;
}

.auth-modal {
  background: rgba(240, 245, 255, 0.62);
}

.auth-modal .auth-card {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 255, 0.92));
}

.kb-preview-modal {
  background: rgba(236, 242, 252, 0.58);
}
/* ===== 20260330-pill-refine: 思路/来源胶囊按钮 ===== */
.chat-thinking-toggle,
.source-button-row {
  display: flex;
  align-items: center;
}

.chat-toggle-pill {
  min-height: 34px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid rgba(37, 56, 92, 0.14);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(246, 250, 255, 0.94));
  color: #2f3b55;
  box-shadow: 0 2px 7px rgba(33, 47, 72, 0.06);
}

.chat-toggle-pill:hover {
  border-color: rgba(55, 91, 156, 0.3);
  background: linear-gradient(145deg, rgba(246, 250, 255, 0.98), rgba(235, 243, 255, 0.95));
  box-shadow: 0 6px 14px rgba(43, 63, 97, 0.1);
}

.chat-toggle-pill:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(40, 58, 90, 0.08);
}

.thought-pill {
  color: #2c4168;
  border-color: rgba(71, 108, 182, 0.22);
}

.source-pill {
  color: #3b4a68;
  border-color: rgba(73, 95, 136, 0.2);
}

.fill-pill {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid rgba(34, 44, 62, 0.16);
  background: rgba(255, 255, 255, 0.9);
  color: #4a5672;
}

.fill-pill:hover {
  border-color: rgba(56, 81, 128, 0.3);
  background: rgba(243, 248, 255, 0.96);
}
/* ===== 20260330-workbench-upgrade: 模式切换 + 字段面板 + Diff确认 ===== */
.mode-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(34, 44, 62, 0.14);
  background: rgba(255, 255, 255, 0.94);
  font-size: 12px;
  color: #4f5a73;
}

.mode-select-wrap select {
  border: 1px solid rgba(34, 44, 62, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  color: #1f2b43;
  padding: 5px 8px;
  min-height: 30px;
}

.template-field-list {
  min-height: 180px;
  max-height: 320px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px;
}

.field-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -2px;
}

.field-badge {
  border-radius: 999px;
  border: 1px solid rgba(34, 44, 62, 0.14);
  background: rgba(255, 255, 255, 0.94);
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
}

.field-badge.filled { color: #2f6b48; border-color: rgba(78, 156, 105, 0.34); background: rgba(226, 244, 233, 0.88); }
.field-badge.pending { color: #73551c; border-color: rgba(175, 134, 63, 0.34); background: rgba(248, 238, 212, 0.88); }
.field-badge.empty { color: #5d6782; border-color: rgba(101, 116, 151, 0.28); background: rgba(237, 242, 255, 0.84); }

.template-field-item {
  border: 1px solid rgba(34, 44, 62, 0.11);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 10px;
  display: grid;
  gap: 6px;
}

.template-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.template-field-name {
  font-size: 13px;
  font-weight: 700;
  color: #1a243a;
}

.template-field-value {
  font-size: 12px;
  color: #57617a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-field-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.template-field-actions button {
  padding: 4px 10px;
  font-size: 11px;
}

.template-field-item.status-filled {
  border-color: rgba(78, 156, 105, 0.34);
  background: rgba(242, 250, 246, 0.96);
}

.template-field-item.status-pending {
  border-color: rgba(175, 134, 63, 0.34);
  background: rgba(253, 248, 236, 0.95);
}

.apply-diff-modal {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 18% 12%, rgba(179, 204, 222, 0.26), transparent 50%),
    rgba(233, 240, 245, 0.7);
  backdrop-filter: blur(10px);
}

.apply-diff-card {
  width: min(980px, 94vw);
  max-height: min(84vh, 760px);
  border-radius: 24px;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(160px, 1fr) auto;
  gap: 12px;
  border: 1px solid rgba(139, 154, 170, 0.34);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.96), rgba(246, 249, 252, 0.92));
  box-shadow:
    0 26px 56px rgba(56, 75, 96, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.apply-diff-head {
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(154, 170, 187, 0.3);
}

.apply-diff-head h3 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0;
  letter-spacing: 0.01em;
}

.apply-diff-head p {
  margin: 0;
  font-size: 13px;
  color: #55657a;
}

.apply-diff-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.apply-diff-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #4a5c71;
  border: 1px solid rgba(133, 151, 171, 0.36);
  background: rgba(248, 252, 255, 0.88);
}

.apply-diff-chip.success {
  color: #2c6a49;
  border-color: rgba(78, 156, 105, 0.36);
  background: rgba(241, 251, 246, 0.95);
}

.apply-diff-chip.warn {
  color: #8a5a43;
  border-color: rgba(194, 138, 101, 0.34);
  background: rgba(255, 246, 238, 0.95);
}

.apply-diff-list {
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(140, 156, 174, 0.28);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px;
}

.apply-diff-item {
  border: 1px solid rgba(128, 145, 165, 0.24);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  padding: 10px 12px;
  display: grid;
  gap: 9px;
  box-shadow: 0 5px 14px rgba(84, 102, 123, 0.08);
}

.apply-diff-item.changed {
  border-color: rgba(78, 156, 105, 0.34);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(244, 251, 246, 0.96));
}

.apply-diff-item.same {
  border-color: rgba(125, 144, 166, 0.25);
}

.apply-diff-item.unmatched {
  border-color: rgba(186, 128, 128, 0.38);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(252, 244, 244, 0.95));
}

.apply-diff-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.apply-diff-title .field-name {
  font-size: 16px;
  font-weight: 700;
  color: #26364a;
}

.apply-diff-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.apply-diff-status.status-ok {
  color: #2e6c4b;
  border-color: rgba(73, 151, 100, 0.35);
  background: rgba(239, 250, 244, 0.95);
}

.apply-diff-status.status-same {
  color: #4f6076;
  border-color: rgba(131, 148, 170, 0.34);
  background: rgba(242, 247, 253, 0.95);
}

.apply-diff-status.status-warn {
  color: #92584a;
  border-color: rgba(187, 132, 113, 0.34);
  background: rgba(255, 245, 239, 0.95);
}

.apply-diff-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.apply-diff-row {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(145, 162, 182, 0.24);
  border-radius: 10px;
  padding: 8px;
  background: rgba(249, 252, 255, 0.88);
}

.apply-diff-row.after {
  border-color: rgba(104, 151, 123, 0.28);
  background: rgba(245, 251, 247, 0.95);
}

.apply-diff-row span:first-child {
  color: #69798f;
  font-size: 12px;
}

.apply-diff-row code {
  background: rgba(236, 242, 255, 0.8);
  border-radius: 8px;
  padding: 6px 8px;
  color: #233755;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.apply-diff-row.after code {
  background: rgba(228, 245, 236, 0.9);
  color: #1e5b3f;
}

.apply-diff-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.apply-diff-actions button {
  min-height: 40px;
  min-width: 108px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.apply-diff-actions #confirmApplyDiffBtn {
  border-color: rgba(102, 132, 168, 0.46);
  background: linear-gradient(145deg, rgba(235, 244, 255, 0.96), rgba(220, 233, 250, 0.96));
  color: #2b4f7a;
}

.apply-diff-actions #confirmApplyDiffBtn:hover {
  border-color: rgba(82, 114, 156, 0.62);
}

@media (max-width: 860px) {
  .mode-select-wrap {
    width: 100%;
    justify-content: space-between;
    border-radius: 14px;
  }

  .mode-select-wrap select {
    flex: 1;
  }

  .apply-diff-card {
    width: 96vw;
    max-height: 88vh;
  }

  .apply-diff-row {
    grid-template-columns: 1fr;
  }
}
