@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f7f3ea;
  --panel: #fffefa;
  --panel-soft: #fbf7ef;
  --panel-2: #fbf7ef;
  --panel-3: #f1eadf;
  --text: #26231f;
  --text-strong: #26231f;
  --muted: #8a8073;
  --border: #ebe3d7;
  --border-soft: #f1eadf;
  --primary: #7c5c37;
  --primary-dark: #5f4324;
  --primary-hover: #5f4324;
  --primary-soft: #f1eadf;
  --soft: #f1eadf;
  --danger: #b4533a;
  --danger-soft: #f8e7df;
  --success: #5f7f4f;
  --success-soft: #edf4e8;
  --warning: #a36b27;
  --warning-soft: #fbf0dc;
  --purple: #8064a2;
  --cyan: #4f8b8f;
  --input-bg: #fffefa;
  --input-border: #ebe3d7;
  --input-text: #26231f;
  --placeholder: #9b9287;
  --header-bg: rgba(255, 254, 250, 0.9);
  --overlay: rgba(38, 35, 31, 0.32);
  --button-text: #fffefa;
  --shadow: none;
  --radius: 14px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #21252b;
  --panel: #282c34;
  --panel-soft: #2c313a;
  --panel-2: #2c313a;
  --panel-3: #323842;
  --text: #abb2bf;
  --text-strong: #d7dae0;
  --muted: #7f8796;
  --border: #3a404a;
  --border-soft: #343a44;
  --primary: #61afef;
  --primary-dark: #78bdf2;
  --primary-hover: #528fc7;
  --primary-soft: rgba(97, 175, 239, 0.14);
  --soft: rgba(97, 175, 239, 0.14);
  --success: #98c379;
  --success-soft: rgba(152, 195, 121, 0.14);
  --warning: #e5c07b;
  --warning-soft: rgba(229, 192, 123, 0.14);
  --danger: #e06c75;
  --danger-soft: rgba(224, 108, 117, 0.14);
  --purple: #c678dd;
  --cyan: #56b6c2;
  --input-bg: #1f2329;
  --input-border: #3a404a;
  --input-text: #d7dae0;
  --placeholder: #6f7785;
  --header-bg: rgba(40, 44, 52, 0.92);
  --overlay: rgba(12, 15, 20, 0.68);
  --button-text: #20242a;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  padding: 10px 20px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1920px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.app-title-button {
  border: 0;
  border-radius: 9px;
  padding: 4px 6px;
  margin: -4px -6px;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}

.app-title-button:hover:not(:disabled) {
  background: var(--panel-soft);
  border-color: transparent;
}

h2 {
  margin: 0;
  font-size: 16px;
}

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

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

.status-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-dark);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.status-pill:hover {
  background: var(--primary-soft);
}

.model-status-tooltip {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 2147483600;
  width: max-content;
  min-width: 230px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-3);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.65;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.status-pill:hover .model-status-tooltip,
.status-pill:focus-visible .model-status-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.model-status-tooltip strong {
  color: var(--text-strong);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
}

.status-pill[data-api-status="error"] .status-dot {
  background: var(--danger);
}

.status-pill[data-api-status="error"] #apiConnectionStatus {
  color: var(--danger);
}

main {
  flex: 1;
  width: 100%;
  max-width: 1920px;
  margin: 0 auto;
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 300px 370px minmax(420px, 1fr) 360px;
  gap: 16px;
  align-items: stretch;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.panel-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inbox-panel-header {
  flex-wrap: nowrap;
  align-items: flex-start;
}

.inbox-header-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.inbox-header-copy .small {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.inbox-panel-header .icon-row {
  flex: 0 0 auto;
}

.panel-body {
  padding: 14px;
  overflow: auto;
  min-height: 0;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 112, 100, 0.35) transparent;
}


label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-strong);
}

select,
textarea,
input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 10px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--input-text);
  background: var(--input-bg);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus,
textarea:focus,
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.5;
}

button {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

button:hover:not(:disabled) {
  border-color: var(--border);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  background: var(--primary);
  color: var(--button-text);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--panel-soft);
  color: var(--text);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-success {
  background: var(--success-soft);
  color: var(--success);
}

.btn-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.button-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
}

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

.split-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.split-action .icon-btn:first-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

.split-action .icon-btn:last-child {
  width: 26px;
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

.insight-action-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 2147483600;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fffefa;
  box-shadow: 0 14px 34px rgba(38, 35, 31, 0.14);
  display: none;
}

.insight-action-menu.show {
  display: grid;
  gap: 4px;
}

.insight-action-menu button {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
}

.insight-action-menu button:hover {
  background: var(--panel-soft);
}

.insight-source-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.insight-source-link {
  width: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 7px;
  background: var(--panel-soft);
  color: var(--primary-dark);
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}

.insight-source-link:disabled {
  cursor: default;
  opacity: 0.55;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 15px;
  line-height: 1;
  background: var(--panel-soft);
  color: #5f574d;
  border: 1px solid var(--border);
}

.icon-btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.icon-btn.success {
  background: var(--success-soft);
  color: #4d6b3d;
}

.icon-btn.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.icon-btn.active {
  background: var(--soft);
  color: var(--primary-dark);
  border-color: #d8cdbd;
}

.icon-btn.danger {
  background: var(--danger-soft);
  color: var(--danger);
}


.svg-icon {
  width: 16px;
  height: 16px;
  display: block;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  flex: none;
}

.icon-btn .svg-icon {
  width: 16px;
  height: 16px;
}

.search-clear .svg-icon {
  width: 14px;
  height: 14px;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  align-items: start;
}

.search-wrap {
  position: relative;
}

.search-wrap input {
  padding-right: 38px;
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 0;
}

.field {
  margin-bottom: 10px;
}

