*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── Theme variables ──────────────────────────────────────────── */
:root {
  --bg: #111113;
  --surface: #18181b;
  --surface-alt: #232326;
  --border: #34343a;
  --text: #e2e5ed;
  --text-dim: #9a9aa3;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-bg: rgba(59, 130, 246, 0.11);
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.08);
  --green-border: rgba(52, 211, 153, 0.22);
  --yellow: #fbbf24;
  --yellow-bg: rgba(251, 191, 36, 0.08);
  --yellow-border: rgba(251, 191, 36, 0.22);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.08);
  --red-border: rgba(248, 113, 113, 0.22);
  --gray-bg: rgba(126, 132, 153, 0.08);
  --gray-border: rgba(126, 132, 153, 0.22);
  --purple: #a78bfa;
  --purple-bg: rgba(167, 139, 250, 0.08);
  --purple-border: rgba(167, 139, 250, 0.22);
  --teal: #2dd4bf;
  --teal-bg: rgba(45, 212, 191, 0.08);
  --teal-border: rgba(45, 212, 191, 0.22);
  --glass-bg: rgba(24, 24, 27, 0.88);
  --glass-border: rgba(255, 255, 255, 0.1);
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  color-scheme: dark;
}

html {
  font-size: 16px;
}

[data-theme="light"] {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-alt: #f0f1f4;
  --border: #dde0e6;
  --text: #1a1d27;
  --text-dim: #6b7084;
  --accent: #3b6fe0;
  --accent-hover: #2d5bc7;
  --accent-bg: rgba(59, 111, 224, 0.06);
  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.06);
  --green-border: rgba(22, 163, 74, 0.2);
  --yellow: #ca8a04;
  --yellow-bg: rgba(202, 138, 4, 0.06);
  --yellow-border: rgba(202, 138, 4, 0.2);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.06);
  --red-border: rgba(220, 38, 38, 0.2);
  --gray-bg: rgba(107, 112, 132, 0.06);
  --gray-border: rgba(107, 112, 132, 0.2);
  --purple: #7c3aed;
  --purple-bg: rgba(124, 58, 237, 0.06);
  --purple-border: rgba(124, 58, 237, 0.2);
  --teal: #0d9488;
  --teal-bg: rgba(13, 148, 136, 0.06);
  --teal-border: rgba(13, 148, 136, 0.2);
  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(59, 111, 224, 0.12);
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.1);
  color-scheme: light;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Layout ───────────────────────────────────────────────────── */
.page-wrap {
  max-width: 1800px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  padding-bottom: 4.75rem;
}

.main-columns {
  display: block;
}

.col-entries { min-width: 0; }

h1 {
  font-size: 1.65rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  background: var(--surface-alt);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88em;
}

/* ─── Hero ─────────────────────────────────────────────────────── */
.hero {
  margin-bottom: 0.85rem;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-top-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.github-star-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.36rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.github-star-btn:hover {
  border-color: var(--accent);
  background: var(--surface-alt);
  text-decoration: none;
}

.github-star-btn svg {
  flex-shrink: 0;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
:root:not([data-theme]) .theme-toggle .icon-sun { display: block; }

.hero-tagline {
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 500;
  margin-top: 0.2rem;
}

.hero-lead {
  color: var(--text-dim);
  font-size: 0.98rem;
  line-height: 1.6;
  max-width: 780px;
  margin-top: 0.35rem;
}

.hero-lead strong {
  color: var(--red);
  font-weight: 600;
}

.start-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 0.75rem;
  align-items: stretch;
  margin-bottom: 0.75rem;
}

.start-card,
.reference-card,
.feature-card,
.faq details {
  --guide-color: var(--accent);
  --guide-bg: var(--accent-bg);
  --guide-border: rgba(59, 130, 246, 0.34);
  background: linear-gradient(180deg, var(--guide-bg), var(--surface) 64%);
  border: 1.5px solid var(--guide-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.015);
}

.start-card-header,
.reference-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.95rem;
  background: var(--guide-bg);
  border-bottom: 1px solid var(--guide-border);
}

.start-card-header h2,
.reference-card-header h2 {
  font-size: 0.92rem;
  font-weight: 700;
  margin: 0;
}

.start-card-header p,
.reference-card-header p {
  margin-top: 0.18rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  line-height: 1.45;
}

.input-workbench {
  --guide-color: var(--accent);
  --guide-bg: var(--accent-bg);
  --guide-border: rgba(59, 130, 246, 0.38);
}

.review-brief {
  --guide-color: var(--yellow);
  --guide-bg: var(--yellow-bg);
  --guide-border: var(--yellow-border);
}

.mini-status-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.35rem 0;
}

.mini-status-row {
  display: grid;
  grid-template-columns: 0.75rem minmax(0, 1fr);
  gap: 0.65rem;
  padding: 0.62rem 0.9rem;
  align-items: baseline;
}

.mini-status-row + .mini-status-row {
  border-top: 1px solid var(--border);
}

.mini-status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  margin-top: 0.32rem;
}

.mini-verified .mini-status-dot { background: var(--teal); }
.mini-update .mini-status-dot { background: var(--yellow); }
.mini-notfound .mini-status-dot { background: var(--text-dim); }

.mini-status-row strong {
  display: block;
  font-size: 0.82rem;
}

.mini-status-row span:last-child {
  display: block;
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.35;
  margin-top: 0.12rem;
}

/* ─── Input tabs ───────────────────────────────────────────────── */
.input-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  padding: 0 0.95rem;
  border-bottom: 1px solid var(--border);
}

