:root {
  --bg: #f7faff;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --line: #dbe6f5;
  --line-strong: #c7d7ed;
  --text: #18243a;
  --muted: #687891;
  --muted-2: #8a98ad;
  --blue: #2563eb;
  --blue-600: #1d4ed8;
  --blue-soft: #eaf2ff;
  --green: #16a34a;
  --green-soft: #eaf8ef;
  --red: #ef4444;
  --red-soft: #fff0f0;
  --orange: #f59e0b;
  --orange-soft: #fff7e6;
  --shadow: 0 10px 28px rgba(20, 55, 104, 0.08);
  --shadow-soft: 0 4px 14px rgba(20, 55, 104, 0.06);
  font-family: Inter, "SF Pro Display", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  min-height: 100vh;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  background:
    radial-gradient(circle at 16% 0%, rgba(37, 99, 235, 0.08), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  color: #29415f;
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover {
  border-color: #9bb9ea;
  box-shadow: var(--shadow-soft);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  color: #9aa8bb;
  background: #f5f7fb;
  box-shadow: none;
}

button.feedback-click::after,
button.feedback-success::after,
button.feedback-error::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  pointer-events: none;
  animation: button-feedback-flash 0.52s ease-out both;
}

button.feedback-click::after {
  background: rgba(37, 99, 235, 0.14);
}

button.feedback-success::after {
  background: rgba(22, 163, 74, 0.18);
  animation-duration: 0.72s;
}

button.feedback-error::after {
  background: rgba(239, 68, 68, 0.18);
  animation-duration: 0.72s;
}

button.is-busy {
  cursor: progress;
  opacity: 0.9;
}

button.is-busy:disabled {
  border-color: #bfd4f8;
  color: #29415f;
  background: #eef5ff;
}

button.is-busy::before {
  content: "";
  position: absolute;
  top: 50%;
  right: 8px;
  width: 10px;
  height: 10px;
  margin-top: -5px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  opacity: 0.72;
  animation: button-busy-spin 0.72s linear infinite;
}

.primary.is-busy:disabled {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

.icon-button.is-busy::before {
  right: 50%;
  margin-right: -5px;
}

@keyframes button-feedback-flash {
  0% {
    opacity: 0;
    transform: scale(0.86);
  }
  28% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.04);
  }
}

@keyframes button-busy-spin {
  to {
    transform: rotate(360deg);
  }
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.35;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #8bb5ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
  resize: vertical;
}

.app-shell {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 10px 16px;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  color: #183862;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #5aa4ff 100%);
  box-shadow: 0 9px 18px rgba(37, 99, 235, 0.24);
  letter-spacing: 0;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 68px;
  padding: 0;
  border: 1px solid transparent;
  color: #53647b;
  background: transparent;
  font-size: 12px;
  box-shadow: none;
}

.rail-item:hover,
.rail-item.active {
  border-color: #d8e7ff;
  background: var(--blue-soft);
  color: var(--blue);
  box-shadow: none;
}

.rail-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  font-size: 18px;
  line-height: 1;
  color: currentColor;
}

.rail-health {
  margin-top: auto;
  width: 62px;
  color: #7790af;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
}

.workspace {
  padding: 26px 30px 34px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1520px;
  margin: 0 auto 18px;
}

.topbar-title p {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-title h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar-actions,
.button-row,
.filter-actions,
.source-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-picker {
  display: grid;
  grid-template-columns: auto 178px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
}

.language-picker {
  display: grid;
  grid-template-columns: auto 108px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.language-picker select {
  height: 36px;
  padding: 6px 30px 6px 10px;
  border-color: #cfe0ff;
  color: #23456f;
  background-color: rgba(255, 255, 255, 0.94);
  font-size: 12.5px;
  font-weight: 750;
}

.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.18);
}

.primary:hover {
  border-color: var(--blue-600);
  background: var(--blue-600);
}

.primary.loading,
.primary.loading:disabled {
  border-color: #f6c766;
  color: #9a6400;
  background: var(--orange-soft);
  box-shadow: none;
}

.status-pill {
  min-width: 72px;
  padding: 8px 12px;
  border: 1px solid #cbe0ff;
  border-radius: 999px;
  color: var(--blue);
  background: #edf5ff;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.feedback-toast {
  position: fixed;
  right: 28px;
  top: 92px;
  z-index: 30;
  display: grid;
  gap: 5px;
  width: min(420px, calc(100vw - 56px));
  border: 1px solid #cfe0ff;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(28, 55, 96, 0.16);
  padding: 12px 14px;
  color: var(--text);
  backdrop-filter: blur(14px);
}

.feedback-toast[hidden] {
  display: none;
}

.feedback-toast strong {
  font-size: 14px;
  line-height: 1.25;
}

.feedback-toast span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.feedback-toast.success {
  border-color: #bfe6cd;
  border-left-color: var(--green);
}

.feedback-toast.warning {
  border-color: #f6d58b;
  border-left-color: var(--orange);
}

.feedback-toast.error {
  border-color: #ffc7c7;
  border-left-color: var(--red);
}

.view {
  display: none;
  max-width: 1520px;
  margin: 0 auto;
}

.view.active {
  display: block;
}

body.chat-view {
  overflow: hidden;
}

body.chat-view .workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  padding: 18px 20px;
}

body.chat-view .topbar {
  max-width: none;
  margin-bottom: 12px;
}

body.chat-view #chat {
  width: 100%;
  height: 100%;
  max-width: none;
  min-height: 0;
}

