/* ═══════════════════════════════════════════════
   Citation Intelligence Agent — Light Theme
   ═══════════════════════════════════════════════ */

:root {
  --bg:       #f0f4f8;
  --bg2:      #f8fafc;
  --surface:  #ffffff;
  --border:   #e2e8f0;
  --border2:  #cbd5e1;

  --text:     #0f172a;
  --muted:    #475569;
  --light:    #94a3b8;

  --accent:       #2563eb;
  --accent-light: #dbeafe;
  --accent-mid:   #3b82f6;

  --green:        #16a34a;
  --green-light:  #dcfce7;
  --green-mid:    #22c55e;

  --amber:        #d97706;
  --amber-light:  #fef3c7;

  --red:          #dc2626;
  --red-light:    #fee2e2;

  --purple:       #7c3aed;
  --purple-light: #ede9fe;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow:     0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.10);

  /* Log panel stays dark for readability contrast */
  --log-bg:     #0f172a;
  --log-bg2:    #1e293b;
  --log-border: #334155;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  line-height: 1.6;
}

/* ─── Navbar ─── */
.agent-navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.agent-navbar-toggler {
  display: none !important;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
}

.agent-navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
}

.agent-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
}

.agent-brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.agent-brand-sub {
  font-size: 10px;
  color: var(--light);
  letter-spacing: 0.4px;
}

.agent-nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.agent-nav-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s, background .15s;
}
.agent-nav-link:hover { color: var(--text); background: var(--bg); }
.agent-nav-link.active { color: var(--accent); background: var(--accent-light); }

/* ─── Page Layout ─── */
.agent-page-content {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 24px 56px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

/* ─── Footer ─── */
.agent-footer {
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--light);
  background: var(--surface);
}

/* ─── Hero ─── */
.agent-hero {
  background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 45%, #2563eb 100%);
  border-radius: 14px;
  padding: 38px 38px 34px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(37,99,235,0.25);
}

.agent-hero::before {
  content: '';
  position: absolute;
  top: -80px; right: -60px;
  width: 320px; height: 320px;
  background: radial-gradient(ellipse, rgba(255,255,255,0.07) 0%, transparent 65%);
  pointer-events: none;
}

.agent-hero::after {
  content: '';
  position: absolute;
  bottom: -40px; left: 30%;
  width: 200px; height: 200px;
  background: radial-gradient(ellipse, rgba(96,165,250,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.hero-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(191,219,254,0.85);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hero-eyebrow::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #93c5fd;
  box-shadow: 0 0 8px #93c5fd;
  animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
  0%,100% { opacity:1; box-shadow: 0 0 6px #93c5fd; }
  50%      { opacity:.6; box-shadow: 0 0 14px #93c5fd; }
}

.hero-title {
  font-size: 27px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 10px;
  line-height: 1.3;
}

.hero-title span { color: #93c5fd; }

.hero-desc {
  font-size: 13.5px;
  color: rgba(219,234,254,0.80);
  max-width: 520px;
  line-height: 1.75;
}

/* ─── Cards ─── */
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s;
}
.agent-card:focus-within { border-color: var(--accent); }

.agent-card-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.agent-textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13.5px;
  padding: 12px 14px;
  resize: vertical;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  line-height: 1.7;
}
.agent-textarea::placeholder { color: var(--light); }
.agent-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: var(--surface);
}

/* ─── Accordion / Config ─── */
.accordion-item {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.accordion-button {
  background: var(--surface) !important;
  color: var(--muted) !important;
  font-size: 13px;
  font-weight: 500;
  box-shadow: none !important;
}
.accordion-button:not(.collapsed) {
  color: var(--accent) !important;
  background: var(--accent-light) !important;
}
.accordion-button::after { opacity: 0.5; }

.accordion-body {
  background: var(--surface) !important;
  border-top: 1px solid var(--border);
  padding: 20px;
}

/* Form elements */
.form-label {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 6px;
}

.form-control, .form-select {
  background: var(--bg2) !important;
  border: 1px solid var(--border2) !important;
  color: var(--text) !important;
  font-size: 13px;
  border-radius: 7px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1) !important;
  background: var(--surface) !important;
}
.form-control::placeholder { color: var(--light) !important; }
.form-check-label { color: var(--muted); font-size: 13px; }
.form-text { color: var(--light) !important; font-size: 11px; }

/* ─── Buttons ─── */
.btn-agent-primary {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 24px;
  border-radius: 9px;
  cursor: pointer;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.btn-agent-primary:hover {
  background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 100%);
  box-shadow: 0 4px 16px rgba(37,99,235,0.4);
  transform: translateY(-1px);
  color: #fff;
}
.btn-agent-primary:disabled {
  opacity: 0.6; cursor: not-allowed; transform: none;
  box-shadow: none;
}

.btn-agent-danger {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 9px;
  cursor: pointer;
  transition: all .2s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: var(--shadow-sm);
}
.btn-agent-danger:hover {
  border-color: var(--red);
  background: var(--red-light);
}

.btn-agent-sm {
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.btn-agent-sm:hover { color: var(--text); border-color: var(--accent); background: var(--accent-light); }

/* ─── Provider Preset Buttons ─── */
.btn-provider-preset {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border2);
  background: var(--bg2);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
  font-weight: 500;
}
.btn-provider-preset:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-light);
}
.btn-provider-preset.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