.input-tab {
  padding: 0.55rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.input-tab:hover {
  color: var(--text);
}

.input-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ─── Paste area ───────────────────────────────────────────────── */
.bib-textarea {
  width: calc(100% - 1.9rem);
  min-height: 190px;
  margin: 0.85rem 0.95rem 0;
  padding: 0.8rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.55;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
}

.bib-textarea::placeholder {
  color: var(--text-dim);
  opacity: 0.6;
}

.bib-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-verify-paste {
  display: block;
  margin: 0.75rem 0.95rem 0.95rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-verify-paste:hover {
  background: var(--accent-hover);
}

/* ─── Upload area ──────────────────────────────────────────────── */
.upload-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1.45rem 1.25rem;
  margin: 0.95rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.upload-zone p {
  color: var(--text-dim);
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.upload-zone .icon {
  font-size: 1.65rem;
  margin-bottom: 0.25rem;
  display: block;
}

.upload-zone .label {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--text);
}

.upload-zone input[type="file"] {
  display: none;
}

/* ─── In-bar progress ──────────────────────────────────────────── */
.bar-progress {
  display: none;
  flex: 0 1 420px;
  width: 420px;
  min-width: 180px;
  max-width: none;
  flex-direction: column;
  gap: 0.22rem;
  transition: opacity 0.3s, max-width 0.4s;
}

.bar-progress.active {
  display: flex;
}

.bar-progress.fade-out {
  opacity: 0;
  max-width: 0;
  min-width: 0;
  overflow: hidden;
}

.bar-progress-track {
  background: var(--surface-alt);
  border-radius: 999px;
  height: 5px;
  overflow: hidden;
}

.bar-progress-fill {
  background: var(--accent);
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.3s ease, background 0.3s;
}

.bar-progress-fill.done {
  background: var(--green);
}

.bar-progress-text {
  font-size: 0.74rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Results ──────────────────────────────────────────────────── */
.results-section {
  display: none;
  margin-top: 1rem;
}

.progress-log-wrap {
  display: flex;
  flex-direction: column;
  width: auto;
  max-width: min(780px, calc(100vw - 2rem));
  background: rgba(8, 11, 16, 0.86);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  box-shadow: var(--shadow);
  transition: max-width 0.3s, opacity 0.3s;
}

.activity-log.expanded {
  width: min(780px, calc(100vw - 2rem));
}

.progress-log-main {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.6rem;
}

[data-theme="light"] .activity-log {
  background: #111827;
  border-color: #1f2937;
}

.activity-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  width: 160px;
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0;
  background: transparent;
  border-bottom: none;
}

.activity-log-toggle {
  padding: 0.28rem 0.52rem;
  border: 1px solid #374151;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: #e5e7eb;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.activity-log-toggle:hover,
.activity-log.expanded .activity-log-toggle {
  border-color: #5b8def;
  color: #ffffff;
  background: rgba(91, 141, 239, 0.14);
}

.activity-log-subtitle {
  flex: 1;
  color: #9ca3af;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-log-clear {
  padding: 0.28rem 0.56rem;
  border: 1px solid #374151;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #cbd5e1;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.activity-log-clear:hover {
  border-color: #5b8def;
  color: #ffffff;
  background: rgba(91, 141, 239, 0.12);
}

.activity-log-body {
  display: none;
  height: 230px;
  overflow-y: auto;
  padding: 0.7rem 0;
  border-top: 1px solid #1f2937;
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.76rem;
  line-height: 1.5;
  color: #d1d5db;
  background:
    linear-gradient(rgba(255,255,255,0.025) 50%, transparent 50%) 0 0 / 100% 3rem,
    #080b10;
}

.activity-log.expanded .activity-log-body {
  display: block;
}

.activity-line {
  display: grid;
  grid-template-columns: 4.8rem 4.9rem minmax(0, 1fr);
  gap: 0.55rem;
  padding: 0.08rem 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.activity-line-time {
  color: #64748b;
  user-select: none;
}

.activity-line-level {
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
  user-select: none;
}

.activity-line-text {
  color: #d1d5db;
}

.activity-line-info .activity-line-level { color: #60a5fa; }
.activity-line-query .activity-line-level { color: #2dd4bf; }
.activity-line-success .activity-line-level { color: #34d399; }
.activity-line-warning .activity-line-level { color: #fbbf24; }
.activity-line-error .activity-line-level { color: #f87171; }
.activity-line-muted .activity-line-level,
.activity-line-muted .activity-line-text { color: #94a3b8; }

.summary-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.summary-badge {
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.2s;
}

.summary-badge.active { opacity: 1; }
.summary-badge:not(.active) { opacity: 0.45; }

.badge-review { background: var(--teal-bg); color: var(--teal); border-color: var(--teal-border); }
.badge-parsed { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.badge-notfound { background: var(--gray-bg); color: var(--text-dim); border-color: var(--gray-border); }
.badge-duplicates { background: var(--purple-bg); color: var(--purple); border-color: var(--purple-border); }
.badge-error { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.entry-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}

.entry-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.82rem 1rem;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.entry-header:hover {
  background: var(--accent-bg);
}

.entry-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.entry-card.collapsed .entry-header {
  border-bottom-color: transparent;
}

.entry-header-main {
  display: flex;
  align-items: flex-start;
  gap: 0.72rem;
  min-width: 0;
  flex: 1;
}

.entry-header-index {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  width: 3.1rem;
  flex: 0 0 3.1rem;
}

.entry-header-text {
  min-width: 0;
  flex: 1;
  padding-top: 0.03rem;
}

.entry-collapse-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  flex-shrink: 0;
  transition: transform 0.15s, color 0.15s, border-color 0.15s;
}

.entry-list-position {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: var(--text-dim);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
}

.entry-card.expanded .entry-collapse-icon {
  transform: rotate(180deg);
  color: var(--accent);
  border-color: var(--accent);
}

.entry-body {
  padding: 0.85rem 1.05rem 1.2rem;
}

.entry-card.collapsed .entry-body {
  display: none;
}

.entry-header-aside {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-top: 0.02rem;
}

.entry-title {
  font-weight: 600;
  font-size: 0.94rem;
}

.entry-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 0.18rem;
}

.initial-match-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  border: 1px solid var(--teal-border);
  border-radius: var(--radius-sm);
  background: var(--teal-bg);
  color: var(--teal);
  flex-shrink: 0;
}

/* ── Search links – top-right in header ── */
.search-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.search-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
  opacity: 1;
}

.search-link img,
.search-link svg,
.search-link-icon {
  display: block;
  min-width: 15px;
  height: 15px;
  border-radius: 2px;
}

.search-link-icon {
  color: var(--text-dim);
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
}

.search-link-google { color: #4285f4; }
.search-link-s2 { color: var(--teal); }
.search-link-dblp { color: var(--accent); }
.search-link-zenodo { color: var(--purple); }

.search-link:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  opacity: 1;
  text-decoration: none;
  transform: translateY(-1px);
}

.entry-card:hover .search-link {
  opacity: 1;
}

.status-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0;
  border-radius: 0;
  white-space: nowrap;
  flex-shrink: 0;
  background: transparent !important;
}

.tag-verified,
.tag-review { background: var(--teal-bg); color: var(--teal); }
.tag-parsed { background: var(--accent-bg); color: var(--accent); }
.tag-updated { background: var(--yellow-bg); color: var(--yellow); }
.tag-needs_review,
.tag-needs_update { background: var(--yellow-bg); color: var(--yellow); }
.tag-not_found { background: var(--gray-bg); color: var(--text-dim); }
.tag-parse_error { background: var(--red-bg); color: var(--red); }
.tag-parse_warning { background: var(--yellow-bg); color: var(--yellow); }
.tag-error { background: var(--red-bg); color: var(--red); }
.tag-duplicate { background: var(--purple-bg); color: var(--purple); }

.entry-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.4rem;
  flex-shrink: 0;
}

.duplicate-row {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--purple);
}

.duplicate-row strong { color: var(--text); }

.parsed-info-panel,
.diagnostic-panel,
.evidence-panel {
  margin-top: 0.65rem;
  padding: 0.55rem 0 0;
  border-top: 1px solid var(--border);
  background: transparent;
  font-size: 0.82rem;
  text-align: left;
}

.parsed-field-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.parsed-field-table td {
  padding: 0.22rem 0.35rem;
  vertical-align: top;
}

.parsed-field-table .field-name {
  width: 92px;
  white-space: nowrap;
  font-weight: 600;
}

.parsed-field-value {
  color: var(--text);
  word-break: break-word;
  line-height: 1.45;
}

.panel-title {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.diagnostic-row {
  display: flex;
  gap: 0.55rem;
  line-height: 1.45;
  align-items: baseline;
}

.diagnostic-row strong {
  min-width: 4.5rem;
  text-transform: uppercase;
}

.diagnostic-error strong { color: var(--red); }
.diagnostic-warning strong { color: var(--yellow); }
.diagnostic-info strong { color: var(--accent); }

.evidence-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.evidence-panel-head .panel-title {
  margin-bottom: 0;
}

.evidence-count {
  color: var(--text-dim);
  font-size: 0.72rem;
  white-space: nowrap;
}

.evidence-list.collapsed .evidence-extra {
  display: none;
}

.evidence-row {
  display: block;
  width: 100%;
  padding: 0.3rem 0.48rem;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.evidence-row + .evidence-row { margin-top: 0.22rem; }

.evidence-row:hover {
  background: var(--surface-alt);
  border-color: var(--border);
}

.evidence-row.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  cursor: default;
}

.evidence-main {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  min-width: 0;
}

.evidence-rank {
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
}

.evidence-title {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-selected {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.evidence-meta {
  margin-top: 0.16rem;
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.25;
  padding-left: 1.55rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-toggle-btn {
  margin-top: 0.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.evidence-toggle-btn:hover {
  color: var(--text);
}

.layer-panel {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
  text-align: left;
}

.layer-line {
  color: var(--text-dim);
  font-size: 0.74rem;
  line-height: 1.5;
}

/* ─── Diff table ───────────────────────────────────────────────── */
.diff-table {
  width: 100%;
  margin-top: 0.75rem;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.diff-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  padding: 0.35rem 0.35rem;
  border-bottom: none;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.diff-table td {
  padding: 0.45rem 0.35rem;
  border-bottom: none;
  vertical-align: top;
}

.diff-table .field-name {
  font-weight: 600;
  white-space: nowrap;
  width: 80px;
}

.diff-table .field-name-pill {
  display: inline;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0;
}

/* ── Original & Suggested value columns ── */
.diff-table .val-original {
  color: var(--text);
  opacity: 0.7;
  word-break: break-word;
  max-width: 250px;
  font-size: 0.8rem;
  transition: opacity 0.2s, text-decoration 0.2s;
}

.diff-table .val-original .empty-val {
  color: var(--text-dim);
  font-style: italic;
}

.diff-table .val-suggested {
  color: var(--green);
  word-break: break-word;
  max-width: 250px;
  transition: opacity 0.2s;
}

.diff-table .val-choices {
  word-break: break-word;
}

.diff-table .score-val { color: var(--text-dim); text-align: right; white-space: nowrap; }

/* ── Value columns for pills ── */
.val-col {
  vertical-align: top;
  padding: 0.3rem 0.35rem;
  border-bottom: none;
  text-align: left;
}

.val-col-original {
  width: 42%;
}

.val-col-suggested {
  width: 42%;
}

.val-col .empty-val {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.8rem;
  opacity: 0.5;
}

/* ── Choice pills (original & suggested as clickable values) ── */
.choice-pills {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.choice-pill {
  display: inline;
  padding: 0;
  border-radius: 0;
  font-size: 0.8rem;
  line-height: 1.45;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text);
  transition: all 0.15s;
  word-break: break-word;
  max-width: 100%;
  outline: none;
  min-height: 1.4em;
  text-align: left;
  font: inherit;
}

.choice-pill:hover {
  color: var(--text);
  text-decoration: underline;
}

.choice-pill.pill-original.active {
  background: transparent;
  border-color: transparent;
  color: var(--text);
  font-weight: 500;
}

.choice-pill.pill-suggested.active {
  background: transparent;
  border-color: transparent;
  color: var(--green);
  font-weight: 500;
}

.choice-pill.pill-suggested:not(.active) {
  opacity: 0.6;
}

.choice-pill.pill-original:not(.active) {
  opacity: 0.6;
}

.choice-pill.pill-suggested[contenteditable="true"]:focus {
  border-color: transparent;
  background: transparent;
  color: var(--text);
  opacity: 1;
  box-shadow: inset 0 -1px 0 var(--accent);
}

.choice-pill.removed {
  opacity: 0.2;
  text-decoration: line-through;
  pointer-events: none;
}

/* ── Plain field value pill ── */
.choice-pill.pill-value {
  color: var(--text);
  border-color: transparent;
  background: transparent;
}

.choice-pill.pill-value.active {
  border-color: transparent;
  background: transparent;
  color: var(--text);
  font-weight: 400;
}

.choice-pill.pill-value[contenteditable="true"]:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: inset 0 -1px 0 var(--accent);
}

/* ── Mini × button ── */
.field-actions-mini {
  white-space: nowrap;
  text-align: left;
  width: 28px;
  vertical-align: top;
}

.fa-btn-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  opacity: 0.4;
  transition: all 0.12s;
  vertical-align: middle;
}

.fa-btn-x:hover {
  opacity: 1;
  background: transparent;
  color: var(--red);
}

.fa-btn-x.active {
  opacity: 1;
  background: transparent;
  color: var(--red);
}

.diff-row {
  transition: background 0.2s, border-color 0.2s;
  border-left: 3px solid transparent;
}

/* Row states: subtle left border only */
.diff-row[data-action="found"] {
  background: transparent;
  border-left-color: var(--green);
}

.diff-row[data-action="original"] {
  background: transparent;
  border-left-color: transparent;
}

.diff-row[data-action="custom"] {
  background: transparent;
  border-left-color: var(--accent);
}

.diff-row[data-action="remove"] {
  background: transparent;
  border-left-color: var(--red);
}

@keyframes row-flash {
  0%   { filter: brightness(1.4); }
  100% { filter: brightness(1); }
}
.diff-row.flash { animation: row-flash 0.3s ease-out; }
.diff-row.author-match-hidden { display: none; }

.fields-toggle-wrap { margin-top: 0.5rem; }
.fields-toggle-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0;
  transition: color 0.15s;
}
.fields-toggle-btn:hover { color: var(--text); }
.fields-chevron { transition: transform 0.2s; }
.fields-toggle-wrap.collapsed .fields-chevron { transform: rotate(-90deg); }
.fields-toggle-wrap.collapsed .fields-table { display: none; }
.fields-table .current-val { color: var(--text); }
.field-row-plain .found-text { color: var(--text); }

.found-text {
  display: block;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  border: 1px solid transparent;
  outline: none;
  min-height: 1.3em;
  transition: border-color 0.15s, background 0.15s;
  word-break: break-word;
}

.found-text[contenteditable="true"]:hover {
  border-color: var(--border);
  background: var(--surface-alt);
}

.found-text[contenteditable="true"]:focus {
  border-color: var(--accent);
  background: var(--surface-alt);
}

/* Editable suggestion text */
.found-text.removed {
  opacity: 0.3;
  text-decoration: line-through;
  pointer-events: none;
}

.field-actions {
  white-space: nowrap;
  text-align: right;
  width: 60px;
}

.fa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  margin-left: 2px;
  transition: all 0.12s;
  vertical-align: middle;
}

.fa-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--text-dim);
}

.fa-btn.fa-use-found.active { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.fa-btn.fa-revert.active { background: var(--yellow-bg); border-color: var(--yellow); color: var(--yellow); }
.fa-btn.fa-remove.active { background: var(--red-bg); border-color: var(--red); color: var(--red); }

/* ─── Entry actions (segmented toggle) ─────────────────────────── */
.entry-actions {
  display: flex;
  gap: 0;
  margin-top: 0.6rem;
}
.entry-actions .seg-btn {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-dim);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.entry-actions .seg-btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.entry-actions .seg-btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; border-left: none; }
.entry-actions .seg-btn:only-child { border-radius: var(--radius-sm); border-left: 1px solid var(--border); }

.entry-actions .seg-btn:hover { color: var(--text); border-color: var(--text-dim); }
.entry-actions .seg-btn.active-accept {
  background: var(--green-bg); border-color: var(--green-border); color: var(--green); font-weight: 500;
}
.entry-actions .seg-btn.active-revert {
  background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow); font-weight: 500;
}

.review-hint {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-dim);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.review-hint strong { color: var(--text); }
.review-hint .review-hint-match { color: var(--accent); word-break: break-word; }

.not-found-hint {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-dim);
  background: var(--gray-bg);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
}

.btn {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: var(--border); }

/* ─── Detail panel inline (四视图，直接展开在卡片下方) ────────────── */
.entry-detail-inline {
  margin-top: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.diff-line {
  display: block;
  padding: 0 0.75rem 0 0.5rem;
  min-height: 1.5em;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-line::before {
  display: inline-block;
  width: 1.6em;
  margin-right: 0.6em;
  text-align: right;
  color: var(--text-dim);
  opacity: 0.5;
  user-select: none;
  font-size: 0.7rem;
}

.diff-line.diff-add {
  background: var(--green-bg);
  border-left: 3px solid var(--green);
}
.diff-line.diff-add::before {
  content: "+";
  color: var(--green);
  opacity: 0.8;
}

.diff-line.diff-del {
  background: var(--red-bg);
  border-left: 3px solid var(--red);
  text-decoration: line-through;
  opacity: 0.7;
}
.diff-line.diff-del::before {
  content: "−";
  color: var(--red);
  opacity: 0.8;
}

.diff-line.diff-ctx {
  border-left: 3px solid transparent;
}
.diff-line.diff-ctx::before {
  content: " ";
}

.diff-sep {
  display: block;
  padding: 0.15rem 0.75rem;
  font-size: 0.7rem;
  color: var(--accent);
  background: var(--accent-bg);
  border-left: 3px solid var(--accent);
  user-select: none;
  opacity: 0.7;
}

@keyframes highlight-pulse {
  0%   { background: var(--yellow-bg); box-shadow: inset 0 0 0 1px var(--yellow-border); }
  100% { background: transparent; box-shadow: none; }
}

.diff-line.highlight-flash {
  animation: highlight-pulse 1.5s ease-out;
}

.preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}

/* ─── Floating toolbar ─────────────────────────────────────────── */
.floating-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  padding: 0 1rem 1rem;
  pointer-events: none;
}

.floating-bar.visible {
  display: flex;
  justify-content: center;
  animation: floatIn 0.25s ease-out;
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.floating-bar-inner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

.download-bar { display: none; }

/* Floating workflow guide */
.floating-help {
  position: relative;
  flex: 0 0 auto;
}

.floating-help-toggle {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 32px;
  padding: 0 0.65rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #374151;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.floating-help-toggle::-webkit-details-marker { display: none; }

[data-theme="light"] .floating-help-toggle {
  background: rgba(0, 0, 0, 0.03);
}

.floating-help-toggle:hover,
.floating-help[open] .floating-help-toggle {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-bg);
}

.floating-help-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  width: min(430px, calc(100vw - 1rem));
  max-height: min(560px, calc(100vh - 5.5rem));
  overflow-y: auto;
  padding: 0.8rem 0.95rem;
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

.floating-help-panel::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 18px;
  width: 12px;
  height: 12px;
  background: var(--glass-bg);
  border-right: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  transform: rotate(45deg);
}

.floating-help-title {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.floating-help-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.45;
}

.floating-help-list li + li {
  margin-top: 0.32rem;
}

.floating-help-list strong {
  color: var(--text);
}

/* ─── Settings popover ─────────────────────────────────────────── */
.settings-anchor {
  position: relative;
}

.settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #374151;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.3s;
}

[data-theme="light"] .settings-btn {
  background: rgba(0, 0, 0, 0.03);
}

.settings-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.settings-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
  transform: rotate(60deg);
}

