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

/* ================================================================
   DESIGN TOKENS — Dark Default
   ================================================================ */
:root {
  /* Accent */
  --accent:       #FF007A;
  --accent-soft:  rgba(255, 0, 122, 0.15);
  --accent-glow:  rgba(255, 0, 122, 0.25);

  /* Surfaces */
  --bg:           #0D0D0F;
  --panel:        #18181B;
  --panel-alt:    #1E1E22;
  --panel-hover:  #222226;

  /* Text */
  --ink:          #EDEDED;
  --ink-soft:     #A1A1AA;
  --muted:        #71717A;

  /* Borders */
  --border:       rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.14);

  /* Semantic */
  --danger:       #F87171;
  --success:      #4ADE80;
  --green:        #4ADE80;
  --red:          #F87171;
  --blue:         #60A5FA;
  --purple:       #A78BFA;
  --amber:        #FBBF24;
  --orange:       #FB923C;

  /* Border Radius */
  --r-xs:   4px;
  --r-sm:   6px;
  --r:      10px;
  --r-lg:   14px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.14);
  --shadow:        0 4px 16px rgba(0,0,0,0.24), 0 1px 4px rgba(0,0,0,0.16);
  --shadow-lg:     0 16px 48px rgba(0,0,0,0.32);
  --shadow-accent: 0 4px 24px rgba(255, 0, 122, 0.15);

  /* Typography Scale */
  --text-2xs:  0.625rem;
  --text-xs:   0.6875rem;
  --text-sm:   0.8125rem;
  --text-base: 0.875rem;
  --text-lg:   1rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;

  /* Sentiment (hardcoded — same in both themes) */
  --sentiment-extreme-greed: #22c55e;
  --sentiment-greed: #84cc16;
  --sentiment-neutral: #6b7280;
  --sentiment-fear: #f97316;
  --sentiment-extreme-fear: #ef4444;
}

/* ================================================================
   LIGHT THEME OVERRIDES
   ================================================================ */
[data-theme="light"] {
  --bg:           #F8F8F6;
  --panel:        #FFFFFF;
  --panel-alt:    #F0F0EE;
  --panel-hover:  #E8E8E6;
  --ink:          #111416;
  --ink-soft:     #4A5560;
  --muted:        #7A8794;
  --border:       rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.14);
  --danger:       #EF4444;
  --success:      #22C55E;
  --green:        #15803D;
  --red:          #B91C1C;
  --blue:         #2563EB;
  --purple:       #7C3AED;
  --amber:        #D97706;
  --orange:       #EA580C;
  --accent-soft:  rgba(255, 0, 122, 0.08);
  --accent-glow:  rgba(255, 0, 122, 0.12);
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:        0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:     0 16px 48px rgba(0,0,0,0.1);
  --shadow-accent: 0 4px 24px rgba(255, 0, 122, 0.08);
}

/* ================================================================
   BODY
   ================================================================ */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ================================================================
   TOPBAR
   ================================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

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

.brand-wordmark {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.brand-wordmark span { color: var(--accent); }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
}

.topbar-nav a {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 14px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.topbar-nav a:hover { color: var(--ink-soft); }

.topbar-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  position: relative;
}

.pulse-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--success);
  animation: pulse-ring 2s ease-out infinite;
}

.theme-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  transition: all 0.2s;
}

.theme-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ================================================================
   PAGE SHELL
   ================================================================ */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.page-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.page-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: var(--text-2xl);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ================================================================
   SHARED COMPONENTS — Tab Bar
   ================================================================ */
.tab-bar {
  display: inline-flex;
  background: var(--panel-alt);
  border-radius: var(--r-pill);
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  gap: 2px;
}

.tab-btn {
  padding: 7px 16px;
  border: none;
  background: transparent;
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn .count {
  font-size: var(--text-2xs);
  background: var(--border);
  padding: 1px 6px;
  border-radius: var(--r-pill);
  font-weight: 600;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}

.tab-btn.active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.tab-btn.active .count {
  background: var(--accent-soft);
  color: var(--accent);
}

.tab-btn:hover:not(.active) { color: var(--ink-soft); }

/* ================================================================
   SHARED COMPONENTS — Filter Bar
   ================================================================ */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 8px 12px;
  background: var(--panel);
  border-radius: var(--r);
  border: 1px solid var(--border);
  align-items: center;
}

