/* ==========================================================================
   Citation Matcher — visual design system
   ========================================================================== */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;

  --ink-900: #0b1020;
  --ink-800: #16203a;
  --ink-700: #2b3648;
  --ink-500: #566072;
  --ink-400: #737e91;
  --ink-300: #98a1b1;

  --canvas: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fafbfd;

  --line: rgba(16, 24, 40, 0.08);
  --line-strong: rgba(16, 24, 40, 0.14);

  --accent: #4f46e5;
  --accent-strong: #4338ca;
  --accent-ink: #312e81;
  --accent-soft: rgba(79, 70, 229, 0.08);
  --accent-ring: rgba(79, 70, 229, 0.16);

  --success: #15803d;
  --success-strong: #166534;
  --success-soft: rgba(21, 128, 61, 0.1);
  --success-ring: rgba(21, 128, 61, 0.18);

  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 6px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.04),
    0 14px 28px -14px rgba(16, 24, 40, 0.16);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.04),
    0 30px 60px -28px rgba(16, 24, 40, 0.3);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-800);
  background-color: var(--canvas);
  background-image:
    radial-gradient(900px 520px at 8% -12%, rgba(99, 102, 241, 0.16), transparent 62%),
    radial-gradient(760px 460px at 96% -6%, rgba(20, 184, 166, 0.12), transparent 58%),
    radial-gradient(700px 480px at 50% 108%, rgba(244, 114, 182, 0.08), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv05" 1, "ss01" 1;
}

::selection {
  background: rgba(79, 70, 229, 0.16);
}

.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ============================ Header ============================ */

.site-header {
  padding: clamp(2.5rem, 6vw, 4.25rem) 0 clamp(1.75rem, 4vw, 2.75rem);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 1.4rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(145deg, #6366f1 0%, #4338ca 55%, #3730a3 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset,
    0 8px 18px -8px rgba(67, 56, 202, 0.85);
}

.brand-mark svg {
  width: 19px;
  height: 19px;
}

.brand-name {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.site-header h1 {
  margin: 0 0 0.8rem;
  font-family: var(--font-display);
  font-weight: 640;
  font-size: clamp(2.2rem, 3vw, 3.3rem);
  line-height: 1.06;
  letter-spacing: -0.033em;
  color: var(--ink-900);
  font-optical-sizing: auto;
}

.site-header h1 em {
  font-style: normal;
  background: linear-gradient(100deg, #4f46e5, #7c3aed 55%, #0d9488);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  margin: 0;
  max-width: 58ch;
  font-size: 1.03rem;
  color: var(--ink-500);
}

.header-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.32rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-500);
  box-shadow: var(--shadow-xs);
}

.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot, var(--accent));
}

/* ============================ Cards ============================ */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: clamp(1.35rem, 3.2vw, 2.15rem);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

.form-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(79, 70, 229, 0.55),
    rgba(13, 148, 136, 0.4),
    transparent
  );
}

/* ============================ Form sections ============================ */

.form-section + .form-section {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin-bottom: 1.35rem;
}

.section-num {
  flex: none;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.section-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink-900);
}

.section-sub {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-400);
}

/* ============================ Fields ============================ */

.field {
  margin-bottom: 1.35rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
}

label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink-800);
}

.hint {
  margin: 0 0 0.6rem;
  font-size: 0.815rem;
  line-height: 1.5;
  color: var(--ink-400);
}

input[type="text"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink-900);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease),
    background-color 0.18s var(--ease);
}

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