.settings-popover {
  display: none;
  position: absolute;
  bottom: calc(100% + 12px);
  right: -0.5rem;
  width: min(380px, calc(100vw - 1rem));
  min-width: 0;
  max-height: min(620px, calc(100vh - 5.5rem));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.75rem 0.85rem;
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  text-align: left;
}

.settings-popover.pico {
  --pico-font-size: 100%;
  --pico-form-element-spacing-vertical: 0.32rem;
  --pico-form-element-spacing-horizontal: 0.5rem;
  --pico-border-radius: var(--radius-sm);
  --pico-primary: var(--accent);
  --pico-primary-hover: var(--accent-hover);
  color: var(--text);
}

.settings-popover.open {
  display: block;
  animation: popoverIn 0.15s ease-out;
}

@keyframes popoverIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.popover-arrow {
  position: absolute;
  bottom: -6px;
  right: 14px;
  width: 12px;
  height: 12px;
  background: var(--glass-bg);
  border-right: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  transform: rotate(45deg);
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0;
}

.setting-icon {
  flex-shrink: 0;
  color: var(--text-dim);
  opacity: 0.7;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

.settings-section-title {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 0.1rem;
}

.engine-tier {
  margin: 0.3rem 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.035);
}

[data-theme="light"] .engine-tier {
  border-color: rgba(0, 0, 0, 0.06);
  background: rgba(0, 0, 0, 0.025);
}

