:root {
  --navy: #1a1a2e;
  --accent: #0066cc;
  --bg: #ffffff;
  --surface: #f8f8fc;
  --text: #1a1a2e;
  --muted: #5a5a6e;
  --border: #e2e2ea;
  --green-bg: #e3f6e8;
  --green-fg: #1b7a37;
  --amber-bg: #fdf3d8;
  --amber-fg: #9a6b00;
  --highly-cited-bg: #fff0e0;
  --highly-cited-fg: #b45309;
  --cache-bg: #e8f4fd;
  --cache-fg: #1565a8;
  --color-success: #1b7a37;
  --color-warn: #9a6b00;
  --color-error: #c0392b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy: #0d0d1a;
    --accent: #4d9fff;
    --bg: #12121f;
    --surface: #1a1a2e;
    --text: #e8e8f0;
    --muted: #8888aa;
    --border: #2e2e4a;
    --green-bg: #0f2e18;
    --green-fg: #4ade80;
    --amber-bg: #2a1f00;
    --amber-fg: #f0b429;
    --highly-cited-bg: #2e1800;
    --highly-cited-fg: #f6a23e;
    --cache-bg: #0d1e30;
    --cache-fg: #60b0f0;
    --color-success: #4ade80;
    --color-warn: #f0b429;
    --color-error: #f87171;
  }
}

[data-theme="dark"] {
  --navy: #0d0d1a;
  --accent: #4d9fff;
  --bg: #12121f;
  --surface: #1a1a2e;
  --text: #e8e8f0;
  --muted: #8888aa;
  --border: #2e2e4a;
  --green-bg: #0f2e18;
  --green-fg: #4ade80;
  --amber-bg: #2a1f00;
  --amber-fg: #f0b429;
  --highly-cited-bg: #2e1800;
  --highly-cited-fg: #f6a23e;
  --cache-bg: #0d1e30;
  --cache-fg: #60b0f0;
  --color-success: #4ade80;
  --color-warn: #f0b429;
  --color-error: #f87171;
}

[data-theme="light"] {
  --navy: #1a1a2e;
  --accent: #0066cc;
  --bg: #ffffff;
  --surface: #f8f8fc;
  --text: #1a1a2e;
  --muted: #5a5a6e;
  --border: #e2e2ea;
  --green-bg: #e3f6e8;
  --green-fg: #1b7a37;
  --amber-bg: #fdf3d8;
  --amber-fg: #9a6b00;
  --highly-cited-bg: #fff0e0;
  --highly-cited-fg: #b45309;
  --cache-bg: #e8f4fd;
  --cache-fg: #1565a8;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  /* The tiered nav (2026-07-05) is always compact, so the old scroll-triggered
     .compact toggle and its min-height:calc(100vh + 100px) oscillation
     workaround are gone. */
  min-height: 100vh;
}

main {
  flex: 1;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* Header */
.site-header {
  background: var(--navy);
  color: #fff;
  padding: 1.75rem 1rem;
}
.header-inner {
  max-width: 860px;
  margin: 0 auto;
}
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.5px;
}
.tagline {
  margin: 0.25rem 0 0;
  color: #b9b9d0;
  font-size: 0.95rem;
}
.usage-line {
  margin: 0.2rem 0 0;
  color: #8888aa;
  font-size: 0.8rem;
}

/* Header auth controls */
.header-auth {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.signin-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 0.4rem 0.9rem;
  font-size: 0.88rem;
  border-radius: 6px;
}
.signin-btn:hover {
  background: rgba(255,255,255,0.22);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.user-badge {
  display: inline-block;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.82rem;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signout-btn {
  background: transparent;
  color: #b9b9d0;
  border: none;
  padding: 0.25rem 0.5rem;
  font-size: 0.82rem;
  border-radius: 4px;
}
.signout-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

/* Theme toggle */
.theme-toggle-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 0.3rem 0.55rem;
  font-size: 1rem;
  border-radius: 6px;
  line-height: 1;
}
.theme-toggle-btn:hover {
  background: rgba(255,255,255,0.22);
}

/* Auth modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-overlay[hidden] {
  display: none;
}
.modal-box {
  background: var(--bg);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}
.modal-close:hover {
  background: var(--border);
  color: var(--text);
}
.modal-title {
  margin: 0 0 1rem;
  font-size: 1.2rem;
  color: var(--text);
}

/* Tab switcher */
.tab-switcher {
  display: flex;
  gap: 0;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
}
.tab-btn {
  background: none;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 1.1rem;
  margin-bottom: -2px;
  font-size: 0.95rem;
  font-weight: 600;
}
.tab-btn:hover {
  background: none;
  color: var(--text);
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: none;
}

/* Auth form */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.auth-form label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.25rem;
}
.auth-form input {
  font: inherit;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.12);
}
.auth-btn {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.65rem;
  font-size: 0.95rem;
}
.auth-error {
  background: #fdecec;
  border: 1px solid #f5b5b5;
  color: #a12626;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}
[data-theme="dark"] .auth-error {
  background: rgba(200, 60, 60, 0.15);
  border-color: rgba(200, 60, 60, 0.35);
  color: #ff9999;
}
@media (prefers-color-scheme: dark) {
  .auth-error { background: rgba(200,60,60,0.15); border-color: rgba(200,60,60,0.35); color: #ff9999; }
}
.auth-error[hidden] {
  display: none;
}
.auth-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.82rem;
}
.tos-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.88rem;
}
.tos-check label {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
}
.tos-check a {
  color: var(--accent);
}