input[type="text"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
textarea:hover,
select:hover {
  border-color: rgba(16, 24, 40, 0.22);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

textarea {
  min-height: 132px;
  line-height: 1.65;
  resize: vertical;
}

textarea#scientists {
  min-height: 116px;
}

textarea::-webkit-scrollbar {
  width: 10px;
}

textarea::-webkit-scrollbar-thumb {
  background: rgba(16, 24, 40, 0.16);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1.05rem;
  height: 1.05rem;
  cursor: pointer;
}

/* ============================ Autocomplete ============================ */

.autocomplete-wrap {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 0.35rem);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.autocomplete-list.hidden {
  display: none;
}

.autocomplete-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  text-align: left;
  color: var(--ink-800);
  cursor: pointer;
  transition: background-color 0.14s var(--ease);
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: var(--accent-soft);
}

.autocomplete-item-name {
  font-weight: 600;
}

.autocomplete-item-hint {
  color: var(--ink-400);
  font-size: 0.82rem;
}

.autocomplete-item-count {
  margin-left: auto;
  color: var(--ink-300);
  font-size: 0.78rem;
  white-space: nowrap;
}

/* ============================ Presets ============================ */

.preset-group {
  margin-bottom: 0.9rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(248, 249, 252, 0.9), rgba(255, 255, 255, 0.6));
}

.preset-label {
  margin-bottom: 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-400);
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-btn {
  --chip: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 550;
  color: var(--ink-700);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease),
    background-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.preset-btn::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--chip);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--chip) 16%, transparent);
}

.preset-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--chip) 42%, var(--line-strong));
  background: color-mix(in srgb, var(--chip) 5%, #fff);
  box-shadow: var(--shadow-sm);
}

.preset-btn:active:not(:disabled) {
  transform: translateY(0);
}

.preset-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.preset-btn-color-0 { --chip: #3b82f6; }
.preset-btn-color-1 { --chip: #10b981; }
.preset-btn-color-2 { --chip: #8b5cf6; }
.preset-btn-color-3 { --chip: #f97316; }
.preset-btn-color-4 { --chip: #ec4899; }
.preset-btn-color-5 { --chip: #14b8a6; }
.preset-btn-color-6 { --chip: #f59e0b; }
.preset-btn-color-7 { --chip: #6366f1; }

/* ============================ Choice controls ============================ */

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease);
}

.checkbox-field:has(input:checked) {
  border-color: rgba(79, 70, 229, 0.35);
  background: var(--accent-soft);
}

.checkbox-field:has(input:disabled) {
  opacity: 0.62;
  cursor: not-allowed;
  border-color: var(--line);
  background: var(--surface-2);
}

.checkbox-field:has(input:disabled) label {
  cursor: not-allowed;
}

.checkbox-field input {
  margin-top: 0.28rem;
}

.checkbox-field label {
  margin-bottom: 0;
  font-weight: 550;
  cursor: pointer;
}

.checkbox-field .hint {
  margin: 0.1rem 0 0;
}

.source-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.source-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.source-option:hover {
  border-color: rgba(16, 24, 40, 0.24);
}

.source-option:has(input:checked) {
  border-color: rgba(79, 70, 229, 0.45);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.source-option label {
  margin-bottom: 0;
  font-weight: 550;
  cursor: pointer;
}

.source-option .source-note {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--ink-400);
}

/* ============================ Buttons ============================ */

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.9rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--line);
}

.form-actions .hint {
  margin: 0;
  max-width: 42ch;
}

button[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.78rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #5b54ec 0%, #4338ca 100%);
  color: #fff;
  font-family: inherit;
  font-size: 0.97rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset,
    0 12px 24px -12px rgba(67, 56, 202, 0.95);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease),
    filter 0.18s var(--ease);
}

button[type="submit"] svg {
  width: 16px;
  height: 16px;
  transition: transform 0.18s var(--ease);
}

button[type="submit"]:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset,
    0 18px 30px -14px rgba(67, 56, 202, 0.95);
}

button[type="submit"]:hover:not(:disabled) svg {
  transform: translateX(3px);
}

button[type="submit"]:active:not(:disabled) {
  transform: translateY(0);
}

button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

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

.export-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 1rem 0 1.35rem;
}

.export-hint {
  flex: 1 1 100%;
  margin: 0 0 0.15rem;
  font-size: 0.84rem;
  color: var(--ink-400);
}

.review-banner-slot {
  margin: 1.1rem 0 0.35rem;
}

.review-banner-slot.hidden {
  display: none;
}

.review-banner {
  margin: 0;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(79, 70, 229, 0.22);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(238, 242, 255, 0.75), rgba(255, 255, 255, 0.9));
}

