:root {
  /* Light mode (default) */
  --bg: #fafaf9;
  --bg-elev: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f5f4;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #18181b;
  --text-dim: #57575c;
  --text-dimmer: #8a8a92;
  --accent: #7c3aed;
  --accent-glow: rgba(124, 58, 237, 0.25);
  --accent-soft: rgba(124, 58, 237, 0.08);
  --green: #16a34a;
  --red: #dc2626;
  --gold: #d97706;
  --silver: #94a3b8;
  --bronze: #b45309;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #0a0a0c;
  --bg-elev: #111114;
  --bg-card: #15151a;
  --bg-card-hover: #1c1c22;
  --border: #232329;
  --border-strong: #2e2e36;
  --text: #f5f5f7;
  --text-dim: #9a9aa3;
  --text-dimmer: #6b6b75;
  --accent: #a78bfa;
  --accent-glow: rgba(167, 139, 250, 0.4);
  --accent-soft: rgba(167, 139, 250, 0.12);
  --green: #22c55e;
  --red: #ef4444;
  --gold: #f59e0b;
  --silver: #cbd5e1;
  --bronze: #b45309;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.2s, color 0.2s;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

/* Theme toggle */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* Layout — 3 columns: ads left, content, ads right */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  gap: 24px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
}

.col-ads {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 24px;
  align-self: start;
  height: calc(100vh - 48px);
  overflow: hidden;
}

.col-main { min-width: 0; }

/* Ad cards */
.ad {
  position: relative;
  border-radius: 14px;
  padding: 18px 16px;
  min-height: 170px;
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}
.ad:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.ad-slide {
  position: absolute;
  inset: 0;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}
.ad-slide.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ad-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 16px; color: white;
  margin-bottom: 12px;
}
.ad-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; color: var(--text); }
.ad-desc { font-size: 12px; color: var(--text-dim); line-height: 1.45; }
.ad-tag {
  position: absolute; top: 10px; right: 12px;
  font-family: var(--mono); font-size: 9px;
  color: var(--text-dimmer); letter-spacing: 0.08em;
}

.ad-empty {
  border: 1px dashed var(--border-strong);
  background: transparent;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 140px;
  flex: 0 0 auto;
  box-shadow: none;
}
.ad-empty .ad-title { color: var(--text-dim); }
.ad-empty .ad-desc { color: var(--text-dimmer); }
.ad-empty:hover { border-color: var(--accent); color: var(--accent); }

/* Header / Brand */
.brand-row {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 13px;
  margin-bottom: 24px;
  color: var(--text-dim);
}
.brand-row .star { color: var(--accent); }
.brand-row a:hover { color: var(--text); }

/* Hero */
.hero {
  text-align: center;
  padding: 32px 0 40px;
}
.hero-brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}
.hero-brand .star { color: var(--accent); font-size: 18px; }
.hero-title {
  font-family: var(--mono);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 28px;
  line-height: 1.15;
}
.hero-title .accent { color: var(--accent); }

.search-row {
  display: flex; justify-content: center; gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  width: 360px;
  max-width: 90vw;
  box-shadow: var(--shadow-sm);
}
.search-box input {
  background: transparent; border: none; outline: none; color: var(--text);
  font-size: 13px; width: 100%;
}
.search-box input::placeholder { color: var(--text-dimmer); }
.btn-primary {
  background: var(--accent);
  color: white;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: filter 0.2s, transform 0.2s;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--border-strong); background: var(--bg-card-hover); }

.hero-links {
  font-family: var(--mono); font-size: 12px;
  color: var(--text-dim);
  display: flex; justify-content: center; gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.hero-links a:hover { color: var(--accent); }
.hero-links span { color: var(--text-dimmer); }

.hero-sub {
  color: var(--text-dim); font-size: 13px;
  margin-top: 16px;
}
.hero-sub a { color: var(--accent); }
.hero-sub a:hover { text-decoration: underline; }

/* Sections */
.section { margin-bottom: 40px; }
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 16px;
}
.section-head h2 {
  font-family: var(--mono);
  font-size: 16px; font-weight: 600;
}
.section-head a {
  font-size: 12px; color: var(--text-dim);
  font-family: var(--mono);
}
.section-head a:hover { color: var(--accent); }

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.coups-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .coups-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) { .coups-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .coups-grid { grid-template-columns: 1fr; } }

/* Anti-Discovery card integrated in Discovery grid */
.fcard-anti {
  background: linear-gradient(135deg, var(--accent-soft), transparent), var(--bg-card);
  border: 1px solid var(--accent-soft);
  display: flex;
  flex-direction: column;
}
.fcard-anti:hover { border-color: var(--accent); }
.anti-card-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}
.anti-card-desc {
  -webkit-line-clamp: unset !important;
  display: block !important;
  min-height: 0 !important;
  margin-bottom: 14px !important;
  flex: 1;
}
.anti-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: auto;
}
.anti-card-price {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
}

/* Discovery grid — fixed 4 cols (3 cards + anti card) */
.discovery-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .discovery-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .discovery-grid { grid-template-columns: 1fr; } }

