/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f4f5f7;
  color: #1a1a2e;
  line-height: 1.5;
  min-height: 100vh;
}

/* =============================================
   HEADER
   ============================================= */
.site-header {
  background-color: #ffffff;
  border-bottom: 1px solid #e2e5ea;
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-title h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.01em;
}

.header-subtitle {
  font-size: 0.82rem;
  color: #6b7280;
  margin-top: 3px;
}

.header-stats {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f0f4ff;
  border: 1px solid #d1dbf9;
  border-radius: 10px;
  padding: 8px 16px;
  min-width: 64px;
}

.stat-pill--total {
  background: #f5f5f5;
  border-color: #ddd;
}

.stat-number {
  font-size: 1.4rem;
  font-weight: 700;
  color: #2f54eb;
  line-height: 1;
}

.stat-pill--total .stat-number {
  color: #6b7280;
}

.stat-label {
  font-size: 0.7rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* =============================================
   FILTER BAR
   ============================================= */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.82rem;
  color: #6b7280;
  font-weight: 500;
  margin-right: 4px;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #374151;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  border-color: #2f54eb;
  color: #2f54eb;
  background: #f0f4ff;
}

.filter-btn.active {
  background: #2f54eb;
  border-color: #2f54eb;
  color: #ffffff;
}

.filter-btn.active .filter-count {
  background: rgba(255,255,255,0.25);
  color: #fff;
}

.filter-count {
  display: inline-block;
  background: #e5e7eb;
  color: #374151;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  line-height: 1.4;
  transition: all 0.15s;
}

.source-icon {
  font-size: 0.9em;
}

.filter-bar-sep {
  width: 1px;
  height: 20px;
  background: #e5e7eb;
  margin: 0 4px;
}

.hidden-toggle {
  display: none;
  align-items: center;
  gap: 0;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px dashed #d1d5db;
  background: transparent;
  color: #6b7280;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hidden-toggle:hover {
  border-color: #9ca3af;
  color: #374151;
  background: #f9fafb;
}

.hidden-toggle--active {
  border-color: #f59e0b;
  color: #92400e;
  background: #fffbeb;
}

.hidden-toggle--active:hover {
  border-color: #d97706;
  background: #fef3c7;
}

.hidden-toggle--dup {
  border-color: #c4b5fd;
  color: #5b21b6;
}

.hidden-toggle--dup:hover {
  border-color: #7c3aed;
  color: #4c1d95;
  background: #f5f3ff;
}

.hidden-toggle--dup.hidden-toggle--active {
  border-color: #7c3aed;
  color: #4c1d95;
  background: #f5f3ff;
}

.hidden-toggle--dup.hidden-toggle--active:hover {
  background: #ede9fe;
}

/* =============================================
   ARTICLE CARDS
   ============================================= */
.articles-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.article-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px 18px;
  transition: opacity 0.25s ease, box-shadow 0.15s ease;
}

.article-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.article-card--deselected {
  opacity: 0.45;
  background: #fafafa;
}

.article-card--deselected:hover {
  opacity: 0.6;
}

.article-card--gone {
  display: none;
}

.article-card--dup-gone {
  display: none;
}

.article-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.article-checkbox-wrap {
  padding-top: 2px;
  flex-shrink: 0;
}

.article-checkbox {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: #2f54eb;
}

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

.article-meta-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

/* =============================================
   RELEVANCE BADGE
   ============================================= */
.relevance-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  letter-spacing: 0.03em;
  min-width: 36px;
  text-align: center;
}

.relevance-badge--green {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.relevance-badge--yellow {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.relevance-badge--red {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* =============================================
   FOUND-IN TAG
   ============================================= */
.found-in-tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.70rem;
  color: #9ca3af;
  font-style: italic;
  white-space: nowrap;
}

/* =============================================
   DUPLICATE BADGE
   ============================================= */
.duplicate-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  letter-spacing: 0.03em;
  background: #f5f3ff;
  color: #5b21b6;
  border: 1px solid #c4b5fd;
}

/* =============================================
   SOURCE TAG
   ============================================= */
.source-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid transparent;
}

.source-tag--gmail {
  background: #fce8e6;
  color: #c5221f;
  border-color: #f5c6c4;
}

.source-tag--brave {
  background: #fff0e6;
  color: #b35900;
  border-color: #ffd9b3;
}

.source-tag--reddit {
  background: #fff0f0;
  color: #b33a00;
  border-color: #ffccb3;
}

.source-tag--forum {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
}

/* =============================================
   ARTICLE CONTENT
   ============================================= */
.article-headline {
  font-size: 0.97rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.4;
  margin-bottom: 5px;
}

.article-headline a {
  color: #111827;
  text-decoration: none;
  transition: color 0.15s;
}

.article-headline a:hover {
  color: #2f54eb;
  text-decoration: underline;
}

.article-summary {
  font-size: 0.85rem;
  color: #4b5563;
  line-height: 1.55;
}

.score-reason {
  font-size: 0.78rem;
  color: #9ca3af;
  font-style: italic;
  margin-top: 4px;
  line-height: 1.45;
}

/* =============================================
   NOTE ROW (rejection feedback)
   ============================================= */
.article-note-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.note-input {
  flex: 1;
  min-width: 180px;
  max-width: 420px;
  padding: 5px 10px;
  font-size: 0.82rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  color: #374151;
  background: #f9fafb;
  outline: none;
  transition: border-color 0.15s;
}

.note-input:focus {
  border-color: #2f54eb;
  background: #fff;
}

.note-save-btn {
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  background: #2f54eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.note-save-btn:hover {
  background: #1d3fc7;
}


/* =============================================
   CLUSTER TOGGLE
   ============================================= */
.hidden-toggle--cluster {
  border-color: #bfdbfe;
  color: #1e40af;
}

.hidden-toggle--cluster:hover {
  border-color: #3b82f6;
  color: #1e3a8a;
  background: #eff6ff;
}

.hidden-toggle--cluster.hidden-toggle--active {
  border-color: #3b82f6;
  color: #1e3a8a;
  background: #eff6ff;
}

.hidden-toggle--cluster.hidden-toggle--active:hover {
  background: #dbeafe;
}

/* =============================================
   CLUSTER SOURCES (inline expander)
   ============================================= */
.article-card--cluster-gone {
  display: none;
}

.cluster-sources {
  margin-top: 8px;
}

.cluster-expand-btn {
  font-size: 0.78rem;
  color: #2f54eb;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cluster-expand-btn:hover {
  color: #1d3fc7;
}

.cluster-list {
  margin-top: 6px;
  padding: 8px 10px;
  background: #f8faff;
  border-left: 2px solid #d1dbf9;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cluster-item {
  font-size: 0.82rem;
  color: #374151;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.cluster-item a {
  color: #2f54eb;
  text-decoration: none;
}

.cluster-item a:hover {
  text-decoration: underline;
}

.cluster-item-source {
  font-size: 0.72rem;
  color: #9ca3af;
  flex-shrink: 0;
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: #6b7280;
}

.empty-state code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-stats {
    align-self: flex-end;
  }

  .filter-bar {
    gap: 6px;
  }

  .article-note-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .note-input {
    width: 100%;
    max-width: 100%;
  }
}
