.rrf-finder {
  --rrf-bg: #f4f8ff;
  --rrf-surface: #ffffff;
  --rrf-text: #0f172a;
  --rrf-muted: #4b5563;
  --rrf-primary: #0f2a5f;
  --rrf-secondary: #1d4ed8;
  --rrf-accent: #0e9f6e;
  --rrf-border: #d8e2f2;
  --rrf-warning: #7f1d1d;
  --rrf-warning-bg: #fee2e2;

  max-width: 1180px;
  margin: 0 auto;
  color: var(--rrf-text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at 7% -16%, #c8ddff 0, rgba(200, 221, 255, 0) 42%),
    radial-gradient(circle at 96% -24%, #d0f5e7 0, rgba(208, 245, 231, 0) 45%),
    var(--rrf-bg);
  border-radius: 24px;
  padding: 20px;
}

.rrf-hero {
  display: grid;
  gap: 14px;
  background: linear-gradient(130deg, var(--rrf-primary) 0%, #17387a 35%, var(--rrf-secondary) 100%);
  border-radius: 20px;
  padding: 28px;
  color: #fff;
  box-shadow: 0 15px 35px rgba(15, 42, 95, 0.35);
}

.rrf-kicker {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  opacity: 0.9;
  margin: 0 0 8px;
}

.rrf-hero h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw, 2.2rem);
}

.rrf-hero p {
  margin: 10px 0 0;
  max-width: 72ch;
  line-height: 1.5;
}

.rrf-hero-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rrf-hero-chips span {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.rrf-panel {
  background: var(--rrf-surface);
  border: 1px solid var(--rrf-border);
  border-radius: 18px;
  margin-top: 18px;
  padding: 18px;
  box-shadow: 0 8px 26px rgba(15, 42, 95, 0.08);
}

.rrf-form.is-loading {
  opacity: 0.6;
  pointer-events: none;
}

.rrf-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.rrf-field {
  margin-bottom: 14px;
}

.rrf-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.rrf-field input,
.rrf-field textarea,
.rrf-field select,
.rrf-inline-group select {
  width: 100%;
  border: 1px solid var(--rrf-border);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
  color: var(--rrf-text);
}

.rrf-field textarea {
  resize: vertical;
}

.rrf-abstract-meta {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--rrf-muted);
}

.rrf-keyword-chips {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rrf-chip {
  border: 1px solid #c6d8ff;
  border-radius: 999px;
  background: #e9f1ff;
  color: #1e3a8a;
  font-size: 0.84rem;
  padding: 6px 10px;
  cursor: pointer;
}

.rrf-help {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--rrf-muted);
}

.rrf-advanced {
  margin-top: 6px;
  border: 1px solid var(--rrf-border);
  border-radius: 12px;
  background: #f8fbff;
}

.rrf-advanced summary {
  cursor: pointer;
  padding: 12px;
  font-weight: 600;
}

.rrf-advanced-grid {
  padding: 2px 12px 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.rrf-checkbox-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.rrf-checkbox-grid label {
  font-weight: 500;
  margin-bottom: 0;
}

.rrf-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.rrf-btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.rrf-btn:hover {
  transform: translateY(-1px);
}

.rrf-btn-primary {
  background: var(--rrf-primary);
  color: #fff;
  box-shadow: 0 8px 16px rgba(15, 42, 95, 0.25);
}

.rrf-btn-primary:hover {
  background: #16397f;
}

.rrf-btn-ghost {
  background: #fff;
  border-color: var(--rrf-border);
  color: var(--rrf-text);
}

.rrf-loading {
  margin-top: 14px;
  border: 1px solid var(--rrf-border);
  border-radius: 12px;
  background: #f8fbff;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.rrf-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #c6d8ff;
  border-top-color: var(--rrf-secondary);
  border-radius: 50%;
  animation: rrf-spin 0.8s linear infinite;
}

@keyframes rrf-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.rrf-results-controls {
  margin-top: 16px;
  border: 1px solid var(--rrf-border);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #f8fbff;
  position: sticky;
  top: 14px;
  z-index: 3;
}

.rrf-smart-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rrf-tab {
  border: 1px solid #c7d6ef;
  background: #eef4ff;
  color: #1e3a8a;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.rrf-tab.is-active {
  background: #1d4ed8;
  color: #fff;
  border-color: #1d4ed8;
}

.rrf-inline-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rrf-inline-group label {
  font-size: 0.88rem;
  font-weight: 600;
}

.rrf-view-toggle {
  display: inline-flex;
  border: 1px solid #c7d6ef;
  border-radius: 10px;
  overflow: hidden;
}

.rrf-mini-btn {
  border: none;
  background: #fff;
  color: #334155;
  font-size: 0.8rem;
  padding: 7px 11px;
  cursor: pointer;
}

.rrf-mini-btn + .rrf-mini-btn {
  border-left: 1px solid #c7d6ef;
}

.rrf-mini-btn.is-active {
  background: #e7efff;
  color: #1e3a8a;
  font-weight: 700;
}

.rrf-results-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.rrf-results-grid.is-list {
  grid-template-columns: 1fr;
}

.rrf-card {
  border: 1px solid var(--rrf-border);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  box-shadow: 0 10px 22px rgba(15, 42, 95, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rrf-results-grid.is-list .rrf-card {
  gap: 12px;
}

.rrf-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.rrf-card-title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.3;
}

.rrf-card-sub {
  margin: 4px 0 0;
  color: var(--rrf-muted);
  font-size: 0.88rem;
}

.rrf-score-wrap {
  text-align: right;
}

.rrf-score {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 0.84rem;
}

.rrf-confidence {
  display: block;
  font-size: 0.78rem;
  color: var(--rrf-muted);
  margin-top: 4px;
}

.rrf-meta,
.rrf-metrics,
.rrf-link-row,
.rrf-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rrf-badge {
  font-size: 0.78rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
}

.rrf-metrics span {
  font-size: 0.82rem;
  color: var(--rrf-muted);
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 4px 8px;
}

.rrf-summary {
  margin: 0;
  color: #374151;
  font-size: 0.9rem;
  line-height: 1.45;
}

.rrf-why {
  margin: 0;
  padding-left: 18px;
  color: #1f2937;
  font-size: 0.86rem;
}

.rrf-warnings {
  display: grid;
  gap: 6px;
}

.rrf-warning {
  margin: 0;
  padding: 8px;
  border-radius: 8px;
  background: var(--rrf-warning-bg);
  color: var(--rrf-warning);
  font-size: 0.82rem;
}

.rrf-link-row a {
  font-size: 0.84rem;
  color: #1d4ed8;
  text-decoration: none;
}

.rrf-link-row a:hover {
  text-decoration: underline;
}

.rrf-empty {
  border: 1px dashed #cbd5e1;
  padding: 16px;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--rrf-muted);
}

.rrf-empty-setup {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
}

.rrf-compare {
  margin-top: 18px;
  border: 1px solid var(--rrf-border);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
}

.rrf-compare-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.rrf-compare-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.rrf-compare-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.rrf-compare-table th,
.rrf-compare-table td {
  border: 1px solid #e5e7eb;
  padding: 8px;
  text-align: left;
  font-size: 0.85rem;
}

.rrf-compare-actions {
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.rrf-modal {
  border: none;
  border-radius: 14px;
  max-width: 720px;
  width: calc(100% - 30px);
  box-shadow: 0 20px 44px rgba(15, 42, 95, 0.25);
}

.rrf-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.rrf-modal-content {
  max-height: 70vh;
  overflow: auto;
  margin-bottom: 10px;
}

.rrf-disclaimer {
  margin-top: 14px;
  font-size: 0.84rem;
  color: #334155;
  border-top: 1px dashed var(--rrf-border);
  padding-top: 12px;
}

.rrf-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #0f172a;
  color: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}

.rrf-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.rrf-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

@media (max-width: 920px) {
  .rrf-grid-2,
  .rrf-advanced-grid {
    grid-template-columns: 1fr;
  }

  .rrf-results-controls {
    position: static;
  }

  .rrf-card-head {
    flex-direction: column;
  }

  .rrf-score-wrap {
    text-align: left;
  }
}