/* Paid slot CTA card */
.fcard-slot {
  border: 1px dashed var(--border-strong);
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.fcard-slot:hover { border-color: var(--accent); transform: translateY(-2px); }
.fcard-slot .slot-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}
.fcard-slot .slot-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.fcard-slot .slot-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 10px;
  max-width: 200px;
  line-height: 1.4;
}
.fcard-slot .slot-price {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.fcard {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.fcard:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.fcard-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.fcard-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 14px; color: white;
  flex-shrink: 0;
}
.fcard-name { font-weight: 600; font-size: 14px; }
.fcard-cat { font-size: 11px; color: var(--text-dimmer); font-family: var(--mono); }
.fcard-desc {
  font-size: 12px; color: var(--text-dim);
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 34px;
}
.fcard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.fcard-stat .label {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-dimmer);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.fcard-stat .value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 13px;
}
.fcard-tag {
  position: absolute;
  top: 12px; right: 12px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  letter-spacing: 0.05em;
}
.fcard-tag.sale { background: rgba(22, 163, 74, 0.12); color: var(--green); }
.fcard-tag.hot { background: rgba(217, 119, 6, 0.12); color: var(--gold); }

/* Leaderboard */
.leaderboard {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.lb-controls {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.lb-controls h2 { font-family: var(--mono); font-size: 16px; font-weight: 600; }
.lb-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.lb-filter {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--mono);
  display: flex; align-items: center; gap: 6px;
  color: var(--text-dim);
}
.lb-filter:hover { color: var(--text); }
.lb-filter.active { color: var(--text); border-color: var(--border-strong); background: var(--bg-card-hover); }

.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dimmer);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.lb-table th.num { text-align: right; }
.lb-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.lb-table tr:last-child td { border-bottom: none; }
.lb-table tr:hover td { background: var(--bg-card-hover); cursor: pointer; }

.lb-rank {
  font-family: var(--mono);
  font-weight: 700;
  width: 32px;
}
.lb-rank.gold { color: var(--gold); }
.lb-rank.silver { color: var(--silver); }
.lb-rank.bronze { color: var(--bronze); }

.lb-formation { display: flex; align-items: center; gap: 10px; }
.lb-logo {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 12px; color: white;
  flex-shrink: 0;
}
.lb-name { font-weight: 600; }
.lb-tagline { font-size: 11px; color: var(--text-dimmer); }
.lb-founder { color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
.lb-founder-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-family: var(--mono); color: var(--accent);
  font-weight: 700;
}
.lb-mrr { font-family: var(--mono); font-weight: 600; text-align: right; }
.lb-growth { text-align: right; font-family: var(--mono); font-size: 12px; }
.lb-growth.up { color: var(--green); }
.lb-growth.down { color: var(--red); }
.lb-growth.flat { color: var(--text-dimmer); }
.lb-mask {
  filter: blur(5px);
  user-select: none;
  display: inline-block;
}

/* Anti-discovery banner */
.anti-discovery {
  margin-top: 24px;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--accent-soft);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
}
.anti-discovery .ad-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  color: white;
  font-size: 22px;
}
.anti-discovery h3 {
  font-family: var(--mono);
  font-size: 19px;
  margin-bottom: 8px;
}
.anti-discovery p {
  font-size: 13px;
  color: var(--text-dim);
  max-width: 560px;
  line-height: 1.55;
}
.anti-discovery .price {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dimmer);
  margin-top: 10px;
}
.anti-discovery .price strong { color: var(--text); font-weight: 600; }

/* Footer */
.footer {
  margin-top: 60px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
  font-size: 12px;
  padding-bottom: 28px;
}
.footer h4 {
  font-family: var(--mono);
  font-size: 12px;
  margin-bottom: 12px;
  color: var(--text);
}
.footer ul { list-style: none; }
.footer li { margin-bottom: 6px; }
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--text); }

/* Detail page */
.detail-head {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 24px;
}
.detail-logo {
  width: 96px; height: 96px;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 32px; color: white;
}
.detail-info h1 {
  font-family: var(--mono);
  font-size: 32px;
  margin-bottom: 10px;
}
.detail-desc {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 720px;
  line-height: 1.55;
}
.detail-actions { display: flex; gap: 8px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 24px 0;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.stat-card .value {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}
.stat-card .sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dimmer);
}
.stat-card.flag .value { display: flex; align-items: center; gap: 8px; font-size: 18px; }

/* Chart card */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.chart-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.chart-title { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.chart-title .big {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
}
.chart-title .delta { font-family: var(--mono); font-size: 12px; }
.chart-title .delta.down { color: var(--red); }
.chart-title .delta.up { color: var(--green); }
.chart-title .sub-label {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dimmer);
}
.chart-controls { display: flex; gap: 8px; }
.chart-select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  font-family: var(--mono);
}

.chart { width: 100%; height: 320px; }

/* Detail extra rows */
.detail-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.info-card h3 {
  font-family: var(--mono);
  font-size: 14px;
  margin-bottom: 14px;
}
.info-row {
  display: flex; justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--text-dim); }
.info-row .value { font-family: var(--mono); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.verified { background: rgba(22, 163, 74, 0.12); color: var(--green); }

/* Responsive */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 180px 1fr 180px; }
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .col-ads { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-head { grid-template-columns: 1fr; }
  .footer { grid-template-columns: repeat(2, 1fr); }
  .anti-discovery { grid-template-columns: 1fr; }
  .detail-row { grid-template-columns: 1fr; }
}