.current-panel .editor-grid {
  gap: 9px;
}

.card-detail-section {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fffefa;
  padding: 10px;
}

.card-detail-section.soft {
  background: var(--panel-soft);
}

.card-detail-section .field {
  margin-bottom: 0;
}

.card-meta-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.card-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.card-section-title label {
  margin-bottom: 0;
}

.card-detail-section textarea {
  background: #fffefa;
}

.type-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
}

.type-label-row label {
  margin-bottom: 0;
}

.info-dot {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--soft);
  color: var(--primary-dark);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483647;
  background: #111827;
  color: #fff;
  padding: 11px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.2s ease;
  max-width: 420px;
  white-space: pre-wrap;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.list-tools {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.search-row {
  display: block;
}



.list-action-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.filter-menu {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 120;
  width: min(430px, calc(100vw - 36px));
  max-height: min(520px, calc(100vh - 180px));
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fffefa;
  box-shadow: 0 14px 34px rgba(38, 35, 31, 0.12);
  display: none;
  overflow: hidden;
}

.filter-menu.show {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 8px;
}

.filter-groups,
.filter-options {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 0;
  overflow: auto;
}

.filter-groups {
  padding-right: 8px;
  border-right: 1px solid var(--border);
}

.filter-group-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 10px;
  background: transparent;
  color: #5f574d;
  font-weight: 800;
  text-align: left;
}

.filter-group-option.active {
  background: var(--soft);
  color: var(--primary-dark);
}

.filter-option {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  text-align: left;
}

.filter-option.active {
  background: var(--soft);
  color: var(--primary-dark);
}

.filter-clear-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 9px;
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--primary-dark);
  border: 1px solid var(--border);
  font-weight: 800;
}

.filter-count {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

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

.inbox-card {
  border: 1px solid var(--border);
  border-radius: 15px;
  background: #fffefa;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  /* width: calc(100% - 12px);de */
  width: 274px;
}

.inbox-card:hover {
  transform: translateY(-1px);
  border-color: #ded2c1;
}

.inbox-card.active {
  border-color: var(--primary);
  background: #fbf3e7;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.card-title {
  min-width: 0;
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracking-id-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-soft);
}

.tracking-id-value {
  font-size: 14px;
  font-weight: 900;
  color: var(--primary-dark);
  letter-spacing: 0.02em;
}

.card-preview {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  max-height: 42px;
  overflow: hidden;
  white-space: pre-wrap;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
}

.card-meta-left {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.card-tracking-id {
  flex: none;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
  background: #efe6d7;
  color: var(--primary-dark);
  border: 1px solid #dfcfbb;
  letter-spacing: 0.01em;
  cursor: pointer;
  user-select: none;
}

.card-tracking-id:hover {
  border-color: var(--primary);
  background: #eadcc9;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  background: #f3f4f6;
  color: var(--muted);
  white-space: nowrap;
}

.badge.done {
  color: #047857;
  background: #ecfdf5;
}

.badge.scored {
  color: #047857;
  background: #ecfdf5;
}

.badge.guiding {
  color: #1d4ed8;
  background: #eff6ff;
}

.badge.pending {
  color: #6b7280;
  background: #f3f4f6;
}

.badge.archived {
  color: #5f4324;
  background: #efe6d7;
}



.card-score-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid transparent;
  white-space: nowrap;
}