/* Layout */
.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* Mode selector — tiered nav (2026-07-05): a compact pill row (Level 1)
   plus a collapsed "More tools" accordion row (Level 2).  Cards carry only
   icon + label; badges/descriptions render inside the tool panels. */
.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: 0.4rem 0;
}
.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.mode-card {
  /* Override the global button styling. */
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  text-align: left;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.mode-more-toggle {
  color: var(--muted);
  border-style: dashed;
}
.mode-more-toggle[aria-expanded="true"] .mode-more-chevron {
  display: inline-block;
  transform: rotate(180deg);
}
.panel-badge-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.6rem;
}
.panel-badge-row .mode-badge { margin-top: 0; }
.panel-tool-desc {
  font-size: 0.82rem;
  color: var(--muted);
}
.mode-card:hover {
  background: var(--surface);
}
.mode-card.active {
  border: 2px solid var(--accent);
  background: var(--bg);
  box-shadow: 0 1px 3px rgba(0, 102, 204, 0.12);
}
.mode-card.disabled,
.mode-card:disabled {
  background: var(--surface);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.7;
}
.mode-card.disabled:hover {
  background: var(--surface);
  border-color: var(--border);
}
.mode-icon {
  font-size: 1rem;
  line-height: 1;
}
.mode-title {
  font-weight: 600;
  font-size: 0.88rem;
}
.mode-badge {
  margin-top: 0.3rem;
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.mode-badge.free {
  background: var(--green-bg);
  color: var(--green-fg);
}
.mode-badge.soon {
  background: var(--border);
  color: var(--muted);
}

/* Hint text below the textarea */
.hint {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Search form */
.search-form textarea {
  width: 100%;
  /* Tall enough that the placeholder/example hints are fully visible without
     the user having to drag the resize handle. */
  min-height: 120px;
  padding: 0.75rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 8px;
  resize: vertical;
}
/* The Cite textarea takes longer pasted text — give it more room. */
#cite-text {
  min-height: 160px;
}
.search-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  gap: 1rem;
}
.form-row label {
  color: var(--muted);
  font-size: 0.9rem;
}
select {
  font: inherit;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}
button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1.2rem;
  transition: background 0.15s ease;
}
button:hover {
  background: #0052a3;
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Status / spinner */
.status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1.5rem 0;
  color: var(--muted);
}
.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error */
.error {
  margin: 1.5rem 0;
  padding: 0.9rem 1rem;
  background: #fdecec;
  border: 1px solid #f5b5b5;
  color: #a12626;
  border-radius: 8px;
}
.retry-btn {
  margin-top: 0.6rem;
  background: #a12626;
  color: #fff;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
}
.retry-btn:hover {
  background: #842020;
}
[data-theme="dark"] .error {
  background: rgba(200, 60, 60, 0.15);
  border-color: rgba(200, 60, 60, 0.35);
  color: #ff9999;
}
@media (prefers-color-scheme: dark) {
  .error { background: rgba(200,60,60,0.15); border-color: rgba(200,60,60,0.35); color: #ff9999; }
}

/* Partial-failure warning banner */
.warning {
  margin: 1rem 0;
  padding: 0.6rem 0.9rem;
  background: var(--amber-bg);
  border: 1px solid #f0d28a;
  color: var(--amber-fg);
  border-radius: 8px;
  font-size: 0.85rem;
}

/* Export controls */
.export-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.export-label {
  font-weight: 600;
  color: var(--text);
}
.export-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted);
  cursor: pointer;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 1.5rem 0 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}
#export-btn {
  background: var(--navy);
}
#export-btn:hover {
  background: #2b2b48;
}

/* Results */
.results {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
}
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  background: var(--bg);
  box-shadow: 0 1px 3px rgba(26, 26, 46, 0.06);
}
.card-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
  line-height: 1.35;
}
.result-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}
.card-title a {
  color: var(--accent);
  text-decoration: none;
}
.card-title a:hover {
  text-decoration: underline;
}
.card-authors {
  color: var(--text);
  font-size: 0.92rem;
  margin: 0 0 0.25rem;
}
.card-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 0.6rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
}
.badge.verified {
  background: var(--green-bg);
  color: var(--green-fg);
}
.badge.unverified {
  background: var(--amber-bg);
  color: var(--amber-fg);
}
.doi-badge {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.75em;
  vertical-align: middle;
  margin-left: 0.3rem;
}
.doi-badge.verified {
  background: #22c55e20;
  border: 1px solid #22c55e;
  color: #22c55e;
}

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