.tier-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.22rem;
}

.tier-hint {
  font-weight: 400;
  opacity: 0.7;
}

.tier-engines {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
}

.engine-option {
  min-height: 1.55rem;
}

.engine-option-fixed {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-dim);
  font-size: 0.88rem;
  user-select: none;
}

.engine-fixed-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.7rem;
  height: 1.05rem;
  padding: 0 0.28rem;
  border-radius: 3px;
  background: var(--teal-bg);
  color: var(--teal);
  border: 1px solid var(--teal-border);
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

.setting-help {
  color: var(--text-dim);
  font-size: 0.76rem;
  line-height: 1.4;
  margin: 0.2rem 0 0.25rem;
  max-width: none;
}

.sub-option {
  display: none;
  margin: 0 0 0.2rem 2rem;
  padding: 0.3rem 0.6rem;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-dim);
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.sub-option.visible { display: flex; }

.sub-label { font-weight: 500; margin-right: 0.15rem; }

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  font-size: 0.8rem;
}

.radio-label input[type="radio"] { accent-color: var(--accent); }

.option-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}

.option-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.05rem;
  height: 1.05rem;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}

.option-toggle input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.option-toggle input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 0.5px;
  width: 5px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.option-toggle:hover input[type="checkbox"] { border-color: var(--accent); }