.card-score-badge.score-high {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.card-score-badge.score-mid {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.card-score-badge.score-low {
  background: #dbeafe;
  color: #1e40af;
  border-color: #bfdbfe;
}

.card-score-badge.score-very-low {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #e5e7eb;
}

.filter-section-label {
  padding: 7px 9px 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

@media (max-width: 520px) {
  .filter-menu {
    left: 0;
  }

  .filter-menu.show {
    grid-template-columns: 1fr;
  }

  .filter-groups {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 0 8px;
  }
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
}

.field-label-row label {
  margin-bottom: 0;
}

.field-label-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.card-context-menu {
  position: fixed;
  z-index: 80;
  min-width: 148px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fffefa;
  box-shadow: 0 14px 34px rgba(38, 35, 31, 0.14);
  display: none;
}

.card-context-menu.show {
  display: grid;
  gap: 4px;
}

.context-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  text-align: left;
}

.context-menu-item.danger {
  color: var(--danger);
}

.context-menu-item.warning {
  color: var(--warning);
}

.context-menu-meta {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding: 8px 10px 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  white-space: nowrap;
}

.empty-state {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 24px 14px;
  color: var(--muted);
  text-align: center;
  background: var(--panel-soft);
  font-size: 13px;
  line-height: 1.6;
}

.editor-grid {
  display: grid;
  gap: 8px;
}

.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.chat-body {
  overflow-y: auto;
  padding: 12px 14px;
  background: linear-gradient(180deg, #fffefa 0%, #fbf7ef 100%);
  min-height: 0;
}

.message {
  display: flex;
  margin-bottom: 13px;
}

.message.assistant {
  justify-content: flex-start;
}

.message.user {
  justify-content: flex-end;
}

.bubble {
  max-width: min(780px, 88%);
  padding: 10px 12px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble.markdown-body {
  white-space: normal;
}

.bubble.markdown-body p,
.bubble.markdown-body ul,
.bubble.markdown-body ol,
.bubble.markdown-body blockquote,
.bubble.markdown-body pre {
  margin: 0 0 8px;
}

.bubble.markdown-body p:last-child,
.bubble.markdown-body ul:last-child,
.bubble.markdown-body ol:last-child,
.bubble.markdown-body blockquote:last-child,
.bubble.markdown-body pre:last-child {
  margin-bottom: 0;
}

.bubble.markdown-body h1,
.bubble.markdown-body h2,
.bubble.markdown-body h3,
.bubble.markdown-body h4 {
  margin: 10px 0 6px;
  line-height: 1.35;
  font-size: 1em;
}

.bubble.markdown-body ul,
.bubble.markdown-body ol {
  padding-left: 1.35em;
}

.bubble.markdown-body code {
  padding: 1px 4px;
  border-radius: 5px;
  background: var(--panel-soft);
  font-size: 0.92em;
}

.bubble.markdown-body pre {
  padding: 9px;
  overflow: auto;
  border-radius: 10px;
  background: var(--panel-soft);
}

.bubble.markdown-body pre code {
  padding: 0;
  background: transparent;
}

.bubble.markdown-body blockquote {
  padding-left: 10px;
  border-left: 3px solid var(--border);
  color: #5f574d;
}

.assistant .bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-top-left-radius: 6px;
}

.user .bubble {
  background: var(--primary);
  color: #fff;
  border-top-right-radius: 6px;
}

.system-note {
  margin: 8px auto 16px;
  padding: 8px 12px;
  max-width: 760px;
  text-align: center;
  color: var(--muted);
  background: #f3f4f6;
  border-radius: 999px;
  font-size: 12px;
}

.composer {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: #fffefa;
}

.composer textarea {
  min-height: 58px;
  max-height: 110px;
}

.composer-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.composer-label-row label {
  margin-bottom: 0;
}

.danger-writing-controls {
  position: relative;
  flex: none;
}

.dangerous-writing-field textarea {
  transition: border-color 0.15s, box-shadow 0.15s, filter 0.2s ease;
}

.dangerous-writing-field.danger-warning textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 83, 58, 0.18);
  animation: dangerPulse 0.55s ease-in-out infinite alternate;
  filter: blur(1.4px);
}

.dangerous-writing-field.danger-active textarea {
  border-color: var(--warning);
}

.danger-writing-btn {
  position: relative;
  z-index: 3;
}

.danger-writing-btn.active {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: #e8c58d;
}

.danger-writing-menu {
  position: absolute;
  right: 0;
  top: 38px;
  z-index: 20;
  width: 176px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fffefa;
  box-shadow: 0 12px 30px rgba(38, 35, 31, 0.12);
  display: none;
  gap: 6px;
}

.danger-writing-menu.show {
  display: grid;
}

.danger-writing-option {
  width: 100%;
  text-align: left;
  background: var(--panel-soft);
  color: #5f574d;
  border: 1px solid var(--border);
}

.danger-writing-option.stop {
  color: var(--danger);
  background: var(--danger-soft);
}

.danger-writing-status {
  color: var(--muted);
  font-size: 12px;
  min-height: 18px;
  text-align: right;
  white-space: nowrap;
}

.composer-action-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.composer-action-status .loading {
  justify-content: flex-end;
}

.danger-writing-status.active {
  color: var(--warning);
  font-weight: 700;
}

.danger-writing-status.failed {
  color: var(--danger);
  font-weight: 800;
}

@keyframes dangerPulse {
  from {
    border-color: var(--danger);
  }

  to {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.24);
  }
}

.composer-actions {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.progress {
  width: 54px;
  height: 5px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.25s ease;
}

.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #d1d5db;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.result-output {
  margin: 0;
  padding: 11px;
  min-height: 168px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  border-radius: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.65;
}

.score-grid {
  display: grid;
  gap: 6px;
  margin-top: 0;
}

.score-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 8px;
  background: var(--panel-soft);
}

.score-item label {
  margin: 0 0 4px;
  line-height: 1.25;
}

.score-select {
  min-height: 36px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.score-explain {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.28;
  max-height: 28px;
  overflow: hidden;
}

.score-summary {
  margin-top: 10px;
  padding: 10px;
  padding-top: 8px;
  padding-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  display: grid;
  gap: 8px;
}

.score-total {
  font-size: 19px;
  font-weight: 900;
}

.score-level {
  color: var(--muted);
  font-size: 13px;
}

.score-tags {
  background: #f3f4f6;
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.danger-zone {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 8px;
}

#scorePanel {
  padding-top: 0px;
}

.score-summary-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.score-summary-top .icon-row {
  flex: none;
}


.inline-score-card {
  margin-top: 0;
}

.score-action-btn {
  background: var(--warning-soft);
  color: var(--warning);
}

.note-panel-editor {
  display: grid;
  gap: 10px;
  height: 100%;
  grid-template-rows: minmax(0, 1fr);
  padding-top: 6px;
}

.note-panel-editor>div {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.knowledge-note-area {
  min-height: 520px;
  height: 100%;
  resize: vertical;
  line-height: 1.65;
}

.markdown-note-shell {
  min-height: 0;
}

.markdown-note-shell .EasyMDEContainer {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: #fffefa;
}

.markdown-note-shell .editor-toolbar {
  border: 0;
  border-bottom: 1px solid var(--border);
  background: var(--panel-soft);
  opacity: 1;
}

.markdown-note-shell .CodeMirror {
  min-height: 520px;
  height: 100%;
  border: 0;
  background: #fffefa;
  color: var(--text);
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.65;
}

.markdown-note-shell .CodeMirror-scroll {
  min-height: 520px;
}

.note-stats {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

.markdown-note-shell .CodeMirror .cm-header-1 {
  font-size: 1.55em;
  line-height: 1.35;
}

.markdown-note-shell .CodeMirror .cm-header-2 {
  font-size: 1.36em;
  line-height: 1.35;
}

.markdown-note-shell .CodeMirror .cm-header-3 {
  font-size: 1.22em;
  line-height: 1.4;
}

.markdown-note-shell .CodeMirror .cm-header-4 {
  font-size: 1.12em;
  line-height: 1.45;
}

.markdown-note-shell .CodeMirror .cm-header-5 {
  font-size: 1.05em;
  line-height: 1.5;
}

.markdown-note-shell .CodeMirror .cm-header-6 {
  font-size: 1em;
  line-height: 1.55;
}

.markdown-note-shell .editor-preview,
.markdown-note-shell .editor-preview-side {
  background: #fffefa;
  color: var(--text);
  padding: 14px;
}

.markdown-note-shell .editor-preview h1,
.markdown-note-shell .editor-preview-side h1 {
  font-size: 1.55em;
  line-height: 1.35;
}

.markdown-note-shell .editor-preview h2,
.markdown-note-shell .editor-preview-side h2 {
  font-size: 1.36em;
  line-height: 1.35;
}

.markdown-note-shell .editor-preview h3,
.markdown-note-shell .editor-preview-side h3 {
  font-size: 1.22em;
  line-height: 1.4;
}

.markdown-note-shell .editor-preview h4,
.markdown-note-shell .editor-preview-side h4 {
  font-size: 1.12em;
  line-height: 1.45;
}

.markdown-note-shell .editor-preview h5,
.markdown-note-shell .editor-preview-side h5 {
  font-size: 1.05em;
  line-height: 1.5;
}

.markdown-note-shell .editor-preview h6,
.markdown-note-shell .editor-preview-side h6 {
  font-size: 1em;
  line-height: 1.55;
}

.score-modal {
  width: min(1280px, 96vw);
  height: min(860px, 94vh);
}

.score-modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) 360px;
  gap: 14px;
  height: 100%;
  min-height: 0;
}

.score-modal-note,
.score-modal-scoring {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fffefa;
  padding: 10px;
}

.score-modal-note pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
  font-family: inherit;
  font-size: 15px;
}