/* ─── Pre-test Button & Result ─── */
.btn-pretest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  transition: all .2s;
  font-size: 16px;
  padding: 0;
}
.btn-pretest:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-pretest:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.btn-pretest.spinning i {
  animation: spin-icon .8s linear infinite;
}
@keyframes spin-icon {
  to { transform: rotate(360deg); }
}
.pretest-result {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
}
.pretest-result.success {
  background: rgba(34,197,94,.1);
  color: #22c55e;
  border: 1px solid rgba(34,197,94,.25);
}
.pretest-result.error {
  background: rgba(239,68,68,.1);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,.25);
}

/* ─── API Config Three-Section Layout ─── */
.api-config-section {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  background: var(--bg2);
}
.api-config-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.api-config-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  border: 1.5px solid var(--border2);
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
}
.api-config-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.api-config-desc {
  font-size: 12px;
  color: var(--light);
  font-weight: 400;
}

/* ─── Pipeline Architecture Indicator ─── */
.pipeline-phases {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 0;
  overflow-x: auto;
}
.pipeline-phase {
  text-align: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  min-width: 90px;
  transition: all .3s;
  flex-shrink: 0;
}
.pipeline-phase.active {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 12px rgba(37,99,235,0.15);
}
.pipeline-phase.done {
  border-color: var(--green);
  background: var(--green-light);
}
.pp-icon { font-size: 18px; margin-bottom: 4px; color: var(--muted); }
.pipeline-phase.active .pp-icon { color: var(--accent); }
.pipeline-phase.done .pp-icon { color: var(--green); }
.pp-label { font-size: 11px; font-weight: 600; color: var(--text); line-height: 1.3; }
.pp-source { font-size: 9.5px; color: var(--light); margin-top: 2px; }
.pipeline-arrow { color: var(--light); font-size: 12px; flex-shrink: 0; }

/* ─── Phase Progress ─── */
.agent-progress-wrap { margin-bottom: 20px; }

.agent-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.agent-phase-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 7px;
}

.agent-phase-label .phase-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.5s ease infinite;
}