.review-banner--pinned {
  position: fixed;
  top: 0;
  z-index: 200;
  margin: 0;
  padding: 0.55rem 1.15rem 0.65rem;
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: 0 8px 24px -12px rgba(16, 24, 40, 0.28);
  backdrop-filter: blur(10px);
}

.review-banner--pinned .review-bulk-actions {
  display: none;
}

.review-banner--pinned .review-banner-head {
  margin-bottom: 0.15rem;
}

.review-banner--pinned .review-banner-text {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
}

.review-banner-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}

.review-banner-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.export-btn.export-btn-banner {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  gap: 0.3rem;
  line-height: 1;
  box-shadow: none;
}

.export-btn.export-btn-banner svg {
  width: 12px;
  height: 12px;
}

.export-btn.export-btn-banner:hover:not(:disabled) {
  transform: none;
  filter: brightness(1.04);
  box-shadow: none;
}

.export-btn.export-btn-banner:active:not(:disabled) {
  transform: none;
}

.review-banner--pinned .review-banner-head {
  margin-bottom: 0;
  gap: 0.45rem 0.75rem;
}

.review-banner--pinned .review-banner-controls {
  margin-left: auto;
}

.review-banner h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-ink);
}

.review-banner-text {
  margin: 0 0 0.75rem;
  font-size: 0.86rem;
  color: var(--ink-500);
}

.approval-summary {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--accent-ink);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.review-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.bulk-approval-btn {
  padding: 0.42rem 0.8rem;
  border: 1px solid rgba(79, 70, 229, 0.35);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease);
}

.bulk-approval-btn:hover {
  background: var(--accent-soft);
}

.bulk-approval-btn-muted {
  border-color: var(--line-strong);
  color: var(--ink-500);
}

.bulk-approval-btn-muted:hover {
  background: var(--surface-2);
}

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #22a858 0%, var(--success) 100%);
  font-family: inherit;
  font-size: 0.87rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset,
    0 10px 20px -12px rgba(21, 128, 61, 0.85);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease),
    filter 0.18s var(--ease);
}

.export-btn svg {
  width: 15px;
  height: 15px;
  color: #fff;
}

.export-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset,
    0 14px 24px -12px rgba(21, 128, 61, 0.9);
}

.export-btn:active:not(:disabled) {
  transform: translateY(0);
}

.export-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  filter: none;
  box-shadow: none;
}

/* ============================ Loading ============================ */

#loading {
  display: none;
  margin-bottom: 1.5rem;
  padding: 1.05rem 1.25rem;
  border: 1px solid rgba(79, 70, 229, 0.22);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(238, 242, 255, 0.9), rgba(255, 255, 255, 0.85));
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}

#loading.visible {
  display: block;
}

.loading-content {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.loading-top {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}

.loading-status {
  display: flex;
  flex: 1;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  min-width: 0;
}

#loading-text {
  font-size: 0.92rem;
  line-height: 1.45;
}

.loading-percent {
  flex: none;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-strong);
}

.loading-progress {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: rgba(79, 70, 229, 0.12);
}

.loading-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6366f1 0%, var(--accent) 55%, #7c3aed 100%);
  transition: width 0.35s var(--ease);
}

.spinner {
  flex: none;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(79, 70, 229, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================ Results ============================ */

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 2.25rem 0 1.1rem;
}

.results-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 640;
  font-size: 1.55rem;
  letter-spacing: -0.028em;
  color: var(--ink-900);
  font-optical-sizing: auto;
}

