/* ═══════════════════════════════════════════════════════════════
   NoteRank Design System — xratios.app-inspired dark mode
   ═══════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0A0A0A;
  --bg-sidebar: #121212;
  --bg-elevated: #27272A;
  --bg-hover: #27272A;
  --bg-active: #3f3f46;
  --bg-card: #18181B;
  --border: #27272A;
  --border-light: #3f3f46;
  --text-primary: #FFFFFF;
  --text-secondary: #A1A1AA;
  --text-faint: #71717A;
  --accent: #FFFFFF;
  --accent-hover: #e4e4e7;
  --accent-faint: rgba(255,255,255,0.08);
  --green: #22c55e;
  --green-faint: rgba(34,197,94,0.15);
  --yellow: #eab308;
  --yellow-faint: rgba(234,179,8,0.15);
  --red: #ef4444;
  --red-faint: rgba(239,68,68,0.15);
  --gray: #71717A;

  --font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --sidebar-width: 280px;
  --top-nav-height: 48px;
  --bottom-nav-height: 52px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.6);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.7);

  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums lining-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── App Layout ───────────────────────────────────────────── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  height: 100dvh;
  overflow: hidden;
}

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
}

/* ─── Filter Sidebar ───────────────────────────────────────── */
.filter-sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

@media (max-width: 860px) {
  .filter-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }
  .filter-sidebar.open { transform: translateX(0); }
}

/* Sidebar logo */
.sidebar-brand {
  padding: 4px 0 8px;
}
.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.sidebar-brand-link:hover { text-decoration: none; opacity: 0.85; }
.sidebar-brand-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-primary);
}
.sidebar-brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}
.sidebar-brand-sub a {
  color: var(--text-faint);
  text-decoration: none;
}
.sidebar-brand-sub a:hover { color: var(--text-secondary); text-decoration: none; }

/* Sidebar search */
.sidebar-search {
  position: relative;
}
.sidebar-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px 9px 32px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-family);
  outline: none;
  transition: border-color var(--transition-fast);
}
.sidebar-search input:focus { border-color: var(--text-faint); }
.sidebar-search input::placeholder { color: var(--text-faint); }
.sidebar-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
.sidebar-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 300px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
}
.sidebar-search-results.hidden { display: none; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
  color: inherit;
}
.search-result-item:hover { background: var(--bg-elevated); text-decoration: none; }

/* Sidebar sections */
.filter-section { display: flex; flex-direction: column; gap: 8px; }
.filter-section-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  text-transform: uppercase;
  font-family: var(--font-family);
}

/* Sort dropdown */
.filter-dropdown {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-family);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23A1A1AA' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.filter-dropdown:focus { border-color: var(--text-faint); }
.filter-dropdown option { background: var(--bg-card); color: var(--text-primary); }

/* Topic filter list */
.filter-topic-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.filter-topic-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  font-family: var(--font-family);
  width: 100%;
  text-align: left;
}
.filter-topic-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.filter-topic-item.active { background: var(--accent-faint); color: var(--accent); }
.filter-topic-count {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-family);
}
.filter-topic-item.active .filter-topic-count { color: var(--accent); opacity: 0.7; }

/* Quick stats card */
.stat-counter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-top: auto;
}
.stat-counter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.stat-counter-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  text-transform: uppercase;
  font-family: var(--font-family);
}
.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--green);
  font-weight: 500;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.stat-counter-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}
.stat-counter-label { font-size: 12px; color: var(--text-secondary); }
.stat-counter-value { font-size: 13px; font-weight: 700; color: var(--text-primary); }

.sidebar-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.sidebar-footer-link {
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: none;
}
.sidebar-footer-link:hover { color: var(--text-secondary); text-decoration: none; }
.sidebar-credit {
  width: 100%;
  margin-top: 4px;
}
.sidebar-credit a {
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: none;
}
.sidebar-credit a:hover { color: var(--text-secondary); }

/* ─── Main Content ─────────────────────────────────────────── */
.main-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Top bar (mobile only) */
.top-bar {
  display: none;
  align-items: center;
  gap: 12px;
  height: 50px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
}
@media (max-width: 860px) {
  .top-bar { display: flex; }
}
.top-bar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  flex: 1;
  letter-spacing: 1px;
  text-decoration: none;
  color: inherit;
}
.top-bar-brand:hover { text-decoration: none; }
.menu-toggle, .mobile-search-toggle {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
}
.menu-toggle:hover, .mobile-search-toggle:hover { background: var(--bg-elevated); }