.abstract-snippet {
  font-style: italic;
  color: #888;
  font-size: 0.85em;
  margin: 0.2rem 0 0 0;
  line-height: 1.4;
}

/* Abstract */
.abstract-toggle {
  background: none;
  color: var(--accent);
  padding: 0;
  font-size: 0.85rem;
}
.abstract-toggle:hover {
  background: none;
  text-decoration: underline;
}
.abstract {
  margin: 0.5rem 0 0;
  color: var(--text);
  font-size: 0.9rem;
  white-space: pre-wrap;
}
.abstract[hidden] {
  display: none;
}

/* Card actions */
.card-actions {
  margin-top: 0.7rem;
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.copy-btn {
  background: var(--surface);
  color: var(--accent);
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}
.copy-btn:hover {
  background: var(--border);
}
.copy-btn.copied {
  background: var(--green-bg);
  color: var(--green-fg);
}

.warning-inline {
  color: var(--amber-fg);
}

/* Source breakdown line */
.source-stats {
  margin: 1.25rem 0 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* "Showing X–Y of N" */
#results-meta {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin: 1.5rem 0 0.5rem;
}
.page-btn {
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  min-width: 36px;
}
.page-btn:hover:not(:disabled) {
  background: var(--surface);
}
.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.page-gap {
  align-self: center;
  color: var(--muted);
  padding: 0 0.15rem;
}

/* ---- Cite mode ---- */
.cite-summary {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 600;
}
.cite-results {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}
.claim-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  background: var(--bg);
}
.claim-sentence {
  background: #fff8d6;
  border-left: 4px solid #e6c200;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
  font-size: 0.95rem;
  margin-bottom: 0.8rem;
}
[data-theme="dark"] .claim-sentence {
  background: rgba(230, 194, 0, 0.12);
  border-left-color: #c9a800;
}
@media (prefers-color-scheme: dark) {
  .claim-sentence { background: rgba(230,194,0,0.12); border-left-color: #c9a800; }
}
.claim-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.4rem 0 0.6rem;
  font-size: 0.8rem;
}
.claim-type-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--muted);
  font-weight: 600;
  text-transform: capitalize;
}
.claim-query-hint {
  color: var(--muted);
  font-style: italic;
}
.claim-sources {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.claim-none {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}
.claim-info-note {
  font-size: 0.85rem;
  color: var(--color-muted, #888);
  padding: 0.5rem 0;
  font-style: italic;
}
.cite-source {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
}
.cite-source.accepted {
  background: var(--green-bg);
  border-color: var(--green-fg);
}
.cite-source-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.cite-source-title a {
  color: var(--accent);
  text-decoration: none;
}
.cite-source-title a:hover {
  text-decoration: underline;
}
.cite-source-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.use-btn {
  background: var(--surface);
  color: var(--accent);
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
}
.use-btn:hover {
  background: var(--border);
}
.cite-source.accepted .use-btn {
  background: var(--green-fg);
  color: #fff;
}
#cite-export {
  margin-top: 1.5rem;
  background: var(--navy);
}
#cite-export:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Highly-cited badge */
.badge-highly-cited {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--highly-cited-bg);
  color: var(--highly-cited-fg);
  margin-left: 0.35rem;
  vertical-align: middle;
}

/* Cache-hit badge */
.cache-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--cache-bg);
  color: var(--cache-fg);
  margin-left: 0.35rem;
  vertical-align: middle;
}

/* Domain field row (Cite mode) */
.field-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.6rem;
}
.field-row label {
  font-size: 0.88rem;
  color: var(--muted);
  white-space: nowrap;
}
.field-row input[type="text"] {
  font: inherit;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  flex: 1;
  max-width: 300px;
}
.field-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}
.hint-inline {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Pro badge for gated mode cards */
.mode-badge.pro {
  background: #ebe5ff;
  color: #6d28d9;
}
[data-theme="dark"] .mode-badge.pro {
  background: rgba(109, 40, 217, 0.25);
  color: #c4b5fd;
}
@media (prefers-color-scheme: dark) {
  .mode-badge.pro { background: rgba(109,40,217,0.25); color: #c4b5fd; }
}

/* Auth modal gate note */
.auth-gate-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.75rem;
}
.auth-gate-note[hidden] {
  display: none;
}

/* Google OAuth */
.oauth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 16px 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.oauth-divider::before,
.oauth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease;
}
.btn-google:hover {
  background: var(--surface);
}

/* Upgrade modal */
.upgrade-modal-box {
  background: var(--bg);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}
.upgrade-modal-box .modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
}
.upgrade-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  line-height: 1;
}
.upgrade-price {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin: 1rem 0;
}
.upgrade-price span {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 400;
}
.btn-primary {
  display: block;
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  margin-top: 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary:hover {
  background: #0052a3;
}
.btn-ghost {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  margin-top: 0.75rem;
  padding: 0.4rem;
  font-size: 0.9rem;
  border-radius: 6px;
}
.btn-ghost:hover {
  color: var(--text);
  background: transparent;
}

/* Global form element theming */
input:not([type="radio"]):not([type="checkbox"]),
select,
textarea {
  background: var(--bg);
  color: var(--text);
}

/* Draft mode output */
.draft-output {
  margin-top: 1.5rem;
}
.draft-output-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.draft-output-label {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
  flex: 1;
}
.draft-pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-family: "Courier New", Courier, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  margin: 0;
  max-height: 400px;
  overflow-y: auto;
}