.score-modal-scoring {
  display: grid;
  gap: 6px;
  align-content: start;
  background: var(--panel-soft);
}

@media (max-width: 900px) {
  .score-modal-layout {
    grid-template-columns: 1fr;
  }
}


.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(38, 35, 31, 0.32);
  backdrop-filter: blur(6px);
}

.modal-backdrop.show {
  display: flex;
}

#rawContentModal.show {
  z-index: 2147483000;
}

#ocrConfirmModal.show {
  z-index: 2147483001;
}

#aiModelEditorModal.show {
  z-index: 2147483001;
}

.content-modal {
  width: min(960px, 94vw);
  height: min(780px, 88vh);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  box-shadow: 0 20px 60px rgba(38, 35, 31, 0.18);
}

.content-modal-header,
.content-modal-footer {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.content-modal-footer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.content-modal-title {
  font-size: 14px;
  font-weight: 800;
}

.content-modal-body {
  padding: 14px;
  min-height: 0;
}

.content-modal textarea {
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  font-size: 15px;
  line-height: 1.7;
  border-radius: 16px;
}

.bulk-add-modal {
  width: min(1040px, 96vw);
  height: min(860px, 92vh);
}

.bulk-add-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.bulk-add-controls {
  display: grid;
  grid-template-columns: 170px 190px;
  gap: 10px;
  align-items: end;
}

.bulk-add-option {
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-soft);
  color: #5f574d;
  font-size: 13px;
  font-weight: 800;
}

.bulk-add-option input {
  width: auto;
}

#bulkAddText {
  min-height: 0;
  height: 100%;
  resize: none;
  font-size: 14px;
  line-height: 1.65;
}

@media (max-width: 760px) {

  .bulk-add-controls,
  .card-meta-section {
    grid-template-columns: 1fr;
  }
}


.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.settings-modal {
  width: min(1120px, 96vw);
  height: min(820px, 90vh);
}

.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

.settings-sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel-soft);
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.settings-tab {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #5f574d;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  font-weight: 800;
}

.settings-tab.active {
  background: #fffefa;
  border-color: var(--border);
  color: var(--primary-dark);
}

.settings-content {
  padding: 14px;
  overflow: auto;
  min-height: 0;
}

.settings-section {
  display: grid;
  gap: 14px;
}

.settings-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: #fffefa;
}

.settings-card textarea {
  height: auto !important;
  min-height: 160px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.model-library-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.model-library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-soft);
}

.model-library-item strong {
  color: var(--text-strong);
}

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

.feature-config-card.topic-center-feature {
  grid-column: 1 / -1;
}

.topic-center-feature-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 10px;
}

.topic-center-feature-column {
  min-width: 0;
}

.prompt-settings-group {
  display: grid;
  gap: 10px;
}

.prompt-setting-item {
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

.prompt-setting-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.prompt-setting-item textarea {
  min-height: 150px !important;
}

.feature-model-checklist {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
}

.feature-model-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--input-text);
  cursor: pointer;
}

.feature-model-option:hover {
  background: var(--primary-soft);
}

.feature-model-option input {
  width: auto;
  margin: 0;
}

.ai-model-editor-modal {
  width: min(720px, calc(100vw - 24px));
  height: min(820px, 92vh);
}

.ai-model-editor-body {
  overflow: auto;
}

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

.ai-model-editor-form .field-span-2 {
  grid-column: 1 / -1;
}

.ai-model-editor-form input,
.ai-model-editor-form select,
.ai-model-editor-form textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 10px 11px;
  color: var(--input-text);
  background: var(--input-bg);
  font: inherit;
  outline: none;
}

.ai-model-editor-form input,
.ai-model-editor-form select {
  min-height: 42px;
}

.ai-model-editor-form .field {
  min-width: 0;
}

.ai-model-editor-form label {
  margin-bottom: 7px;
}

.ai-model-editor-form input:focus,
.ai-model-editor-form select:focus,
.ai-model-editor-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.password-input-row {
  position: relative;
}

.password-input-row input {
  padding-right: 42px;
}

