/* ── 主题：浅蓝（默认） ─────────────────────────────────── */
:root, [data-theme="blue"] {
  color-scheme: light;
  --bg: #eaf5ff;
  --bg-strong: #d9ecff;
  --panel: #fafdff;
  --panel-2: #f2f8ff;
  --surface: #ffffff;
  --surface2: #f5f8fc;
  --border: #d0dae5;
  --danger: #c5221f;
  --line: #c6d9eb;
  --line-strong: #8eb6dc;
  --text: #000;
  --muted: #666;
  --text-secondary: #888;
  --hint: #999;
  --primary: #1f7bd7;
  --primary-strong: #155fa9;
  --green: #2d9a68;
  --violet: #7d5fd1;
  --shadow: 0 22px 55px rgba(54, 101, 147, 0.16);
  --nav-bg: #f0f6fc;
  --chat-bg: #ffffff;
  --input-bg: #ffffff;
  --hover-bg: #e8f1fa;
  --code-bg: #f0f5fa;
  --badge-bg: #e8f1fa;
  --step-hover: #e2edf7;
}

/* ── 主题：暗紫 ──────────────────────────────────────── */
[data-theme="purple"] {
  color-scheme: dark;
  --bg: #0f0f23;
  --bg-strong: #151530;
  --panel: #1a1a2e;
  --panel-2: #1e1e35;
  --surface: #1a1a2e;
  --surface2: #222240;
  --border: #2a2a4a;
  --danger: #ef4444;
  --line: #2a2a4a;
  --line-strong: #4a3a7a;
  --text: #e0e0e0;
  --muted: #999;
  --text-secondary: #888;
  --hint: #777;
  --primary: #7c3aed;
  --primary-strong: #a78bfa;
  --green: #34d399;
  --violet: #a78bfa;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --nav-bg: #12122a;
  --chat-bg: #1a1a2e;
  --input-bg: #0f0f23;
  --hover-bg: #222240;
  --code-bg: #0a0a1a;
  --badge-bg: #1e1e35;
  --step-hover: #1e1e40;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0) 34%),
    radial-gradient(circle at 24% 18%, rgba(98, 168, 232, 0.22), transparent 32%),
    linear-gradient(180deg, #f5fbff 0%, var(--bg) 100%);
}

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

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.sidebar,
.panel {
  border: 1px solid var(--line);
  background: rgba(250, 253, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.sidebar {
  position: sticky;
  top: 22px;
  height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  padding: 20px;
  border-radius: 22px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease, padding 0.25s ease, border-radius 0.25s ease;
}

/* ── Sidebar collapse ── */

.sidebar-collapse-btn {
  position: absolute;
  top: 18px;
  right: 10px;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: transform 0.25s ease, right 0.25s ease;
  padding: 0;
  line-height: 1;
}
.sidebar-collapse-btn:hover { color: var(--text); border-color: var(--line-strong); }

.shell.sidebar-collapsed { grid-template-columns: 50px minmax(0, 1fr); }
.shell.sidebar-collapsed .sidebar {
  padding: 20px 8px;
  overflow: hidden;
}
.shell.sidebar-collapsed .sidebar-collapse-btn {
  right: 12px;
  transform: rotate(180deg);
}
.shell.sidebar-collapsed .brand,
.shell.sidebar-collapsed .steps,
.shell.sidebar-collapsed .services-sub,
.shell.sidebar-collapsed .license-badge,
.shell.sidebar-collapsed .model-badge,
.shell.sidebar-collapsed .theme-switcher { display: none; }

/* ── end sidebar collapse ── */

/* rest of sidebar styles unchanged */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  flex-shrink: 0;
  object-fit: contain;
}

.brand h1,
.brand p,
.page-head h2,
.page-head p {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  letter-spacing: 0;
}

.brand p,
.status-card small,
.label,
.eyebrow {
  color: var(--muted);
}

.steps {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.steps:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.step {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.step span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 26px;
  border-radius: 9px;
  background: #e8f3ff;
  color: #4274a6;
  font-size: 12px;
  font-weight: 700;
}

.step.active {
  color: var(--text);
  border-color: #9dc8ef;
  background: #edf7ff;
}

.step-stars {
  margin-left: auto;
  font-size: 10px;
  letter-spacing: 1px;
  color: #d4a017;
  font-weight: 400;
  opacity: 0.85;
}

.services-toggle,
.vip-toggle {
  width: 100%;
}
.services-toggle .chevron,
.vip-toggle .chevron {
  display: inline;
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: 10px;
  font-weight: normal;
  opacity: 0.5;
  margin-left: auto;
}

.services-sub {
  display: grid;
  gap: 4px;
  padding: 2px 0 0 0;
}
.services-sub[hidden] { display: none; }
.sub-item {
  font-size: 12px !important;
  height: 32px !important;
  padding-left: 48px !important;
  opacity: 0.75;
}
.sub-item:first-child {
  margin-top: 2px;
}
.sub-item.active {
  opacity: 1;
  color: var(--primary);
}
.sub-item span { display: none; }

.model-badge {
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.model-badge .mb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.35);
}
.model-badge .mb-name {
  font-weight: 600;
  color: var(--text);
}

/* ── 主题切换器 ─────────────────────────────────────── */
.theme-switcher {
  padding: 8px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all .2s;
  flex-shrink: 0;
}
.theme-dot:hover { transform: scale(1.15); }
.theme-dot.active { border-color: var(--text); box-shadow: 0 0 8px rgba(124,58,237,0.4); }
.theme-dot.blue  { background: linear-gradient(135deg, #1f7bd7, #7d5fd1); }
.theme-dot.purple { background: linear-gradient(135deg, #7c3aed, #a78bfa); }

.workspace {
  min-width: 0;
}

.panel {
  min-height: calc(100vh - 44px);
  padding: 26px;
  border-radius: 24px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.page-head.compact {
  align-items: center;
}

.head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
}

.page-head h2 {
  max-width: 720px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 130px);
  gap: 10px;
}

.feature-grid span {
  padding: 12px;
  border: 1px solid #c8def2;
  border-radius: 12px;
  background: #f3f9ff;
  color: #375a78;
  text-align: center;
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.form-grid.form-grid-compact {
  gap: 12px;
  margin-top: 16px;
}

.field,
.word-select {
  display: grid;
  gap: 9px;
}

.field.wide {
  grid-column: 1 / -1;
}

.project-context-field textarea {
  min-height: 260px;
}

.project-context-pair {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.project-context-field textarea[readonly] {
  color: #45627d;
  background: #f4f9ff;
}

.example-toggle {
  min-width: auto !important;
  height: 26px !important;
  padding: 0 10px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 8px !important;
}

.project-context-field textarea[hidden] {
  display: none;
}

.project-actions-field button {
  height: 46px;
}

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

.button-row .save-tip {
  margin-left: auto;
}

.field span,
.word-select span {
  color: #506a83;
  font-size: 14px;
  font-weight: 700;
}

.field-hint {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  margin-top: 2px;
}

/* ---- paper_info top row ---- */
.paper-info-top-row {
  grid-column: 1 / -1;
}

.inline-field.project-history-field .inline-select-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-field.project-history-field select {
  max-width: 320px;
  flex: 1;
}

.inline-field.project-history-field .ghost {
  white-space: nowrap;
  height: 42px;
  padding: 0 16px;
}

/* ---- paper_info meta display ---- */
.paper-info-meta-row {
  grid-column: 1 / -1;
  display: flex;
  gap: 32px;
  padding: 14px 20px;
  background: #f6fafd;
  border-radius: 12px;
  border: 1px solid #dfecf7;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.meta-label {
  color: #7593af;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.meta-value {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #bdd2e6;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input,
select {
  height: 46px;
  padding: 0 14px;
}

textarea {
  resize: vertical;
  padding: 14px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(31, 123, 215, 0.12);
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
}

.save-tip,
.progress-tip {
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
}

.cute-loader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.08);
  color: var(--primary);
}

.cute-loader span {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--primary);
  animation: cute-bounce 1s infinite ease-in-out;
}

.cute-loader span:nth-child(2) {
  animation-delay: 0.12s;
}

.cute-loader span:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes cute-bounce {

  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }

  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.ghost.loading {
  position: relative;
  color: #0f4d92;
  background: #e8f4ff;
  border-color: #8ac1ff;
}

.ghost.loading::after {
  content: "🌱";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  animation: spin-plant 1.4s linear infinite;
}

@keyframes spin-plant {
  0% {
    transform: translateY(-50%) rotate(0deg);
  }

  50% {
    transform: translateY(-52%) rotate(12deg);
  }

  100% {
    transform: translateY(-50%) rotate(360deg);
  }
}

.actions.split {
  justify-content: space-between;
}

.primary,
.ghost {
  min-width: 128px;
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 700;
}

.primary {
  border: 1px solid var(--primary);
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #38a7dc);
}

.primary:hover {
  background: linear-gradient(135deg, var(--primary-strong), #248fc3);
}

.primary.connected {
  border-color: #77bf91;
  color: #fff;
  background: linear-gradient(135deg, #2d9a68, #4ab88a);
  cursor: default;
}

.ghost {
  border: 1px solid #bcd4ea;
  color: #31526f;
  background: #f8fcff;
}

.ghost:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* ---- Method panel: toolbar & tabs ---- */
.method-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}
.method-toolbar input {
  max-width: 400px;
}
.method-toolbar span {
  color: var(--muted);
  font-size: 0.82rem;
}

.hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.method-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 16px;
  padding: 5px;
  border-radius: 12px;
  background: #eef4fa;
}
.method-tab {
  padding: 9px 22px;
  border: none;
  border-radius: 9px;
  color: #5b7a99;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.method-tab:hover {
  color: #1e4663;
  background: rgba(255,255,255,0.55);
}
.method-tab.active {
  color: #0e3a5c;
  background: #fff;
  box-shadow: 0 1px 4px rgba(24,50,77,0.10);
}
.method-tab.drag-over {
  box-shadow: 0 0 0 3px rgba(31,123,215,0.25);
  background: #e0f0ff;
}

.custom-method {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 14px;
}

/* ---- Method zones ---- */
.method-zone {
  margin-top: 20px;
}
.method-zone-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 9px;
  margin-bottom: 12px;
  font-size: 0.82rem;
  font-weight: 700;
}
.zone-icon { font-size: 0.9rem; }
.zone-count {
  margin-left: auto;
  font-size: 0.72rem;
  padding: 2px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.6);
}

.method-zone-recommended .method-zone-header {
  background: linear-gradient(135deg, #d4edda 0%, #c8e6d0 100%);
  color: #1b5e31;
}
.method-zone-general .method-zone-header {
  background: #eef1f5;
  color: #5b6875;
}
.method-zone-cross .method-zone-header {
  background: linear-gradient(135deg, #e8eaf6 0%, #d1d9ff 100%);
  color: #1a237e;
}

.method-zone-pool {
  margin-bottom: 16px;
  padding: 4px;
  border: 2px dashed #bbdefb;
  border-radius: 14px;
  background: #fafcff;
}

.method-zone-pool .method-zone-header {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  color: #0d47a1;
  border: none;
  border-radius: 10px 10px 0 0;
}

.pool-hint {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.7;
  margin-left: 4px;
}

.pool-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 2px 8px;
  border: 1px solid #ef9a9a;
  border-radius: 6px;
  background: #fff;
  color: #c62828;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s;
  z-index: 2;
}

.pool-remove-btn:hover {
  background: #ffebee;
  border-color: #e53935;
}

.method-zone-pool .method-card {
  border-color: #90caf9;
  background: #fafcff;
}

.saved-flash {
  background: #e8f5e9 !important;
  border-color: #66bb6a !important;
  color: #2e7d32 !important;
}

.method-zone-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

/* ---- Method cards ---- */
.method-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1.5px solid #dae3ed;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: all 0.18s;
}
.method-card:hover {
  border-color: #a8c8e8;
  box-shadow: 0 2px 12px rgba(24,50,77,0.06);
  transform: translateY(-1px);
  z-index: 50;
}
.method-card.selectable:has(.method-check:checked) {
  border-color: #4a9adf;
  background: #f2f9ff;
  box-shadow: 0 4px 18px rgba(41,112,178,0.10);
}

.method-check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-right: 12px;
  margin-top: 1px;
  accent-color: var(--primary);
}

.method-card-inner {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.method-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.method-card-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.method-card-tooltip {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 100%;
  min-width: 260px;
  max-width: 380px;
  background: #fff;
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.65;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid #d0dce8;
  z-index: 200;
  box-shadow: 0 6px 28px rgba(24,50,77,0.12);
  white-space: normal;
  word-break: break-word;
}
.method-card-tooltip::before {
  content: "";
  position: absolute;
  left: 18px;
  top: -8px;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #d0dce8;
}
.method-card-tooltip::after {
  content: "";
  position: absolute;
  left: 19px;
  top: -6px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 7px solid #fff;
}
.method-card-tooltip.empty-tip {
  background: #fafafa;
  color: var(--muted);
  font-style: italic;
}
.method-card:hover .method-card-tooltip {
  display: block;
}
.method-card-detail {
  font-size: 0.73rem;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.method-icon {
  flex-shrink: 0;
  font-size: 0.75rem;
  opacity: 0.7;
}

.method-diff {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.method-diff-beginner { background: #e6f4ea; color: #216e39; }
.method-diff-intermediate { background: #fff3d6; color: #8a6300; }
.method-diff-advanced { background: #fde8e8; color: #9b1c1c; }

.method-zone-recommended .method-card {
  border-left: 4px solid #5bb974;
}
.method-zone-cross .method-card {
  border-left: 4px solid #5c6bc0;
}
.method-zone-general .method-card {
  border-left: 4px solid #c0c7cf;
}

/* Pair / conflict indicators */
.method-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.method-tag-pair { background: #d6ecfb; color: #175d8f; }
.method-tag-conflict { background: #fde8e8; color: #9b1c1c; }

.method-card-paired {
  border-color: #8bc4ea !important;
  box-shadow: 0 0 0 3px rgba(74,154,223,0.12);
}
.method-card-conflict {
  border-color: #e69c9c !important;
  box-shadow: 0 0 0 3px rgba(220,80,80,0.10);
}
.method-card-conflict.method-card-paired {
  border-color: #d4a04a !important;
  box-shadow: 0 0 0 3px rgba(200,150,60,0.12);
}

.method-card-hint {
  color: #5b8cbf !important;
  font-size: 0.7rem !important;
  margin-top: 2px;
}

.svg-preview {
  display: grid;
  place-items: center;
  min-height: 580px;
  margin-top: 24px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #eef7ff;
}

.svg-preview svg {
  width: 100%;
  height: auto;
}

/* ---- Mermaid Editor ---- */
.mermaid-toggle-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.mermaid-toggle-bar .ghost.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.mermaid-editor-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fafdff;
}

.mermaid-editor {
  width: 100%;
  min-height: 400px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.7;
  resize: vertical;
  background: #1e2a3a;
  color: #cdd7e2;
}

.mermaid-preview {
  min-height: 400px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: auto;
  padding: 12px;
}

.mermaid-preview svg {
  max-width: 100%;
  height: auto;
}

.mermaid-error {
  grid-column: 1 / -1;
  color: #c44;
  padding: 8px;
  background: #fff0f0;
  border-radius: 8px;
  margin-top: 8px;
  font-size: 12px;
}

/* ---- Table Generator ---- */
.table-generator {
  margin-top: 36px;
  border-top: 1px solid var(--line);
  padding-top: 24px;
}

.table-gen-head { margin-bottom: 14px; }

.table-gen-head h3 {
  margin: 0 0 6px;
  font-size: 18px;
  color: var(--text);
}

.table-upload-area {
  border: 2px dashed var(--line-strong);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  background: #f8fcff;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.table-upload-area:hover { border-color: var(--primary); }

.table-upload-area.drag-over {
  border-color: var(--primary);
  background: #eef5ff;
}

.table-upload-icon { font-size: 36px; margin: 0 0 8px; }

.table-upload-label { font-size: 13px; color: var(--muted); margin: 0 0 10px; }

.table-desc {
  width: 100%;
  min-height: 80px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: vertical;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.table-result { margin-top: 20px; }

.table-result-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.table-result-head h4 { margin: 0; }

.table-result-content {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: #fff;
}

.table-result-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table-result-content th,
.table-result-content td {
  padding: 8px 12px;
  border: 1px solid #d8dde3;
  text-align: left;
}

.table-result-content th {
  background: #f2f7fc;
  font-weight: 700;
  color: #18324d;
}

.table-result-content tr:nth-child(even) td {
  background: #fafcfe;
}

/* Table Modal */
.table-modal {
  max-width: 820px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-modal .modal-head { margin-bottom: 12px; flex-shrink: 0; }
.table-modal .form-grid { gap: 10px; margin-top: 0; }
.table-modal .field textarea { max-height: 120px; }
.table-modal > .field { flex-shrink: 0; }

.table-modal-result {
  margin-top: 12px;
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
}

.table-modal-result .table-result-content {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.table-modal-result .table-result-content table {
  min-width: 100%;
  white-space: nowrap;
}

.table-modal-result .table-result-content th,
.table-modal-result .table-result-content td {
  padding: 6px 12px;
  font-size: 12px;
}

.table-modal .actions.split {
  margin-top: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.file-name {
  display: inline-block;
  margin-left: 10px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}

.word-select {
  min-width: 180px;
}

/* Outline toolbar */
.outline-toolbar {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.ot-main {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ot-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.word-select-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.word-select-inline span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.word-select-inline select {
  width: 72px;
  height: 32px;
  border: none;
  background: transparent;
  font-weight: 700;
  color: var(--text);
  padding: 0 4px;
  cursor: pointer;
}
.word-select-inline select:focus {
  outline: none;
  box-shadow: none;
}

.outline-preview,
.writing-list {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.citation-note,
.empty-state {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid #c4d8eb;
  border-radius: 14px;
  color: #31526f;
  background: #f6fbff;
  line-height: 1.65;
  font-size: 14px;
}

.citation-list:not([hidden]) {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 18px;
}

.citation-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.citation-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #41637f;
  font-size: 12px;
  font-weight: 800;
}

.citation-meta span,
.citation-meta strong,
.citation-meta em {
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf7ff;
  font-style: normal;
}

.citation-meta em {
  color: #8a6424;
  background: #fff6df;
}

.citation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 86px minmax(0, 0.8fr);
  gap: 8px;
}

.citation-card textarea {
  min-height: 260px;
  width: 100%;
  resize: vertical;
}

.citation-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.citation-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.citation-col-head {
  font-size: 0.82rem;
  font-weight: 800;
  color: #31526f;
  padding: 8px 12px;
  background: #f2f8ff;
  border-radius: 10px;
}

.citation-llm-section {
  margin-top: 18px;
}

.citation-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.citation-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  user-select: none;
}

.citation-group-header.citation-local {
  background: #eaf4e8;
  color: #2d5a27;
}

.citation-group-header.citation-llm {
  background: #eef3ff;
  color: #2a4080;
}

.citation-group-header.citation-method {
  background: #f3eef9;
  color: #4a3080;
}

.citation-group-header.citation-merged {
  background: #fef7e6;
  color: #6b5000;
}

.citation-group-count {
  font-size: 0.73rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.65);
}

.citation-group-text {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 14px;
  font-size: 0.78rem;
  line-height: 1.8;
  font-family: inherit;
  background: #fcfcfc;
}

.citation-merged-section {
  margin-top: 18px;
}

.reference-card textarea {
  min-height: 320px;
  width: 100%;
  resize: vertical;
  background: #f6fbff;
  border-color: #c4d8eb;
}

.citation-row {
  grid-template-columns: 150px minmax(0, 1fr);
  align-items: start;
}

.citation-row small {
  grid-column: 2;
  color: var(--muted);
  line-height: 1.5;
}

.citation-count {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #506a83;
  font-size: 13px;
  font-weight: 800;
}

.citation-count input {
  width: 92px;
  height: 38px;
}

.task-log {
  display: grid;
  gap: 8px;
  max-height: 180px;
  margin-top: 16px;
  overflow: auto;
  border: 1px solid #c4d8eb;
  border-radius: 14px;
  background: #f8fcff;
}

.task-log:empty {
  display: none;
}

.task-log div {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #e7f0f8;
  color: #31526f;
  font-size: 13px;
}

.task-log div:last-child {
  border-bottom: 0;
}

.task-log time {
  color: #6f879e;
  font-weight: 700;
}

/* ── PPT confirmation card ── */
.confirm-spec-card {
  margin-top: 12px;
  border: 1px solid #c4d8eb;
  border-radius: 14px;
  background: #f8fcff;
  overflow: hidden;
}
.confirm-spec-card h4 {
  margin: 0;
  padding: 14px 18px;
  background: #eaf3fb;
  font-size: 15px;
  color: #1a3c5e;
}
.confirm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 18px;
  font-size: 13px;
  color: #4a6a85;
  border-bottom: 1px solid #e7f0f8;
}
.confirm-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.12);
  vertical-align: middle;
}
.confirm-slides-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.confirm-slides-table th {
  text-align: left;
  padding: 8px 14px;
  background: #eef5fb;
  color: #31526f;
  font-weight: 700;
}
.confirm-slides-table td {
  padding: 7px 14px;
  border-bottom: 1px solid #eef4f8;
  color: #2c4b65;
}
.confirm-slide-id {
  font-weight: 700;
  color: #6f879e;
  width: 40px;
}
.confirm-slide-hint {
  font-size: 11px;
  color: #809bb3;
}
.confirm-slide-desc {
  color: #54738c;
  font-size: 12px;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid #e7f0f8;
}

/* ── PPT confirm modal ─────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9998;
}
.modal-container {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: #fff; border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,.18);
  z-index: 9999; max-width: 820px; width: 95vw; max-height: 85vh; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #999; padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: #f0f0f0; color: #333; }
.modal-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); justify-content: flex-end; }

.ppt-confirm-modal { max-width: 860px; }
.ppt-confirm-meta { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.ppt-confirm-meta strong { color: var(--text); }
.ppt-edit-table-wrap { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.ppt-edit-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ppt-edit-table th { background: #f5f8fb; padding: 8px 10px; text-align: left; font-weight: 600; position: sticky; top: 0; }
.ppt-edit-table td { padding: 6px 8px; border-bottom: 1px solid #f0f0f0; }
.ppt-edit-row:hover td { background: #fafcfe; }
.ppt-edit-id { color: var(--muted); font-weight: 600; text-align: center; width: 40px; }
.ppt-edit-table input { width: 100%; border: 1px solid #dde; border-radius: 4px; padding: 5px 8px; font-size: 13px; }
.ppt-edit-table input:focus { border-color: var(--primary); outline: none; }
.ppt-edit-table select { width: 100%; border: 1px solid #dde; border-radius: 4px; padding: 5px 6px; font-size: 13px; background: #fff; }
.ppt-remove-slide { color: #d33 !important; padding: 4px 8px !important; font-size: 14px !important; }
.ppt-remove-slide:hover { background: #fdf0f0 !important; }

.chapter-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.chapter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #f2f8ff;
  font-weight: 800;
}

.chapter-head input[data-kind="chapter"] {
  height: 36px;
  border: 0;
  background: transparent;
  font-weight: 800;
  flex: 1;
  min-width: 200px;
}

.chapter-title-input {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.chapter-title-input span {
  flex-shrink: 0;
  color: #31526f;
}

.writing-chapter-head {
  align-items: flex-start;
}

.writing-chapter-head strong {
  color: #000;
}

.writing-chapter-head small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.chapter-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.chapter-tools button {
  height: 34px;
  border: 1px solid #bcd4ea;
  border-radius: 10px;
  color: #31526f;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.section-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 84px 86px auto;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid #edf3f9;
}

.section-row:last-child {
  border-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title.stacked {
  display: grid;
  align-items: start;
}

.section-title.stacked>div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title input {
  height: 38px;
  max-width: 80%;
}

.subsection-line {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 68px 62px auto;
  gap: 8px;
  align-items: center;
  margin: 4px 0 0 34px;
  color: #6f879e;
  font-size: 12px;
  line-height: 1.45;
}

.formula-toggle {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: #6f879e;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.formula-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: #3b82f6;
}

.subsection-line input:not(.word-input) {
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.word-chip {
  padding: 7px 8px;
  border: 1px solid #c8dbea;
  border-radius: 10px;
  color: #000;
  background: #f6fbff;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.word-input {
  width: 82px;
  height: 34px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.word-input.small {
  width: 72px;
  height: 30px;
  font-size: 11px;
}

.word-summary,
.actual-chip {
  color: #000;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.word-summary {
  padding: 8px 10px;
  border: 1px solid #c8dbea;
  border-radius: 10px;
  background: #f6fbff;
}

.actual-chip {
  padding: 6px 8px;
  border-radius: 9px;
  background: #eef7ff;
}

.outline-mini-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.outline-mini-tools button {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #bcd4ea;
  border-radius: 9px;
  color: #31526f;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

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

.mini-actions button {
  height: 34px;
  min-width: 66px;
  border: 1px solid #bcd4ea;
  border-radius: 10px;
  color: #31526f;
  background: #fff;
  font-weight: 700;
}

.mini-actions button.saved {
  border-color: #77bf91;
  color: #187047;
  background: #eaf8f0;
}

.draft-save-state {
  color: #2f7d55;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.writing-section {
  border-bottom: 1px solid #edf3f9;
}

.writing-section .section-title span,
.writing-section .section-title strong {
  color: #000;
}

.writing-section:last-child {
  border-bottom: 0;
}

.inline-draft {
  min-height: 160px;
  margin: 0 18px 16px;
  width: calc(100% - 36px);
  background: #fbfdff;
}

.table-preview {
  margin: 0 18px 10px;
  overflow-x: auto;
}

.table-preview table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.table-preview th,
.table-preview td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.table-preview th {
  background: #eef4fa;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.table-preview tr:nth-child(even) td {
  background: #fafcff;
}

.table-preview h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text);
}

.section-prompt {
  min-height: 74px;
  margin: 0 18px 10px;
  width: calc(100% - 36px);
  border-color: #c7ddf1;
  background: #f6fbff;
  font-size: 13px;
}

.consistency-feedback {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #dde7f0;
  font-size: 0.82rem;
  line-height: 1.6;
}

.cf-item {
  padding: 4px 0;
}

.cf-item.cf-ok {
  color: #2e7d32;
}

.cf-item.cf-warn {
  color: #c62828;
  font-weight: 500;
}

.cf-item.cf-stale {
  color: #e65100;
  font-weight: 500;
}

.cf-tag {
  display: inline-block;
  margin: 0 3px;
  padding: 1px 8px;
  border-radius: 4px;
  background: #ffebee;
  color: #b71c1c;
  font-size: 0.78rem;
}

.stale-chapter-badge {
  display: none;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 10px;
  background: #fff3e0;
  color: #e65100;
  font-size: 0.72rem;
  font-weight: 600;
  vertical-align: middle;
  cursor: help;
}

.serial-progress {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid #bcd4ea;
  border-radius: 16px;
  background: #f6fbff;
}

.snail-track {
  position: relative;
  height: 42px;
  border-bottom: 3px solid #9fc4e5;
}

.snail-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 3px;
  background: linear-gradient(90deg, #7db8ee, #80d0b6, #b9a7ef);
}

.snail {
  position: absolute;
  bottom: 0;
  left: -18px;
  width: 44px;
  height: 30px;
  transition: left 0.5s ease;
  animation: snail-bob 1.4s ease-in-out infinite;
}

.snail-shell {
  position: absolute;
  left: 4px;
  bottom: 3px;
  width: 22px;
  height: 22px;
  border: 3px solid #7d5fd1;
  border-radius: 50%;
  background: #d8ccff;
}

.snail-shell::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2px solid #7d5fd1;
  border-radius: 50%;
}

.snail-body {
  position: absolute;
  right: 0;
  bottom: 3px;
  width: 26px;
  height: 13px;
  border-radius: 14px 16px 8px 8px;
  background: #69bfa2;
}

.snail-eye {
  position: absolute;
  right: 2px;
  bottom: 18px;
  width: 4px;
  height: 14px;
  border-radius: 999px;
  background: #69bfa2;
}

.snail-eye::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -1px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #18324d;
}

.serial-progress-text {
  margin-top: 10px;
  color: #31526f;
  font-size: 13px;
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(560px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fafdff;
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-head h3 {
  margin: 0;
  color: var(--text);
  font-size: 24px;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

@keyframes snail-bob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }
}

/* ---- Chat Bottom Bar ---- */
.chat-bar {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 20vh;
  min-height: 140px;
  border-top: 1px solid var(--line);
  background: rgba(250, 253, 255, 0.97);
  backdrop-filter: blur(12px);
  z-index: 100;
}
.chat-bar[hidden] { display: none; }

.chat-bar-resize {
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  z-index: 10;
}
.chat-bar-resize:hover { background: rgba(31, 123, 215, 0.08); }

.chat-bar-left {
  flex: 0 0 35%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-right: 1px solid var(--line);
}

.chat-bar-left textarea {
  flex: 1;
  min-height: 0;
  padding: 10px 14px;
  border: 1px solid #bdd2e6;
  border-radius: 10px;
  background: #fff;
  resize: none;
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
}

.chat-bar-left textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 123, 215, 0.1);
  outline: none;
}

.chat-bar-left .primary {
  min-width: 64px;
  height: 36px;
  align-self: flex-end;
}

.chat-bar-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-bar-right-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
  background: #f6fbff;
  flex-shrink: 0;
}

.chat-bar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.chat-bar-right-head .ghost {
  min-width: auto;
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.chat-bar-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

/* retain existing chat message styles */
.chat-empty {
  color: var(--muted);
  text-align: center;
  padding: 20px 16px;
  font-size: 13px;
  line-height: 1.6;
}

.chat-msg {
  max-width: 92%;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-start;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.chat-msg.assistant {
  align-self: flex-end;
  background: #e5f0ff;
  color: var(--text);
  border: 1px solid #c4d8f0;
}

.chat-msg.system-msg {
  align-self: center;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 10px;
  max-width: 100%;
}

.chat-msg h3,
.chat-msg h4 {
  margin: 0 0 4px;
  color: var(--text);
}

.chat-msg h3 { font-size: 14px; }
.chat-msg h4 { font-size: 13px; }

.chat-msg p { margin: 2px 0; }

.chat-msg strong { color: var(--primary-strong); }

.chat-msg.assistant { position: relative; }

.msg-bookmark {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  display: grid;
  place-items: center;
}

.chat-msg.assistant:hover .msg-bookmark { opacity: 1; }

.msg-bookmark:hover {
  background: #e8f3ff;
  color: var(--primary);
}

.msg-bookmark.saved {
  opacity: 1;
  color: #d4a017;
}

/* ---- Best Practices Panel (slide-in) ---- */
.bp-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  z-index: 110;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: #fafdff;
  box-shadow: -12px 0 44px rgba(54, 101, 147, 0.14);
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.bp-panel.open { transform: translateX(0); }

.bp-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #f6fbff;
}

.bp-panel-head h3 { margin: 0; font-size: 17px; }

.bp-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.bp-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.bp-card h4 { margin: 0 0 6px; font-size: 14px; color: var(--text); }

.bp-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

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

.bp-card-tags { display: flex; flex-wrap: wrap; gap: 4px; }

.bp-card-tags span {
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf7ff;
  color: #41637f;
  font-size: 11px;
  font-weight: 700;
}

.bp-card-delete {
  border: 0;
  background: transparent;
  color: #c44;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
}

.bp-overlay {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: rgba(24, 50, 77, 0.24);
}

.chat-table {
  width: 100%;
  margin: 4px 0;
  border-collapse: collapse;
  font-size: 12px;
}

.chat-table th,
.chat-table td {
  padding: 4px 8px;
  border: 1px solid var(--line);
  text-align: left;
}

.chat-table th {
  background: #f0f7ff;
  font-weight: 700;
  color: var(--primary-strong);
}

.chat-typing {
  align-self: flex-start;
  padding: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.chat-typing::after {
  content: "...";
  animation: dot-pulse 1.2s infinite;
}

/* Push workspace up so content isn't hidden behind chat bar */
.shell {
  padding-bottom: 20vh;
}

@media (max-width: 720px) {
  .chat-bar {
    height: 30vh;
    flex-direction: column;
  }
  .chat-bar-left {
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 8px 12px;
  }
  .chat-bar-right {
    flex: 1;
  }
  .shell {
    padding-bottom: 30vh;
  }
}

@keyframes dot-pulse {
  0%, 20% { content: "."; }
  40% { content: ".."; }
  60%, 100% { content: "..."; }
}


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

  .sidebar {
    position: static;
    height: auto;
  }

  .method-list,
  .method-zone-cards,
  .svg-editor,
  .citation-list {
    grid-template-columns: 1fr;
  }

  .feature-grid {
    display: none;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 12px;
  }

  .panel {
    padding: 20px;
  }

  .page-head,
  .form-grid,
  .project-context-pair {
    grid-template-columns: 1fr;
    display: grid;
  }

  .page-head h2 {
    font-size: 26px;
  }

  .method-list,
  .method-zone-cards {
    grid-template-columns: 1fr;
  }

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

/* ---- Blind Review Risk Check ---- */
.risk-summary {
  margin: 12px 0;
}
.risk-summary-grid {
  display: flex;
  gap: 16px;
}
.risk-stat {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 20px;
  text-align: center;
  min-width: 80px;
}
.risk-stat strong {
  display: block;
  font-size: 1.6rem;
  color: var(--text);
}
.risk-stat small {
  color: var(--muted);
  font-size: 0.75rem;
}
.risk-stat.triggered strong { color: #d03801; }
.risk-stat.critical strong { color: #9b1c1c; }
.risk-stat.high strong { color: #d03801; }

.risk-results {
  margin-top: 16px;
}
.risk-chapter {
  margin-bottom: 20px;
}
.risk-chapter h3 {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.risk-card {
  background: var(--panel-2);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.risk-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.risk-sev {
  display: inline-block;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.risk-cat {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: auto;
}
.risk-evidence {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.risk-evidence ul {
  margin: 4px 0 0 16px;
}
.risk-evidence li {
  margin-bottom: 2px;
  font-style: italic;
}
.risk-detail {
  margin-top: 6px;
  font-size: 0.82rem;
}
.risk-detail summary {
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}
.risk-detail ul {
  margin: 4px 0 0 18px;
  color: var(--muted);
}
.risk-detail li {
  margin-bottom: 2px;
}

/* ---- AIGC Rate Check Two-Column ---- */
.aigc-layout {
  display: flex;
  gap: 0;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 55vh;
  max-height: 65vh;
}
.aigc-overall {
  padding: 12px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
  font-size: 0.9rem;
  color: var(--text);
}
.aigc-overall strong { font-size: 1.1rem; }
.aigc-overall strong.risk-无 { color: #047857; }
.aigc-overall strong.risk-低 { color: #854d0e; }
.aigc-overall strong.risk-中 { color: #c2410c; }
.aigc-overall strong.risk-高 { color: #b91c1c; }
.aigc-text-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--panel);
}
.aigc-reason-panel {
  width: 320px;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 20px;
  background: var(--panel-2);
  border-left: 1px solid var(--line);
}
.aigc-reason-placeholder {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding-top: 60px;
  line-height: 1.8;
}
.aigc-mark-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: #f0c040;
  vertical-align: middle;
  margin: 0 4px;
}
.aigc-chapter {
  margin-bottom: 24px;
}
.aigc-chapter-title {
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.aigc-risk-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  vertical-align: middle;
}
.aigc-risk-badge.risk-无 { background: #ecfdf5; color: #047857; }
.aigc-risk-badge.risk-低 { background: #fef9c3; color: #854d0e; }
.aigc-risk-badge.risk-中 { background: #ffedd5; color: #9a3412; }
.aigc-risk-badge.risk-高 { background: #fee2e2; color: #991b1b; }
.aigc-chapter-text {
  font-size: 0.9rem;
  line-height: 2;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}
.aigc-highlight {
  cursor: pointer;
  border-radius: 2px;
  padding: 1px 0;
  transition: background 0.15s;
}
.aigc-highlight.aigc-medium {
  background: #fef08a;
}
.aigc-highlight.aigc-high {
  background: #fca5a5;
}
.aigc-highlight.aigc-low {
  background: #fef9c3;
}
.aigc-highlight:hover {
  filter: brightness(0.9);
}
.aigc-highlight.selected {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  background: #fbbf24;
}
.aigc-reason-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.aigc-reason-card h5 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--text);
}
.aigc-reason-severity {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.aigc-reason-detail {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 10px;
}
.aigc-reason-snippet {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--panel-2);
  padding: 10px;
  border-radius: 6px;
  line-height: 1.6;
}

/* ============ 09 开题报告 ============ */
.proposal-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 32px;
  min-height: 300px;
  max-height: 60vh;
  overflow-y: auto;
  line-height: 1.8;
  color: var(--text);
}
.proposal-result:empty::after {
  content: "点击「生成PPT」按钮，系统将自动提取前两章内容生成开题报告PPT。";
  color: var(--muted);
  font-style: italic;
}
.proposal-result h2 {
  font-size: 20px;
  margin: 28px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
  color: var(--text);
}
.proposal-result h3 {
  font-size: 16px;
  margin: 20px 0 8px;
  color: var(--text);
}
.proposal-result p {
  margin: 8px 0;
  text-indent: 2em;
}
.proposal-result ul, .proposal-result ol {
  margin: 8px 0 8px 20px;
}
.proposal-result li {
  margin-bottom: 4px;
}

/* Supplement button in method cards */
.supplement-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 12px;
  margin-top: 8px;
  min-width: auto !important;
  width: auto;
  height: auto !important;
  color: #e65100;
  border: 1.5px solid #ff9800;
  border-radius: 8px;
  background: #fff8e1;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.supplement-btn:hover {
  background: #ffecd2;
  border-color: #e65100;
  color: #bf360c;
}
.supplement-btn.supplemented {
  color: #1a7a1a;
  border-color: #66bb6a;
  background: #e8f5e9;
  cursor: default;
}

/* 方法候选池中的卡片始终勾选（视觉反馈） */
.method-zone-pool .method-card .method-check {
  accent-color: var(--primary);
}

/* ============ Citation Maintenance Page ============ */
/* --- Merged Citation Library (generate + pending + library) --- */

.library-section {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.library-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8fcff;
  border-bottom: 1px solid var(--line);
}

.library-head h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.library-head h3 span {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

.library-actions {
  display: flex;
  gap: 8px;
}

.library-actions button {
  min-width: auto;
  height: 30px;
  padding: 0 12px;
  font-size: 11px;
}

.library-table-wrap {
  overflow: auto;
  max-height: 40vh;
  background: #fff;
}

.library-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.lib-col-type { width: 60px; }
.lib-col-year { width: 44px; }
.lib-col-status { width: 74px; }
.lib-col-actions { width: 96px; }
.lib-col-abstract { width: 180px; }

.lib-cell-abstract {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: #666;
  cursor: default;
  line-height: 1.5;
}

.abstract-expandable {
  cursor: pointer;
}

.abstract-expandable:hover {
  background: #f5f5f5;
}

.abstract-short { }

.abstract-full {
  display: none;
  white-space: normal;
}

.abstract-expandable:hover .abstract-short,
.abstract-expanded .abstract-short {
  display: none;
}

.abstract-expandable:hover .abstract-full,
.abstract-expanded .abstract-full {
  display: inline;
  white-space: normal;
}

.abstract-expandable:hover,
.abstract-expanded {
  white-space: normal;
  overflow: visible;
  max-width: 360px;
  background: #fffef5;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.abstract-more {
  color: #1890ff;
  font-size: 10px;
  white-space: nowrap;
}

.lib-actions-cell {
  display: flex;
  gap: 4px;
  align-items: center;
}

.lib-actions-cell button {
  height: 28px;
  padding: 0 8px;
  font-size: 11px;
  min-width: auto;
  white-space: nowrap;
}

.lib-actions-cell .lib-add-btn { min-width: 42px; }
.lib-actions-cell .lib-edit-btn { min-width: 32px; color: var(--muted); }
.lib-actions-cell .checklist-remove-btn { color: #c44; min-width: 36px; }

.lib-added-label {
  display: inline-block;
  padding: 0 8px;
  font-size: 11px;
  color: #2d9a68;
  white-space: nowrap;
}

.library-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.library-table th {
  padding: 8px 6px;
  background: #f2f8ff;
  border-bottom: 2px solid var(--line);
  color: #41637f;
  font-weight: 700;
  font-size: 11px;
  text-align: left;
  white-space: nowrap;
}

.library-table td {
  padding: 6px;
  border-bottom: 1px solid #edf3f9;
  vertical-align: middle;
}

.library-table tbody tr:hover { background: #fafeff; }

.lib-cell-text {
  max-width: 500px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  line-height: 1.5;
}

.lib-empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 32px !important;
}

.lib-status-ok { color: #2d9a68; font-weight: 600; font-size: 12px; }
.lib-status-warn { color: #d97706; font-weight: 600; font-size: 12px; }
.lib-status-pend { color: var(--muted); font-size: 12px; }

.library-empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---- Library filter toolbar ---- */

.lib-toolbar {
  background: #f8fcff;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}

.lib-toolbar-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.lib-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lib-field span {
  font-size: 10px;
  font-weight: 600;
  color: #41637f;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lib-field select,
.lib-field input {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  background: #fff;
  color: var(--text);
}

.lib-field select { min-width: 140px; }
.lib-field input { min-width: 160px; }

.lib-field-sm select,
.lib-field-sm input {
  min-width: 80px;
  width: 90px;
}

.lib-method-wrap {
  display: flex;
  gap: 4px;
  align-items: center;
}

.lib-method-wrap select { flex: 1; min-width: 120px; }
.lib-method-wrap input { width: 110px; min-width: auto; }
.lib-method-wrap button {
  height: 30px;
  min-width: 28px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 700;
}

#libSearch {
  height: 30px;
  padding: 0 20px;
  font-size: 12px;
  white-space: nowrap;
}

/* Keep cm-edit-modal styles (used for editing library entries) */
.cm-edit-modal { max-width: 640px; }
.cm-edit-modal .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.cm-edit-modal .form-grid .wide {
  grid-column: 1 / -1;
}

/* Citation selector in writing sections */
.cite-box {
  margin: 4px 0 8px;
  border: 1px solid #d8dde3;
  border-radius: 4px;
  font-size: 12px;
}
.cite-head {
  padding: 4px 10px;
  color: #5a7a9a;
  background: #f6f9fc;
  font-size: 12px;
  border-bottom: 1px solid #eef2f6;
}
.cite-head small { color: #999; font-weight: normal; }
.cite-grid {
  padding: 4px 10px;
  max-height: 200px;
  overflow-y: auto;
}
.cite-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 1px 0;
}
.cite-row input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
}
.cite-text {
  font-size: 11px;
  color: #333;
  line-height: 1.6;
  word-break: break-all;
}

/* ---------- Generation progress bar ---------- */
.gen-progress {
  margin: 8px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.gen-progress .gen-bar-track {
  flex: 1;
  height: 6px;
  background: #e0e8f0;
  border-radius: 3px;
  overflow: hidden;
}
.gen-progress .gen-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s ease;
}
.gen-progress .gen-status-text {
  font-size: 12px;
  color: #5a7a9a;
  white-space: nowrap;
}

/* ── License badge in sidebar ── */
.license-badge {
  margin-top: auto;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 12px;
}
.license-badge:hover {
  background: var(--panel);
}
.license-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.license-dot.active { background: #10b981; }
.license-dot.trial { background: #f59e0b; }
.license-dot.expired { background: #ef4444; }
.license-dot.none { background: #94a3b8; }

.license-label {
  color: #5a7a9a;
  flex: 1;
}
.license-days {
  color: #3b6080;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ── License page ── */
.license-status-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 32px;
  text-align: center;
  margin-bottom: 24px;
}
.license-tier-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.license-tier-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}
.license-tier-desc {
  font-size: 13px;
  color: #5a7a9a;
  margin-bottom: 12px;
}
.license-meta {
  font-size: 12px;
  color: #7a9ab8;
  line-height: 1.7;
}
.license-meta .days-warning {
  color: #f59e0b;
  font-weight: 600;
}
.license-meta .days-critical {
  color: #ef4444;
  font-weight: 600;
}

.license-actions {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.license-actions h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 6px;
}
.license-input-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.license-code-input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: monospace;
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
}
.license-code-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ── Inline license activation (setup page) ── */
.license-inline {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.license-inline-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.license-inline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}
.license-inline-dot.active { background: #10b981; }
.license-inline-dot.trial { background: #f59e0b; }
.license-inline-dot.expired { background: #ef4444; }
.license-inline-label {
  font-weight: 600;
  color: var(--text);
}
.license-inline-days {
  color: #7a9ab8;
  margin-left: auto;
}
.license-inline-activate {
  display: flex;
  gap: 8px;
  align-items: center;
}
.license-inline-activate[hidden] { display: none; }
.license-code-input.compact {
  flex: 1;
  padding: 7px 10px;
  font-size: 11px;
}
.license-inline-trial {
  display: flex;
  gap: 8px;
  align-items: center;
}
.license-inline-trial[hidden] { display: none; }

/* ── Menu gating ── */
.step.gated {
  opacity: 0.45;
  cursor: not-allowed;
  position: relative;
}
.step.gated::after {
  content: "🔒";
  font-size: 10px;
  margin-left: 4px;
}
.step.sub-item.gated::after {
  content: "🔒";
  font-size: 10px;
  margin-left: 4px;
}

/* ── License upgrade cards ── */
.license-upgrade-section {
  margin-top: 8px;
}
.license-upgrade-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px;
}
.upgrade-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.upgrade-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
}
.upgrade-card:hover {
  border-color: var(--primary);
}
.upgrade-tier {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-strong);
  margin-bottom: 4px;
}
.upgrade-price {
  font-size: 14px;
  color: #f59e0b;
  font-weight: 600;
  margin-bottom: 10px;
}
.upgrade-features {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  text-align: left;
  font-size: 13px;
  color: var(--text-secondary);
}
.upgrade-features li {
  padding: 3px 0;
}
.upgrade-features li::before {
  content: "✓ ";
  color: #10b981;
  font-weight: 700;
}
.upgrade-hint {
  font-size: 12px;
  color: var(--hint);
  margin: 0;
}

/* ---------- Citation outline tree (citations page) ---------- */
.citation-outline {
  margin-bottom: 16px;
}
.cite-outline-chapter {
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--panel-2);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.cite-outline-chapter h3 {
  font-size: 14px;
  color: var(--primary-strong);
  margin: 0 0 8px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.cite-outline-section {
  margin-bottom: 2px;
}
.cite-outline-section-head {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 2px 8px;
}
.cite-outline-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 24px;
  border-radius: 4px;
  font-size: 12px;
  transition: background 0.15s;
}
.cite-outline-row:hover {
  background: rgba(31, 123, 215, 0.06);
}
.cite-outline-row.active {
  background: #e8f0fe;
  border-left: 3px solid var(--primary);
  padding-left: 21px;
}
.cite-outline-num {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 11px;
  color: var(--muted);
  min-width: 40px;
}
.cite-outline-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.cite-outline-count {
  color: var(--green);
  font-size: 11px;
  min-width: 52px;
  text-align: right;
  font-weight: 500;
}
.cite-manage-btn {
  font-size: 11px !important;
  padding: 2px 10px !important;
  min-width: auto !important;
  height: 26px !important;
  border: 1px solid var(--primary) !important;
  color: var(--primary) !important;
  border-radius: 3px !important;
}
.cite-manage-btn:hover {
  background: var(--primary) !important;
  color: #fff !important;
}

/* ---------- Per-subsection citation panel ---------- */
.citation-subsection-panel {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  margin-bottom: 16px;
  background: var(--panel);
  overflow: hidden;
}
.citation-subsection-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.citation-subsection-head h3 {
  font-size: 13px;
  margin: 0;
  color: var(--primary-strong);
}
.citation-subsection-panel .library-section {
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--line);
}
.citation-subsection-panel .library-section:last-of-type {
  border-bottom: none;
}

/* ═══════════════════════════════════════════
   Welcome / Landing Page
   ═══════════════════════════════════════════ */

.brand {
  cursor: pointer;
  transition: opacity 0.2s;
}
.brand:hover {
  opacity: 0.78;
}

.welcome-hero {
  padding: 68px 32px 42px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(117, 181, 241, 0.16), transparent 38%),
    linear-gradient(180deg, rgba(245, 251, 255, 0.78), rgba(250, 253, 255, 0));
}

.welcome-badge {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid #c4ddf4;
  background: rgba(245, 251, 255, 0.92);
  color: #3472aa;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  margin-bottom: 22px;
}

.welcome-title {
  margin: 0;
  color: #172f45;
  font-size: clamp(34px, 4vw, 54px);
  font-weight: 800;
  letter-spacing: -1.8px;
  line-height: 1.2;
}
.welcome-title strong {
  color: var(--primary-strong);
}

.welcome-subtitle {
  max-width: 720px;
  margin: 20px auto 0;
  color: #64788b;
  font-size: 16px;
  line-height: 1.8;
}
.welcome-trial-note {
  margin: 13px 0 0;
  color: #8495a5;
  font-size: 12px;
}

.welcome-product-preview {
  max-width: 1060px;
  margin: 4px auto 0;
  overflow: hidden;
  border: 1px solid #bfd5e8;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(48, 93, 134, 0.17);
}
.preview-browser-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 42px;
  padding: 0 16px;
  border-bottom: 1px solid #d9e7f2;
  background: #f7fbfe;
  color: #7790a6;
  font-size: 11px;
}
.preview-browser-bar b {
  margin-left: auto;
  color: #4f9a73;
  font-size: 11px;
  font-weight: 700;
}
.preview-window-dots {
  display: flex;
  gap: 5px;
}
.preview-window-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #bed2e3;
}
.preview-workspace {
  display: grid;
  grid-template-columns: 174px minmax(0, 1fr) 212px;
  min-height: 370px;
}
.preview-nav {
  padding: 24px 14px;
  border-right: 1px solid #e1ebf3;
  background: #f8fbfd;
}
.preview-nav p,
.preview-score p {
  margin: 0 0 14px;
  color: #8497a8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
}
.preview-nav div {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 9px 8px;
  border-radius: 8px;
  color: #6e8396;
  font-size: 11px;
}
.preview-nav div.is-active {
  background: #eaf4fd;
  color: #286da9;
  font-weight: 700;
}
.preview-nav span {
  color: #9aabba;
  font-size: 10px;
}
.preview-document {
  padding: 28px 26px;
}
.preview-document-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.preview-document-head p {
  margin: 0 0 7px;
  color: #7690a7;
  font-size: 11px;
}
.preview-document-head h3 {
  margin: 0;
  color: #294a67;
  font-size: 18px;
}
.preview-document-head > span {
  padding: 5px 8px;
  border-radius: 999px;
  background: #edf6ff;
  color: #3478b4;
  font-size: 11px;
}
.preview-outline {
  margin-top: 26px;
}
.preview-outline div {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid #edf2f6;
  color: #647c91;
  font-size: 12px;
}
.preview-outline div.is-current {
  border-radius: 8px;
  border-bottom-color: transparent;
  background: #f3f9ff;
  color: #276da8;
}
.preview-outline i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d2dfe9;
}
.preview-outline i.is-blue,
.preview-outline .is-current i {
  background: #5b9ed9;
}
.preview-outline b {
  color: #96a7b6;
  font-size: 10px;
  font-weight: 600;
}
.preview-editor-lines {
  display: grid;
  gap: 8px;
  margin-top: 25px;
}
.preview-editor-lines i {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: #edf2f6;
}
.preview-editor-lines i:nth-child(2) { width: 92%; }
.preview-editor-lines i:nth-child(3) { width: 96%; }
.preview-editor-lines i:nth-child(4) { width: 72%; }
.preview-editor-lines i:nth-child(5) { width: 84%; }
.preview-insights {
  padding: 25px 17px;
  border-left: 1px solid #e1ebf3;
  background: #fbfdff;
}
.preview-score strong {
  display: block;
  color: #286ea9;
  font-size: 38px;
  line-height: 1;
}
.preview-score strong span {
  font-size: 18px;
}
.preview-score small,
.preview-source-count small {
  display: block;
  margin-top: 7px;
  color: #8a9bab;
  font-size: 11px;
}
.preview-insight-list {
  margin-top: 25px;
  padding-top: 13px;
  border-top: 1px solid #e4edf4;
}
.preview-insight-list p {
  margin: 9px 0;
  color: #6b8194;
  font-size: 11px;
}
.preview-insight-list span {
  display: inline-grid;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  place-items: center;
  border-radius: 50%;
  background: #e6f5ed;
  color: #388b60;
  font-size: 10px;
  font-weight: 800;
}
.preview-insight-list p:last-child span {
  background: #fff3dc;
  color: #ad751d;
}
.preview-source-count {
  margin-top: 24px;
  padding: 13px;
  border-radius: 10px;
  background: #f0f7fd;
}
.preview-source-count span {
  display: block;
  color: #6a849b;
  font-size: 11px;
}
.preview-source-count strong {
  display: block;
  margin-top: 5px;
  color: #2e6fa7;
  font-size: 24px;
}

.welcome-section-head {
  margin: 74px 8px 22px;
  text-align: center;
}
.welcome-section-head p {
  margin: 0 0 6px;
  color: #4785bd;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
}
.welcome-section-head h3 {
  margin: 0;
  color: #243e55;
  font-size: 25px;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  padding: 0 8px;
}

.wfc-card {
  padding: 26px 24px;
  border: 1px solid #d7e4ee;
  border-radius: 12px;
  background: #fff;
  transition: transform 0.2s, box-shadow 0.2s;
}
.wfc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(24, 50, 77, 0.08);
  border-color: #add0ee;
}
.wfc-number {
  display: inline-grid;
  width: 34px;
  height: 34px;
  margin-bottom: 30px;
  place-items: center;
  border-radius: 9px;
  background: #eef6fd;
  color: #4d8cc4;
  font-size: 11px;
  font-weight: 800;
}
.wfc-card h3 {
  margin: 0 0 9px;
  color: #29465e;
  font-size: 16px;
  font-weight: 700;
}
.wfc-card p {
  margin: 0;
  color: #728494;
  font-size: 13px;
  line-height: 1.8;
}

.welcome-toolbox {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr);
  gap: 46px;
  align-items: center;
  margin: 78px 8px 0;
  padding: 38px 42px;
  border: 1px solid #d4e3ef;
  border-radius: 16px;
  background: linear-gradient(135deg, #f4f9fd, #fbfdff);
}
.welcome-toolbox-copy p {
  margin: 0 0 7px;
  color: #4785bd;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
}
.welcome-toolbox-copy h3 {
  margin: 0;
  color: #27445d;
  font-size: 24px;
  line-height: 1.45;
}
.welcome-toolbox-copy span {
  display: block;
  margin-top: 12px;
  color: #728494;
  font-size: 13px;
  line-height: 1.8;
}
.welcome-toolbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.welcome-toolbox-grid div {
  padding: 17px 16px;
  border: 1px solid #dbe8f1;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
}
.welcome-toolbox-grid b,
.welcome-toolbox-grid span {
  display: block;
}
.welcome-toolbox-grid b {
  color: #346d9e;
  font-size: 14px;
}
.welcome-toolbox-grid span {
  margin-top: 6px;
  color: #8495a5;
  font-size: 12px;
}

.welcome-cta {
  margin: 78px 8px 8px;
  text-align: center;
  padding: 46px 24px 30px;
  border-top: 1px solid #dce8f1;
}
.welcome-cta h3 {
  margin: 0 0 9px;
  color: #243e55;
  font-size: 24px;
}
.welcome-cta p {
  max-width: 600px;
  margin: 0 auto 22px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--muted);
}
.welcome-cta strong {
  color: var(--text);
}

.welcome-disclaimer {
  max-width: 520px !important;
  margin: 20px auto 0 !important;
  font-size: 12px !important;
  line-height: 1.6 !important;
  color: #8a9bb5 !important;
}

.welcome-start-btn {
  font-size: 15px;
  padding: 12px 48px;
  height: 48px;
  border-radius: 14px;
}
.welcome-cta-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}
.welcome-plan-btn {
  min-width: 140px;
  height: 48px;
  border-radius: 14px;
  font-size: 15px;
}

@media (max-width: 900px) {
  .welcome-hero {
    padding: 46px 16px 30px;
  }
  .welcome-title {
    font-size: 32px;
    letter-spacing: -1px;
  }
  .preview-workspace {
    grid-template-columns: 1fr;
  }
  .preview-nav,
  .preview-insights {
    display: none;
  }
  .preview-document {
    min-height: 330px;
    padding: 22px 18px;
  }
  .welcome-features {
    grid-template-columns: 1fr;
  }
  .welcome-toolbox {
    grid-template-columns: 1fr;
    gap: 22px;
    margin-top: 54px;
    padding: 26px 20px;
  }
  .welcome-toolbox-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Citation add modal preview ────────────────────────────── */
.cm-add-citation-modal {
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
}

.cm-preview-summary {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}

.cm-preview-summary span:first-child {
  font-weight: 600;
  color: var(--text);
}

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

.cm-preview-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  max-height: 380px;
  overflow-y: auto;
}

.cm-preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
}

.cm-preview-card.selected {
  border-color: var(--line-strong);
  background: var(--bg);
}

.cm-preview-card.excluded {
  opacity: 0.55;
  background: #fafafa;
}

.cm-preview-card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.cm-preview-card-header input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.row-btns {
  display: flex;
  gap: 8px;
  align-items: center;
}

.cm-preview-formatted {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  flex: 1;
  word-break: break-all;
}

.cm-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
}

.cm-preview-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.cm-tag-type {
  background: #e8f0fe;
  color: #1a73e8;
}

.cm-tag-year {
  background: #e6f4ea;
  color: #137333;
}

.cm-tag-doi {
  background: #fef7e0;
  color: #b06000;
}

.cm-tag-complete {
  background: #e6f4ea;
  color: #137333;
}

.cm-tag-incomplete {
  background: #fce8e6;
  color: #c5221f;
}

.cm-tag-no-citation {
  background: #f1f3f4;
  color: #5f6368;
}

.cm-preview-issues {
  margin-top: 6px;
  font-size: 12px;
  color: #c5221f;
  line-height: 1.5;
}

.cm-preview-issues li {
  margin: 0;
  padding: 0;
  list-style: disc inside;
}

/* ── Grade badges ────────────────────────────────────── */
.grade-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.grade-a { background: #e6f4ea; color: #137333; }
.grade-b { background: #e8f0fe; color: #1a73e8; }
.grade-c { background: #fef7e0; color: #b06000; }
.grade-d { background: #fce8e6; color: #c5221f; }
.grade-none { background: #f1f3f4; color: #5f6368; }

/* ── Relevance column ────────────────────────────────── */
.lib-col-rel { width: 78px; text-align: center; }
.lib-rel-cell { text-align: center; font-size: 12px; font-weight: 500; white-space: nowrap; }
.lib-rel-cell.rel-high { color: #137333; }
.lib-rel-cell.rel-mid  { color: #1a73e8; }
.lib-rel-cell.rel-low  { color: #b06000; }
.lib-rel-cell.rel-none { color: #999; }

/* ── Auth overlay ─────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.auth-overlay.hidden { display: none; }

.auth-card {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  padding: 36px 32px 24px;
  width: 100%; max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.auth-close {
  position: absolute; top: 12px; right: 14px;
  background: none; border: none; font-size: 22px; color: #999;
  cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1;
}
.auth-close:hover { background: #f0f0f0; color: #333; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand h2 { font-size: 24px; margin: 0; color: var(--primary); }
.auth-brand p  { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

.auth-tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tab {
  flex: 1; padding: 10px; border: none; background: none;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; transition: all .15s;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.auth-fields { display: flex; flex-direction: column; gap: 14px; }
.auth-error {
  color: var(--danger); font-size: 13px; margin: 8px 0 0; padding: 6px 10px;
  background: #fce8e6; border-radius: 6px;
}
.auth-error.hidden { display: none; }

.disclaimer-check {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 14px;
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none;
}
.disclaimer-check input[type="checkbox"] {
  flex-shrink: 0; margin-top: 1px; width: 15px; height: 15px; accent-color: var(--primary);
}
.disclaimer-check a { color: var(--primary); text-decoration: underline; }
.disclaimer-check[hidden] { display: none; }

.auth-submit { width: 100%; margin-top: 18px; }
.auth-footer { text-align: center; font-size: 11px; color: var(--muted); margin-top: 16px; }
.auth-footer-link { text-align: center; font-size: 12px; margin-top: 8px; }
.auth-footer-link a { color: var(--primary); text-decoration: underline; }
.auth-success { text-align: center; font-size: 14px; color: #16a34a; margin-top: 12px; padding: 12px 16px; background: #f0fdf4; border-radius: 8px; border: 1px solid #bbf7d0; line-height: 1.8; }
.auth-success.hidden { display: none; }
.auth-form.hidden { display: none; }
.auth-tabs.hidden { display: none; }

#disclaimerModal.modal-backdrop {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: none;
}
.disclaimer-card {
  max-width: 680px; max-height: 85vh;
  background: #fff; border-radius: 12px; box-shadow: 0 12px 48px rgba(0,0,0,0.3);
  display: flex; flex-direction: column; overflow: hidden;
}
.disclaimer-card .modal-head {
  margin-bottom: 0; padding: 18px 22px; border-bottom: 1px solid #e5e7eb;
}
.disclaimer-card .modal-head h2 { color: #111; }
.disclaimer-card .modal-foot {
  padding: 14px 22px; border-top: 1px solid #e5e7eb;
  display: flex; justify-content: flex-end;
}
.disclaimer-body { font-size: 13px; line-height: 1.8; color: #1a1a1a; }
.disclaimer-body h3 { font-size: 15px; margin: 18px 0 8px; color: #111; }
.disclaimer-body h3:first-child { margin-top: 0; }
.disclaimer-body ol { padding-left: 20px; margin: 6px 0; }
.disclaimer-body li { margin-bottom: 4px; }
.disclaimer-body p { margin: 6px 0; }

/* Logged-in user badge in sidebar */
.user-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; margin: 8px 12px;
  background: var(--surface2); border-radius: 8px;
  font-size: 12px; color: var(--text);
  cursor: pointer;
}
.user-badge .user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.user-badge .user-info { flex: 1; }
.user-badge .user-email { color: var(--muted); font-size: 11px; }
.user-badge .logout-btn { color: var(--muted); font-size: 11px; border: none; background: none; cursor: pointer; }

@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

/* ── Blind review file upload ── */
.blind-upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 16px;
  text-align: center;
  background: var(--surface2);
  transition: border-color 0.2s, background 0.2s;
}
.blind-upload-zone.drag-over {
  border-color: #3b82f6;
  background: #eff6ff;
}
.blind-upload-zone .blind-upload-label {
  font-size: 14px;
  color: var(--muted);
}
.blind-upload-zone .blind-upload-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 6px;
}
.blind-upload-zone .blind-upload-file {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.blind-upload-zone .blind-upload-file span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.blind-upload-zone .blind-upload-file button {
  flex-shrink: 0;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1;
}
.blind-upload-zone #blindUploadScan {
  margin-top: 12px;
}

/* ── Figure generator ── */
.head-actions { display: flex; align-items: center; gap: 10px; }
.quota-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: #e8f5e8;
  color: #2d7a3e;
  border: 1px solid #b8e0b8;
}
.quota-badge.warning { background: #fffbe6; color: #ad6800; border-color: #ffe58f; }
.quota-badge.exhausted { background: #fff2f0; color: #cf1322; border-color: #ffccc7; }
.quota-badge.unlimited { background: #e6f7ff; color: #0050b3; border-color: #91d5ff; }

.figure-generator { display: flex; flex-direction: column; gap: 14px; }
.ppt-style-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.ppt-style-controls label { display: flex; flex-direction: column; gap: 6px; }
.ppt-style-controls span { font-size: 12px; color: var(--muted); }
.ppt-style-controls select {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.visual-generator-tabs {
  display: flex;
  gap: 8px;
  margin: 16px 0 12px;
  border-bottom: 1px solid var(--border);
}
.visual-generator-tab {
  padding: 9px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}
.visual-generator-tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
}
.visual-table-mode {
  margin-top: 0;
  border-top: 0;
  padding-top: 6px;
}
.figure-type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.figure-type-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.figure-type-card:hover { border-color: #91d5ff; background: #f0f9ff; }
.figure-type-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.figure-type-card:has(input[type="radio"]:checked) {
  border-color: #1890ff;
  background: #e6f7ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(24,144,255,0.15);
}
.figure-type-icon { font-size: 28px; line-height: 1; margin-bottom: 6px; }
.figure-type-name { font-weight: 600; font-size: 14px; }
.figure-type-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }

.figure-desc {
  width: 100%;
  min-height: 110px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
}
.figure-actions-top, .figure-actions-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
}
.figure-result {
  margin-top: 6px;
  padding: 16px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.figure-result img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto 14px;
  background: white;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.figure-spec-detail {
  margin-top: 12px;
  font-size: 12px;
}
.figure-spec-detail summary {
  cursor: pointer;
  color: var(--muted);
  padding: 4px 0;
}
.figure-spec-detail pre {
  background: var(--surface);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 11px;
  border: 1px solid var(--border);
}
@media (max-width: 720px) {
  .figure-type-grid { grid-template-columns: repeat(2, 1fr); }
}

.figure-presets {
  margin-top: -6px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.figure-presets-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.figure-presets-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.figure-preset-btn {
  padding: 5px 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.figure-preset-btn:hover {
  background: #e6f7ff;
  border-color: #91d5ff;
}
.figure-upload-zone {
  margin-top: 8px;
  padding: 14px 18px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  text-align: center;
  background: var(--surface2);
  transition: border-color 0.15s, background 0.15s;
}
.figure-upload-zone.drag-over { border-color: #3b82f6; background: #eff6ff; }
.figure-upload-zone .figure-upload-label {
  font-size: 13px;
  color: var(--muted);
}
.figure-upload-zone .figure-upload-icon {
  font-size: 22px;
  display: block;
  margin-bottom: 4px;
}
.figure-upload-zone .figure-upload-file {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 6px 10px; background: var(--surface); border-radius: 6px;
  border: 1px solid var(--border); font-size: 13px;
}

/* ── Peer Review ── */
.peer-review-source {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.peer-source-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.peer-source-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.peer-source-card:has(input[type="radio"]:checked) {
  border-color: #1890ff;
  background: #e6f7ff;
}
.peer-source-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.peer-source-desc { font-size: 12px; color: var(--muted); }

.peer-upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 18px 24px;
  margin-bottom: 14px;
  text-align: center;
  background: var(--surface2);
}
.peer-upload-zone.drag-over { border-color: #3b82f6; background: #eff6ff; }
.peer-upload-label { font-size: 14px; color: var(--muted); }
.peer-upload-icon { font-size: 28px; display: block; margin-bottom: 6px; }
.peer-upload-file {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 12px; background: var(--surface); border-radius: 6px;
  border: 1px solid var(--border); font-size: 13px;
}

.peer-actions { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; }

.peer-result { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }

.peer-verdict-card {
  padding: 18px 22px;
  border-radius: 10px;
  text-align: center;
  background: linear-gradient(135deg, #e8f5e8 0%, #d4ecd4 100%);
  border: 1px solid #b8e0b8;
}
.peer-verdict-card.verdict-Minor { background: linear-gradient(135deg, #fffbe6 0%, #fff1b8 100%); border-color: #ffe58f; }
.peer-verdict-card.verdict-Major { background: linear-gradient(135deg, #fff7e6 0%, #ffd591 100%); border-color: #ffbf85; }
.peer-verdict-card.verdict-Reject { background: linear-gradient(135deg, #fff2f0 0%, #ffccc7 100%); border-color: #ffaaa3; }
.peer-verdict-label {
  display: inline-block; padding: 4px 14px;
  border-radius: 12px; background: white;
  font-weight: 700; font-size: 14px; margin-bottom: 6px;
}
.peer-verdict-score { font-size: 36px; font-weight: 700; margin: 2px 0; }
.peer-verdict-desc { font-size: 12px; color: var(--muted); }

.peer-dimensions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.peer-dim-card {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.peer-dim-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.peer-dim-name { font-weight: 600; font-size: 13px; }
.peer-dim-weight { font-size: 11px; color: var(--muted); }
.peer-dim-score {
  font-size: 24px; font-weight: 700; margin-right: 6px;
}
.peer-dim-score.high { color: #2d7a3e; }
.peer-dim-score.med { color: #ad6800; }
.peer-dim-score.low { color: #cf1322; }
.peer-dim-comment { font-size: 12px; color: #333; line-height: 1.5; }

.peer-strengths-weaknesses {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.peer-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
}
.peer-block h4 { margin: 0 0 8px; font-size: 14px; }
.peer-strengths { border-left: 4px solid #2d7a3e; }
.peer-weaknesses { border-left: 4px solid #cf1322; }
.peer-priorities { border-left: 4px solid #1890ff; }
.peer-block ul, .peer-block ol { margin: 0; padding-left: 22px; }
.peer-block li { font-size: 13px; line-height: 1.6; margin-bottom: 4px; }

.peer-section-item {
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 6px;
  margin-bottom: 8px;
}
.peer-section-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.peer-section-issues, .peer-section-suggestions { font-size: 12px; margin: 4px 0; }
.peer-section-issues strong { color: #cf1322; }
.peer-section-suggestions strong { color: #2d7a3e; }

/* ── Revision Coach ── */
#revisionInput {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 180px;
}
.revision-actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }

.revision-result { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.revision-summary-card {
  padding: 14px 18px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f0ff 100%);
  border: 1px solid #91d5ff;
  border-radius: 8px;
}
.revision-summary-card .verdict-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  background: white;
  margin-right: 8px;
}
.revision-filters {
  display: flex; gap: 14px; align-items: center;
  padding: 8px 0;
  font-size: 13px;
}
.revision-filters label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.revision-filters .ghost { margin-left: auto; }

.revision-comment-card {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
}
.revision-comment-card.cat-Major { border-left-color: #cf1322; }
.revision-comment-card.cat-Minor { border-left-color: #ad6800; }
.revision-comment-card.cat-Comment { border-left-color: #1890ff; }
.revision-comment-head {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px; margin-bottom: 6px;
}
.revision-tag {
  display: inline-block; padding: 2px 8px;
  border-radius: 10px; font-size: 11px; font-weight: 600;
}
.revision-tag.cat-Major { background: #fff2f0; color: #cf1322; }
.revision-tag.cat-Minor { background: #fff7e6; color: #ad6800; }
.revision-tag.cat-Comment { background: #e6f7ff; color: #0050b3; }
.revision-tag.priority-P0 { background: #fff2f0; color: #cf1322; }
.revision-tag.priority-P1 { background: #fffbe6; color: #ad6800; }
.revision-tag.priority-P2 { background: #f0f9ff; color: #0050b3; }
.revision-tag.section { background: #f0f0f0; color: #555; }
.revision-tag.effort { background: #e6fff0; color: #2d7a3e; }
.revision-comment-summary { font-size: 14px; font-weight: 600; margin: 4px 0 6px; }
.revision-comment-raw {
  font-size: 12px; color: var(--muted);
  font-style: italic; margin-bottom: 8px;
  padding: 4px 8px; background: var(--surface2);
  border-radius: 4px;
}
.revision-comment-actions { font-size: 13px; margin: 4px 0; }
.revision-comment-actions ol { margin: 4px 0; padding-left: 22px; }
.revision-comment-actions li { line-height: 1.6; margin-bottom: 2px; }

@media (max-width: 720px) {
  .peer-review-source, .peer-strengths-weaknesses { grid-template-columns: 1fr; }
}

/* ── AIGC upload row (shared by check/reduce) ── */
.aigc-source-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.aigc-source-card {
  position: relative;
  display: flex; flex-direction: column;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
}
.aigc-source-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.aigc-source-card:has(input[type="radio"]:checked) {
  border-color: #1890ff;
  background: #e6f7ff;
}
.aigc-source-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.aigc-source-desc { font-size: 11px; color: var(--muted); }

.aigc-upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 14px;
  text-align: center;
  background: var(--surface2);
}
.aigc-upload-zone.drag-over { border-color: #3b82f6; background: #eff6ff; }
.aigc-upload-zone .aigc-upload-label { font-size: 13px; color: var(--muted); }
.aigc-upload-zone .aigc-upload-icon { font-size: 22px; display: block; margin-bottom: 4px; }
.aigc-upload-zone .aigc-upload-file {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 6px 10px; background: var(--surface); border-radius: 6px;
  border: 1px solid var(--border); font-size: 13px;
}
@media (max-width: 720px) { .aigc-source-row { grid-template-columns: 1fr; } }

/* ── Purchase + Referral ────────────────────────────────────────── */
.purchase-plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.purchase-plan-card {
  padding: 22px 20px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  text-align: center;
  transition: border-color 0.15s, transform 0.1s;
}
.purchase-plan-card:hover { border-color: #91d5ff; transform: translateY(-2px); }
.purchase-plan-card[data-tier="vip"]   { border-color: #faad14; background: linear-gradient(135deg, #fffbe6 0%, #ffefb3 100%); }
.purchase-plan-card[data-tier="pro"]   { border-color: #1890ff; background: linear-gradient(135deg, #f0f9ff 0%, #d6ebff 100%); }
.purchase-plan-card[data-tier="basic"] { border-color: #52c41a; }
.purchase-plan-tier { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.05em; }
.purchase-plan-card h3 { margin: 6px 0 12px; font-size: 18px; }
.purchase-plan-price { font-size: 32px; font-weight: 700; color: #cf1322; }
.purchase-plan-price small { font-size: 14px; color: #666; }
.purchase-plan-duration { font-size: 12px; color: var(--muted); margin: 4px 0 12px; }
.purchase-plan-desc { font-size: 13px; color: #555; min-height: 36px; }
.purchase-plan-card button { width: 100%; margin-top: 10px; }

.payment-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000; padding: 20px;
}
.payment-modal {
  background: white; padding: 24px 28px; border-radius: 12px;
  max-width: 420px; width: 100%; box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  display: flex; flex-direction: column; gap: 8px;
}
.payment-modal-wide { max-width: 480px; }
.payment-modal h3 { margin: 0 0 4px; }
.payment-method-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.payment-method-btn {
  padding: 12px 16px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; text-align: left; font-size: 14px;
  transition: background 0.15s;
}
.payment-method-btn:hover { background: #e6f7ff; border-color: #1890ff; }
.payment-qr-area {
  display: flex; flex-direction: column; align-items: center;
  margin: 12px 0; padding: 12px; background: var(--surface2); border-radius: 8px;
}
.payment-qr-img { max-width: 260px; width: 100%; height: auto; }
.payment-upload-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.payment-modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

.referral-card {
  padding: 22px 24px;
  background: linear-gradient(135deg, #fff7e6 0%, #ffefb3 100%);
  border: 1px solid #ffd591;
  border-radius: 10px;
}
.referral-code-row {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 18px;
}
.referral-code-label { font-size: 13px; color: var(--muted); }
.referral-code-value {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 28px; font-weight: 700; color: #cf1322;
  padding: 6px 16px; background: white; border-radius: 8px;
  letter-spacing: 0.15em;
}
.referral-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.referral-stat {
  text-align: center; padding: 10px;
  background: white; border-radius: 8px;
}
.referral-stat strong { font-size: 22px; display: block; color: #0050b3; }
.referral-stat small { font-size: 11px; color: var(--muted); }

.commission-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.commission-table th, .commission-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left;
}
.commission-table th { background: var(--surface2); font-weight: 600; }
.commission-table .status-pending { color: #ad6800; }
.commission-table .status-settled { color: #2d7a3e; font-weight: 600; }
.commission-table .status-cancelled { color: #cf1322; }

@media (max-width: 720px) {
  .referral-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ── PPT file upload ── */
.ppt-source-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.ppt-source-card {
  display: flex; flex-direction: column; padding: 10px 14px;
  border: 2px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer;
}
.ppt-source-card input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.ppt-source-card:has(input[type="radio"]:checked) { border-color: #1890ff; background: #e6f7ff; }
.ppt-source-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.ppt-source-desc { font-size: 11px; color: var(--muted); }

.ppt-upload-zone {
  border: 2px dashed var(--border); border-radius: 8px; padding: 14px 18px;
  margin-bottom: 14px; text-align: center; background: var(--surface2);
}
.ppt-upload-zone.drag-over { border-color: #3b82f6; background: #eff6ff; }
.ppt-upload-zone .ppt-upload-label { font-size: 13px; color: var(--muted); }
.ppt-upload-file {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 6px 10px; background: var(--surface); border-radius: 6px;
  border: 1px solid var(--border); font-size: 13px;
}
@media (max-width: 720px) { .ppt-source-row { grid-template-columns: 1fr; } }

.ppt-history { margin-top: 16px; border: 1px solid var(--border); border-radius: 8px; padding: 0 14px; }
.ppt-history summary { padding: 10px 0; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.ppt-history-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.ppt-history-topic { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ppt-history-meta { color: var(--muted); white-space: nowrap; }
.ppt-history-dl-btn { flex-shrink: 0; }

/* ── 紫色主题特殊覆盖（硬编码颜色修正） ──────────────── */
[data-theme="purple"] .model-badge .mb-dot { background: #a78bfa; box-shadow: 0 0 6px rgba(167,139,250,0.4); }
[data-theme="purple"] body { background: var(--bg); }
[data-theme="purple"] input,
[data-theme="purple"] textarea,
[data-theme="purple"] select { background: var(--input-bg); color: var(--text); border-color: var(--border); }
[data-theme="purple"] input:focus,
[data-theme="purple"] textarea:focus,
[data-theme="purple"] select:focus { border-color: var(--primary); }
[data-theme="purple"] .page-head { border-bottom-color: var(--line); }
[data-theme="purple"] .actions.split { border-top-color: var(--line); }
[data-theme="purple"] table th { background: var(--surface2); }
[data-theme="purple"] table td { border-bottom-color: var(--line); }
[data-theme="purple"] .chat-bar { background: var(--chat-bg); border-top-color: var(--border); }
[data-theme="purple"] .chat-bar input { background: var(--input-bg); }
[data-theme="purple"] .license-badge { border-top-color: var(--line); }
[data-theme="purple"] .model-badge { border-top-color: var(--line); }
[data-theme="purple"] #annBanner { background: linear-gradient(135deg, #2d1b69 0%, #5b21b6 100%) !important; }
[data-theme="purple"] .welcome-hero { background: linear-gradient(135deg, #1a1a2e, #2d1b69); }
[data-theme="purple"] .upgrade-card { background: var(--surface); border-color: var(--border); }
[data-theme="purple"] .license-status-card { background: var(--surface); }
[data-theme="purple"] .step { color: var(--muted); }
[data-theme="purple"] .step.active { background: var(--hover-bg); color: var(--text); }
[data-theme="purple"] .step:hover { background: var(--step-hover); }
[data-theme="purple"] code { background: var(--code-bg); color: var(--violet); }
[data-theme="purple"] .brand { color: var(--text); }
[data-theme="purple"] .save-tip { color: var(--muted); }