/* Responsive */
@media (max-width: 600px) {
  .mode-selector {
    grid-template-columns: 1fr;
  }
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }
  .form-row button {
    width: 100%;
  }
}

/* Save to library button */
.save-btn {
  background: #fff8e8;
  color: #8a5c00;
  border: 1px solid #e8d89a;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
}
.save-btn:hover {
  background: #fef3c7;
}
.save-btn.saved {
  background: var(--green-bg);
  color: var(--green-fg);
  border-color: var(--green-fg);
}

/* Library delete button */
.delete-btn {
  background: transparent;
  color: #c0392b;
  border: 1px solid #e0b0b0;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
}
.delete-btn:hover {
  background: #fdf0ef;
}

/* Manage subscription button */
.manage-sub-btn {
  background: transparent;
  color: #b9b9d0;
  border: none;
  padding: 0.25rem 0.5rem;
  font-size: 0.82rem;
  border-radius: 4px;
  cursor: pointer;
}
.manage-sub-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

/* Upgrade success banner */
.upgraded-banner {
  background: #1b7a37;
  color: #fff;
  text-align: center;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  position: sticky;
  top: 0;
  z-index: 200;
}

/* Upgrade modal features list */
.upgrade-features {
  text-align: left;
  margin: 0.75rem 0 0 0;
  padding-left: 1.4rem;
  font-size: 0.95rem;
  color: var(--text);
}
.upgrade-features li {
  margin: 0.35rem 0;
}

/* Upgrade modal compare link */
.upgrade-compare-link {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.upgrade-compare-link:hover {
  color: var(--accent);
}

/* Footer */
.site-footer {
  padding: 1rem 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--border);
}

/* Footer links */
.site-footer a {
  color: inherit;
  opacity: 0.8;
}
.site-footer a:hover {
  opacity: 1;
}

/* ---- Draft interactive claims panel ---- */
.draft-claims-panel {
  margin-top: 2rem;
  border-top: 2px solid var(--border);
  padding-top: 1.5rem;
}

.draft-claim-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  background: var(--bg);
  margin-bottom: 0.9rem;
  transition: opacity 0.15s;
}

.draft-claim-row.excluded {
  opacity: 0.45;
}

