:root { color-scheme: light; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f7f7fb;
  color: #111;
  font-family: -apple-system, "SF Pro", "Inter", system-ui, sans-serif;
  line-height: 1.5;
}

main#app { max-width: 1100px; margin: 0 auto; padding: 0.5rem; }

/* Top bar */
.topbar {
  background: #1f2937; color: #fff; padding: 0.7rem 0.95rem;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.82rem;
  position: sticky; top: 0; z-index: 10;
}
.topbar .me { font-weight: 600; }
.topbar .stats { font-size: 0.74rem; opacity: 0.85; }

/* Top tabs (desktop) */
.top-tabs { display: none; background: #f3f4f6; border-bottom: 1px solid #e5e7eb; }
.top-tabs .tab {
  flex: 1; text-align: center; padding: 0.6rem; font-size: 0.82rem;
  color: #6b7280; cursor: pointer; text-decoration: none;
}
.top-tabs .tab.active { color: #111; font-weight: 600; box-shadow: inset 0 -2px 0 #2563eb; }

/* Bottom tabs (mobile) */
.bottom-tabs {
  display: flex; background: #fff; border-top: 1px solid #e5e7eb;
  position: sticky; bottom: 0; z-index: 10;
}
.bottom-tabs .tab {
  flex: 1; text-align: center; padding: 0.55rem 0.3rem; font-size: 0.7rem;
  color: #6b7280; cursor: pointer; text-decoration: none;
}
.bottom-tabs .tab.active { color: #2563eb; font-weight: 600; }
.bottom-tabs .tab .icon { display: block; font-size: 1rem; line-height: 1; margin-bottom: 0.15rem; }

@media (min-width: 768px) {
  .top-tabs { display: flex; }
  .bottom-tabs { display: none; }
  main#app { padding: 1rem; }
}

/* Pair grid: stacked on mobile, side-by-side on desktop */
.pair-grid { display: flex; flex-direction: column; gap: 0.7rem; }
@media (min-width: 768px) {
  .pair-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
}

/* Cluster grid: stacked on mobile, 2-col on desktop */
.cluster-grid { display: flex; flex-direction: column; gap: 0.55rem; }
@media (min-width: 768px) {
  .cluster-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.55rem; }
}

/* Article card (pair view) */
.article-card {
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 0.7rem 0.8rem;
  background: #fafafa;
}
.art-meta {
  font-size: 0.72rem; color: #6b7280; margin-bottom: 0.2rem;
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
}
.art-meta .src { font-weight: 600; color: #374151; }
.art-title {
  font-size: 0.94rem; font-weight: 600; line-height: 1.3;
  margin: 0.15rem 0 0.4rem; color: #111;
}
.art-link {
  display: inline-block; font-size: 0.74rem; color: #2563eb;
  text-decoration: none; margin-bottom: 0.45rem;
}
.art-snippet {
  font-size: 0.78rem; line-height: 1.5; color: #374151;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
  overflow: hidden;
}
.article-card.expanded .art-snippet {
  display: block; -webkit-line-clamp: unset;
}
.more-toggle {
  font-size: 0.72rem; color: #6b7280; margin-top: 0.35rem; cursor: pointer;
  background: none; border: none; padding: 0;
}

/* Article row (cluster view) */
.article-row {
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 0.65rem 0.75rem;
  background: #fafafa; margin-bottom: 0; cursor: pointer;
  display: flex; gap: 0.55rem; align-items: flex-start;
}
.article-row.flagged { background: #fee2e2; border-color: #fca5a5; }
.article-row.flagged .art-title { text-decoration: line-through; opacity: 0.7; }
.toggle-flag {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 6px;
  border: 1.5px solid #d1d5db; background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; color: #fff; margin-top: 0.15rem;
}
.article-row.flagged .toggle-flag { border-color: #dc2626; background: #dc2626; }
.art-block { flex: 1; min-width: 0; }

/* Question + verdicts */
.question { font-size: 0.95rem; font-weight: 600; margin: 1.1rem 0 0.5rem; color: #111; }
.verdicts { display: flex; gap: 0.5rem; max-width: 420px; }
.verdict-btn {
  flex: 1; padding: 0.7rem 0.4rem; border: 1px solid #d1d5db; border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 0.85rem; font-weight: 600; color: #111;
  min-height: 44px;
}
.verdict-btn.selected { box-shadow: inset 0 0 0 2px currentColor; }
.verdict-btn[data-verdict="same"], .verdict-btn[data-verdict="yes"] {
  border-color: #10b981; color: #065f46;
}
.verdict-btn[data-verdict="different"], .verdict-btn[data-verdict="no"] {
  border-color: #ef4444; color: #991b1b;
}
.verdict-btn[data-verdict="unsure"] { color: #374151; }

.cluster-hint {
  font-size: 0.78rem; color: #374151; background: #fef3c7;
  padding: 0.55rem 0.65rem; border-radius: 6px; margin-bottom: 0.75rem;
}

.comment-input {
  width: 100%; max-width: 420px; box-sizing: border-box;
  margin-top: 0.75rem; padding: 0.5rem;
  border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 0.85rem; min-height: 2.4rem; color: #111;
}
.footer-row {
  display: flex; justify-content: space-between; gap: 0.5rem;
  margin-top: 0.75rem; max-width: 420px;
}
.skip-btn {
  background: transparent; border: none; color: #6b7280;
  cursor: pointer; font-size: 0.85rem; min-height: 44px;
}
.submit-btn {
  background: #2563eb; color: #fff; border: none;
  padding: 0.6rem 1rem; border-radius: 6px;
  font-size: 0.85rem; cursor: pointer; font-weight: 600;
  min-height: 44px;
}
.submit-btn[disabled], .skip-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* History */
.history-row {
  border-bottom: 1px solid #f3f4f6; padding: 0.6rem 0;
  display: flex; gap: 0.5rem; align-items: center; cursor: pointer;
  text-decoration: none; color: inherit;
}
.history-row:hover { background: #f9fafb; }
.badge {
  display: inline-block; padding: 0.12rem 0.5rem; border-radius: 99px;
  font-size: 0.66rem; font-weight: 700; flex-shrink: 0;
}
.badge.same { background: #d1fae5; color: #065f46; }
.badge.diff { background: #fee2e2; color: #991b1b; }
.badge.unsure { background: #e5e7eb; color: #374151; }
.badge.split { background: #fef3c7; color: #92400e; }
.h-main { flex: 1; min-width: 0; }
.h-title { font-size: 0.8rem; color: #111; line-height: 1.35; }
.h-sub { font-size: 0.68rem; color: #6b7280; margin-top: 0.12rem; }
.h-edit { font-size: 0.72rem; color: #2563eb; flex-shrink: 0; }

.filter-row {
  display: flex; gap: 0.35rem; margin-bottom: 0.55rem; flex-wrap: wrap;
}
.filter-chip {
  font-size: 0.7rem; padding: 0.25rem 0.6rem;
  border: 1px solid #d1d5db; border-radius: 99px; background: #fff;
  color: #374151; cursor: pointer;
}
.filter-chip.active { background: #1f2937; color: #fff; border-color: #1f2937; }

/* Skeleton, toast, empty state */
.skeleton {
  border: 1px solid #e5e7eb; border-radius: 8px; padding: 0.7rem 0.8rem;
  background: linear-gradient(90deg, #eee 25%, #f6f6f6 50%, #eee 75%);
  background-size: 200% 100%; animation: skeleton-shimmer 1.4s infinite;
  height: 7rem;
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.empty-state { padding: 2rem 0.5rem; text-align: center; color: #6b7280; }

.toast-host { position: fixed; left: 0; right: 0; bottom: 1rem; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; z-index: 100; pointer-events: none; }
.toast {
  background: #1f2937; color: #fff; padding: 0.6rem 0.9rem; border-radius: 6px;
  font-size: 0.82rem; box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  display: flex; gap: 0.7rem; align-items: center; pointer-events: auto;
}
.toast button { background: transparent; border: 1px solid rgba(255,255,255,0.4); color: #fff; padding: 0.3rem 0.6rem; border-radius: 4px; font-size: 0.78rem; cursor: pointer; }

/* Unauthorized landing */
body.unauthorized { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.unauthorized-card {
  background: #fff; border-radius: 12px; padding: 2rem 2.5rem;
  box-shadow: 0 6px 24px rgba(0,0,0,0.10);
  max-width: 360px; text-align: center;
}
.unauthorized-card h1 { font-size: 1.2rem; margin: 0 0 0.5rem; }
.unauthorized-card p { margin: 0; color: #4b5563; font-size: 0.95rem; }