.recommend-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.paper-main,
.workflow-panel,
.report-list-pane,
.report-reader,
.wiki-main,
.related-pane,
.chat-history-pane,
.chat-main,
.source-pane,
.setting-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.paper-main {
  padding: 14px;
}

.control-strip {
  display: grid;
  grid-template-columns: 38px 160px 38px 104px auto;
  gap: 8px;
  align-items: center;
}

.days-control {
  display: grid;
  grid-template-columns: auto 48px auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.days-control input {
  padding: 8px 6px;
  text-align: center;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.metric-strip div {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  border-right: 1px solid #edf2fa;
}

.metric-strip div:last-child {
  border-right: 0;
}

.metric-strip span {
  color: var(--muted);
  font-size: 12px;
}

.metric-strip strong {
  color: var(--blue);
  font-size: 22px;
  letter-spacing: 0;
}

.metric-strip em {
  color: var(--muted-2);
  font-style: normal;
  font-size: 12px;
}

.source-config {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

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

.source-toolbar strong,
.pane-head h2,
.panel-title h2,
.related-pane h2,
.source-pane h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.source-toolbar span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.source-group {
  border: 1px solid #e3ebf7;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  min-width: 0;
  max-height: 132px;
  overflow: auto;
}

.source-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.source-head strong {
  font-size: 13px;
}

.mini-button {
  padding: 5px 8px;
  font-size: 12px;
}

.choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-choice,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 4px 7px;
  border: 1px solid #d9e7fb;
  border-radius: 999px;
  color: #385071;
  background: #f8fbff;
  font-size: 11px;
}

.source-choice input {
  width: auto;
}

.empty {
  color: var(--muted-2);
}

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

.meta-line.compact {
  padding: 0 2px 8px;
}

.paper-list {
  display: grid;
  gap: 10px;
}

.paper-list.empty.syncing {
  min-height: 118px;
  place-items: center;
  border: 1px dashed #bcd2f4;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0)),
    #f8fbff;
  color: #49627f;
  font-weight: 700;
}

.paper-card {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 128px;
  gap: 14px;
  align-items: start;
  min-height: 120px;
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 12px;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.paper-card[data-disposition] {
  box-shadow: 0 7px 18px rgba(20, 55, 104, 0.09);
}

.paper-card[data-disposition="read"] {
  border-color: #9bb9ea;
  background: linear-gradient(90deg, #f2f7ff 0%, #fff 42%);
}

.paper-card[data-disposition="skip"] {
  border-color: #ffb1b1;
  background: linear-gradient(90deg, #fff5f5 0%, #fff 42%);
}

.paper-card[data-disposition="later"] {
  border-color: #f2ca72;
  background: linear-gradient(90deg, #fff9e9 0%, #fff 42%);
}

.score-ring {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  background:
    radial-gradient(circle at center, #fff 58%, transparent 59%),
    conic-gradient(var(--blue) var(--score), #d8e8ff 0);
  font-size: 18px;
  font-weight: 800;
}

.paper-content {
  min-width: 0;
}

.paper-content h3 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.35;
}

.paper-content p {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.paper-authors,
.paper-abstract {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.paper-authors {
  -webkit-line-clamp: 1;
}

.paper-abstract {
  -webkit-line-clamp: 6;
}

.paper-tags,
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.paper-tags span,
.tag-cloud span,
.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid #d8e7ff;
  border-radius: 7px;
  color: var(--blue);
  background: #eef5ff;
  font-size: 12px;
  line-height: 1;
}

.paper-actions {
  display: grid;
  gap: 8px;
}

.paper-actions button {
  padding: 7px 9px;
  font-size: 12px;
  text-align: center;
}

.paper-actions button[data-action="read"].active,
.paper-actions button[data-action="read"]:hover {
  border-color: #9bb9ea;
  color: var(--blue);
  background: var(--blue-soft);
}

.paper-actions button[data-action="read"].loading,
.paper-actions button[data-action="read"].loading:disabled {
  border-color: #f6c766;
  color: #9a6400;
  background: var(--orange-soft);
}

.paper-actions button[data-action="read"].ready,
.paper-actions button[data-action="read"].ready:hover {
  border-color: #86d4a5;
  color: var(--green);
  background: var(--green-soft);
}

.paper-actions button[data-action="skip"].active,
.paper-actions button[data-action="skip"]:hover {
  border-color: #ffb1b1;
  color: var(--red);
  background: var(--red-soft);
}

.paper-actions button[data-action="later"].active,
.paper-actions button[data-action="later"]:hover {
  border-color: #f2ca72;
  color: #9a6400;
  background: var(--orange-soft);
}

.submit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  padding: 13px;
  border: 1px solid #d7e6fb;
  border-radius: 8px;
  background: #f5f9ff;
}

.submit-bar strong {
  font-size: 14px;
}

.submit-bar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.paper-feedback-result {
  display: grid;
  gap: 3px;
  max-width: 620px;
  margin-top: 10px;
  border: 1px solid #cfe0ff;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  padding: 9px 10px;
  color: #223852;
  box-shadow: 0 8px 18px rgba(28, 55, 96, 0.06);
}

.paper-feedback-result[hidden] {
  display: none;
}

.paper-feedback-result strong {
  font-size: 13px;
}

.paper-feedback-result span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.paper-feedback-result.success {
  border-color: #bfe6cd;
  border-left-color: var(--green);
  background: #f4fbf6;
}

.paper-feedback-result.warning {
  border-color: #f6d58b;
  border-left-color: var(--orange);
  background: #fff9eb;
}

.paper-feedback-result.error {
  border-color: #ffc7c7;
  border-left-color: var(--red);
  background: #fff5f5;
}

.paper-feedback-result.pending {
  border-color: #cfe0ff;
  border-left-color: var(--blue);
  background: #f7fbff;
}

.workflow-panel {
  padding: 14px;
  position: sticky;
  top: 20px;
}

.panel-title,
.pane-head,
.reader-head,
.document-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workflow-steps {
  list-style: none;
  padding: 4px 0 0;
  margin: 0;
}

.workflow-steps li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid #edf2fa;
}

.workflow-steps li:last-child {
  border-bottom: 0;
}

.workflow-steps span {
  grid-row: 1 / span 2;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 800;
}

.workflow-steps strong,
.workflow-steps em {
  grid-column: 2;
  display: block;
}

.workflow-steps strong {
  font-size: 13px;
}

.workflow-steps em {
  margin-top: 3px;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
  line-height: 1.45;
}

.storage-grid,
.storage-counters {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.storage-grid div,
.storage-counters div {
  border: 1px solid #e1eaf7;
  border-radius: 8px;
  background: #f9fbff;
  padding: 10px;
}

.storage-grid span,
.storage-counters span {
  display: block;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.storage-grid strong,
.storage-counters strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.reports-layout,
.wiki-layout,
.chat-layout {
  display: grid;
  gap: 16px;
  align-items: start;
}

.reports-layout {
  grid-template-columns: 330px minmax(0, 1fr);
}

.report-list-pane,
.related-pane,
.chat-history-pane,
.source-pane {
  padding: 14px;
}

.report-list-pane {
  font-size: 13px;
}

.report-list-pane .pane-head {
  gap: 8px;
}

.report-list-pane .pane-head h2 {
  font-size: 14px;
}

.report-list-pane .pane-head .button-row {
  display: grid;
  grid-template-columns: 112px 48px;
  gap: 6px;
  align-items: stretch;
}

.report-list-pane .pane-head select,
.report-list-pane .pane-head button,
.report-filter-row input,
.filter-actions button {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12.5px;
  line-height: 1.25;
}

.report-list-pane .pane-head button,
.filter-actions button,
.report-reader .reader-head .button-row button {
  white-space: nowrap;
}

.report-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 7px;
  margin: 10px 0 7px;
}

.filter-actions {
  justify-content: space-between;
  margin-bottom: 7px;
}

.filter-actions .checkline {
  font-size: 12px;
}

.filter-actions button {
  min-width: 48px;
}

.checkline,
.radio-card {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #40536f;
  font-size: 13px;
}

.checkline input,
.radio-card input,
.source-settings input {
  width: auto;
}

.reports-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding-right: 2px;
}

.report-row {
  width: 100%;
  display: block;
  text-align: left;
  border-color: #e0e9f6;
  background: #fff;
  padding: 8px 9px;
  font-size: 12px;
}

.report-row.active {
  border-color: #9bbcff;
  background: #f1f6ff;
}

.report-row.highlighted {
  border-color: #f4c84a;
  background: #fff8d8;
  box-shadow: inset 3px 0 0 #d99a00;
}

.report-row.highlighted.active {
  border-color: #d99a00;
  background: #fff3bd;
}

.report-row h3 {
  margin: 0 0 4px;
  font-size: 12.5px;
  line-height: 1.32;
}

.report-row p {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.34;
}

.report-context-menu {
  position: fixed;
  z-index: 1200;
  min-width: 132px;
  padding: 4px;
  border: 1px solid #d9e3f1;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(31, 48, 79, 0.16);
}

.report-context-menu.hidden {
  display: none;
}

.report-context-menu button {
  display: block;
  width: 100%;
  padding: 7px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
}

.report-context-menu button:hover {
  background: #f2f6fb;
}

.report-context-menu button.danger {
  color: #b42318;
}

.report-context-menu button.danger:hover {
  background: #fff1f0;
}

.report-reader {
  padding: 16px;
  min-height: 640px;
  font-size: 13px;
}

.reader-head {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.report-reader .reader-head .button-row {
  gap: 7px;
  align-items: stretch;
}

.report-reader .reader-head .button-row button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.25;
}

.reader-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.28;
}

.reader-head p {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.markdown-body {
  padding: 14px 0 4px;
  color: #25354f;
  line-height: 1.68;
  font-size: 13.5px;
}

.annotation-toolbar {
  position: fixed;
  z-index: 50;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 28px rgba(24, 39, 75, 0.16);
}

.annotation-toolbar.visible {
  display: flex;
}

.annotation-swatch {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.annotation-swatch.bg-red {
  background: #fee2e2;
}

.annotation-swatch.bg-yellow {
  background: #fef3c7;
}

.annotation-swatch.bg-green {
  background: #dcfce7;
}

.annotation-swatch.text-red {
  background: #fff;
  color: #b91c1c;
}

.annotation-swatch.text-yellow {
  background: #fff;
  color: #a16207;
}

.annotation-swatch.text-green {
  background: #fff;
  color: #15803d;
}

.annotation-swatch.style-bold,
.annotation-swatch.style-italic {
  background: #fff;
  color: #25354f;
}

.annotation-swatch.text-red::before,
.annotation-swatch.text-yellow::before,
.annotation-swatch.text-green::before {
  content: "A";
  font-weight: 700;
}

.annotation-swatch.style-bold::before {
  content: "B";
  font-weight: 800;
}

.annotation-swatch.style-italic::before {
  content: "I";
  font-style: italic;
  font-weight: 700;
}

.annotation-divider {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.annotation-clear {
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 18px 0 8px;
  line-height: 1.35;
}

.markdown-body h1 {
  font-size: 19px;
}

.markdown-body h2 {
  font-size: 15.5px;
}

.markdown-body h3 {
  font-size: 14px;
}

.markdown-body p {
  margin: 0 0 10px;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 10px;
  padding-left: 20px;
}

.markdown-body blockquote {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-left: 3px solid #8bb8e8;
  background: #f3f8fd;
  color: #3a506c;
}

.markdown-body pre {
  overflow-x: auto;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 7px;
  background: #101827;
  color: #e5eefb;
}

.markdown-body pre code {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

.markdown-body a {
  color: #1d4ed8;
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body code {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef4fb;
  color: #1d4ed8;
}

.direct-read-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.direct-card {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.direct-card h3 {
  margin: 0;
  font-size: 14px;
}

.direct-read-status {
  display: grid;
  gap: 3px;
  min-height: 46px;
  border: 1px solid #cfe0ff;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #f7fbff;
  padding: 9px 10px;
  color: #223852;
  font-size: 12px;
  line-height: 1.45;
}

.direct-read-status[hidden] {
  display: none;
}

.direct-read-status strong {
  font-size: 12.5px;
}

.direct-read-status span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.direct-read-status.success {
  border-color: #bfe6cd;
  border-left-color: var(--green);
  background: #f4fbf6;
}

.direct-read-status.warning {
  border-color: #f6d58b;
  border-left-color: var(--orange);
  background: #fff9eb;
}

.direct-read-status.error {
  border-color: #ffc7c7;
  border-left-color: var(--red);
  background: #fff5f5;
}

.wiki-layout {
  grid-template-columns: minmax(760px, 1fr) 292px;
  max-width: 1280px;
  margin: 0 auto;
}

.wiki-main {
  padding: 18px;
}

.wiki-main .pane-head {
  align-items: start;
  border-bottom: 1px solid #edf2fa;
  padding-bottom: 14px;
}

.wiki-main .pane-head h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.wiki-main .pane-head .button-row {
  align-items: stretch;
}

.wiki-main .pane-head .button-row button {
  min-height: 38px;
  padding-inline: 16px;
}

.wiki-toolbar {
  display: grid;
  grid-template-columns: auto 132px 128px minmax(280px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 14px 0 12px;
}

.wiki-toolbar select,
.wiki-toolbar input[type="month"] {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font-size: 12px;
}

.wiki-toolbar span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 3px;
}

.segmented button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #58708f;
  box-shadow: none;
  padding: 7px 10px;
  font-size: 12px;
}

.segmented button.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 4px rgba(20, 55, 104, 0.08);
}

.wiki-graph {
  position: relative;
  height: clamp(680px, 72vh, 820px);
  overflow: hidden;
  border: 1px solid #d7e4f5;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(239, 246, 255, 0.86), rgba(255, 255, 255, 0.96) 46%, rgba(245, 252, 248, 0.88)),
    repeating-linear-gradient(115deg, rgba(177, 196, 225, 0.09) 0 1px, transparent 1px 36px),
    #fbfdff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -24px 60px rgba(231, 239, 251, 0.42);
}

.graph-canvas {
  position: absolute;
  inset: 1px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.graph-canvas.dragging {
  cursor: grabbing;
}

.graph-canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.62), transparent 18%, transparent 82%, rgba(255, 255, 255, 0.64)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), transparent 22%, transparent 76%, rgba(255, 255, 255, 0.76));
}

.graph-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}

.graph-viewport {
  position: absolute;
  inset: 0;
  transform-origin: center;
  will-change: transform;
}

.graph-svg-link {
  fill: none;
  stroke: rgba(65, 105, 181, 0.26);
  stroke-width: 0.9;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.graph-svg-link.strong {
  stroke: rgba(37, 99, 235, 0.6);
  stroke-width: 1.35;
}

.graph-svg-link.medium {
  stroke: rgba(70, 125, 224, 0.38);
  stroke-width: 0.95;
}

.graph-svg-link.light {
  stroke: rgba(91, 115, 150, 0.18);
  stroke-dasharray: 2 5;
}

.graph-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 460px;
  border: 1px solid rgba(213, 225, 244, 0.88);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  padding: 6px;
  color: #526782;
  font-size: 11px;
  backdrop-filter: blur(10px);
}

.graph-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 7px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue);
}

.legend-dot.method {
  background: #16a34a;
}

.legend-dot.paper {
  background: #7c92b3;
}

.legend-dot.frontier {
  background: #f97316;
}

.graph-tools {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 3;
  display: flex;
  gap: 6px;
}

.graph-tools button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #405d80;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: none;
  cursor: pointer;
}

.graph-node {
  position: absolute;
  z-index: 2;
  display: block;
  width: calc(var(--node-size, 28px) * var(--node-zoom, 1));
  height: calc(var(--node-size, 28px) * var(--node-zoom, 1));
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  overflow: visible;
  color: var(--text);
  background: transparent;
  box-shadow: none;
  transform: translate(-50%, -50%);
  cursor: pointer;
}

.graph-node:hover {
  transform: translate(-50%, -50%) scale(1.04);
}

.graph-svg {
  transform-origin: center;
}

.node-dot {
  position: absolute;
  inset: 0;
  display: block;
  border: 3px solid rgba(255, 255, 255, 0.96);
  border-radius: 999px;
  background: var(--node-color, var(--blue));
  box-shadow:
    0 0 0 6px var(--node-halo, rgba(37, 99, 235, 0.08)),
    0 10px 24px rgba(31, 65, 116, 0.14);
}

.node-label {
  position: absolute;
  left: calc(100% + 9px);
  top: 50%;
  max-width: 190px;
  transform: translateY(-50%);
  border: 1px solid rgba(210, 222, 241, 0.92);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 18px rgba(28, 55, 96, 0.08);
  color: #243957;
  padding: 5px 8px;
  font-size: calc(11px * var(--label-zoom, 1));
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.graph-node.core {
  --node-size: 62px;
}

.graph-node.core .node-label {
  top: 50%;
  left: calc(100% + 10px);
  max-width: 250px;
  transform: translateY(-50%);
  border-color: #a9c6ff;
  color: var(--blue);
  background: #fff;
  padding: 7px 10px;
  font-size: calc(13px * var(--label-zoom, 1));
  box-shadow: 0 10px 26px rgba(31, 83, 175, 0.15);
}

.graph-node.large {
  --node-size: 36px;
}

.graph-node.medium {
  --node-size: 28px;
}

.graph-node.small {
  --node-size: 20px;
}

.wiki-graph.real .graph-node.small .node-label {
  display: none;
}

.wiki-graph.real .graph-node.small:hover .node-label,
.wiki-graph.real .graph-node.small.active .node-label {
  display: block;
}

.graph-node.topic {
  --node-color: #4f8df7;
  --node-halo: rgba(79, 141, 247, 0.1);
}

.graph-node.method {
  --node-color: #17a667;
  --node-halo: rgba(23, 166, 103, 0.1);
}

.graph-node.paper {
  --node-color: #657a9b;
  --node-halo: rgba(101, 122, 155, 0.11);
}

.graph-node.frontier {
  --node-color: #f97316;
  --node-halo: rgba(249, 115, 22, 0.12);
}

.graph-node.active .node-dot {
  box-shadow:
    0 0 0 6px rgba(37, 99, 235, 0.14),
    0 0 0 14px rgba(37, 99, 235, 0.07),
    0 18px 34px rgba(31, 65, 116, 0.2);
}

.graph-node.active .node-label {
  border-color: #9bb9ea;
  color: var(--blue);
  background: #fff;
}

.graph-note {
  position: absolute;
  right: 14px;
  bottom: 14px;
  max-width: min(58%, 560px);
  color: var(--muted);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #e1eaf7;
  border-radius: 999px;
  padding: 6px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wiki-document {
  margin-top: 14px;
  border: 1px solid #dbe6f5;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  padding: 16px;
  box-shadow: 0 8px 22px rgba(20, 55, 104, 0.05);
}

.wiki-empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  height: 100%;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.wiki-empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.wiki-empty-state p {
  max-width: 420px;
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}

.document-label {
  margin: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.wiki-document h2 {
  margin: 8px 0 8px;
  font-size: 20px;
}

.wiki-entry-body {
  display: grid;
  gap: 8px;
  color: #33445e;
}

.wiki-entry-body h1,
.wiki-entry-body h2,
.wiki-entry-body h3 {
  margin: 6px 0 0;
  color: #17315d;
  font-size: 14px;
  line-height: 1.35;
}

.wiki-entry-body h1 {
  font-size: 15px;
}

.wiki-entry-body ul {
  margin: 0;
  padding-left: 18px;
}

.wiki-document p,
.wiki-entry-body li {
  margin: 0;
  color: #33445e;
  line-height: 1.7;
}

.wiki-entry-editor {
  margin-top: 10px;
}

.result-list {
  display: grid;
  gap: 8px;
  margin: 10px 0 18px;
}

.result-item {
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  text-align: left;
}

button.result-item {
  cursor: pointer;
  width: 100%;
}

.result-item h3 {
  margin: 0 0 5px;
  font-size: 13px;
}

.result-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.relationship-row {
  position: relative;
}

.relationship-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--blue), var(--green));
}

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

.related-head span {
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
}

.wiki-evidence-pane {
  position: sticky;
  top: 26px;
  align-self: start;
  padding: 14px;
  background: rgba(255, 255, 255, 0.92);
}

.wiki-evidence-pane .related-head {
  border-bottom: 1px solid #edf2fa;
  padding-bottom: 10px;
}

.wiki-evidence-pane .related-head h2,
.wiki-evidence-pane > h2 {
  font-size: 14px;
}

.wiki-evidence-pane .related-head span {
  border: 1px solid #ccebd8;
  border-radius: 999px;
  background: var(--green-soft);
  padding: 4px 7px;
  white-space: nowrap;
}

.wiki-evidence-pane .result-list {
  max-height: 492px;
  overflow: auto;
  padding-right: 2px;
}

.wiki-evidence-pane .result-item {
  position: relative;
  border-color: #dfe8f6;
  background: linear-gradient(180deg, #fff, #fbfdff);
  padding: 11px 10px 11px 12px;
  box-shadow: none;
}

.wiki-evidence-pane .result-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--blue), var(--green));
}