#warnings,
#placement-warnings {
  margin-bottom: 0.85rem;
}

.warning {
  position: relative;
  padding: 0.75rem 1rem 0.75rem 1.1rem;
  margin-bottom: 0.5rem;
  border: 1px solid rgba(180, 83, 9, 0.2);
  border-left: 3px solid #d97706;
  border-radius: var(--radius-sm);
  background: #fffbeb;
  color: #92400e;
  font-size: 0.87rem;
}

.warning-error {
  border-color: rgba(185, 28, 28, 0.2);
  border-left-color: #dc2626;
  background: #fef2f2;
  color: #991b1b;
}

#meta {
  padding: 0.7rem 1rem;
  margin-bottom: 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.66);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: 0.855rem;
  color: var(--ink-500);
}

#meta:empty {
  display: none;
}

.result-card {
  padding: 1.15rem 1.35rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
  animation: rise 0.5s var(--ease) both;
}

.result-card:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 70, 229, 0.28);
  box-shadow: var(--shadow-md);
}

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

.result-card:nth-child(1) { animation-delay: 0.02s; }
.result-card:nth-child(2) { animation-delay: 0.06s; }
.result-card:nth-child(3) { animation-delay: 0.1s; }
.result-card:nth-child(4) { animation-delay: 0.14s; }
.result-card:nth-child(5) { animation-delay: 0.18s; }
.result-card:nth-child(6) { animation-delay: 0.22s; }
.result-card:nth-child(7) { animation-delay: 0.26s; }
.result-card:nth-child(n + 8) { animation-delay: 0.3s; }

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.result-rank {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.4rem;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.14), rgba(79, 70, 229, 0.1));
  border: 1px solid rgba(79, 70, 229, 0.2);
  color: var(--accent-ink);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result-score {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.79rem;
  font-weight: 550;
  color: var(--ink-400);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.score-bar {
  display: block;
  width: 82px;
  height: 5px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.08);
  overflow: hidden;
}

.score-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #0d9488);
}

.result-title {
  margin: 0.2rem 0 0.45rem;
  font-size: 1.06rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.011em;
}

.result-title a {
  color: var(--ink-900);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: color 0.18s var(--ease), background-size 0.25s var(--ease);
}

.result-title a:hover {
  color: var(--accent);
  background-size: 100% 1px;
}

.result-meta {
  margin: 0 0 0.55rem;
  font-size: 0.845rem;
  color: var(--ink-400);
}

.result-meta a {
  color: #0f766e;
  font-weight: 550;
  text-decoration: none;
  border-bottom: 1px solid rgba(15, 118, 110, 0.3);
}

.result-meta a:hover {
  border-bottom-color: #0f766e;
}

.result-abstract {
  margin: 0;
  font-size: 0.895rem;
  line-height: 1.65;
  color: var(--ink-700);
}

.result-abstract:empty {
  display: none;
}

#results > p {
  padding: 2.25rem 1rem;
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
  color: var(--ink-400);
}

/* ============================ Badges ============================ */

.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.12rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

.badge-pubmed {
  background: #ecfeff;
  color: #0e7490;
  border-color: #a5f3fc;
}

.badge-openalex {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #ddd6fe;
}

.badge-open-access {
  background: #ecfdf5;
  color: #15803d;
  border-color: #bbf7d0;
}

.badge-abstract-only {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.badge-title-only {
  background: #eef2ff;
  color: #4338ca;
  border-color: #c7d2fe;
}

/* ============================ Citation suggestions ============================ */

.citation-suggestions {
  margin-top: 0.95rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line-strong);
}

.citation-suggestions h3 {
  margin: 0 0 0.6rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-400);
}

.citation-suggestion-item {
  position: relative;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
  border-left: 2px solid rgba(79, 70, 229, 0.4);
  background: rgba(79, 70, 229, 0.045);
  font-size: 0.855rem;
  line-height: 1.6;
  color: var(--ink-700);
}