.option-toggle span { line-height: 1; }

.option-select {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  margin-left: 0.25rem;
  transition: border-color 0.15s;
}

.option-select:hover,
.option-select:focus {
  border-color: var(--accent);
}

.btn-primary-action,
.btn-download {
  flex: 0 0 auto;
  padding: 0.42rem 0.8rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}

.settings-popover.pico .option-toggle,
.settings-popover.pico .option-toggle input,
.settings-popover.pico .option-toggle select {
  margin-bottom: 0;
}

.ignored-fields-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0.35rem 0;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
}

.ignored-fields-input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  box-sizing: border-box;
}

.ignored-fields-input:focus { border-color: var(--accent); }

.api-key-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.4rem 0;
}

.api-key-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
}

.api-key-source-link {
  color: var(--accent);
  text-decoration: none;
}
.api-key-source-link:hover { text-decoration: underline; }

.api-key-input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.api-key-input:focus { border-color: var(--accent); }
.api-key-input::placeholder { color: var(--text-muted, var(--text-dim)); opacity: 0.6; }

.api-key-input-error {
  border-color: var(--red) !important;
  background: var(--red-bg);
}

.api-key-error-msg {
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--red);
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  margin-top: 0.1rem;
}

.btn-primary-action:hover,
.btn-download:hover { background: var(--accent-hover); }