.agent-progress-count {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.agent-progress-track {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.agent-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #16a34a);
  border-radius: 3px;
  transition: width .5s ease;
  width: 0%;
}

/* ─── Reasoning / Log Panel ─── */
/* Header is light, body is dark — creates "terminal in app" contrast */
.reasoning-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.reasoning-panel-header {
  background: var(--surface);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.rp-dots { display: flex; gap: 5px; }
.rp-dot { width: 11px; height: 11px; border-radius: 50%; }
.rp-dot.r { background: #ff5f57; }
.rp-dot.y { background: #febc2e; }
.rp-dot.g { background: #28c840; }

.rp-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  flex: 1;
  letter-spacing: 0.2px;
}

.rp-thinking {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
}
.rp-thinking.active { display: flex; }

.think-dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinkBounce 1.2s ease infinite;
}
.think-dot:nth-child(2) { animation-delay: .2s; }
.think-dot:nth-child(3) { animation-delay: .4s; }

@keyframes thinkBounce {
  0%,60%,100% { transform:translateY(0); opacity:.6; }
  30%          { transform:translateY(-4px); opacity:1; }
}

/* Dark terminal body */
.reasoning-body {
  height: 360px;
  overflow-y: auto;
  padding: 14px 16px;
  background: var(--log-bg);
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
}

.reasoning-body::-webkit-scrollbar { width: 5px; }
.reasoning-body::-webkit-scrollbar-track { background: var(--log-bg); }
.reasoning-body::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.reasoning-body::-webkit-scrollbar-thumb:hover { background: #475569; }

.reasoning-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: #475569;
}
.reasoning-empty-icon { font-size: 28px; opacity: .5; }
.reasoning-empty-text { font-size: 12px; font-family: 'Inter', sans-serif; color: #475569; }

/* Log entries */
.re-entry {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
  align-items: flex-start;
  animation: reFadeIn .25s ease both;
  font-size: 11.5px;
  line-height: 1.6;
}

@keyframes reFadeIn {
  from { opacity:0; transform:translateY(3px); }
  to   { opacity:1; transform:none; }
}

.re-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.re-ts {
  color: #334155;
  font-size: 9.5px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.re-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
  letter-spacing: .5px;
}
.re-msg { word-break: break-word; flex: 1; }

/* INFO */
.re-dot-info    { background: #60a5fa; }
.re-badge-info  { color: #93c5fd; background: rgba(96,165,250,.15); }
.re-msg-info    { color: #cbd5e1; }

/* SUCCESS */
.re-dot-success   { background: #4ade80; animation: glowGreen 1s ease 1; }
.re-badge-success { color: #4ade80; background: rgba(74,222,128,.15); }
.re-msg-success   { color: #4ade80; }

@keyframes glowGreen {
  0%   { box-shadow: 0 0 0 0 rgba(74,222,128,.5); }
  50%  { box-shadow: 0 0 0 5px rgba(74,222,128,0); }
  100% { box-shadow: none; }
}

/* WARNING */
.re-dot-warning   { background: #fbbf24; }
.re-badge-warning { color: #fbbf24; background: rgba(251,191,36,.15); }
.re-msg-warning   { color: #fbbf24; }

/* ERROR */
.re-dot-error   { background: #f87171; }
.re-badge-error { color: #f87171; background: rgba(248,113,113,.15); }
.re-msg-error   { color: #f87171; }

/* ─── Results Section ─── */
.agent-results-card {
  background: var(--surface);
  border: 1px solid #86efac;
  border-radius: 10px;
  overflow: hidden;
  animation: reFadeIn .4s ease;
  box-shadow: 0 2px 10px rgba(22,163,74,.10);
}

.agent-results-header {
  background: linear-gradient(90deg, #f0fdf4, var(--surface));
  border-bottom: 1px solid #bbf7d0;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}

.agent-results-body { padding: 16px; }

.result-file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.result-file-row:last-child { border-bottom: none; }
.result-file-icon { font-size: 18px; flex-shrink: 0; }
.result-file-name { flex: 1; color: var(--text); font-weight: 500; }

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid;
  transition: all .15s;
  white-space: nowrap;
}

.btn-dl-excel {
  color: var(--green);
  border-color: #86efac;
  background: var(--green-light);
}
.btn-dl-excel:hover { background: #bbf7d0; color: var(--green); }

.btn-dl-json {
  color: var(--accent);
  border-color: #93c5fd;
  background: var(--accent-light);
}
.btn-dl-json:hover { background: #bfdbfe; color: var(--accent); }

.btn-dl-report {
  color: var(--purple);
  border-color: #c4b5fd;
  background: var(--purple-light);
}
.btn-dl-report:hover { background: #ddd6fe; color: var(--purple); }

.dashboard-cta {
  margin-top: 14px;
  padding: 14px 16px;
  background: linear-gradient(90deg, var(--purple-light), #f0f9ff);
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.dashboard-cta-text {
  flex: 1;
  font-size: 12.5px;
  color: var(--muted);
}

/* ─── Cost Summary ─── */
.cost-summary-card {
  margin-top: 16px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 1px solid #fde68a;
  border-radius: 10px;
}
.cost-summary-header {
  font-size: 13px;
  font-weight: 600;
  color: #92400e;
  margin-bottom: 10px;
}
.cost-summary-table {
  width: 100%;
  font-size: 12.5px;
  border-collapse: collapse;
}
.cost-summary-table td {
  padding: 5px 0;
  color: var(--text);
  border-bottom: 1px solid #fde68a;
}
.cost-summary-table td:first-child {
  color: var(--muted);
  width: 45%;
}
.cost-summary-table td:last-child {
  font-weight: 500;
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.cost-summary-table tr:last-child td { border-bottom: none; }
.cost-summary-note {
  margin-top: 10px;
  font-size: 11px;
  color: #92400e;
  line-height: 1.6;
}

/* ─── Save indicator ─── */
#idx-save-indicator {
  font-size: 11px;
  color: var(--green);
  opacity: 0;
  transition: opacity .5s;
}

/* ─── Spin animation ─── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ─── Paper Tag List ─── */
#paper-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 0;
}

.paper-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px 9px 12px;
  transition: border-color .15s, box-shadow .15s;
  animation: reFadeIn .18s ease both;
}
.paper-item:focus-within {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.07);
}

.paper-item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

.paper-item-title {
  flex: 1;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  line-height: 1.5;
  padding: 0 2px;
  border-radius: 3px;
  word-break: break-word;
}
.paper-item-title:focus { background: rgba(37,99,235,0.04); }

.paper-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.paper-btn-alias, .paper-btn-delete {
  width: 24px; height: 24px;
  border-radius: 5px;
  border: 1px solid var(--border2);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}
.paper-btn-alias { color: var(--accent); font-weight: 700; }
.paper-btn-alias:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.paper-btn-delete { color: var(--light); }
.paper-btn-delete:hover {
  border-color: var(--red);
  background: var(--red-light);
  color: var(--red);
}

.paper-aliases {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 5px;
}

.paper-alias-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding-left: 2px;
}

.paper-alias-prefix {
  font-size: 11px;
  color: var(--light);
  flex-shrink: 0;
  user-select: none;
  line-height: 1.8;
}

.paper-alias {
  font-size: 13px;
  color: var(--accent);
  outline: none;
  border-radius: 3px;
  padding: 0 3px;
  min-width: 80px;
  word-break: break-word;
  line-height: 1.6;
}
.paper-alias:focus { background: var(--accent-light); }
.paper-alias:empty::before {
  content: '输入曾用名…';
  color: var(--light);
  pointer-events: none;
  font-style: italic;
}

#paper-list:not(:empty) + #paper-input {
  border-top: 1px dashed var(--border2);
  padding-top: 10px;
  margin-top: 6px;
}

#paper-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 2px 2px;
  font-size: 13.5px;
  color: var(--text);
  font-family: 'Inter', -apple-system, sans-serif;
  line-height: 1.5;
  display: block;
}
#paper-input::placeholder { color: var(--light); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Bootstrap card overrides (for config/results pages) ─── */
.card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-sm) !important;
}
.card-header {
  background: var(--bg2) !important;
  border-bottom: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 13px;
  font-weight: 600;
}
.card-body { color: var(--muted) !important; }
.card-body p, .card-body label { color: var(--muted) !important; }

.btn { transition: all .2s ease; }

.btn-primary {
  background: linear-gradient(135deg, #1d4ed8, #2563eb) !important;
  border-color: #2563eb !important;
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(37,99,235,0.35); }

.badge { font-weight: 500; }

/* Old log terminal (config / task pages) */
.log-terminal {
  height: 500px;
  overflow-y: auto;
  background: var(--log-bg);
  color: #e2e8f0;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  padding: 15px;
  border-radius: 8px;
}
.log-entry { margin-bottom: 5px; word-wrap: break-word; line-height: 1.6; }
.log-timestamp { color: #4ade80; }
.log-level { font-weight: bold; }
.log-message { color: #e2e8f0; }

.font-monospace {
  font-family: 'Menlo', 'Monaco', 'Consolas', monospace !important;
}
code {
  background: var(--accent-light);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.footer {
  position: relative;
  bottom: 0;
  width: 100%;
  margin-top: auto;
}

/* ─── SPA Panel Switching ─── */
.spa-panel { display: none; }
.spa-panel-active {
  display: block;
  animation: spaFadeIn .25s ease both;
}
@keyframes spaFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ─── Global Floating Progress Bar ─── */
.spa-global-progress {
  position: sticky;
  top: 54px; /* navbar height */
  z-index: 90;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
  margin: -32px -24px 24px;
  padding-left: 24px;
  padding-right: 24px;
  display: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: opacity .3s;
}
.spa-global-progress.active { display: block; }

.spa-global-progress-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spa-global-progress-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse-dot 1.5s ease infinite;
  flex-shrink: 0;
}

.spa-global-progress-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.spa-global-progress-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  min-width: 80px;
}

.spa-global-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #16a34a);
  border-radius: 2px;
  transition: width .5s ease;
  width: 0%;
}

.spa-global-progress-pct {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Scholar Profile Import ─── */
.scholar-import-toggle { cursor: pointer; user-select: none; }
.scholar-import-toggle:hover { opacity: 0.85; }

.scholar-paper-row {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.scholar-paper-row:last-child { border-bottom: none; }
.scholar-paper-row:hover { background: #f8faff; }
.scholar-paper-row label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin: 0;
}
.scholar-paper-row input[type="checkbox"] { flex-shrink: 0; }
.scholar-paper-title { flex: 1; font-size: 13px; line-height: 1.4; }
.scholar-paper-meta {
  color: var(--light);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Authority Citation Overview ─── */
.authority-overview {
  max-width: 1100px;
  margin: 0 auto;
}

.authority-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 22px;
}

.authority-eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  margin-bottom: 5px;
}

.authority-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0;
}

.authority-header-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.authority-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--light);
}

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

.authority-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}

.authority-stat {
  min-width: 0;
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-right: 1px solid var(--border);
}

.authority-stat:last-child { border-right: 0; }

.authority-stat > i {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border-radius: 7px;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 16px;
}

.authority-stat:nth-child(2) > i {
  color: #047857;
  background: #ecfdf5;
}

.authority-stat:nth-child(3) > i {
  color: #a16207;
  background: #fefce8;
}

.authority-stat:nth-child(4) > i {
  color: #b45309;
  background: #fff7ed;
}

.authority-stat:nth-child(5) > i,
.authority-stat:nth-child(6) > i,
.authority-stat:nth-child(7) > i {
  color: #15803d;
  background: #f0fdf4;
}

.authority-stat strong {
  display: block;
  color: var(--text);
  font-size: 21px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.authority-stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.authority-audit-strip {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  padding: 9px 12px;
  color: #854d0e;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
}

.authority-audit-strip > i {
  color: #ca8a04;
  font-size: 15px;
  flex-shrink: 0;
}

.authority-filter-count {
  margin-left: auto;
  color: #713f12;
  font-weight: 600;
  white-space: nowrap;
}

.authority-ppt-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 10px;
  padding: 11px 12px;
  color: #164e63;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  border-radius: 6px;
}

.authority-ppt-strip-copy {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.authority-ppt-strip-copy > i {
  color: #0891b2;
  font-size: 20px;
}

.authority-ppt-strip-copy strong,
.authority-ppt-strip-copy span {
  display: block;
}

.authority-ppt-strip-copy strong {
  font-size: 12px;
}

.authority-ppt-strip-copy span {
  margin-top: 2px;
  color: #0e7490;
  font-size: 10px;
}

.authority-ppt-strip-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.authority-ppt-strip-actions .btn-agent-sm:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.authority-clear-button {
  color: #991b1b;
}

.authority-toolbar {
  position: sticky;
  top: 62px;
  z-index: 70;
  display: grid;
  grid-template-columns: minmax(230px, 1.5fr) repeat(3, minmax(145px, 1fr));
  align-items: center;
  gap: 8px;
  margin: 14px 0;
  padding: 10px;
  background: rgba(255,255,255,0.97);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

.authority-toolbar select,
.authority-search {
  height: 38px;
  min-width: 0;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--surface);
}

.authority-toolbar select {
  width: 100%;
  padding: 0 30px 0 10px;
  color: var(--text);
  font-size: 12px;
}

.authority-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
}

.authority-search i {
  color: var(--light);
  flex-shrink: 0;
}

.authority-search input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
}

.authority-toggle {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.authority-toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
}

.authority-state {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.authority-state > i {
  color: var(--light);
  font-size: 28px;
}

.authority-paper-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.authority-paper-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.authority-paper-group > summary {
  min-height: 58px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto 18px;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  list-style: none;
}

.authority-paper-group > summary::-webkit-details-marker { display: none; }
.authority-paper-group[open] > summary {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.authority-rank {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.authority-paper-title {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.authority-paper-metrics {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.authority-report-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 11px;
  text-decoration: none;
  white-space: nowrap;
}

.authority-report-link:hover { text-decoration: underline; }
.authority-chevron {
  color: var(--light);
  transition: transform .2s ease;
}
.authority-paper-group[open] .authority-chevron { transform: rotate(180deg); }

.authority-citation-list {
  padding: 0 16px;
}

.authority-citation {
  position: relative;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  transition: background-color .15s ease, box-shadow .15s ease;
}

.authority-citation.ppt-selected {
  margin: 0 -10px;
  padding: 18px 10px;
  background: #f0fdf4;
  box-shadow: inset 3px 0 #22c55e;
}

.authority-citation:last-child { border-bottom: 0; }

.authority-citation-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.authority-citing-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.authority-citing-meta {
  min-height: 23px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
}

.authority-citing-meta > span:not(.authority-context-badge):not(.authority-stance):not(.authority-source):not(.authority-ppt-readiness) {
  padding-right: 6px;
  border-right: 1px solid var(--border);
}

.authority-context-badge,
.authority-stance,
.authority-source,
.authority-ppt-readiness,
.authority-level,
.authority-identity {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 21px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.25;
}

.authority-context-badge.available {
  color: #166534;
  background: #dcfce7;
}
.authority-context-badge.pending,
.authority-context-badge.unavailable {
  color: #92400e;
  background: #fef3c7;
}

.authority-stance.positive,
.authority-stance.supportive {
  color: #166534;
  background: #ecfdf5;
}
.authority-stance.neutral,
.authority-stance.unclassified {
  color: #475569;
  background: #f1f5f9;
}
.authority-stance.critical {
  color: #991b1b;
  background: #fee2e2;
}

.authority-source {
  color: #1e40af;
  background: #eff6ff;
}

.authority-ppt-readiness {
  color: #92400e;
  background: #fef3c7;
}

.authority-ppt-readiness.ready {
  color: #166534;
  background: #dcfce7;
}

.authority-citation-actions {
  min-width: 112px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.authority-ppt-button {
  min-width: 104px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  color: #0e7490;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.authority-ppt-button:hover {
  background: #cffafe;
}

.authority-ppt-button.selected {
  color: #166534;
  background: #dcfce7;
  border-color: #86efac;
}

.authority-citation-links {
  min-width: 42px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.authority-citation-links a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 11px;
  text-decoration: none;
  white-space: nowrap;
}

.authority-scholar-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.authority-scholar {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 10px;
  background: #f8fafc;
  border-left: 3px solid #f59e0b;
  border-radius: 0 5px 5px 0;
}

.authority-scholar-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: #a16207;
  background: #fef3c7;
  border-radius: 5px;
}

.authority-scholar-main { min-width: 0; }

.authority-scholar-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
}

.authority-level {
  color: #92400e;
  background: #fef3c7;
  font-size: 9px;
  font-weight: 600;
}

.authority-identity {
  color: #9a3412;
  background: #fff7ed;
  font-size: 9px;
  font-weight: 500;
}

.authority-identity.confirmed {
  color: #166534;
  background: #dcfce7;
}

.authority-identity.corroborated {
  color: #155e75;
  background: #cffafe;
}

.authority-identity.unverified {
  color: #991b1b;
  background: #fee2e2;
}

.authority-identity.pending {
  color: #92400e;
  background: #fef3c7;
}

.authority-manual-audit {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  color: #075985;
  background: #e0f2fe;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
}

.authority-scholar-honors,
.authority-scholar-affiliation {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.authority-scholar-affiliation { color: var(--light); }

.authority-official-source {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin-top: 5px;
  color: #166534;
  font-size: 10px;
  font-weight: 600;
  text-decoration: none;
}

.authority-official-source:hover { text-decoration: underline; }

.authority-evidence-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}

.authority-authorship-links .authority-official-source {
  color: #1d4ed8;
}

.authority-repeat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  padding: 3px 6px;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 4px;
  font-size: 9px;
  line-height: 1.35;
}

.authority-identity-reason {
  max-width: 780px;
  margin-top: 5px;
  color: #64748b;
  font-size: 10px;
  line-height: 1.45;
}

.authority-quote {
  position: relative;
  margin: 14px 0 0;
  padding: 12px 14px 12px 18px;
  background: #f8fafc;
  border: 0;
  border-left: 3px solid #3b82f6;
}

.authority-quote-label,
.authority-translation-label {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0;
}

.authority-quote p,
.authority-translation p {
  margin: 0;
  color: #334155;
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.authority-occurrences {
  margin-top: 8px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--border2);
  border-radius: 4px;
}

.authority-occurrences-label {
  margin-bottom: 7px;
  color: #475569;
  font-size: 10px;
  font-weight: 700;
}

.authority-occurrence {
  padding: 8px 0;
  border-top: 1px solid #e2e8f0;
}

.authority-occurrence:first-of-type { border-top: 0; }

.authority-occurrence-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  color: #64748b;
  font-size: 10px;
}

.authority-occurrence-source,
.authority-occurrence-reason {
  color: #64748b;
  font-size: 10px;
}

.authority-occurrence-reason {
  margin-top: 5px;
  line-height: 1.45;
}

.authority-occurrence p {
  margin: 0;
  color: #334155;
  font-size: 11px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.authority-translation {
  margin-top: 8px;
  padding: 12px 14px;
  background: #f0fdf4;
  border-left: 3px solid #22c55e;
}

.authority-translation-label { color: #15803d; }

.authority-interpretation {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 9px;
  padding-top: 9px;
  color: #166534;
  border-top: 1px solid #bbf7d0;
  font-size: 11px;
  line-height: 1.55;
}

.authority-interpretation i {
  margin-top: 1px;
  flex-shrink: 0;
}

.authority-presentation-candidates {
  margin-top: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #f8fbff;
  overflow: hidden;
}

.authority-presentation-candidates > summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  color: #1e3a8a;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 700;
  background: linear-gradient(90deg, #eff6ff, #f8fbff);
}

.authority-presentation-candidates > summary::-webkit-details-marker {
  display: none;
}

.authority-presentation-candidates > summary > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.authority-presentation-candidates > summary > .bi-chevron-down {
  margin-left: auto;
  transition: transform .2s ease;
}

.authority-presentation-candidates[open] > summary > .bi-chevron-down {
  transform: rotate(180deg);
}

.authority-copy-summary-meta {
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
}

.authority-copy-summary-meta b {
  color: #15803d;
  font-weight: 700;
}

.authority-copy-body {
  padding: 14px;
  border-top: 1px solid #dbeafe;
}

.authority-copy-all {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.authority-copy-group {
  min-width: 0;
  padding: 11px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
}

.authority-copy-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.authority-copy-group-head strong {
  color: #1e3a8a;
  font-size: 12px;
}

.authority-copy-group-head span {
  color: #64748b;
  font-size: 9px;
  text-align: right;
}

.authority-copy-group-items {
  display: grid;
  gap: 9px;
}

.authority-copy-card {
  min-width: 0;
  padding: 9px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.authority-copy-card.selected {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, .1);
}

.authority-copy-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 20px;
  margin-bottom: 6px;
}

.authority-copy-length {
  color: #475569;
  font-size: 10px;
  font-weight: 700;
}

.authority-copy-selected {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #15803d;
  font-size: 9px;
  font-weight: 700;
}

.authority-copy-card .authority-copy-editor {
  min-height: 86px;
  padding: 9px 10px;
  border-color: #cbd5e1;
  font-size: 11px;
  line-height: 1.55;
}

.authority-copy-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.authority-copy-card-actions .authority-copy-status {
  min-width: 0;
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.authority-copy-card-actions button {
  flex-shrink: 0;
  min-height: 27px;
  padding: 4px 8px;
  border: 1px solid #bfdbfe;
  border-radius: 5px;
  color: #1d4ed8;
  background: #fff;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}

.authority-copy-card-actions button:hover {
  background: #eff6ff;
}

.authority-copy-card-actions button.primary {
  color: #fff;
  border-color: #2563eb;
  background: #2563eb;
}

.authority-copy-card-actions button.primary:hover {
  background: #1d4ed8;
}

.authority-copy-card-actions button:disabled {
  cursor: wait;
  opacity: .65;
}

.authority-copy-toolbar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 12px;
}

.authority-copy-toolbar > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.authority-copy-toolbar-label {
  color: #64748b;
  font-size: 10px;
  font-weight: 700;
}

.authority-copy-options {
  display: inline-flex;
  padding: 3px;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  background: #fff;
}

.authority-copy-option {
  min-height: 28px;
  padding: 4px 10px;
  border: 0;
  border-radius: 5px;
  color: #64748b;
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.authority-copy-option:hover {
  color: #1d4ed8;
  background: #eff6ff;
}

.authority-copy-option.active {
  color: #fff;
  background: #2563eb;
  box-shadow: 0 2px 5px rgba(37, 99, 235, .22);
}

.authority-copy-editor {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  padding: 12px 14px;
  color: #172554;
  background: #fff;
  border: 1px solid #93c5fd;
  border-radius: 7px;
  outline: none;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
}

.authority-copy-editor:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.authority-copy-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.authority-copy-status {
  color: #64748b;
  font-size: 10px;
}

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

.authority-copy-actions button {
  min-height: 31px;
  padding: 6px 11px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  color: #1d4ed8;
  background: #fff;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.authority-copy-actions button:hover {
  background: #eff6ff;
}

.authority-copy-actions button.primary {
  color: #fff;
  border-color: #2563eb;
  background: #2563eb;
}

.authority-copy-actions button.primary:hover {
  background: #1d4ed8;
}

.authority-copy-actions button:disabled {
  cursor: wait;
  opacity: .65;
}

.authority-copy-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  color: #64748b;
  font-size: 11px;
}

@media (max-width: 1180px) {
  .authority-copy-all {
    grid-template-columns: 1fr;
  }

  .authority-copy-group-items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .authority-copy-group-items {
    grid-template-columns: 1fr;
  }
}

.authority-translation-pending,
.authority-context-placeholder {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  padding: 10px 12px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed var(--border2);
  border-radius: 5px;
  font-size: 11px;
}

.authority-context-placeholder.unavailable {
  color: #92400e;
  background: #fffbeb;
  border-color: #fde68a;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .agent-navbar-toggler { display: block !important; }
  .agent-navbar-inner { position: relative; }
  .agent-nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 1px);
    left: 16px;
    right: 16px;
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    box-shadow: var(--shadow-md);
  }
  .agent-nav-links.show { display: flex; }
  .agent-nav-link {
    width: 100%;
    justify-content: flex-start;
  }
  .agent-hero { padding: 26px 20px 22px; }
  .hero-title { font-size: 22px; }
  .agent-page-content, .container { padding: 20px 16px 40px; }
  .reasoning-body { height: 280px; }
  .agent-navbar-inner { padding: 0 16px; }
  .agent-brand-sub { display: none; }
  .spa-global-progress {
    margin: -20px -16px 20px;
    padding-left: 16px;
    padding-right: 16px;
  }
  .authority-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }
  .authority-header-actions { width: 100%; }
  .authority-header-actions .btn-agent-sm { flex: 1; }
  .authority-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .authority-stat {
    min-height: 70px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }
  .authority-stat:nth-child(2n) { border-right: 0; }
  .authority-stat:nth-last-child(-n + 2) { border-bottom: 0; }
  .authority-stat:last-child {
    grid-column: auto;
    border-bottom: 0;
  }
  .authority-audit-strip { align-items: flex-start; flex-wrap: wrap; }
  .authority-filter-count {
    width: 100%;
    margin-left: 24px;
  }
  .authority-ppt-strip {
    align-items: flex-start;
    flex-direction: column;
  }
  .authority-ppt-strip-actions {
    width: 100%;
  }
  .authority-ppt-strip-actions .btn-agent-sm {
    flex: 1;
  }
  .authority-toolbar {
    position: static;
    grid-template-columns: 1fr 1fr;
  }
  .authority-search { grid-column: 1 / -1; }
  .authority-citation-heading {
    flex-direction: column;
  }
  .authority-citation-actions {
    width: 100%;
    align-items: stretch;
  }
  .authority-ppt-button {
    width: 100%;
  }
  .authority-citation-links {
    justify-content: flex-start;
  }
  .authority-paper-group > summary {
    grid-template-columns: 34px minmax(0, 1fr) 18px;
    gap: 7px;
  }
  .authority-paper-metrics {
    grid-column: 2;
    white-space: normal;
  }
  .authority-report-link { grid-column: 2; }
  .authority-chevron {
    grid-column: 3;
    grid-row: 1 / span 3;
  }
  .authority-citation-list { padding: 0 12px; }
  .authority-citation-heading { gap: 10px; }
  .authority-scholar-list { grid-template-columns: 1fr; }
  .authority-copy-foot {
    align-items: stretch;
    flex-direction: column;
  }
  .authority-copy-actions {
    width: 100%;
  }
  .authority-copy-actions button {
    flex: 1;
  }
  .authority-citation-links { min-width: 36px; }
}

@media (max-width: 480px) {
  .authority-toolbar { grid-template-columns: 1fr; }
  .authority-search { grid-column: 1; }
  .authority-header h1 { font-size: 24px; }
}

/* ─── Heartbeat running indicator ─── */
.hb-crawler {
  position: absolute;
  top: 50%;
  font-size: 16px;
  line-height: 1;
  transform: translateY(-50%) rotate(90deg);
  animation: hb-crawl 10s linear infinite;
  pointer-events: none;
}

@keyframes hb-crawl {
  from { left: -1.5em; }
  to   { left: calc(100% + 0.5em); }
}