.wiki-evidence-pane .result-item h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #1f3657;
  font-size: 12px;
  line-height: 1.35;
}

.wiki-evidence-pane .result-item p,
.wiki-list-view .result-item p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.evidence-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.evidence-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  background: #f3f7fd;
  color: #5c708c;
  padding: 3px 6px;
  font-size: 10px;
  line-height: 1;
}

.wiki-list-view {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  height: 100%;
  overflow: auto;
  padding: 12px;
}

.chat-layout {
  grid-template-columns: 238px minmax(0, 1fr) 312px;
}

body.chat-view .chat-layout {
  grid-template-columns: 228px minmax(640px, 1fr) 360px;
  height: 100%;
  min-height: 0;
  align-items: stretch;
}

.chat-history-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  max-height: calc(100vh - 174px);
  min-height: 360px;
}

body.chat-view .chat-history-pane {
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

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

.chat-history-head h2 {
  margin: 0;
  color: #223b58;
  font-size: 15px;
  line-height: 1.2;
}

.chat-history-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.chat-history-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.chat-history-head button {
  flex: 0 0 auto;
  padding: 6px 9px;
  font-size: 12px;
}

#clearChatHistoryBtn {
  color: #9f3f3f;
  background: #fff7f7;
  border-color: #f2caca;
}