.password-visibility-btn {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.password-visibility-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.password-visibility-btn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.feedback-compose {
  display: grid;
  gap: 8px;
}

.feedback-compose textarea {
  min-height: 96px !important;
  font-family: inherit;
}

.feedback-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.feedback-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
}

.feedback-item p {
  margin: 4px 0 0;
  white-space: pre-wrap;
  line-height: 1.55;
}

.ocr-confirm-modal {
  width: min(1120px, 96vw);
  height: min(780px, 90vh);
}

.ocr-confirm-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  overflow: hidden;
}

.ocr-image-preview,
.ocr-result-panel {
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-soft);
  overflow: auto;
}

.ocr-image-preview {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
}

.ocr-import-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.ocr-import-zone:hover,
.ocr-import-zone.is-drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.ocr-import-zone strong {
  color: var(--text-strong);
  font-size: 14px;
}

.ocr-import-zone .small {
  line-height: 1.65;
}

.ocr-image-item {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  cursor: grab;
  user-select: none;
}

.ocr-image-item.is-dragging {
  opacity: 0.45;
}

.ocr-image-item.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.ocr-drag-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.ocr-image-item img {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 8px;
}

.ocr-result-panel {
  position: relative;
  padding: 10px;
}

.ocr-result-panel textarea {
  min-height: 100%;
  resize: none;
}

.ocr-result-panel .loading {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  justify-content: center;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}

@media (max-width: 760px) {
  .feature-config-grid,
  .ocr-confirm-body,
  .ai-model-editor-form {
    grid-template-columns: 1fr;
  }

  .feature-config-card.topic-center-feature {
    grid-column: auto;
  }

  .topic-center-feature-layout {
    grid-template-columns: 1fr;
  }

  .ai-model-editor-form .field-span-2 {
    grid-column: auto;
  }
}

.settings-card {
  overflow: visible;
}

.settings-card+.settings-card {
  margin-top: 0;
}

#settingsSystemPrompt {
  min-height: 220px;
}

#settingsFinalPrompt {
  min-height: 360px;
}

.type-guides-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.type-guide-item textarea {
  min-height: 86px;
}

.placeholder-list {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.placeholder-chip {
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

@media (max-width: 900px) {
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .type-guides-grid {
    grid-template-columns: 1fr;
  }
}


.sort-menu {
  left: 77px;
  width: 230px;
  min-width: 210px;
}

.sort-menu.show {
  grid-template-columns: 1fr;
}

.round-inline {
  width: 54px !important;
  height: 32px;
  padding: 6px 8px !important;
  border-radius: 10px !important;
  font-size: 12px !important;
  font-weight: 800;
  text-align: center;
}

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

.chat-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-soft);
}

.chat-mode-btn {
  position: relative;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.chat-mode-btn.has-content::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 2px;
  width: 7px;
  height: 7px;
  border: 2px solid var(--panel-soft);
  border-radius: 999px;
  background: var(--danger);
}

.chat-mode-btn.active {
  background: #fffefa;
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px var(--border);
}

.guide-only.hidden {
  display: none !important;
}

.dashboard-modal {
  width: min(1360px, 96vw);
  height: min(860px, 90vh);
}

.dashboard-modal .content-modal-body {
  overflow: auto;
}

.dashboard-modal .content-modal-footer {
  flex-wrap: wrap;
  align-items: flex-start;
}

.insight-entry-btn {
  position: relative;
}

.topic-entry-btn {
  position: relative;
}

.insight-entry-icon {
  font-size: 18px;
  line-height: 1;
}

.insight-entry-badge {
  position: absolute;
  right: -6px;
  top: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: #fffefa;
  border: 1px solid var(--panel);
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  display: none;
  white-space: nowrap;
}

.insight-entry-badge.show {
  display: block;
}

.insight-modal {
  width: min(1540px, 98vw);
  height: min(920px, 94vh);
}

.insight-header {
  align-items: flex-start;
}

.insight-body {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
  background: #fffefa;
}

.insight-result-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.topic-center-modal {
  width: min(1180px, calc(100vw - 24px));
  height: min(860px, 94vh);
}

.topic-center-modal-body {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
  background: #fffefa;
}

.topic-center-nav {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.topic-center-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.topic-center-header h2 {
  font-size: 16px;
}

.topic-center-stats {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

.topic-center-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

.topic-center-stat strong {
  color: var(--text);
  font-size: 14px;
}

.topic-center-tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 8px;
}

.topic-center-tabs button {
  border: 0;
  background: transparent;
  padding: 10px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
}

.topic-center-tabs button.active {
  color: var(--primary-dark);
  background: var(--soft);
}

.topic-center-main {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.topic-center-content {
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.topic-center-toolbar,
.topic-card-actions,
.topic-detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-center-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.topic-center-modal .topic-center-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  align-items: start;
}

.topic-governance-card {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fffefa;
}

.topic-governance-card h3 {
  font-size: 14px;
}

.topic-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.topic-card-actions {
  justify-content: flex-start;
}

.topic-card-actions button {
  padding: 6px 9px;
  font-size: 12px;
}

.topic-editor-modal {
  width: min(620px, calc(100vw - 24px));
}

.structure-candidate-modal {
  width: min(980px, calc(100vw - 24px));
  height: min(760px, 90vh);
}

.structure-candidate-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  height: 100%;
}

.structure-candidate-direction {
  flex: 0 0 auto;
  min-height: 0;
}

.structure-candidate-direction textarea {
  display: block;
  height: 96px;
  min-height: 96px;
  max-height: 180px;
  resize: vertical;
}

.structure-candidate-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-content: start;
  padding: 1px;
}

.structure-candidate-group {
  display: grid;
  gap: 8px;
}

.structure-candidate-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-strong);
  font-weight: 800;
}