.chain-pills { display: inline-flex; gap: 4px; }

.pill {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: var(--text-2xs);
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill:hover { border-color: var(--accent); color: var(--ink-soft); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pill.sol.active { background: #9945FF; border-color: #9945FF; }
.pill.eth.active { background: #627EEA; border-color: #627EEA; }
.pill.base.active { background: #0052FF; border-color: #0052FF; }

.filter-sep { width: 1px; height: 18px; background: var(--border); }

.filter-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  background: var(--panel-alt);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  cursor: pointer;
}

.filter-select:focus { outline: none; border-color: var(--accent); }

.search-input {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-size: var(--text-xs);
  width: 180px;
  background: var(--panel-alt);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.filter-spacer { flex: 1; }

.sort-group {
  display: inline-flex;
  background: var(--panel-alt);
  border-radius: var(--r-pill);
  padding: 3px;
  border: 1px solid var(--border);
  gap: 2px;
}

.sort-chip {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--text-2xs);
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
  transition: all 0.15s;
}

.sort-chip.active { background: var(--panel); color: var(--ink); box-shadow: var(--shadow-sm); }
.sort-chip:hover:not(.active) { color: var(--ink-soft); }

/* ================================================================
   SHARED COMPONENTS — Pagination
   ================================================================ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.15s;
}

.page-btn:hover { border-color: var(--accent); color: var(--ink-soft); }

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.page-input {
  width: 48px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
}

.page-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.page-label { font-size: var(--text-xs); color: var(--muted); padding: 0 4px; }

/* ================================================================
   SHARED COMPONENTS — Buttons
   ================================================================ */
.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover { box-shadow: var(--shadow-accent); }

.btn-ghost {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Legacy .btn — remap to primary */
.btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.btn:hover { box-shadow: var(--shadow-accent); }

.btn.btn-ghost {
  background: var(--panel-alt);
  color: var(--ink-soft);
  border: 1px solid var(--border);
}

.btn.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.icon-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  background: var(--panel-alt);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
}

.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.icon-btn.target:hover { border-color: var(--blue); color: var(--blue); background: rgba(96,165,250,0.1); }
.icon-btn.quarantine:hover { border-color: var(--amber); color: var(--amber); background: rgba(251,191,36,0.1); }
.icon-btn.reject:hover { border-color: var(--red); color: var(--red); background: rgba(248,113,113,0.1); }

/* ================================================================
   SHARED COMPONENTS — Modal
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.visible { opacity: 1; pointer-events: all; }

.modal-content {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  max-width: 720px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--muted);
  cursor: pointer;
}

.modal-close:hover { color: var(--ink); }

/* Legacy modal (used by index settings + admin) */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
}

.modal[aria-hidden="false"] {
  display: flex;
}

/* ================================================================
   SHARED COMPONENTS — Badges
   ================================================================ */
.status-badge {
  font-size: var(--text-2xs);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.status-badge.active { background: rgba(74,222,128,0.12); color: var(--green); }
.status-badge.waiting { background: rgba(251,191,36,0.12); color: var(--amber); }
.status-badge.review { background: rgba(96,165,250,0.12); color: var(--blue); }

.tier-badge {
  display: inline-flex;
  padding: 1px 6px;
  border-radius: var(--r-xs);
  font-size: 0.5625rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tier-badge.micro { background: rgba(148,163,184,0.15); color: #94a3b8; }
.tier-badge.small { background: rgba(96,165,250,0.15); color: #60a5fa; }
.tier-badge.mid   { background: rgba(52,211,153,0.15); color: #34d399; }
.tier-badge.large { background: rgba(251,191,36,0.12); color: #fbbf24; }
.tier-badge.giant { background: rgba(196,181,253,0.12); color: #c4b5fd; }

[data-theme="light"] .tier-badge.micro { background: rgba(148,163,184,0.2); color: #475569; }
[data-theme="light"] .tier-badge.small { background: rgba(37,99,235,0.12); color: #2563eb; }
[data-theme="light"] .tier-badge.mid   { background: rgba(22,163,74,0.12); color: #15803d; }
[data-theme="light"] .tier-badge.large { background: rgba(217,119,6,0.12); color: #b45309; }
[data-theme="light"] .tier-badge.giant { background: rgba(124,58,237,0.12); color: #6d28d9; }

.chain-badge {
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chain-badge.sol { color: #9945FF; }
.chain-badge.eth { color: #627EEA; }
.chain-badge.base { color: #0052FF; }

.token-symbol {
  font-size: var(--text-2xs);
  color: var(--muted);
  background: var(--panel-alt);
  padding: 1px 6px;
  border-radius: var(--r-xs);
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.composite-badge {
  font-size: var(--text-2xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

.composite-badge.high { background: #059669; color: #fff; }
.composite-badge.low { background: #dc2626; color: #fff; }
.composite-badge.mid { color: var(--ink); font-weight: 700; }

.narrative-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 7px;
  border-radius: var(--r-xs);
  font-size: 0.5625rem;
  font-weight: 500;
}

.narrative-tag.bullish { background: rgba(74, 222, 128, 0.12); color: var(--green); }
.narrative-tag.bearish { background: rgba(248, 113, 113, 0.12); color: var(--red); }
.narrative-tag.neutral { background: rgba(96, 165, 250, 0.12); color: var(--blue); }

/* ================================================================
   SHARED COMPONENTS — Score Bars
   ================================================================ */
.score-section {
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  position: relative;
  z-index: 1;
}

.score-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.score-title {
  font-size: 0.5625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-family: 'Space Grotesk', sans-serif;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}

.score-label {
  width: 70px;
  color: var(--muted);
  font-size: 0.5625rem;
  flex-shrink: 0;
  font-weight: 500;
}

.score-bar-bg {
  flex: 1;
  height: 14px;
  background: var(--panel-alt);
  border-radius: var(--r-xs);
  overflow: hidden;
  position: relative;
}

.score-bar-fill {
  height: 100%;
  border-radius: var(--r-xs);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.score-bar-fill.trading { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.score-bar-fill.social  { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.score-bar-fill.holder  { background: linear-gradient(90deg, #10b981, #34d399); }

.score-value {
  min-width: 34px;
  text-align: right;
  font-weight: 600;
  font-size: var(--text-2xs);
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

.growth-indicator {
  font-size: 0.5rem;
  font-weight: 600;
}

/* ================================================================
   SHARED COMPONENTS — Tables
   ================================================================ */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.5625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}

.data-table tr:hover { background: var(--panel-alt); }
.data-table .sortable { cursor: pointer; }
.data-table .sortable:hover { color: var(--accent); }

/* ================================================================
   SHARED COMPONENTS — Forms
   ================================================================ */
.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--panel-alt);
  color: var(--ink);
  font-size: var(--text-sm);
  font-family: 'Inter', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input::placeholder { color: var(--muted); }

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--panel-alt);
  color: var(--ink);
  font-size: var(--text-sm);
  font-family: 'Inter', sans-serif;
  cursor: pointer;
}

.form-select:focus { outline: none; border-color: var(--accent); }

.form-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-soft);
  margin-bottom: 4px;
  display: block;
}

/* ================================================================
   SHARED — Directional & Semantic Colors
   ================================================================ */
.positive, .up { color: var(--green); }
.negative, .down { color: var(--red); }

/* Holder growth status classes */
.growth-explosive { color: var(--green); }
.growth-steady { color: #16a34a; }
[data-theme="light"] .growth-steady { color: #15803d; }
.growth-stagnant { color: var(--muted); }
.growth-declining { color: var(--orange); }
.growth-exodus { color: var(--red); }

/* ================================================================
   ANIMATIONS
   ================================================================ */
@keyframes pulse-ring {
  0% { opacity: 0.6; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.2); }
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ================================================================
   INDEX PAGE — Keyword Nav
   ================================================================ */
.keyword-nav {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px 14px;
  margin-bottom: 16px;
}

.keyword-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.keyword-pill {
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--panel-alt);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--ink-soft);
  transition: all 0.15s;
}

.keyword-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.keyword-pill span {
  font-size: 0.75rem;
  color: var(--muted);
}

.keyword-pill.active span {
  color: rgba(255, 255, 255, 0.8);
}

.keyword-pill .delta {
  font-size: 0.7rem;
  margin-left: 4px;
}

.keyword-pill .delta.positive { color: var(--green); }
.keyword-pill .delta.negative { color: var(--red); }

.keyword-pill.active .delta.positive,
.keyword-pill.active .delta.negative {
  color: rgba(255, 255, 255, 0.85);
}

.keyword-stats {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}

.keyword-stats .count { font-weight: 500; }
.keyword-stats .share { opacity: 0.8; }
.keyword-stats .share::before { content: "\2022"; margin-right: 4px; opacity: 0.5; }

.keyword-pill.active .keyword-stats { color: rgba(255, 255, 255, 0.75); }
.keyword-pill.active .keyword-stats .count,
.keyword-pill.active .keyword-stats .share { color: rgba(255, 255, 255, 0.85); }

/* ================================================================
   INDEX PAGE — Refresh Strip
   ================================================================ */
.refresh-strip {
  display: none;
  align-items: center;
  gap: 16px;
  background: var(--panel-alt);
  border-radius: var(--r);
  border: 1px solid var(--border);
  padding: 10px 16px;
  margin-bottom: 16px;
}

.refresh-strip.active { display: flex; }

.refresh-progress {
  flex: 1;
  height: 8px;
  background: var(--accent-soft);
  border-radius: var(--r-pill);
  overflow: hidden;
}

.refresh-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.refresh-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ================================================================
   INDEX PAGE — Window Selector
   ================================================================ */
.topbar-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.window-selector {
  display: flex;
  gap: 4px;
  background: var(--panel-alt);
  padding: 4px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
}

.window-selector button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-size: var(--text-xs);
  transition: all 0.15s;
}

.window-selector button.active {
  background: var(--accent);
  color: #fff;
}

/* ================================================================
   INDEX PAGE — Layout (3-col)
   ================================================================ */
.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 320px;
  gap: 24px;
}

.left-rail,
.right-rail {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.rail-card {
  background: var(--panel);
  border-radius: var(--r-lg);
  border: 1px dashed var(--border);
  padding: 16px;
}

.rail-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  margin-bottom: 6px;
}

.rail-placeholder {
  color: var(--muted);
  font-size: 0.9rem;
}

.rail-subtitle {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 10px;
}

/* ================================================================
   INDEX PAGE — Panels
   ================================================================ */
.panel {
  background: var(--panel);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: 18px;
  margin-bottom: 20px;
}

.panel.compact { margin-bottom: 0; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: var(--text-lg);
}

.panel-title.small { font-size: var(--text-sm); }

.panel-subtitle {
  color: var(--muted);
  font-size: 0.85rem;
}

.panel-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ================================================================
   INDEX PAGE — Macro Assets
   ================================================================ */
.macro-grid {
  display: grid;
  gap: 10px;
}

.macro-asset {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px;
  background: var(--panel-alt);
}

.macro-asset-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.macro-asset-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.macro-asset-price {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', monospace;
}

.macro-rows {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.macro-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.macro-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', monospace;
}

.macro-value.positive { color: var(--green); }
.macro-value.negative { color: var(--red); }
.macro-value.muted { font-weight: 500; color: var(--muted); }

/* ================================================================
   INDEX PAGE — ETF Flows
   ================================================================ */
.etf-flow-grid {
  display: grid;
  gap: 12px;
}

.etf-flow-asset {
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px;
  background: var(--panel-alt);
}

.etf-flow-asset-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.etf-flow-asset-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.etf-flow-asset-date {
  font-size: 0.75rem;
  color: var(--muted);
}

.etf-flow-rows {
  display: grid;
  gap: 6px;
}

.etf-flow-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.etf-flow-row span:last-child {
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', monospace;
}

.etf-flow-value {
  font-weight: 600;
  font-size: 0.95rem;
  font-family: 'JetBrains Mono', monospace;
}

.etf-flow-value.positive { color: var(--green); }
.etf-flow-value.negative { color: var(--red); }
.etf-flow-value.muted { font-weight: 500; font-size: 0.8rem; color: var(--muted); }

.etf-flow-row .muted { color: var(--muted); }

/* ================================================================
   INDEX PAGE — Story Cards
   ================================================================ */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.story-card {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: 14px;
  background: var(--panel-alt);
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.story-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 8px;
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-glow);
}

.article-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.article-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  padding: 8px;
  border-radius: var(--r);
  background: var(--panel);
  border: 1px solid var(--border);
}

.article-item a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}

.article-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ================================================================
   INDEX PAGE — Keyword/Cluster Views
   ================================================================ */
.keyword-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.keyword-chip {
  padding: 6px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  color: var(--ink-soft);
  transition: all 0.15s;
}

.keyword-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.subnarratives {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.subnarrative-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  padding: 10px;
  background: var(--panel-alt);
  cursor: pointer;
}

.subnarrative-title {
  font-weight: 600;
  font-size: 0.85rem;
}

.subnarrative-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.keyword-metrics,
.cluster-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  border-radius: var(--r);
  border: 1px solid var(--border);
  padding: 12px;
  background: var(--panel-alt);
  font-size: 0.85rem;
}

.metric-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-value {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.trend-card {
  padding: 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--panel);
  margin-bottom: 18px;
}

.trend-chart {
  width: 100%;
  height: 200px;
}

.cluster-articles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

/* ================================================================
   INDEX PAGE — Settings Modal
   ================================================================ */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.settings-panel {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: 16px;
  background: var(--panel-alt);
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border-radius: var(--r);
  padding: 10px;
  border: 1px solid var(--border);
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.form input[type="text"],
.form input[type="number"] {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  font-family: inherit;
  background: var(--panel-alt);
  color: var(--ink);
}

.form input[type="text"]:focus,
.form input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form label.inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.settings-note {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ================================================================
   INDEX PAGE — Sentiment System
   ================================================================ */
.sentiment-highly-positive { color: #22c55e; }
.sentiment-positive { color: #16a34a; }
.sentiment-neutral { color: #6b7280; }
.sentiment-negative { color: #dc2626; }
.sentiment-highly-negative { color: #ef4444; }

.sentiment-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  font-weight: 600;
}

.sentiment-badge.extreme-greed { background: rgba(34, 197, 94, 0.15); color: #22c55e; }
.sentiment-badge.greed { background: rgba(22, 163, 74, 0.15); color: #16a34a; }
.sentiment-badge.neutral { background: rgba(107, 114, 128, 0.15); color: #6b7280; }
.sentiment-badge.fear { background: rgba(220, 38, 38, 0.15); color: #dc2626; }
.sentiment-badge.extreme-fear { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.sentiment-grid { display: grid; gap: 10px; }

.sentiment-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: var(--r);
  background: var(--panel-alt);
  border: 1px solid var(--border);
}

.sentiment-main-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
}

.sentiment-main-label { font-size: 0.85rem; font-weight: 500; margin-top: 2px; }
.sentiment-main-delta { font-size: 0.75rem; margin-top: 4px; }

.sentiment-metrics { display: grid; gap: 8px; }

.sentiment-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.sentiment-metric:last-child { border-bottom: none; }
.sentiment-metric-label { color: var(--ink-soft); }

.sentiment-metric-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', monospace;
}

.sentiment-metric-delta { font-size: 0.7rem; margin-left: 6px; }

/* Sentiment border for story/cluster cards */
.story-card.sentiment-extreme-greed { border-left: 4px solid var(--sentiment-extreme-greed); }
.story-card.sentiment-greed { border-left: 4px solid var(--sentiment-greed); }
.story-card.sentiment-neutral { border-left: 4px solid var(--sentiment-neutral); }
.story-card.sentiment-fear { border-left: 4px solid var(--sentiment-fear); }
.story-card.sentiment-extreme-fear { border-left: 4px solid var(--sentiment-extreme-fear); }

.subnarrative-item.sentiment-extreme-greed { border-left: 4px solid var(--sentiment-extreme-greed); }
.subnarrative-item.sentiment-greed { border-left: 4px solid var(--sentiment-greed); }
.subnarrative-item.sentiment-neutral { border-left: 4px solid var(--sentiment-neutral); }
.subnarrative-item.sentiment-fear { border-left: 4px solid var(--sentiment-fear); }
.subnarrative-item.sentiment-extreme-fear { border-left: 4px solid var(--sentiment-extreme-fear); }

/* Trend delta colors */
.trend-positive { color: var(--green); }
.trend-negative { color: var(--red); }
.trend-neutral { color: var(--ink-soft); }

/* Story card AI summary */
.story-summary {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--ink);
  line-height: 1.3;
}

.story-sparkline {
  height: 20px;
  margin-top: 6px;
  color: var(--accent);
  opacity: 0.7;
}

.sparkline { width: 100%; height: 100%; }

.cluster-summary {
  margin-top: 12px;
  padding: 12px;
  background: var(--panel-alt);
  border-radius: var(--r);
  font-size: 0.9rem;
  color: var(--ink-soft);
  font-style: italic;
  border-left: 3px solid var(--accent);
}

.cluster-summary.hidden { display: none; }

/* ================================================================
   INDEX PAGE — FNG Chart
   ================================================================ */
.fng-chart-container { margin: 8px 0 4px; }

.fng-chart-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
}

.fng-chart-tabs button {
  border: 1px solid var(--border);
  background: var(--panel-alt);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.fng-chart-tabs button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.fng-chart {
  width: 100%;
  height: auto;
  display: block;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 200px minmax(0, 1fr) 280px;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .left-rail,
  .right-rail {
    display: none;
  }
  .keyword-nav {
    position: sticky;
    top: 56px;
    z-index: 5;
  }
}

/* Hamburger — hidden on desktop */
.hamburger { display: none; }

@media (max-width: 640px) {
  /* --- Hamburger button --- */
  .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    padding: 6px;
    border: 1px solid var(--border);
    background: var(--panel-alt);
    border-radius: var(--r-sm);
    cursor: pointer;
    order: 1;
  }
  .hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--ink-soft);
    border-radius: 1px;
    transition: transform 0.2s, opacity 0.2s;
  }
  .hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .hamburger.open span:nth-child(2) { opacity: 0; }
  .hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* --- Mobile nav dropdown --- */
  /* Note: topbar has backdrop-filter which creates a containing block,
     so position:fixed here is relative to the 48px header, not viewport.
     Use top:100% to sit below header + explicit height to fill screen. */
  .topbar-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: calc(100vh - 48px);
    flex-direction: column;
    align-items: stretch;      /* RESET: full-width links */
    gap: 0;                    /* RESET: spacing via padding+borders */
    background: var(--bg);
    z-index: 200;
    padding: 8px 0;
    overflow-y: auto;
  }
  .topbar-nav.open { display: flex; }
  .topbar-nav a {
    height: auto;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: var(--text-base);
    color: var(--ink);
  }
  .topbar-nav a:last-child { border-bottom: none; }
  .topbar-nav a.active {
    border-bottom: 1px solid var(--border);
    background: var(--accent-soft);
    color: var(--accent);
  }

  /* --- Topbar --- */
  .topbar { padding: 0 12px; height: 48px; }
  .brand-wordmark { display: none; }
  .brand-mark svg { height: 24px; }
  .topbar-right { gap: 8px; }
  .topbar-right .window-selector { display: none; }
  .topbar-right .refresh-block { display: none; }

  /* --- Page spacing --- */
  .page { padding: 12px 12px 32px; }
  .page-title { font-size: 1.25rem; }

  /* --- Tabs --- */
  .tab-bar {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tab-bar::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 6px 12px; white-space: nowrap; }

  /* --- Filters --- */
  .filter-bar { padding: 6px 8px; gap: 6px; }
  .filter-spacer { display: none; }
  .search-input { width: 100%; order: -1; }
  .sort-group { width: 100%; overflow-x: auto; }
  .sort-chips { flex-wrap: nowrap; overflow-x: auto; }

  /* --- Modals --- */
  .modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
    padding: 16px;
  }

  /* --- Token cards --- */
  .token-metrics { gap: 0.5rem 0.75rem; font-size: 0.75rem; }
  .twitter-stats-row { gap: 0.5rem; }
  .score-label { width: 55px; font-size: 0.55rem; }
  .score-value { min-width: 24px; font-size: 0.55rem; }

  /* --- Index (Pulse) layout --- */
  .layout { gap: 12px; }
  .left-rail, .right-rail { display: none; }

  /* --- Global: prevent any horizontal overflow --- */
  html { overflow-x: hidden; }
  .page { max-width: 100% !important; }

  /* --- Scrollable tab bars on mobile --- */
  .tab-buttons {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    max-width: 100%; scrollbar-width: none;
  }
  .tab-buttons::-webkit-scrollbar { display: none; }

  /* --- Filter bars: wrap on mobile --- */
  .filter-bar { flex-wrap: wrap; }

  /* --- Index: story/keyword/cluster grids → single column --- */
  .story-grid { grid-template-columns: 1fr; }
  .keyword-metrics,
  .cluster-metrics { grid-template-columns: 1fr; }
  .cluster-articles { grid-template-columns: 1fr; }

  /* --- Panels: tighter padding on mobile --- */
  .panel { padding: 12px; }
  .narratives-section { padding: 0.75rem; }
}