.chat-history-list {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.chat-history-list.empty {
  display: block;
  border: 1px dashed #d3e1f3;
  border-radius: 8px;
  background: #f8fbff;
  padding: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.chat-history-date {
  display: grid;
  gap: 6px;
}

.chat-history-date-title {
  color: #7a8ba4;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.chat-session-button {
  display: grid;
  width: 100%;
  gap: 4px;
  border-color: #e0e9f6;
  background: #fff;
  padding: 8px 9px;
  text-align: left;
  box-shadow: none;
}

.chat-session-button:hover,
.chat-session-button.active {
  border-color: #9ec2fa;
  background: #f3f8ff;
  box-shadow: none;
}

.chat-session-button strong {
  color: #223b58;
  font-size: 12.5px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-session-button span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.chat-main {
  display: grid;
  grid-template-rows: minmax(480px, calc(100vh - 310px)) auto auto;
  padding: 14px;
}

body.chat-view .chat-main {
  grid-template-rows: minmax(0, 1fr) auto auto;
  min-height: 0;
  height: 100%;
}

.chat-thread {
  overflow: auto;
  overflow-x: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
}

body.chat-view .chat-thread {
  min-height: 0;
}

body.chat-view .message.assistant .bubble {
  max-width: min(920px, 88%);
}

body.chat-view .message.user .bubble {
  max-width: min(720px, 72%);
}

.message {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.message.user {
  flex-direction: row-reverse;
}

.avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.message.user .avatar {
  color: #fff;
  background: var(--blue);
}

.bubble {
  max-width: 76%;
  min-width: 0;
  border: 1px solid #dce8f8;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: var(--shadow-soft);
}

.message.user .bubble {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.bubble p {
  margin: 0 0 8px;
  line-height: 1.6;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.message.user .bubble p {
  margin-bottom: 0;
}

.answer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.answer-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid #dbe8f7;
  border-radius: 999px;
  background: #f5f9ff;
  color: #476280;
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1;
}

.answer-meta .wiki {
  border-color: #cfe7d8;
  background: var(--green-soft);
  color: #15803d;
}

.answer-meta .direct {
  border-color: #d8e7ff;
  background: var(--blue-soft);
  color: var(--blue);
}

.answer-text p:last-child {
  margin-bottom: 0;
}

.answer-text strong {
  font-weight: 700;
}

.answer-text.loading {
  color: var(--muted);
}

.citation-ref {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin: 0 1px;
  border: 0;
  border-radius: 5px;
  background: #e8f3ff;
  color: var(--blue);
  padding: 0 4px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: none;
  vertical-align: baseline;
}

.citation-ref:hover {
  background: #d9ebff;
  box-shadow: none;
}

.mention-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}

.mention-chips[hidden],
.mention-suggestions[hidden] {
  display: none !important;
}

.mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 26px;
  border: 1px solid #cfe0f5;
  border-radius: 999px;
  background: #f6faff;
  color: #365875;
  padding: 3px 8px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.mention-chip button {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: #e7f0fb;
  color: #5f7690;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  box-shadow: none;
}

.mention-suggestions {
  display: grid;
  gap: 6px;
  max-height: 178px;
  overflow: auto;
  margin: -2px 0 8px;
  border: 1px solid #dbe7f4;
  border-radius: 8px;
  background: #fff;
  padding: 6px;
  box-shadow: var(--shadow-soft);
}

.mention-suggestions button {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 7px 8px;
  text-align: left;
  box-shadow: none;
}

.mention-suggestions button:hover {
  background: #f2f7ff;
  box-shadow: none;
}

.mention-suggestions strong {
  color: #223b58;
  font-size: 12px;
  line-height: 1.25;
}

.mention-suggestions span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  align-items: end;
}

.source-pane {
  display: grid;
  gap: 10px;
}

body.chat-view .source-pane {
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.source-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

body.chat-view .source-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #aab7c8 transparent;
  margin-bottom: 2px;
  padding-right: 4px;
}

body.chat-view .source-list::-webkit-scrollbar,
body.chat-view .chat-thread::-webkit-scrollbar,
body.chat-view .chat-history-list::-webkit-scrollbar {
  width: 10px;
}

body.chat-view .source-list::-webkit-scrollbar-track,
body.chat-view .chat-thread::-webkit-scrollbar-track,
body.chat-view .chat-history-list::-webkit-scrollbar-track {
  background: transparent;
}

body.chat-view .source-list::-webkit-scrollbar-thumb,
body.chat-view .chat-thread::-webkit-scrollbar-thumb,
body.chat-view .chat-history-list::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: #aab7c8;
  background-clip: content-box;
}

body.chat-view .source-list.empty {
  align-self: start;
  overflow: hidden;
}

.source-card {
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  min-width: 0;
}

.source-card.active {
  border-color: #8bb5ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.source-card button,
.source-card a {
  justify-self: start;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.source-card h3 {
  margin: 0 0 5px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.source-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.radio-card {
  justify-content: flex-start;
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 360px);
  gap: 16px;
  align-items: start;
  max-width: 1280px;
  margin: 0 auto;
}

.setting-card {
  display: grid;
  gap: 11px;
  padding: 15px;
  align-self: start;
  font-size: 13px;
}

.setting-card button,
.setting-card input,
.setting-card select,
.setting-card textarea {
  font-size: 13px;
  line-height: 1.35;
}

.setting-card input,
.setting-card select,
.setting-card textarea {
  min-height: 34px;
  padding: 7px 9px;
}

.setting-card textarea {
  line-height: 1.45;
}

.setting-card button {
  min-height: 34px;
  padding: 7px 10px;
}

.setting-card .button-row {
  gap: 7px;
  flex-wrap: wrap;
}

.setting-card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 2px;
}

.setting-card-head span {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1px solid #cfe0ff;
  border-radius: 7px;
  color: var(--blue);
  background: #f1f7ff;
  font-size: 11px;
  font-weight: 800;
}

.setting-card-head h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.setting-card-head small {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-align: right;
}

.settings-model {
  grid-column: 1;
  grid-row: 1;
}

.settings-source {
  grid-column: 1;
  grid-row: 2 / span 3;
}

.settings-storage {
  grid-column: 2;
  grid-row: 1;
}

.settings-report {
  grid-column: 2;
  grid-row: 2;
}

.settings-advanced {
  grid-column: 2;
  grid-row: 3;
}

.settings-profile {
  grid-column: 1 / -1;
  grid-row: 5;
}

.profile-card {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.profile-card .setting-card-head,
.profile-card .profile-info-grid {
  grid-column: 1 / -1;
}

.profile-card #pdfPaths {
  grid-column: span 2;
}

.profile-card .checkline {
  grid-column: span 2;
  align-self: center;
}

.profile-card #saveProfileBtn {
  grid-column: 4;
  justify-self: end;
  min-width: 106px;
}

.profile-info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.profile-info-item {
  min-height: 54px;
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: #f8fbff;
  padding: 8px 10px;
}

.profile-info-item.wide {
  grid-column: span 2;
}

.profile-info-item.full {
  grid-column: 1 / -1;
}

.profile-info-item span {
  display: block;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}

.profile-info-item strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.profile-info-item.empty strong {
  color: var(--muted);
  font-weight: 600;
}

.profile-info-item.editable {
  display: grid;
  gap: 6px;
}

.profile-info-item.editable input,
.profile-info-item.editable textarea {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  font-family: inherit;
}

.profile-info-item.editable textarea {
  resize: vertical;
}

.profile-info-item.editable small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.settings-list,
.env-form {
  display: grid;
  gap: 7px;
}

.settings-list {
  grid-template-columns: 1fr;
}

.env-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.setting-row,
.env-row {
  display: grid;
  gap: 6px;
  align-items: center;
  color: #40536f;
  font-size: 13px;
}

.env-row {
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 8px;
}

.env-row.wide-env {
  grid-column: 1 / -1;
}

.setting-row {
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: #f8fbff;
  padding: 8px;
}

.setting-row strong,
.env-row label {
  color: var(--muted);
  font-size: 12px;
}

.setting-row span {
  overflow-wrap: anywhere;
}

.env-row label {
  min-height: 0;
}

.env-row input,
.setting-card > input,
.setting-card > textarea {
  min-height: 34px;
}

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

.setting-inline-grid label,
.advanced-row,
.source-setting-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.source-settings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.settings-source {
  grid-template-columns: minmax(0, 1fr) minmax(270px, 300px);
  align-items: start;
}

.settings-source .setting-card-head,
.settings-source .source-settings,
.settings-source .source-setting-row:not(:has(.conference-source-list)) {
  grid-column: 1 / -1;
}

.settings-source .source-setting-row:has(.conference-source-list) {
  grid-column: 1;
  grid-row: 4 / span 3;
}

.settings-source .source-auth-panel {
  grid-column: 2;
  grid-row: 4;
}

.settings-source .source-edit-row {
  grid-column: 2;
  grid-row: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 74px;
  gap: 7px;
  align-items: stretch;
}

.settings-source .source-edit-row button {
  white-space: normal;
  line-height: 1.2;
  padding-inline: 8px;
}

.settings-source .rss-stack {
  grid-column: 2;
  grid-row: 6;
}

.source-settings label {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: var(--surface-soft);
  min-height: 44px;
  padding: 9px;
  font-size: 13px;
}

.source-settings label span,
.source-mode-grid label span {
  display: grid;
  gap: 2px;
}

.source-settings label strong,
.source-mode-grid label strong {
  color: var(--text);
  font-size: 13px;
}

.source-settings label em,
.source-mode-grid label em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  line-height: 1.35;
}

.source-setting-row {
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  border-top: 1px solid #edf2fa;
  padding-top: 9px;
}

.source-setting-row:has(.conference-source-list) {
  align-items: start;
}

.conference-source-list {
  display: grid;
  gap: 7px;
  max-height: 286px;
  overflow: auto;
  padding-right: 4px;
}

.conference-source-list.empty {
  min-height: 42px;
  place-items: center start;
  color: var(--muted);
  border: 1px dashed #cfdaeb;
  border-radius: 8px;
  background: #f8fbff;
  padding: 10px 12px;
  font-size: 12px;
}

.conference-source-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(118px, 0.35fr);
  gap: 9px;
  align-items: start;
  min-height: 64px;
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: #fff;
  padding: 9px;
  color: #40536f;
  box-shadow: 0 1px 0 rgba(25, 61, 105, 0.03);
}