.structure-candidate-group-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.structure-candidate-grid > .loading,
.structure-candidate-grid > .insight-empty,
.structure-candidate-group > .insight-empty {
  min-height: 64px;
  align-self: start;
}

.structure-candidate-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-soft);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.structure-candidate-card.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.structure-candidate-card-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.structure-candidate-check {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: transparent;
  background: var(--input-bg);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

button.structure-candidate-check {
  padding: 0;
}

.structure-candidate-card.is-selected .structure-candidate-check {
  color: var(--button-text);
  border-color: var(--primary);
  background: var(--primary);
}

.structure-candidate-card h3 {
  font-size: 15px;
  color: var(--text-strong);
}

.structure-candidate-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

@media (max-width: 760px) {
  .structure-candidate-group-row {
    grid-template-columns: 1fr;
  }
}

.topic-detail-modal {
  width: min(920px, calc(100vw - 24px));
  height: min(820px, 92vh);
}

.topic-detail-body {
  overflow: auto;
}

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

.topic-form-grid .span-2 {
  grid-column: 1 / -1;
}

.topic-form-grid input,
.topic-form-grid select,
.topic-form-grid textarea {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 10px 11px;
  color: var(--input-text);
  background: var(--input-bg);
  font: inherit;
  outline: none;
}

.topic-form-grid input:focus,
.topic-form-grid select:focus,
.topic-form-grid textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.topic-binding-row {
  display: grid;
  gap: 7px;
  padding: 8px;
}

.topic-binding-row > div {
  display: grid;
  gap: 4px;
}

.topic-binding-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topic-binding-heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.topic-binding-label-row label {
  margin-bottom: 0;
}

.ai-recommend-btn.is-loading {
  color: var(--primary);
  cursor: progress;
}

.ai-recommend-panel {
  display: grid;
  gap: 5px;
  margin-top: 4px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
}

.ai-recommend-item {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.ai-recommend-item-title,
.ai-recommend-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-relevance {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
}

.ai-recommend-reason,
.ai-no-match {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.ai-no-match {
  white-space: pre-line;
}

.topic-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 18px;
}

.topic-binding-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-dark);
  font-size: 12px;
}

.topic-relation-list {
  align-items: stretch;
  gap: 7px;
}

.topic-relation-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
}

.topic-relation-option:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.topic-relation-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.topic-relation-option input {
  width: auto;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--primary);
}

.topic-relation-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.topic-binding-chip button {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
  padding: 0;
}

.topic-card-table {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.topic-card-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.knowledge-status-badge.absorbed {
  color: #2f5d34;
  background: #e4f0e2;
}

.insight-progress-panel,
.insight-log-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.insight-progress-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.insight-progress-grid div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.insight-progress-grid strong {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.insight-progress-track {
  height: 9px;
  margin-top: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #e7ded1;
}

.insight-progress-fill {
  width: 0%;
  height: 100%;
  background: var(--success);
  transition: width 0.2s ease;
}

.insight-progress-actions,
.insight-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.insight-section-title {
  margin-top: 0;
  margin-bottom: 8px;
}

.insight-log-list {
  display: grid;
  gap: 6px;
  max-height: 132px;
  overflow: auto;
  font-size: 12px;
}

.insight-log-item {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  background: #fffefa;
  border: 1px solid transparent;
}

.insight-log-item.success {
  color: var(--success);
  border-color: rgba(95, 127, 79, 0.22);
}

.insight-log-item.warning {
  color: var(--warning);
  border-color: rgba(163, 107, 39, 0.22);
}

.insight-log-item.error {
  color: var(--danger);
  border-color: rgba(180, 83, 58, 0.22);
}

.insight-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.insight-tab {
  border-radius: 8px;
  white-space: nowrap;
  background: var(--panel-soft);
}

.insight-tab.active {
  background: var(--primary);
  color: #fffefa;
  border-color: var(--primary);
}

.insight-tab-content {
  overflow: auto;
  min-height: 0;
  height: 100%;
  padding-right: 2px;
}

.insight-tab-content:has(.insight-wiki-layout) {
  overflow: hidden;
  padding-right: 0;
}

.insight-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.insight-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.insight-card h3 {
  font-size: 15px;
}

.insight-meta-row,
.insight-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.insight-chip {
  border-radius: 999px;
  background: var(--soft);
  padding: 4px 8px;
  font-size: 12px;
  color: var(--primary-dark);
}

.insight-card .btn-secondary.is-loading,
.insight-wiki-list .btn-primary.is-loading,
.insight-wiki-list .btn-secondary.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0.82;
  cursor: progress;
}

.insight-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.insight-wiki-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.insight-wiki-list,
.insight-wiki-preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  overflow: hidden;
  min-height: 0;
}

.insight-wiki-list-scroll,
.insight-wiki-preview-scroll {
  min-height: 0;
  overflow: auto;
}

.insight-wiki-preview pre {
  white-space: pre-wrap;
  margin: 0;
  line-height: 1.6;
  font-family: inherit;
}

.insight-note-popover {
  position: fixed;
  z-index: 2147483646;
  width: min(420px, calc(100vw - 28px));
  max-height: min(360px, calc(100vh - 28px));
  overflow: auto;
  display: none;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fffefa;
  box-shadow: 0 18px 42px rgba(38, 35, 31, 0.18);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  pointer-events: auto;
}

.insight-note-popover.show {
  display: block;
}

.insight-note-popover h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.markdown-body {
  line-height: 1.7;
  color: var(--text);
  overflow-wrap: anywhere;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 0.8em 0 0.45em;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  margin: 0.55em 0;
}

.markdown-body code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--panel-soft);
}

@media (max-width: 860px) {

  .insight-progress-grid,
  .insight-wiki-layout {
    grid-template-columns: 1fr;
  }

  .insight-modal {
    height: 96vh;
  }
}