.draft-claim-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.draft-claim-checkbox {
  margin-top: 0.3rem;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

.draft-claim-sentence {
  background: #fff8d6;
  border-left: 4px solid #e6c200;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.92rem;
  flex: 1;
  line-height: 1.45;
}

[data-theme="dark"] .draft-claim-sentence {
  background: rgba(230, 194, 0, 0.12);
  border-left-color: #c9a800;
}

@media (prefers-color-scheme: dark) {
  .draft-claim-sentence { background: rgba(230,194,0,0.12); border-left-color: #c9a800; }
}

.draft-sources {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.draft-source-option {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  transition: border-color 0.12s, background 0.12s;
  cursor: pointer;
}

.draft-source-option:hover {
  border-color: var(--accent);
}

.draft-source-option.selected {
  background: var(--green-bg);
  border-color: var(--green-fg);
}

.draft-radio-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  cursor: pointer;
  margin-bottom: 0.35rem;
}

.draft-radio-label input[type="radio"] {
  margin-top: 0.3rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

/* Source database badges (SS / OA) */
.source-db-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  margin-left: 0.5rem;
  vertical-align: middle;
  letter-spacing: 0.04em;
}

.source-db-semantic-scholar {
  background: #dbeafe;
  color: #1d4ed8;
}

.source-db-openalex {
  background: #dcfce7;
  color: #166534;
}

.source-db-crossref {
  background: #fff7ed;
  color: #9a3412;
}

[data-theme="dark"] .source-db-semantic-scholar {
  background: rgba(30, 64, 175, 0.3);
  color: #93c5fd;
}

[data-theme="dark"] .source-db-openalex {
  background: rgba(22, 101, 52, 0.3);
  color: #86efac;
}

[data-theme="dark"] .source-db-crossref {
  background: rgba(154, 52, 18, 0.3);
  color: #fdba74;
}

@media (prefers-color-scheme: dark) {
  .source-db-semantic-scholar { background: rgba(30,64,175,0.3); color: #93c5fd; }
  .source-db-openalex { background: rgba(22,101,52,0.3); color: #86efac; }
  .source-db-crossref { background: rgba(154,52,18,0.3); color: #fdba74; }
}

/* ---- Draft claim number label ---- */
.draft-claim-number {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

/* ---- Bib [N] number badge on source cards ---- */
.draft-bib-num {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  margin-left: 0.5rem;
  flex-shrink: 0;
  align-self: center;
  letter-spacing: 0.03em;
}

/* ---- Editable BibTeX key row ---- */
.draft-cite-key-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0.3rem 0 0.35rem 1.6rem;
}

.draft-cite-key-label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.draft-cite-key-input {
  font-size: 0.78rem;
  font-family: monospace;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  background: var(--surface);
  color: var(--text);
  width: 13rem;
  min-width: 0;
}

.draft-cite-key-input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

/* Checkbox in source option (same alignment as old radio) */
.draft-radio-label input[type="checkbox"] {
  margin-top: 0.3rem;
  flex-shrink: 0;
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Feedback buttons (thumbs up / down) on Scout cards */
.feedback-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.15s;
}
.feedback-btn:hover { opacity: 1; }

/* Feedback buttons in Cite/Draft source cards */
.btn-feedback-up,
.btn-feedback-down {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0.65;
  transition: opacity 0.15s, background 0.15s;
  margin-left: 0.25rem;
}
.btn-feedback-up:hover { opacity: 1; background: var(--green-bg); }
.btn-feedback-down:hover { opacity: 1; background: var(--amber-bg); }
.btn-feedback-up.active {
  opacity: 1;
  background: var(--green-bg);
  border-color: var(--green-fg);
  color: var(--green-fg);
}
.btn-feedback-down.active {
  opacity: 1;
  background: var(--amber-bg);
  border-color: var(--amber-fg);
  color: var(--amber-fg);
}
.btn-feedback-up.grayed,
.btn-feedback-down.grayed {
  opacity: 0.2;
  pointer-events: none;
}

/* Duplicate-paper badge in Cite mode */
.dup-badge {
  font-size: 0.75rem;
  color: #e67e22;
  margin-left: 0.5rem;
}

/* BibCheck panel */
.bibcheck-results {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text);
}
.bibcheck-item {
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--border);
}
.bibcheck-item:last-child { border-bottom: none; }
.bibcheck-ok { color: var(--color-success); }
.bibcheck-warn { color: var(--color-warn); }
.bibcheck-error { color: var(--color-error); }
/* Suppressed issue — CSS source of truth for opacity/strikethrough */
.bibcheck-suppressed { opacity: 0.4; text-decoration: line-through; }
/* Case A duplicate pair — both keys used in .tex */
.bibcheck-dupe-critical { background: #fff5f5; border-color: #fca5a5; }
.bibcheck-conflict-badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: #fee2e2;
  color: #dc2626;
  font-weight: 600;
  white-space: nowrap;
}
/* Unverified paper sub-group badges */
.bibcheck-unverified-badge-a {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: #fef3c7;
  color: #d97706;
  font-weight: 600;
  margin-right: 0.3rem;
}
.bibcheck-unverified-badge-b {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 600;
  margin-right: 0.3rem;
}
/* CRC sub-section spacing */
.bibcheck-crc-sub + .bibcheck-crc-sub { margin-top: 0.5rem; }
details.bibcheck-crc-verified-sub { margin-top: 0.5rem; padding-top: 0.25rem; border-top: 1px solid var(--border); }
.bibcheck-used-badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: var(--green-bg);
  color: var(--green-fg);
  white-space: nowrap;
}
.bibcheck-unused-badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  background: var(--amber-bg);
  color: var(--amber-fg);
  white-space: nowrap;
}

/* BibCheck / Glossary sub-tabs */
.bibcheck-subtab {
  font-size: 0.85rem;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--surface, #f9fafb);
  color: var(--muted, #6b7280);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.bibcheck-subtab.active {
  background: var(--accent, #6366f1);
  color: #fff;
  border-color: var(--accent, #6366f1);
}

/* Glossary result sections */
.glossary-section {
  margin-top: 0.75rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  overflow: hidden;
}
.glossary-section-header {
  padding: 0.5rem 0.75rem;
  background: var(--surface, #f9fafb);
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border, #e5e7eb);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.glossary-row {
  padding: 0.45rem 0.75rem;
  font-size: 0.83rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.glossary-row:last-child { border-bottom: none; }
.glossary-code {
  font-family: monospace;
  background: var(--bg, #f3f4f6);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  font-size: 0.82rem;
  flex: 1;
  word-break: break-all;
}
.glossary-copy-btn {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border, #e5e7eb);
  background: var(--bg, #fff);
  cursor: pointer;
  white-space: nowrap;
}
.glossary-copy-btn:hover { background: var(--surface, #f9fafb); }
.glossary-preamble {
  margin-top: 0.75rem;
  padding: 0.6rem 0.85rem;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  font-size: 0.83rem;
  color: #92400e;
}

/* Scout source warning */
.source-warning {
  font-size: 0.8rem;
  color: var(--color-warn, #e67e22);
  margin: 0.25rem 0;
}

/* Admin panel button (header) */
.admin-panel-btn {
  background: transparent;
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,0.4);
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
  border-radius: 4px;
  cursor: pointer;
}
.admin-panel-btn:hover {
  background: rgba(245,158,11,0.15);
}

/* Admin modal internals */
.admin-section { margin-top: 0.5rem; }
.admin-section-title { font-size: 0.95rem; font-weight: 600; margin: 0 0 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.admin-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.admin-input { flex: 1; min-width: 0; padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--input-bg, var(--surface)); color: var(--text); font-size: 0.9rem; }
.admin-btn { padding: 0.38rem 0.9rem; font-size: 0.88rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; }
.admin-btn:hover { background: var(--hover-bg, rgba(255,255,255,0.06)); }
.admin-btn-sm { font-size: 0.82rem; padding: 0.3rem 0.65rem; }
.admin-btn-danger { color: #ef4444; border-color: rgba(239,68,68,0.4); }
.admin-btn-danger:hover { background: rgba(239,68,68,0.1); }
.admin-select { padding: 0.38rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 0.88rem; cursor: pointer; }
.admin-user-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; margin: 0.75rem 0; }
.admin-user-row { display: flex; gap: 0.5rem; align-items: baseline; margin-bottom: 0.35rem; font-size: 0.9rem; }
.admin-label { color: var(--muted); min-width: 90px; flex-shrink: 0; }
.admin-actions { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.5rem; }
.admin-status { font-size: 0.85rem; min-height: 1.2rem; margin: 0.25rem 0 0; color: var(--muted); }

/* Admin modal wider */
.admin-modal-box { max-width: 720px; width: 96%; }

/* Tabs */
.admin-tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
.admin-tab { background: none; border: none; padding: 0.35rem 0.9rem; border-radius: 6px 6px 0 0; font-size: 0.88rem; color: var(--muted); cursor: pointer; }
.admin-tab:hover { color: var(--text); }
.admin-tab.active { background: var(--surface); color: var(--text); font-weight: 600; border: 1px solid var(--border); border-bottom: 1px solid var(--bg, var(--surface)); }
.admin-tab-content { min-height: 200px; }

/* Users table */
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 0.5rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th { background: var(--surface); color: var(--muted); font-weight: 600; text-align: left; padding: 0.45rem 0.65rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.admin-table td { padding: 0.4rem 0.65rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--hover-bg, rgba(255,255,255,0.03)); }
.admin-table td.td-actions { white-space: nowrap; }

/* Role badges */
.role-badge { display: inline-block; font-size: 0.72rem; padding: 0.1rem 0.4rem; border-radius: 3px; font-weight: 600; }
.role-badge.superadmin { background: rgba(245,158,11,0.15); color: #f59e0b; }
.role-badge.moderator  { background: rgba(99,102,241,0.15); color: #818cf8; }
.role-badge.user       { background: rgba(156,163,175,0.12); color: var(--muted); }

/* Pagination */
.admin-pagination { display: flex; gap: 0.5rem; align-items: center; justify-content: center; margin-top: 0.4rem; }
.admin-page-info { font-size: 0.82rem; color: var(--muted); }

/* Reset link dialog */
.admin-reset-dialog { margin-top: 1rem; padding: 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.admin-reset-title { font-size: 0.85rem; font-weight: 600; margin: 0 0 0.5rem; }
.role-badge.tester { background: rgba(34,197,94,0.12); color: #4ade80; }

/* Report error button (footer) */
.report-error-btn {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  opacity: 0.8;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.report-error-btn:hover { opacity: 1; }

/* Report modal form */
.report-modal-desc { font-size: 0.88rem; color: var(--muted); margin: 0 0 1.1rem; }
.report-label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text); }
.report-required { color: #ef4444; }
.report-optional { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.report-input {
  display: block; width: 100%; box-sizing: border-box;
  padding: 0.45rem 0.65rem; margin-bottom: 0.9rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font-size: 0.9rem;
  font-family: inherit;
}
.report-textarea { min-height: 90px; resize: vertical; }
.report-status { font-size: 0.85rem; margin: 0.5rem 0; }
.report-status.success { color: #4ade80; }
.report-status.error   { color: #ef4444; }
.report-actions { display: flex; gap: 0.6rem; margin-top: 0.25rem; }
.report-submit-btn {
  flex: 1; padding: 0.5rem 1rem; border-radius: 6px; border: none;
  background: var(--accent, #6366f1); color: #fff; font-size: 0.9rem;
  font-weight: 600; cursor: pointer;
}
.report-submit-btn:hover { opacity: 0.88; }
.report-submit-btn:disabled { opacity: 0.5; cursor: default; }
.report-cancel-btn {
  padding: 0.5rem 0.9rem; border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font-size: 0.9rem; cursor: pointer;
}
.report-cancel-btn:hover { color: var(--text); }

/* ---- Tester panel (fixed right-side drawer) ---- */
.tester-panel-wrap {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 800;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
}

.tester-toggle {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 16px 9px;
  border-radius: 6px 0 0 6px;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: inherit;
  line-height: 1.3;
  transition: filter 0.15s;
}
.tester-toggle:hover { filter: brightness(1.12); }

.tester-drawer {
  width: 300px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 8px 0 0 8px;
  box-shadow: -4px 4px 24px rgba(0,0,0,0.14);
}

.tester-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

.tester-drawer-title { font-size: 0.88rem; font-weight: 600; }

.tester-drawer-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 2px 4px;
}
.tester-drawer-close:hover { color: var(--text); }

.tester-form {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tester-label {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 6px;
}

.tester-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.84rem;
  font-family: inherit;
  box-sizing: border-box;
}
.tester-input:focus { outline: none; border-color: var(--accent); }

.tester-textarea { min-height: 80px; resize: vertical; }

.tester-submit-btn {
  width: 100%;
  margin-top: 10px;
  padding: 9px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s;
}
.tester-submit-btn:hover { filter: brightness(1.1); }
.tester-submit-btn:disabled { opacity: 0.6; cursor: default; filter: none; }

/* ---- Verify progress bar ---- */
.verify-progress {
  margin: 1.25rem 0 0.75rem;
}

.verify-steps {
  display: flex;
  align-items: flex-start;
  margin-bottom: 0.8rem;
}

.verify-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Connecting line — drawn to the left of each step */
.verify-step::before {
  content: '';
  position: absolute;
  top: 6px;
  left: -50%;
  right: 50%;
  height: 2px;
  background: var(--border);
  z-index: 0;
  transition: background 0.4s;
}
.verify-step:first-child::before { display: none; }
.verify-step.done::before  { background: var(--accent); }
.verify-step.active::before { background: var(--accent); }

.verify-step-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg);
  position: relative;
  z-index: 1;
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
}
.verify-step.done .verify-step-dot {
  background: var(--accent);
  border-color: var(--accent);
}
.verify-step.active .verify-step-dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,102,204,0.15);
}

.verify-step-label {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 5px;
  font-weight: 400;
  transition: color 0.3s, font-weight 0.2s;
  white-space: nowrap;
}
.verify-step.done .verify-step-label,
.verify-step.active .verify-step-label {
  color: var(--text);
  font-weight: 600;
}

.verify-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.55rem;
}
.verify-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s ease;
}

.verify-progress-text {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  margin: 0;
  min-height: 1.1em;
}

/* ---- Verify annotated text ---- */
.verify-sentence {
  display: inline;
  transition: box-shadow 0.2s;
  border-radius: 3px;
  padding: 1px 3px;
}
.verify-sentence[data-clickable="true"] {
  cursor: pointer;
}
.verify-sentence[data-clickable="true"]:hover {
  filter: brightness(1.15);
}
.verify-flash {
  animation: verifyFlash 1.2s ease-out;
}
@keyframes verifyFlash {
  0%   { box-shadow: 0 0 0 3px transparent; }
  30%  { box-shadow: 0 0 0 3px white; }
  100% { box-shadow: 0 0 0 3px transparent; }
}
.verify-legend {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 6px;
  margin-bottom: 0.5rem;
}
.verify-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.cc-badge, .cc-find-btn {
  cursor: pointer;
  font-size: 0.72em;
  margin-left: 1px;
  opacity: 0.9;
  user-select: none;
  transition: opacity 0.15s;
}
.cc-badge:hover, .cc-find-btn:hover {
  opacity: 1;
}
.cc-popover {
  position: fixed;
  z-index: 9999;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  padding: 0.75rem;
  max-width: 320px;
  font-size: 0.8rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  line-height: 1.5;
}
.cc-validate-card {
  background: var(--surface, #fff);
  border: 2px solid var(--accent, #6366f1);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
}
.cc-validate-card-pulse {
  animation: verifyCardPulse 1.5s ease 2;
}
@keyframes verifyCardPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99,179,237,0); }
  50%       { box-shadow: 0 0 0 6px rgba(99,179,237,0.3); }
}
.cc-validate-btn {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  background: var(--accent, #6366f1);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: filter 0.15s, box-shadow 0.15s;
}
.cc-validate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.cc-validate-btn:not(:disabled):hover {
  filter: brightness(1.1);
}
.cc-validate-btn-pulse {
  animation: ccPulse 2s ease-in-out infinite;
}
@keyframes ccPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.45); }
  50%       { box-shadow: 0 0 0 7px rgba(99, 102, 241, 0); }
}
.cc-hint {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  font-size: 0.77rem;
  color: var(--muted, #6b7280);
  margin-top: 5px;
}
.cc-hint-dismiss {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.45;
  font-size: 0.85rem;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.cc-hint-dismiss:hover { opacity: 0.85; }
.cc-result-summary {
  margin-top: 7px;
  font-size: 0.82rem;
  padding: 0.35rem 0.6rem;
  background: var(--bg, #f9fafb);
  border-radius: 5px;
  border: 1px solid var(--border, #e5e7eb);
}

/* Admin Dashboard tab */
.admin-dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}
@media (max-width: 520px) {
  .admin-dash-grid { grid-template-columns: 1fr; }
}
.admin-dash-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
}
.admin-dash-heading {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.5rem 0;
}

/* ── DiffChecker ────────────────────────────────────────────────── */
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-family: monospace;
  font-size: 0.78rem;
  table-layout: fixed;
}
.diff-table td, .diff-table th {
  padding: 1px 6px;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-all;
  border: none;
}
.diff-table th {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 6px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
.diff-lineno {
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  text-align: right;
  color: var(--muted);
  user-select: none;
  font-size: 0.72rem;
}
.diff-row-unchanged td { background: transparent; }
.diff-row-added td     { background: rgba(34,197,94,0.12); }
.diff-row-removed td   { background: rgba(239,68,68,0.12); }
.diff-row-modified td  { background: rgba(234,179,8,0.12); }
.diff-row-added    .diff-lineno { color: #22c55e; }
.diff-row-removed  .diff-lineno { color: #ef4444; }
.diff-row-modified .diff-lineno { color: #eab308; }
.diff-hunk-sep {
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 2px 6px;
}
.diff-tag-added    { color: #22c55e; font-weight: 700; }
.diff-tag-removed  { color: #ef4444; font-weight: 700; }
.diff-tag-modified { color: #eab308; font-weight: 700; }
.diff-gls-badge {
  display: inline-block;
  font-size: 0.65rem;
  padding: 0 3px;
  border-radius: 3px;
  background: rgba(99,102,241,0.2);
  color: #6366f1;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── BibCheck UX improvements ──────────────────────────────────────────── */
.bibcheck-section {
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.bibcheck-section-summary {
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  color: var(--text);
  user-select: none;
}
.bibcheck-section-summary::-webkit-details-marker { display: none; }
.bibcheck-section-summary::before {
  content: "▶";
  font-size: 0.65rem;
  transition: transform 0.2s;
  color: var(--muted);
  flex-shrink: 0;
}
details[open] .bibcheck-section-summary::before { transform: rotate(90deg); }
.bibcheck-section > *:not(summary) {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}
.bibcheck-section > *:last-child {
  padding-bottom: 0.5rem;
}

/* Summary bar */
.bibcheck-summary-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}
.bibcheck-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.bibcheck-badge-red   { background: #fee2e2; color: #dc2626; }
.bibcheck-badge-amber { background: #fef3c7; color: #d97706; }
.bibcheck-badge-green { background: #dcfce7; color: #16a34a; }

/* Filter input */
.bibcheck-filter-input {
  flex: 1;
  font-size: 0.82rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}
.bibcheck-filter-input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

/* Last-checked note */
#bibcheck-last-checked {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.25rem 0 0;
}

@media (prefers-color-scheme: dark) {
  .bibcheck-badge-red   { background: #450a0a; color: #f87171; }
  .bibcheck-badge-amber { background: #451a03; color: #f0b429; }
  .bibcheck-badge-green { background: #052e16; color: #4ade80; }
}
.dark .bibcheck-badge-red   { background: #450a0a; color: #f87171; }
.dark .bibcheck-badge-amber { background: #451a03; color: #f0b429; }
.dark .bibcheck-badge-green { background: #052e16; color: #4ade80; }

/* ── Sticky mode bar ────────────────────────────────────────────────────── */
/* The tiered nav is always compact (icon + label pills), so the old
   scroll-triggered .compact toggle and its mobile mirror are gone — the
   base .mode-card rules ARE the compact form.  Small screens just tighten
   the pills slightly. */
@media (max-width: 480px) {
  .mode-selector .mode-card { padding: 0.35rem 0.6rem; }
  .mode-selector .mode-title { font-size: 0.82rem; }
}

/* ── BibCheck jump bar ──────────────────────────────────────────────────── */
#bibcheck-jump-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.2rem 0;
}
.bibcheck-jump-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.bibcheck-jump-pill:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Back-to-top button ─────────────────────────────────────────────────── */
#back-to-top {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}
#back-to-top.visible { opacity: 0.85; pointer-events: auto; }
#back-to-top:hover { opacity: 1; background: var(--surface); }

/* ── Duplicate pair cards ───────────────────────────────────────────────── */
.bibcheck-dupe-pair {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.6rem;
  background: var(--surface);
}
.bibcheck-dupe-pair:last-child { margin-bottom: 0; }

/* ── Bibliography health dashboard ─────────────────────────────────────── */
.bibcheck-health-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.83rem;
}
.bibcheck-health-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
  color: var(--text);
}
.bibcheck-health-entries {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}
.bibcheck-health-progress-track {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}
.bibcheck-health-progress-bg {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  min-width: 60px;
}
.bibcheck-health-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease, background 0.35s ease;
  width: 0%;
}
.bibcheck-health-pct {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  min-width: 7em;
  text-align: right;
}
.bibcheck-health-breakdown {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}
.bibcheck-health-remaining {
  color: var(--muted);
  font-size: 0.78rem;
}
.bibcheck-health-alldone {
  color: #16a34a;
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.dark .bibcheck-health-alldone { color: #4ade80; }

/* ── Issue navigation bar ───────────────────────────────────────────────── */
.bibcheck-issue-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.bibcheck-issue-nav-counter {
  flex: 1;
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.bibcheck-nav-btn {
  font-size: 0.8rem !important;
  padding: 0.2rem 0.55rem !important;
  white-space: nowrap;
}

/* Current issue highlight (set by JS navigation) */
.bibcheck-issue-current {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
  scroll-margin: 80px;
}