.conference-source-item.active {
  border-color: #9fd1b6;
  background: linear-gradient(90deg, #f2fbf5 0%, #ffffff 70%);
  box-shadow: inset 3px 0 0 var(--green);
}

.conference-source-item:has(input:disabled) {
  opacity: 0.58;
}

.conference-source-item input {
  width: 15px;
  height: 15px;
  margin-top: 2px;
}

.conference-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.conference-main strong {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
}

.conference-main strong em {
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 2px 6px;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.conference-main small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.conference-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.conference-meta em {
  max-width: 100%;
  border: 1px solid #d9e6f7;
  border-radius: 999px;
  background: #f8fbff;
  color: #385274;
  padding: 3px 7px;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.conference-source-item.active .conference-meta em {
  border-color: #c6e8d2;
  background: var(--green-soft);
  color: #13733b;
}

.source-auth-panel {
  display: grid;
  gap: 9px;
  border: 1px solid #d9e7fb;
  border-radius: 8px;
  background: #fbfdff;
  padding: 12px;
}

.source-auth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.source-auth-head strong {
  font-size: 13px;
}

.source-auth-head span {
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
}

.source-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.settings-source .source-mode-grid {
  grid-template-columns: 1fr;
}

.source-mode-grid label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  border: 1px solid #e1eaf7;
  border-radius: 8px;
  background: #fff;
  padding: 9px;
}

.source-mode-grid label:has(input:checked) {
  border-color: #9bb9ea;
  background: #f1f7ff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

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

.source-auth-fields label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.source-auth-fields input {
  min-height: 34px;
}

.source-auth-panel:not([data-mode="credential"]) .source-auth-fields {
  display: none;
}

.source-auth-panel:not([data-mode="credential"]) .source-auth-fields input {
  cursor: not-allowed;
  background: #f4f7fb;
}

.source-auth-note {
  margin: 0;
  border-top: 1px solid #e7eef8;
  padding-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.tag-cloud.compact {
  gap: 5px;
}

.tag-cloud.compact span {
  min-height: 22px;
  font-size: 11px;
}

.rss-stack {
  display: grid;
  gap: 7px;
}

.rss-stack div {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: #f8fbff;
  padding: 6px 7px;
}

.rss-stack span {
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.rss-stack strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.rss-stack button {
  width: 26px;
  height: 26px;
  padding: 0;
}

.preference-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.preference-grid .checkline {
  flex: 1 1 180px;
  min-height: 34px;
  border: 1px solid #e0e9f6;
  border-radius: 8px;
  background: #f8fbff;
  padding: 7px 9px;
}

.settings-report .preference-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.settings-storage .storage-counters {
  margin-top: 0;
}

.setting-row.editable-path-row {
  align-items: start;
}

.setting-row.editable-path-row input {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  font-family: inherit;
}

.settings-storage .settings-list {
  max-height: 190px;
  overflow: auto;
  padding-right: 2px;
}

.settings-storage .button-row button,
.settings-advanced > button,
.profile-card #saveProfileBtn {
  min-height: 34px;
  font-size: 13px;
  font-weight: 700;
}

.settings-advanced .advanced-row {
  grid-template-columns: 92px minmax(0, 1fr) auto;
}

.preference-tabs {
  width: 100%;
}

.preference-tabs button {
  flex: 1;
}

.advanced-row {
  grid-template-columns: 110px minmax(0, 1fr) auto;
  align-items: center;
}

.advanced-row input {
  min-height: 34px;
}

.advanced-row span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.answer {
  margin: 0;
  min-height: 46px;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 10px;
  color: #33445e;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1240px) {
  body {
    min-width: 1024px;
  }

  .workspace {
    padding: 20px;
  }

  .recommend-layout,
  .wiki-layout,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  body.chat-view {
    overflow: auto;
  }

  body.chat-view .workspace {
    height: auto;
    min-height: 100vh;
  }

  body.chat-view #chat,
  body.chat-view .chat-layout,
  body.chat-view .chat-history-pane,
  body.chat-view .chat-main,
  body.chat-view .source-pane {
    height: auto;
  }

  body.chat-view .chat-layout {
    grid-template-columns: 1fr;
  }

  body.chat-view .chat-main {
    grid-template-rows: minmax(420px, calc(100vh - 360px)) auto auto;
  }

  body.chat-view .source-pane {
    grid-template-rows: auto;
    overflow: visible;
  }

  body.chat-view .source-list {
    max-height: 360px;
  }

  .workflow-panel {
    position: static;
  }

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

  .settings-model,
  .settings-source,
  .settings-storage,
  .settings-report,
  .settings-advanced,
  .settings-profile {
    grid-column: 1;
    grid-row: auto;
  }

  .source-settings,
  .profile-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-source {
    grid-template-columns: 1fr;
  }

  .settings-source .setting-card-head,
  .settings-source .source-settings,
  .settings-source .source-setting-row,
  .settings-source .source-auth-panel,
  .settings-source .source-edit-row,
  .settings-source .rss-stack {
    grid-column: 1;
    grid-row: auto;
  }

  .profile-card #saveProfileBtn {
    grid-column: 1 / -1;
    justify-self: stretch;
  }
}