.about-modal {
  width: min(760px, 94vw);
  height: auto;
  max-height: 86vh;
  grid-template-rows: auto auto auto;
}

.about-content {
  display: grid;
  gap: 14px;
  line-height: 1.75;
  color: #4b433a;
}

.about-content h3 {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 4px;
}

.about-content p {
  margin: 0;
}

.about-content ul {
  margin: 0;
  padding-left: 1.3em;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
}

.dashboard-tabs {
  position: sticky;
  top: 0;
  align-self: start;
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-soft);
}

.dashboard-tab {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #5f574d;
  border: 1px solid transparent;
  font-weight: 800;
}

.dashboard-tab.active {
  background: #fffefa;
  color: var(--primary-dark);
  border-color: var(--border);
}

.dashboard-view {
  display: none;
  min-width: 0;
}

.dashboard-view.active {
  display: block;
}

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

.dashboard-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.dashboard-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin-top: 8px;
}

.dashboard-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fffefa;
  padding: 12px;
}

.dashboard-value {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.dashboard-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.dashboard-section {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel-soft);
  padding: 12px;
  margin-top: 12px;
}

.dashboard-bars {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.dashboard-bar-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: #5f574d;
  font-weight: 800;
}

.dashboard-bar-track {
  height: 9px;
  background: #ede5da;
  border-radius: 999px;
  overflow: hidden;
}

.dashboard-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

.dashboard-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 12px;
  table-layout: fixed;
}

.dashboard-table th,
.dashboard-table td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.dashboard-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#rawInputArea,
#userReply,
#finalNoteArea {
  resize: none;
}

#rawInputArea,
#finalNoteArea,
#chatBox {
  scrollbar-width: thin;
}

.EasyMDEContainer .CodeMirror-vscrollbar {
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 113, 108, 0.35) transparent;
}

@media (max-width: 900px) {

  .dashboard-layout,
  .dashboard-two-col,
  .dashboard-kpi-row {
    grid-template-columns: 1fr;
  }

  .dashboard-tabs {
    position: static;
    grid-auto-flow: column;
    overflow-x: auto;
  }

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

  .dashboard-bar-row {
    grid-template-columns: 92px minmax(0, 1fr) 36px;
  }
}

@media (max-width: 1500px) {
  main {
    grid-template-columns: 300px minmax(420px, 1fr) 360px;
  }

  .current-panel {
    grid-column: 1 / 2;
  }

  .chat-panel {
    grid-column: 2 / 3;
  }

  .score-panel {
    grid-column: 3 / 4;
  }
}

@media (max-width: 1180px) {
  main {
    grid-template-columns: 320px minmax(420px, 1fr);
  }

  .current-panel {
    grid-column: 1 / 2;
  }

  .chat-panel {
    grid-column: 2 / 3;
  }

  .score-panel {
    grid-column: 1 / -1;
    min-height: unset;
  }
}

@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: unset;
  }

  .chat-panel {
    min-height: 720px;
  }

  .topic-center-modal-body {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .topic-center-nav {
    min-height: unset;
  }

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

  .topic-center-tabs button {
    text-align: center;
    padding: 9px 4px;
  }

  .topic-center-main {
    min-height: 520px;
  }

  .topic-form-grid {
    grid-template-columns: 1fr;
  }

  .topic-form-grid .span-2 {
    grid-column: auto;
  }
}
.theme-icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: block;
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .app {
  background: var(--bg);
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .content-modal,
:root[data-theme="dark"] .topic-center-nav,
:root[data-theme="dark"] .topic-center-main,
:root[data-theme="dark"] .insight-card,
:root[data-theme="dark"] .insight-wiki-list,
:root[data-theme="dark"] .insight-wiki-preview {
  background: var(--panel);
  border-color: var(--border);
}

:root[data-theme="dark"] .panel-header,
:root[data-theme="dark"] .content-modal-header,
:root[data-theme="dark"] .content-modal-footer,
:root[data-theme="dark"] .composer {
  background: var(--panel);
  border-color: var(--border);
}

:root[data-theme="dark"] .panel-body,
:root[data-theme="dark"] .settings-sidebar,
:root[data-theme="dark"] .score-modal-scoring,
:root[data-theme="dark"] .insight-progress-panel,
:root[data-theme="dark"] .insight-log-panel,
:root[data-theme="dark"] .dashboard-section,
:root[data-theme="dark"] .topic-center-stat {
  background: var(--panel-soft);
}

:root[data-theme="dark"] .chat-body {
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-soft) 100%);
}

:root[data-theme="dark"] .inbox-card,
:root[data-theme="dark"] .card-detail-section,
:root[data-theme="dark"] .settings-card,
:root[data-theme="dark"] .dashboard-card,
:root[data-theme="dark"] .topic-governance-card,
:root[data-theme="dark"] .score-item,
:root[data-theme="dark"] .score-summary,
:root[data-theme="dark"] .score-modal-note,
:root[data-theme="dark"] .inline-score-card,
:root[data-theme="dark"] .assistant .bubble,
:root[data-theme="dark"] .insight-log-item,
:root[data-theme="dark"] .topic-card-row {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}

:root[data-theme="dark"] .card-detail-section.soft {
  background: var(--panel-soft);
}

:root[data-theme="dark"] .card-detail-section label,
:root[data-theme="dark"] .current-panel label,
:root[data-theme="dark"] .type-label-row label {
  color: var(--text-strong);
}

:root[data-theme="dark"] .card-detail-section textarea {
  background: var(--input-bg);
  color: var(--input-text);
  border-color: var(--input-border);
}

:root[data-theme="dark"] .current-panel .small {
  color: var(--muted);
}

