:root {
  color-scheme: dark;
  --surface-0: #101013;
  --surface-1: #17171b;
  --surface-2: #202026;
  --border: #2c2c33;
  --text-primary: #f3f3f1;
  --text-secondary: #b9b8c4;
  --text-muted: #7c7b87;
  --series-1: #3987e5; /* direct blocks — blue, categorical slot 1 (dark step) */
  --series-2: #d95926; /* including modlist cascade — orange, slot 2 (dark step) */
  --series-3: #39c97a; /* follower growth — green, slot 3, own right-hand axis (different scale from blocks) */
  --good: #0ca30c;
  --critical: #e66767;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
}

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.head { text-align: center; margin-bottom: 28px; }
.head h1 {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}
.cee-anchor { cursor: pointer; }
.tag { color: var(--text-secondary); max-width: 560px; margin: 0 auto; font-size: 0.95rem; }

.lookup {
  display: flex;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto 12px;
}
.lookup input {
  flex: 1;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1rem;
  padding: 10px 12px;
}
.lookup input:focus { outline: 2px solid var(--series-1); outline-offset: 1px; }
.lookup button {
  background: var(--series-1);
  color: #04101f;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 18px;
  cursor: pointer;
}
.lookup button:disabled { opacity: 0.6; cursor: progress; }
.lookup button:hover:not(:disabled) { filter: brightness(1.1); }

.modlist-toggle {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto 20px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.modlist-toggle input { margin-top: 3px; }

.status {
  text-align: center;
  min-height: 1.4em;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.88rem;
}
.status.error { color: var(--critical); }

.data-window-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 10px 2px 0;
  line-height: 1.4;
}
.data-window-note a { color: var(--text-secondary); }

.result { margin-top: 20px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-tile .label { font-size: 0.75rem; color: var(--text-muted); }
.stat-tile .value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2px;
}
.stat-tile .sub { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }

.chart-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 18px 12px;
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.chart-head h2 { font-size: 0.95rem; font-weight: 600; margin: 0; color: var(--text-primary); }

.legend { display: flex; gap: 16px; font-size: 0.78rem; color: var(--text-secondary); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }

.chart-box { position: relative; }
#chart { width: 100%; height: 320px; display: block; }
#chart .grid { stroke: var(--border); stroke-width: 1; }
#chart .axis-text { fill: var(--text-muted); font-size: 10px; font-family: var(--font-mono); }
#chart .axis-text-right { fill: var(--series-3); font-size: 10px; font-family: var(--font-mono); }
#chart .line-direct { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
#chart .line-total { fill: none; stroke: var(--series-2); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
#chart .line-followers { fill: none; stroke: var(--series-3); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 5 3; }
#chart .area-direct { fill: var(--series-1); opacity: 0.08; }
#chart .area-total { fill: var(--series-2); opacity: 0.08; }
#chart .area-followers { fill: var(--series-3); opacity: 0.08; }
#chart .end-dot { stroke: var(--surface-1); stroke-width: 2; }
#chart .spike-marker { fill: var(--series-2); }

.crosshair-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--text-muted);
  pointer-events: none;
}
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  white-space: nowrap;
  transform: translate(-50%, -110%);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.tooltip .t-date { color: var(--text-muted); margin-bottom: 3px; }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; }
.tooltip .t-row + .t-row { margin-top: 2px; }
.tooltip .t-key { width: 10px; height: 2px; display: inline-block; }
.tooltip .t-val { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); }

.table-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 8px 0 2px;
  text-decoration: underline;
}
.table-wrap { max-height: 260px; overflow: auto; margin-top: 8px; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-family: var(--font-mono); }
.table-wrap th, .table-wrap td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.table-wrap th { color: var(--text-muted); position: sticky; top: 0; background: var(--surface-1); }

.spike {
  margin-top: 16px;
  background: var(--surface-1);
  border: 1px solid var(--series-2);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.spike strong { color: var(--text-primary); }

.share-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.share-btn {
  background: var(--series-1);
  color: #04101f;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}
.share-btn.secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--border); }
.share-btn:hover { filter: brightness(1.1); }

.blocklists { margin-top: 20px; }
.blocklists h2 { font-size: 0.95rem; font-weight: 600; margin: 0 0 4px; color: var(--text-primary); }
.blocklists-note { font-size: 0.78rem; color: var(--text-muted); margin: 0 0 10px; }
.blocklists-body {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.blocklist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  font-size: 0.85rem;
}
.blocklist-row + .blocklist-row { border-top: 1px solid var(--border); }
.blocklist-name { color: var(--text-primary); text-decoration: none; }
.blocklist-name[href]:hover { text-decoration: underline; }
.blocklist-count { font-family: var(--font-mono); color: var(--text-secondary); white-space: nowrap; }
.blocklists-empty { padding: 12px 14px; margin: 0; color: var(--text-muted); font-size: 0.85rem; }

.foot {
  margin-top: 48px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.foot a { color: var(--text-secondary); }
.foot p + p { margin-top: 6px; }

@media (max-width: 520px) {
  .lookup { flex-direction: column; }
  .head h1 { font-size: 1.7rem; }
}