.btn-primary-action.hidden,
.btn-download.hidden {
  display: none;
}

.btn-primary-action.fade-in,
.btn-download.fade-in {
  animation: btnAppear 0.35s ease-out;
}

@keyframes btnAppear {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.entry-card.hidden { display: none; }

.btn-jump-preview {
  display: inline-flex;
  align-items: center;
  gap: -2px;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-dim);
  cursor: pointer;
  opacity: 0.75;
  flex-shrink: 0;
  transition: opacity 0.15s, border-color 0.15s, color 0.15s, background 0.15s;
  font-size: 0;
  line-height: 1;
}

.btn-jump-preview svg:last-child { margin-left: -5px; }

.btn-jump-preview:hover {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-bg);
}

/* ─── How it works ─────────────────────────────────────────────── */
.how-it-works {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.step h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.4rem; }
.step p { font-size: 0.88rem; color: var(--text-dim); line-height: 1.55; }

.c-green { color: var(--teal); }
.c-yellow { color: var(--yellow); }
.c-red { color: var(--red); }

/* ─── Features ─────────────────────────────────────────────────── */
.features {
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.feature-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.feature-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.35rem; }
.feature-card p { font-size: 0.85rem; color: var(--text-dim); line-height: 1.5; }

/* ─── FAQ ──────────────────────────────────────────────────────── */
.faq {
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.faq summary {
  padding: 0.85rem 1.25rem;
  font-weight: 600;
  font-size: 0.93rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.faq summary::after {
  content: "+";
  font-size: 1.1rem;
  color: var(--text-dim);
  flex-shrink: 0;
  margin-left: 1rem;
  transition: transform 0.2s;
}

.faq details[open] summary::after { content: "-"; }

.faq details p {
  padding: 0 1.25rem 1rem;
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.6;
}

/* ─── Footer ───────────────────────────────────────────────────── */
.site-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-dim);
  padding-bottom: 2rem;
}

/* ─── Responsive ───────────────────────────────────────────────── */

/* ─── Error hint ─────────────────────────────────────────────────── */
.error-hint {
  margin-top: 0.65rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--red);
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--radius-sm);
}

/* ─── Status card border accents ────────────────────────────────── */
.status-parsed    { border-left: 3px solid var(--accent); }
.status-verified  { border-left: 3px solid var(--teal); }
.status-updated   { border-left: 3px solid var(--yellow); }
.status-needs_review,
.status-needs_update { border-left: 3px solid var(--teal); }
.status-needs_review.opened-once,
.status-needs_update.opened-once { border-left-color: var(--teal); }
.status-not_found { border-left: 3px solid var(--text-dim); }
.status-duplicate { border-left: 3px solid var(--purple); }
.status-error     { border-left: 3px solid var(--red); }

/* ─── Detail button ──────────────────────────────────────────────── */
.btn-detail {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: all 0.15s;
}
.btn-detail:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ─── Detail panel (四视图，内嵌在卡片内) ────────────────────────── */
.bib-readonly {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-dim);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
  overflow-x: auto;
  white-space: pre;
  user-select: text;
}

.detail-panel {
  margin-top: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 0.1rem;
  display: flex;
  flex-direction: column;
  background: transparent;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  flex-shrink: 0;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.detail-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}

.detail-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 500;
  font-size: 0.8rem;
  max-width: 300px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-adopt-found {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--green-border);
  border-radius: var(--radius-sm);
  background: var(--green-bg);
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-adopt-found:hover {
  background: var(--green);
  color: #fff;
}

.btn-close-detail {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-close-detail:hover {
  border-color: var(--red);
  color: var(--red);
}

/* ─── Four-view field table ──────────────────────────────────────── */
.fv-field-table-wrap {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 340px;
}

.fv-field-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  table-layout: fixed;
}

.fv-field-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-alt);
  padding: 0.4rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

.fv-col-field { width: 6rem; }
.fv-col-orig  { width: calc((100% - 6rem - 2.8rem) / 3); }
.fv-col-found { width: calc((100% - 6rem - 2.8rem) / 3); }
.fv-col-edit  { width: calc((100% - 6rem - 2.8rem) / 3); }
.fv-col-act   { width: 2.8rem; text-align: center; }