:root[data-theme="dark"] .inbox-card:hover,
:root[data-theme="dark"] .inbox-card.active,
:root[data-theme="dark"] .settings-tab.active,
:root[data-theme="dark"] .dashboard-tab.active,
:root[data-theme="dark"] .chat-mode-btn.active {
  background: var(--panel-3);
  border-color: var(--primary);
  color: var(--text-strong);
}

:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="password"],
:root[data-theme="dark"] input[type="number"],
:root[data-theme="dark"] .CodeMirror,
:root[data-theme="dark"] .editor-toolbar,
:root[data-theme="dark"] .markdown-note-shell .EasyMDEContainer,
:root[data-theme="dark"] .markdown-note-shell .editor-preview,
:root[data-theme="dark"] .markdown-note-shell .editor-preview-side,
:root[data-theme="dark"] .CodeMirror-gutters {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--input-text);
}

:root[data-theme="dark"] .CodeMirror-cursor {
  border-left-color: var(--text-strong);
}

:root[data-theme="dark"] .CodeMirror-selected {
  background: rgba(97, 175, 239, 0.22);
}

:root[data-theme="dark"] .editor-toolbar button {
  color: var(--muted) !important;
}

:root[data-theme="dark"] .editor-toolbar button:hover,
:root[data-theme="dark"] .editor-toolbar button.active {
  background: var(--panel-3);
  border-color: var(--border);
  color: var(--text-strong) !important;
}

:root[data-theme="dark"] .filter-menu,
:root[data-theme="dark"] .sort-menu,
:root[data-theme="dark"] .card-context-menu,
:root[data-theme="dark"] .danger-writing-menu,
:root[data-theme="dark"] .insight-action-menu,
:root[data-theme="dark"] .insight-note-popover {
  background: var(--panel-3);
  border-color: var(--border);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .modal-backdrop {
  background: var(--overlay);
}

:root[data-theme="dark"] .insight-body,
:root[data-theme="dark"] .topic-center-modal-body {
  background: var(--bg);
}

:root[data-theme="dark"] .user .bubble,
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .icon-btn.primary,
:root[data-theme="dark"] .insight-tab.active {
  background: var(--primary);
  color: var(--button-text);
  border-color: var(--primary);
}

:root[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  color: var(--button-text);
}

:root[data-theme="dark"] .btn-secondary,
:root[data-theme="dark"] .icon-btn,
:root[data-theme="dark"] .insight-tab,
:root[data-theme="dark"] .filter-clear-option {
  background: var(--panel-soft);
  color: var(--text);
  border-color: var(--border);
}

:root[data-theme="dark"] button:hover:not(:disabled),
:root[data-theme="dark"] .filter-option:hover,
:root[data-theme="dark"] .context-menu-item:hover,
:root[data-theme="dark"] .topic-center-tabs button:hover {
  background: var(--panel-3);
  border-color: var(--border);
}

:root[data-theme="dark"] .insight-tab:hover:not(:disabled) {
  background: var(--panel-3);
  color: var(--text-strong);
  border-color: var(--border);
}

:root[data-theme="dark"] .insight-tab.active:hover:not(:disabled) {
  background: var(--primary-hover);
  color: var(--button-text);
  border-color: var(--primary-hover);
}

:root[data-theme="dark"] .filter-group-option.active,
:root[data-theme="dark"] .filter-option.active,
:root[data-theme="dark"] .topic-center-tabs button.active,
:root[data-theme="dark"] .icon-btn.active,
:root[data-theme="dark"] .placeholder-chip,
:root[data-theme="dark"] .insight-chip,
:root[data-theme="dark"] .topic-binding-chip,
:root[data-theme="dark"] .status-pill {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: rgba(97, 175, 239, 0.25);
}

:root[data-theme="dark"] .badge,
:root[data-theme="dark"] .badge.pending,
:root[data-theme="dark"] .badge.archived,
:root[data-theme="dark"] .card-tracking-id,
:root[data-theme="dark"] .system-note {
  background: var(--panel-3);
  color: var(--muted);
  border-color: var(--border);
}

:root[data-theme="dark"] .score-tags,
:root[data-theme="dark"] .progress {
  background: var(--panel-3);
  color: var(--text);
}

:root[data-theme="dark"] .badge.done,
:root[data-theme="dark"] .badge.scored,
:root[data-theme="dark"] .knowledge-status-badge.absorbed {
  background: var(--success-soft);
  color: var(--success);
}

:root[data-theme="dark"] .badge.guiding,
:root[data-theme="dark"] .card-score-badge.score-low {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: rgba(97, 175, 239, 0.25);
}

:root[data-theme="dark"] .card-score-badge.score-high {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(224, 108, 117, 0.25);
}

:root[data-theme="dark"] .card-score-badge.score-mid {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: rgba(229, 192, 123, 0.25);
}

:root[data-theme="dark"] .card-score-badge.score-very-low {
  background: rgba(198, 120, 221, 0.12);
  color: var(--purple);
  border-color: rgba(198, 120, 221, 0.22);
}

:root[data-theme="dark"] .insight-progress-track,
:root[data-theme="dark"] .dashboard-bar-track {
  background: var(--panel-3);
}

:root[data-theme="dark"] .toast {
  background: var(--panel-3);
  color: var(--text-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .about-content,
:root[data-theme="dark"] .dashboard-bar-row,
:root[data-theme="dark"] .settings-tab,
:root[data-theme="dark"] .filter-group-option,
:root[data-theme="dark"] .bulk-add-option,
:root[data-theme="dark"] .bubble.markdown-body blockquote {
  color: var(--text);
}

:root[data-theme="dark"] .markdown-body code,
:root[data-theme="dark"] .bubble.markdown-body code,
:root[data-theme="dark"] .bubble.markdown-body pre {
  background: var(--input-bg);
}

:root[data-theme="dark"] * {
  scrollbar-color: #4b5263 transparent;
}