.citation-suggestion-item:last-child {
  margin-bottom: 0;
}

.citation-suggestion-item strong {
  color: var(--accent-ink);
  font-weight: 600;
}

.citation-suggestion-item em {
  color: var(--ink-400);
}

.citation-approval {
  margin-top: 0.95rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.citation-approval-head {
  margin-bottom: 0.45rem;
}

.approval-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.approval-status-pending {
  color: #b45309;
}

.approval-status-approved {
  color: #15803d;
}

.approval-status-rejected {
  color: var(--ink-400);
}

.citation-approval-prompt {
  margin: 0 0 0.65rem;
  font-size: 0.86rem;
  font-weight: 550;
  color: var(--ink-700);
}

.citation-approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.approval-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-700);
  cursor: pointer;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease),
    color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.approval-btn svg {
  width: 14px;
  height: 14px;
}

.approval-accept.active,
.approval-accept:hover {
  border-color: rgba(21, 128, 61, 0.45);
  background: rgba(21, 128, 61, 0.08);
  color: #15803d;
}

.approval-accept.active {
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.12);
}

.approval-decline.active,
.approval-decline:hover {
  border-color: rgba(100, 116, 139, 0.45);
  background: rgba(100, 116, 139, 0.08);
  color: var(--ink-500);
}

.approval-decline.active {
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.1);
}

.result-card.approval-pending {
  border-left: 3px solid #f59e0b;
}

.result-card.approval-approved {
  border-left: 3px solid #16a34a;
}

.result-card.approval-rejected {
  border-left: 3px solid var(--line-strong);
  opacity: 0.72;
}

.paper-rank-badge.badge-approved {
  background: rgba(21, 128, 61, 0.14);
  color: #15803d;
  border-color: rgba(21, 128, 61, 0.35);
}

.paper-rank-badge.badge-rejected {
  background: rgba(100, 116, 139, 0.1);
  color: var(--ink-400);
  border-color: var(--line-strong);
  text-decoration: line-through;
}

.paper-rank-badge.badge-pending {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.35);
}

/* ============================ Annotated discussion ============================ */

.annotated-discussion-card {
  padding: 1.35rem 1.5rem;
  margin: 0 0 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.annotated-discussion-card h2 {
  margin: 0 0 0.95rem;
  font-family: var(--font-display);
  font-weight: 640;
  font-size: 1.2rem;
  letter-spacing: -0.024em;
  color: var(--ink-900);
  font-optical-sizing: auto;
}

.annotated-sentence {
  margin-bottom: 0.35rem;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink-700);
  transition: background-color 0.18s var(--ease);
}

.annotated-sentence.highlight {
  border-left: 2px solid rgba(79, 70, 229, 0.45);
  background: rgba(79, 70, 229, 0.05);
  color: var(--ink-900);
}

.paper-rank-badge {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.05rem 0.45rem;
  border: 1px solid rgba(79, 70, 229, 0.25);
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.paper-rank-badge:hover {
  transform: translateY(-1px);
  background: var(--accent-soft);
}

.result-card.flash {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow-md);
}

/* ============================ Errors & footer ============================ */

#error {
  padding: 0.85rem 1.1rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(185, 28, 28, 0.22);
  border-left: 3px solid #dc2626;
  border-radius: var(--radius-md);
  background: #fef2f2;
  color: #991b1b;
  font-size: 0.9rem;
  box-shadow: var(--shadow-xs);
}

.site-footer {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-300);
  text-align: center;
}

.site-footer-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0;
  line-height: 1;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
}

.site-footer a svg {
  display: block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.site-footer a:hover {
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* ============================ Responsive ============================ */

@media (max-width: 720px) {
  .container {
    padding: 0 1.1rem 3rem;
  }

  .field-row,
  .source-options {
    grid-template-columns: 1fr;
  }

  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  button[type="submit"] {
    justify-content: center;
    width: 100%;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