.fv-row {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.fv-row:last-child { border-bottom: none; }
.fv-row:hover { background: var(--surface-alt); }
.fv-row-diff { background: rgba(59, 130, 246, 0.03); }
.fv-row-diff:hover { background: rgba(59, 130, 246, 0.07); }
.fv-row.flash { animation: row-flash 0.35s ease; }
@keyframes row-flash { 0%,100% { background: transparent; } 30% { background: rgba(59, 130, 246, 0.15); } }

.fv-row td {
  padding: 0.35rem 0.65rem;
  vertical-align: top;
  line-height: 1.5;
}

.fv-field-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.fv-badge-new {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
  line-height: 1;
}

.fv-cell-val {
  color: var(--text);
  word-break: break-word;
}
.fv-val-changed {
  color: var(--yellow);
}
.fv-cell-empty {
  color: var(--text-dim);
  opacity: 0.4;
}

/* Found cell: clickable button to adopt single field */
.fv-adopt-cell {
  all: unset;
  display: block;
  width: 100%;
  cursor: pointer;
  color: var(--text);
  word-break: break-word;
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.2rem;
  margin: -0.1rem -0.2rem;
  transition: background 0.12s, color 0.12s;
  line-height: 1.5;
}
.fv-val-found-diff {
  color: var(--green);
}
.fv-adopt-cell:hover {
  background: var(--green-bg);
  color: var(--green);
  outline: 1px solid var(--green-border);
}

/* Original cell: clickable button to restore original value */
.fv-orig-cell {
  all: unset;
  display: block;
  width: 100%;
  cursor: pointer;
  color: var(--text);
  word-break: break-word;
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.2rem;
  margin: -0.1rem -0.2rem;
  transition: background 0.12s, color 0.12s;
  line-height: 1.5;
}
.fv-val-changed {
  color: var(--yellow);
}
.fv-orig-cell:hover {
  background: var(--yellow-bg);
  color: var(--yellow);
  outline: 1px solid var(--yellow-border);
}

/* Edit cell: contenteditable */
.fv-edit-cell {
  display: block;
  min-height: 1.4em;
  word-break: break-word;
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.3rem;
  margin: -0.15rem -0.3rem;
  color: var(--text);
  outline: none;
  line-height: 1.5;
  transition: box-shadow 0.12s, background 0.12s;
}
.fv-edit-cell:focus {
  box-shadow: inset 0 0 0 1.5px var(--accent);
  background: var(--accent-bg);
}
.fv-edit-cell.fv-removed {
  text-decoration: line-through;
  opacity: 0.35;
  pointer-events: none;
}
.fv-edit-cell.fv-cleared {
  opacity: 0.35;
  font-style: italic;
}

/* Remove button */
.fv-btn-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
}
.fv-btn-remove:hover { border-color: var(--red); color: var(--red); }
.fv-btn-remove.active { background: var(--red-bg); border-color: var(--red-border); color: var(--red); }

/* Adopt-all button in table header — icon only */
.fv-col-act .btn-adopt-found {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* Source database badge in Found column header */
.fv-source-badge {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.05rem 0.3rem;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 3px;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.25);
  letter-spacing: 0.03em;
  vertical-align: middle;
}

/* ─── Diff panel below field table ───────────────────────────────── */
.fv-diff-wrap {
  margin-top: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.fv-diff-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}

.fv-diff-body {
  margin: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  line-height: 1.55;
  background: var(--surface);
  overflow: auto;
  max-height: 220px;
}

.fv-diff-body .diff-add {
  background: var(--green-bg);
  border-left: 2px solid var(--green);
  display: block;
  padding: 0 0.7rem 0 0.5rem;
}
.fv-diff-body .diff-add::before { content: "+"; color: var(--green); display: inline-block; width: 1em; margin-right: 0.3em; user-select: none; }

.fv-diff-body .diff-del {
  background: var(--red-bg);
  border-left: 2px solid var(--red);
  text-decoration: line-through;
  opacity: 0.7;
  display: block;
  padding: 0 0.7rem 0 0.5rem;
}
.fv-diff-body .diff-del::before { content: "−"; color: var(--red); display: inline-block; width: 1em; margin-right: 0.3em; user-select: none; }

.fv-diff-body .diff-ctx {
  display: block;
  padding: 0 0.7rem 0 1.8rem;
  color: var(--text-dim);
}

/* ─── Candidate list (多候选文献) ────────────────────────────────── */
.candidates-panel {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border);
}

.candidates-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 0.4rem;
}

.candidates-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.candidate-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 2rem;
  gap: 0.35rem;
  align-items: stretch;
}

.candidate-row + .candidate-row { margin-top: 0.2rem; }

.candidate-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  width: 100%;
  text-align: left;
  background: transparent;
  color: inherit;
  font: inherit;
}

.candidate-item:hover {
  background: var(--surface-alt);
  border-color: var(--border);
}

.candidate-item.active {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.candidate-open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  min-height: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-dim);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.candidate-open-link:hover {
  background: var(--surface-alt);
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.candidate-open-link.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.candidate-rank {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  min-width: 1.4em;
  margin-top: 0.1rem;
}

.candidate-item.active .candidate-rank { color: var(--accent); }

.candidate-body { min-width: 0; flex: 1; }

.candidate-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.candidate-item.active .candidate-title { color: var(--accent); }

.candidate-meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate-score {
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: var(--surface-alt);
  color: var(--text-dim);
  margin-top: 0.1rem;
}

.candidate-score.score-high { background: var(--teal-bg); color: var(--teal); }
.candidate-score.score-mid  { background: var(--yellow-bg); color: var(--yellow); }
.candidate-score.score-low  { background: var(--gray-bg); color: var(--text-dim); }

.candidate-selected-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.candidates-more-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
}
.candidates-more-btn:hover { color: var(--text); }
.candidates-more-btn svg { transition: transform 0.2s; }
.candidates-more-btn.expanded svg { transform: rotate(180deg); }

.candidates-extra { display: none; }
.candidates-extra.visible { display: block; }

/* ─── Language toggle ────────────────────────────────────────────── */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.36rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.lang-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .fv-col-field { width: 5.5rem; }
}