/* Tab navigation */
.tab-nav {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-shrink: 0;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-nav-item {
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  flex-shrink: 0;
}
.tab-nav-item:hover { color: var(--text-primary); text-decoration: none; }
.tab-nav-item.active {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
  font-weight: 600;
}

/* Page content scroll area */
.page-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (max-width: 860px) {
  .page-content { padding-bottom: calc(var(--bottom-nav-height) + 12px); }
}

/* ─── Bottom Nav (Mobile) ──────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-primary);
  border-top: 1px solid var(--border);
  z-index: 100;
  align-items: center;
  justify-content: space-around;
}
@media (max-width: 860px) {
  .bottom-nav { display: flex; }
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-fast);
}
.bottom-nav-item.active { color: var(--text-primary); }
.bottom-nav-item:hover { color: var(--text-primary); text-decoration: none; }
.bottom-nav-item svg { color: inherit; }

/* ─── Sidebar Overlay ──────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 190;
  display: none;
}
.sidebar-overlay.active { display: block; }

/* ─── Search Overlay (Mobile) ──────────────────────────────── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 300;
  display: flex;
  flex-direction: column;
}
.search-overlay.hidden { display: none; }
.search-overlay-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.search-overlay-header input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font-family);
  outline: none;
  padding: 6px 0;
}
.search-overlay-results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.search-close {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
}

/* ─── Page Header ──────────────────────────────────────────── */
.page-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
}
.page-header .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ─── Leaderboard Table ────────────────────────────────────── */
.lb-table-header {
  display: grid;
  grid-template-columns: 40px 36px 1fr 80px;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.leaderboard-row {
  display: grid;
  grid-template-columns: 40px 36px 1fr 80px;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
  color: inherit;
}
.leaderboard-row:hover { background: var(--bg-elevated); text-decoration: none; }

.lb-rank {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
}
.lb-rank-1 { color: var(--yellow); }
.lb-rank-2 { color: #aaa; }
.lb-rank-3 { color: #CD7F32; }

.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-card);
}
.lb-info { min-width: 0; }
.lb-name-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lb-display-name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-verified { color: #1D9BF0; flex-shrink: 0; }
.lb-handle {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  flex-shrink: 0;
}
.lb-score {
  font-size: 15px;
  font-weight: 700;
}
.lb-score-label {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ─── Confidence Badges ────────────────────────────────────── */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.confidence-high { background: var(--green-faint); color: var(--green); }
.confidence-medium { background: var(--yellow-faint); color: var(--yellow); }
.confidence-low { background: var(--red-faint); color: var(--red); }
.confidence-unresolved { background: rgba(100,100,100,0.15); color: var(--gray); }

/* ─── Status Chips ─────────────────────────────────────────── */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}
.status-helpful { background: var(--green-faint); color: var(--green); }
.status-not-helpful { background: var(--red-faint); color: var(--red); }
.status-needs-more { background: var(--yellow-faint); color: var(--yellow); }

/* ─── Stat Cards (compact inline row) ──────────────────────── */
.stat-cards-row {
  display: flex;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.stat-card-mini {
  flex: 1;
  background: var(--bg-primary);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.stat-card-label { font-size: 12px; color: var(--text-secondary); }
.stat-card-value { font-size: 18px; font-weight: 700; }
.stat-card-delta {
  font-size: 12px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 2px;
}
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.delta-flat { color: var(--text-secondary); }

/* ─── Cards & Sections ─────────────────────────────────────── */
.section-header {
  padding: 16px 20px 10px;
  font-size: 16px;
  font-weight: 700;
}
.divider { border-bottom: 1px solid var(--border); }

/* ─── Note Card ────────────────────────────────────────────── */
.note-card {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast);
  display: block;
  text-decoration: none;
  color: inherit;
}
.note-card:hover { background: var(--bg-elevated); text-decoration: none; }
.note-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.note-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  flex-shrink: 0;
}
.note-author-info { flex: 1; min-width: 0; }
.note-author-name { font-weight: 600; font-size: 14px; }
.note-author-handle { font-size: 12px; color: var(--text-secondary); }
.note-time { font-size: 12px; color: var(--text-secondary); }
.note-summary {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.note-flags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.flag-chip {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ─── Account Header ───────────────────────────────────────── */
.account-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.account-top { display: flex; gap: 14px; align-items: flex-start; }
.account-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  flex-shrink: 0;
}
.account-info { flex: 1; min-width: 0; }
.account-name {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}
.account-handle { font-size: 14px; color: var(--text-secondary); }
.account-bio { font-size: 14px; color: var(--text-secondary); margin-top: 6px; line-height: 1.4; }
.account-badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ─── Sparkline ────────────────────────────────────────────── */
.sparkline { display: inline-block; vertical-align: middle; }
.chart-section { padding: 12px 20px; }
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.chart-container { width: 100%; min-height: 40px; }
.chart-container svg { display: block; width: 100%; height: auto; }

/* ─── Contributor Table ────────────────────────────────────── */
.contributor-row {
  display: grid;
  grid-template-columns: 36px 1fr repeat(3, 72px) 60px;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-decoration: none;
  color: inherit;
}
.contributor-row:hover { background: var(--bg-elevated); text-decoration: none; }
.contributor-row.header {
  color: var(--text-faint);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: default;
}
.contributor-row.header:hover { background: transparent; }

/* ─── Sort Headers ─────────────────────────────────────────── */
.sort-header {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: color var(--transition-fast);
}
.sort-header:hover { color: var(--text-primary); }
.sort-header .sort-arrow {
  font-size: 10px;
  opacity: 0.6;
}
.sort-header.active { color: var(--text-primary); }
.sort-header.active .sort-arrow { opacity: 1; }

/* ─── Contributor Detail Page ──────────────────────────────── */
.contributor-detail {
  padding: 0;
}
.contributor-detail-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}
.contributor-detail-header h1 {
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.contributor-detail-header .contributor-id-full {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
  word-break: break-all;
  margin-top: 4px;
}
.contributor-stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.contributor-stat-card {
  background: var(--bg-primary);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.contributor-stat-card .label { font-size: 11px; color: var(--text-secondary); font-weight: 400; text-transform: uppercase; letter-spacing: 0.3px; }
.contributor-stat-card .value { font-size: 18px; font-weight: 700; }

/* Target Analysis Table */
.target-analysis-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.target-analysis-section h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}
.target-analysis-table {
  width: 100%;
  border-collapse: collapse;
}
.target-analysis-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.target-analysis-table th:last-child,
.target-analysis-table td:last-child { text-align: right; }
.target-analysis-row td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 400;
}
.target-analysis-row:hover { background: var(--bg-elevated); }
.target-analysis-row td a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
}
.target-analysis-row td a:hover { text-decoration: underline; }

/* Pattern Flag */
.pattern-flag {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  background: var(--yellow-faint);
  border: 1px solid rgba(234,179,8,0.3);
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 400;
  color: var(--yellow);
  margin-top: 8px;
}
.pattern-flag .flag-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* Topic Distribution */
.topic-distribution-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.topic-distribution-section h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}
.topic-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.topic-bar-label {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  min-width: 120px;
  flex-shrink: 0;
}
.topic-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-card);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.topic-bar-fill {
  height: 100%;
  background: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.topic-bar-count {
  font-size: 12px;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}

/* Note History in contributor detail */
.note-history-section {
  padding: 16px 20px;
}
.note-history-section h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}
.note-history-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.note-history-item:last-child { border-bottom: none; }
.note-history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.note-history-summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─── Tabs (inner page tabs) ───────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-family);
}
.tab:hover { background: var(--bg-elevated); color: var(--text-primary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 700; }

/* ─── Compare Page ─────────────────────────────────────────── */
.compare-input-section { padding: 16px 20px; }
.compare-search-row { display: flex; gap: 8px; align-items: center; }
.compare-search-wrapper { flex: 1; position: relative; }
.compare-search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-family);
  outline: none;
}
.compare-search-input:focus { border-color: var(--text-faint); }
.compare-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
}
.compare-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.compare-search-item:hover { background: var(--bg-elevated); }
.compare-selected-handles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.compare-handle-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-faint);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}
.chip-remove {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.7;
}
.chip-remove:hover { opacity: 1; }
.compare-header-row {
  display: grid;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.compare-account-header { text-align: center; padding: 8px; }
.compare-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  margin-bottom: 6px;
  border: 2px solid var(--border);
}
.compare-name {
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.compare-handle { font-size: 12px; color: var(--text-secondary); }
.compare-metric-row {
  display: grid;
  gap: 12px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.compare-metric-label { font-size: 14px; color: var(--text-secondary); font-weight: 400; }
.compare-metric-value { font-size: 14px; font-weight: 700; text-align: center; }
.compare-section-label {
  padding: 14px 20px 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-top: 1px solid var(--border);
}
.compare-sparklines { display: grid; gap: 12px; padding: 8px 20px 14px; }
.compare-sparkline-cell { text-align: center; }
.compare-topics-row { display: grid; gap: 12px; padding: 8px 20px 16px; }
.compare-topics-cell { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.topic-pill {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
}
.topic-pill:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ─── Post Detail ──────────────────────────────────────────── */
.post-detail-card { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.post-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.note-detail-card {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  margin: 10px 20px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--bg-card);
}

/* ─── Admin ────────────────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.admin-card {
  background: var(--bg-primary);
  padding: 16px 20px;
}
.admin-card h4 {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.admin-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}
.admin-stat-label { font-size: 14px; color: var(--text-secondary); }
.admin-stat-value { font-size: 14px; font-weight: 600; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th {
  text-align: left;
  padding: 6px 8px;
  font-weight: 500;
  color: var(--text-faint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.admin-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.admin-table tr:hover { background: var(--bg-elevated); }

.admin-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  gap: 0;
}
.admin-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font-family);
}
.admin-tab:hover { color: var(--text-primary); }
.admin-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  font-family: var(--font-family);
}
.btn-primary { background: var(--text-primary); color: var(--bg-primary); }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-elevated); }

/* ─── Text Content ─────────────────────────────────────────── */
.text-content { padding: 20px; max-width: 640px; }
.text-content h2 { font-size: 18px; font-weight: 700; margin: 24px 0 8px; }
.text-content h2:first-child { margin-top: 0; }
.text-content h3 { font-size: 15px; font-weight: 700; margin: 18px 0 6px; }
.text-content p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 10px; }
.text-content ul, .text-content ol { padding-left: 20px; margin-bottom: 10px; }
.text-content li { font-size: 14px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 4px; }
.text-content code {
  background: var(--bg-card);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.text-content a { color: var(--text-primary); text-decoration: underline; text-decoration-color: var(--text-faint); text-underline-offset: 2px; }
.text-content a:hover { text-decoration-color: var(--text-primary); }

/* ─── Progress Bar ─────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-card);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ─── Empty State ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state svg { color: var(--text-faint); margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.empty-state p { font-size: 14px; color: var(--text-secondary); }

/* ─── Skeleton Loading ─────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-elevated) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-row {
  display: grid;
  grid-template-columns: 40px 36px 1fr 80px;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
.skeleton-circle { border-radius: 50%; }

/* ─── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  white-space: nowrap;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Utilities ────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.font-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.px-20 { padding-left: 20px; padding-right: 20px; }
.py-12 { padding-top: 12px; padding-bottom: 12px; }

/* Anonymous info text */
.anon-info {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

/* ─── Compare responsive ──────────────────────────────────── */
@media (max-width: 640px) {
  .compare-header-row { grid-template-columns: repeat(2, 1fr) !important; }
  .compare-metric-row { grid-template-columns: 90px repeat(2, 1fr) !important; font-size: 12px; }
  .compare-sparklines { grid-template-columns: repeat(2, 1fr) !important; }
  .compare-topics-row { grid-template-columns: 1fr !important; }
  .compare-search-row { flex-direction: column; }
  .compare-search-row .btn-pill { width: 100%; justify-content: center; }
  .stat-cards-row { flex-direction: column; }
  .contributor-row { grid-template-columns: 30px 1fr repeat(2, 56px) 48px; }
  .contributor-row.header > div:nth-child(4) { display: none; }
  .contributor-row > div:nth-child(4) { display: none; }
  .contributor-stat-cards { grid-template-columns: repeat(2, 1fr); }
  .topic-bar-label { min-width: 80px; }
}

/* ─── Cross-reference percentage badges ─────────────────────── */
.pct-badge {
  display: inline-block;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.section-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin: -8px 0 12px 0;
  line-height: 1.4;
}

/* ─── AI Summary Section (Account Profile) ─────────────────── */
.ai-summary-section {
  margin: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0.04) 100%);
}
.ai-summary-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.ai-summary-header svg {
  color: var(--text-faint);
  flex-shrink: 0;
}
.ai-summary-meta {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-faint);
  text-transform: none;
  letter-spacing: 0;
}
.ai-summary-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0;
}

/* ─── Summary Hover Tooltip (Leaderboard) ──────────────────── */
.summary-tooltip {
  position: fixed;
  z-index: 9999;
  max-width: 340px;
  padding: 10px 14px;
  background: #1c1c1e;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

/* ─── Home Stats Banner ──────────────────────────────────── */
.home-stats-banner {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.home-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.home-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.home-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.home-stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  text-align: center;
}
@media (max-width: 600px) {
  .home-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .home-stat-value {
    font-size: 16px;
  }
}