@media (max-width: 640px) {
  html { font-size: 15px; }
  .page-wrap { padding: 1rem; padding-bottom: 4.75rem; }
  .floating-bar { padding-inline: 0.5rem; }
  .floating-bar-inner { width: 100%; padding: 0; gap: 0.35rem; }
  .floating-help-toggle {
    min-width: 42px;
    padding-inline: 0.5rem;
  }
  .floating-help-panel {
    position: fixed;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 3.75rem;
    width: auto;
    max-height: calc(100vh - 4.5rem);
  }
  .floating-help-panel::after { display: none; }
  .progress-log-wrap { width: auto; max-width: none; flex: 1; min-width: 0; }
  .activity-log.expanded { width: auto; }
  .progress-log-main { gap: 0.45rem; padding: 0.45rem; }
  .bar-progress { min-width: 0; width: auto; flex: 1; }
  .activity-log-header { width: 104px; }
  .activity-log-subtitle { display: none; }
  .btn-primary-action,
  .btn-download { padding-inline: 0.65rem; }
  .activity-log-body { height: 200px; font-size: 0.72rem; }
  .activity-line { grid-template-columns: 4rem 4.2rem minmax(0, 1fr); gap: 0.4rem; padding-inline: 0.65rem; }
  .summary-bar { gap: 0.35rem; }
  .summary-badge { font-size: 0.76rem; padding: 0.36rem 0.62rem; }
  .settings-popover {
    position: fixed;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 3.75rem;
    width: auto;
    max-height: calc(100vh - 4.5rem);
  }
  .popover-arrow { display: none; }
  .hero-lead { font-size: 0.92rem; }
  .upload-zone { padding: 1.5rem 1rem; }
  .steps { grid-template-columns: 1fr 1fr; }
  .feature-grid { grid-template-columns: 1fr; }
  .entry-header {
    flex-direction: column;
    align-items: stretch;
  }
  .entry-header-aside {
    align-self: flex-end;
  }
  .fv-col-field { width: 4.5rem; }
  .fv-field-table-wrap { max-height: 280px; }
  .candidate-row { grid-template-columns: minmax(0, 1fr) 1.8rem; }
  .candidate-open-link { width: 1.8rem; }
}

/* ─── Export warning (inline next to download button) ───────────── */
.export-warn {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--yellow);
  white-space: nowrap;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--yellow-bg);
  border: 1px solid var(--yellow-border);
}

/* ─── TOC sidebar ────────────────────────────────────────────────── */
.toc-sidebar {
  position: fixed;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  width: min(260px, calc(100vw - 2rem));
  max-height: min(64vh, 560px);
  display: none;
  flex-direction: column;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 850;
  opacity: 0.96;
  backdrop-filter: blur(12px);
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
}

.toc-sidebar.visible {
  display: flex;
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-shrink: 0;
  gap: 0.5rem;
}

.toc-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.toc-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.toc-toggle:hover { background: var(--border); color: var(--text); }

.toc-body {
  overflow-y: auto;
  flex: 1;
  padding: 0.3rem 0;
  overscroll-behavior: contain;
}

.toc-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none;
  color: inherit;
}

.toc-item:hover {
  background: var(--surface-alt);
}

.toc-item.toc-active {
  background: var(--accent-bg);
  border-left-color: var(--accent);
}

.toc-item-num {
  font-size: 0.65rem;
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 1.5em;
  text-align: right;
  opacity: 0.6;
}

.toc-item-title {
  font-size: 0.76rem;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toc-item-status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.35em;
  align-self: flex-start;
}

/* status dot colours */
.toc-dot-parsed     { background: var(--accent); }
.toc-dot-verified,
.toc-dot-review     { background: var(--teal); }
.toc-dot-updated    { background: var(--yellow); }
.toc-dot-needs_review,
.toc-dot-needs_update { background: var(--yellow); }
.toc-dot-not_found  { background: var(--text-dim); }
.toc-dot-duplicate  { background: var(--purple); }
.toc-dot-error      { background: var(--red); }

@keyframes toc-card-flash {
  0%   { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: none; }
}
.entry-card.toc-flash {
  animation: toc-card-flash 0.9s ease-out;
}

/* collapsed open-tab button */
.toc-open-btn {
  position: fixed;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  z-index: 850;
  box-shadow: var(--shadow);
  transition: background 0.15s, color 0.15s;
}
.toc-open-btn:hover { background: var(--surface-alt); color: var(--accent); }
.toc-open-btn.visible { display: flex; }

@media (max-width: 900px) {
  .toc-sidebar { width: min(230px, calc(100vw - 2rem)); }
}

@media (max-width: 640px) {
  .toc-sidebar {
    top: auto;
    bottom: 4.5rem;
    right: 0.75rem;
    transform: none;
    max-height: 50vh;
    width: min(220px, calc(100vw - 1.5rem));
    border-radius: var(--radius);
  }
  .toc-open-btn {
    top: auto;
    bottom: 5.5rem;
    right: 0.75rem;
    transform: none;
  }
}

/* Initial app view: compact cards aligned with result cards */
.quick-reference {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.reference-card:nth-child(1) {
  --guide-color: var(--accent);
  --guide-bg: var(--accent-bg);
  --guide-border: rgba(59, 130, 246, 0.34);
}
.reference-card:nth-child(2) {
  --guide-color: var(--teal);
  --guide-bg: var(--teal-bg);
  --guide-border: var(--teal-border);
}
.reference-card:nth-child(3) {
  --guide-color: var(--yellow);
  --guide-bg: var(--yellow-bg);
  --guide-border: var(--yellow-border);
}

.reference-card-header {
  min-height: 100%;
  justify-content: flex-start;
}

.reference-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.45rem;
  height: 1.45rem;
  border: 1px solid var(--guide-border);
  border-radius: var(--radius-sm);
  background: var(--guide-bg);
  color: var(--guide-color);
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
}

.features {
  margin-top: 1rem;
  padding-top: 0;
  border-top: none;
}

.feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.65rem;
}

.feature-card {
  --guide-color: var(--purple);
  --guide-bg: var(--purple-bg);
  --guide-border: var(--purple-border);
  padding: 0.75rem 0.95rem;
}

.feature-card h3 {
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.feature-card p {
  font-size: 0.78rem;
  line-height: 1.45;
}

.faq {
  margin-top: 1rem;
  padding-top: 0;
  border-top: none;
}

.faq details {
  --guide-color: var(--text-dim);
  --guide-bg: var(--gray-bg);
  --guide-border: var(--gray-border);
}

.faq summary {
  padding: 0.72rem 0.95rem;
  font-size: 0.84rem;
}

.faq details p {
  padding: 0 0.95rem 0.85rem;
  font-size: 0.8rem;
}

@media (max-width: 960px) {
  .start-workspace {
    grid-template-columns: 1fr;
  }
  .quick-reference,
  .feature-grid {
    grid-template-columns: 1fr;
  }
}
