:root {
  --bg: #0a0e14;
  --bg-2: #10151f;
  --panel: #131a26;
  --panel-2: #172032;
  --line: #232d3f;
  --line-2: #2c3852;
  --text: #e6ecf5;
  --muted: #7d8aa3;
  --muted-2: #56617a;
  --accent: #37e6b0;
  --accent-dim: #1f8f6f;
  --hot: #ff5b52;
  --hot-bg: #2a1414;
  --major: #ff8a3d;
  --minor: #ffd23d;
  --viral: #ff3b6b;
  --blue: #4d9fff;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, #0f1826 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); background: var(--bg-2); padding: 1px 5px; border-radius: 4px; font-size: 0.85em; color: var(--accent); }
h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 14px; font-weight: 600; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 20, 0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); align-self: center; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.brand-name { font-family: var(--mono); font-weight: 700; letter-spacing: 0.14em; font-size: 14px; }
.brand-sub { color: var(--muted-2); font-size: 12px; letter-spacing: 0.02em; }
.topnav { display: flex; gap: 20px; }
.topnav a { color: var(--muted); font-size: 13px; padding: 4px 0; border-bottom: 2px solid transparent; }
.topnav a:hover, .topnav a.is-active { color: var(--text); border-color: var(--accent); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 28px 80px; }

/* ---- stats ---- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-v { font-family: var(--mono); font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.stat-k { color: var(--muted); font-size: 12px; margin-top: 4px; }
.stat--hot { border-color: var(--hot); background: linear-gradient(180deg, #241318, var(--panel)); }
.stat--hot .stat-v { color: var(--hot); }

/* ---- panels ---- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px;
}
.panel--empty { color: var(--muted); text-align: center; padding: 32px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.panel .count { color: var(--accent); font-family: var(--mono); margin-left: 6px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.two-col h2 { margin-bottom: 10px; }

/* ---- dropzone ---- */
.dropzone-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; }
.dropzone {
  border: 1.5px dashed var(--line-2); border-radius: 10px; padding: 30px;
  text-align: center; cursor: pointer; transition: 0.15s; background: var(--bg-2);
}
.dropzone:hover, .dropzone:focus { border-color: var(--accent-dim); background: #0d1320; outline: none; }
.dropzone.is-over { border-color: var(--accent); background: #0e1a18; box-shadow: inset 0 0 40px rgba(55, 230, 176, 0.06); }
.dz-icon { font-size: 26px; color: var(--accent); }
.dz-title { font-weight: 600; margin-top: 8px; }
.dz-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.dz-controls { display: flex; align-items: center; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.dz-controls label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
select, input, button { font-family: var(--sans); font-size: 13px; }
select, input[type=text], .new-tab-form input {
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text);
  padding: 8px 10px; border-radius: 8px;
}
button {
  background: var(--accent); color: #04120d; border: none; padding: 9px 16px;
  border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.15s;
}
button:hover:not(:disabled) { filter: brightness(1.1); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
/* secondary action — outlined, so it reads as distinct from the green primary */
.btn-secondary {
  background: var(--panel-2); color: var(--accent); border: 1px solid var(--accent-dim);
  font-weight: 600;
}
.btn-secondary:hover:not(:disabled) { background: rgba(55,230,176,0.12); filter: none; }
.dz-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.thumb { position: relative; width: 84px; height: 56px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-x { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; padding: 0; border-radius: 50%; background: rgba(0,0,0,0.7); color: #fff; font-size: 12px; line-height: 1; }
.dz-status { margin-top: 10px; font-size: 13px; min-height: 18px; }
.dz-hint { color: var(--muted); font-size: 12.5px; margin: 14px 0 0; line-height: 1.6; }
.dz-hint em { color: var(--accent); font-style: normal; }
.ok { color: var(--accent); }
.err { color: var(--hot); }

.src-channel-label input { width: 180px; }
.src-tag { color: var(--accent); font-family: var(--mono); font-size: 12px; }

/* inline "add channel" on the tab header */
.inline-add { display: inline-flex; gap: 6px; align-items: center; margin-left: 6px; }
.inline-add input { width: 200px; padding: 5px 9px; font-size: 12px; }
.inline-add button { padding: 5px 12px; font-size: 12px; }
.chan-tag { display: inline-block; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 7px; font-family: var(--mono); font-size: 12px; color: var(--text); margin-right: 2px; }

/* ---- new tab form ---- */
.new-tab-form { display: flex; gap: 10px; flex-wrap: wrap; }
.new-tab-form input { flex: 1; min-width: 180px; }

/* ---- tables ---- */
.table-scroll { overflow-x: auto; margin: 0 -4px; }
.vtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.vtable th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.vtable td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.vtable tbody tr:hover { background: var(--panel-2); }
.vtable.small td, .vtable.small th { padding: 6px 8px; }
.c-num { text-align: right; font-family: var(--mono); }
.c-title { font-weight: 500; max-width: 360px; }
.c-handle { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.flame { filter: saturate(1.4); }

/* outlier row emphasis */
.vrow--hot { background: linear-gradient(90deg, rgba(255, 91, 82, 0.08), transparent 40%); }
.vrow--hot .c-title { color: #ffd9d6; }
.vrow--viral { box-shadow: inset 3px 0 0 var(--viral); }
.vrow--major { box-shadow: inset 3px 0 0 var(--major); }
.vrow--minor { box-shadow: inset 3px 0 0 var(--minor); }

/* chips */
.chip { font-family: var(--mono); font-size: 11.5px; padding: 3px 8px; border-radius: 20px; white-space: nowrap; font-weight: 600; }
.chip--viral { background: rgba(255, 59, 107, 0.16); color: var(--viral); border: 1px solid rgba(255,59,107,0.4); }
.chip--major { background: rgba(255, 138, 61, 0.14); color: var(--major); border: 1px solid rgba(255,138,61,0.35); }
.chip--minor { background: rgba(255, 210, 61, 0.12); color: var(--minor); border: 1px solid rgba(255,210,61,0.3); }
.chip--baseline { background: var(--bg-2); color: var(--muted); border: 1px solid var(--line-2); }
.chip--unscored { background: transparent; color: var(--muted-2); border: 1px dashed var(--line-2); }

/* video thumbnails */
.c-thumb { width: 92px; padding-right: 4px; }
.vthumb { width: 84px; height: 47px; border-radius: 6px; object-fit: cover; display: block; border: 1px solid var(--line-2); background: var(--bg-2); }
.thumb-link { display: block; transition: 0.12s; }
.thumb-link:hover .vthumb { border-color: var(--accent); transform: scale(1.04); }
.vthumb--empty { display: flex; align-items: center; justify-content: center; color: var(--muted-2); font-size: 16px; }
.vtitle-link { color: inherit; }
.vtitle-link:hover { color: var(--accent); text-decoration: underline; }
.niche-tag { font-size: 11px; }
.video-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.video-label { display: inline-block; border: 1px solid rgba(255,210,61,0.35); background: rgba(255,210,61,0.10); color: var(--minor); border-radius: 999px; padding: 1px 6px; font-family: var(--mono); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.video-label--pro-canada { border-color: rgba(55,230,176,0.35); background: rgba(55,230,176,0.10); color: var(--accent); }
.video-label--anti-canada { border-color: rgba(255,91,82,0.38); background: rgba(255,91,82,0.11); color: var(--hot); }
.video-label--canada-mixed { border-color: rgba(77,159,255,0.35); background: rgba(77,159,255,0.10); color: var(--blue); }

/* channel avatars + links */
.avatar-wrap { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; overflow: hidden; background: var(--panel-2); }
.avatar-wrap .avatar { width: 100%; height: 100%; display: block; }
.avatar { border-radius: 50%; object-fit: cover; flex: none; background: var(--panel-2); vertical-align: middle; }
.avatar--mono { display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--line-2), var(--panel-2)); color: var(--text); font-weight: 700; font-family: var(--mono); }
.c-chan { min-width: 150px; }
.chan-link { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.chan-link:hover { color: var(--text); }
.chan-link:hover .chan-name { text-decoration: underline; }
.chan-name { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.own-label { margin-right: 2px; }
.own-chan { display: inline-flex; margin-right: 8px; }
.own-chan .chan-link { color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2); padding: 3px 10px 3px 4px; border-radius: 20px; }
.own-chan .chan-name { font-size: 13px; }

/* trend / growth */
.trend { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.trend--up { color: var(--accent); }
.trend--down { color: var(--hot); }
.trend--none { color: var(--muted-2); }
.c-views { font-weight: 600; }

.src { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 4px; }
.src--nexlev { background: rgba(77,159,255,0.15); color: var(--blue); }
.src--fallback { background: rgba(125,138,163,0.14); color: var(--muted); }
.src--none { color: var(--muted-2); }

/* pills */
.pill { font-size: 10.5px; padding: 2px 8px; border-radius: 20px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.pill--direct { background: rgba(77,159,255,0.14); color: var(--blue); }
.pill--rising { background: rgba(55,230,176,0.14); color: var(--accent); }
.pill--wait { background: rgba(255,210,61,0.14); color: var(--minor); }
.pill--proc { background: rgba(55,230,176,0.16); color: var(--accent); display: inline-flex; align-items: center; gap: 6px; }
.pill--err { background: rgba(255,91,82,0.16); color: var(--hot); }
.spin { width: 9px; height: 9px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.batch-err { color: var(--hot); font-family: var(--mono); font-size: 11px; margin: 4px 0 0 4px; }
.pill--port { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line-2); }

/* ---- pending ---- */
.panel--pending { border-color: var(--line-2); background: linear-gradient(180deg, #16130a, var(--panel)); }
.pending-list { list-style: none; padding: 0; margin: 0 0 10px; }
.pending-list li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 12.5px; }

/* ---- track competitor box ---- */
.track-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.track-box .inline-add { margin: 0; }
.track-box input { width: 320px; }
.track-hint { font-size: 12px; }
.channel-filter { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }
.filter-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: var(--text); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.filter-head--secondary { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); }
.filter-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-pills--worth { margin-bottom: 2px; }
.filter-empty { font-size: 12px; margin-bottom: 4px; }
.channel-filter-pill { display: inline-flex; align-items: center; gap: 7px; background: var(--panel); color: var(--muted); border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 10px; font-size: 12px; }
.channel-filter-pill .chan-link { color: inherit; gap: 5px; pointer-events: none; }
.channel-filter-pill .chan-name { font-size: 11px; }
.channel-filter-pill > span { font-family: var(--mono); font-size: 11px; }
.channel-filter-pill:hover, .channel-filter-pill.is-active { border-color: var(--accent-dim); color: var(--text); background: rgba(55,230,176,0.10); filter: none; }
.channel-filter-pill--worth { border-color: rgba(255,210,61,0.45); color: var(--text); background: linear-gradient(180deg, rgba(255,210,61,0.12), var(--panel)); box-shadow: inset 0 0 0 1px rgba(255,210,61,0.05); }
.channel-filter-pill--worth:hover, .channel-filter-pill--worth.is-active { border-color: var(--minor); background: rgba(255,210,61,0.18); }
.worth-mark { color: var(--minor); font-weight: 800; }
.vrow.is-filtered-out { display: none; }

/* ---- audience snapshots gallery ---- */
.snap-list { display: flex; flex-direction: column; gap: 16px; }
.snap-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: var(--panel-2); }
.snap-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.snap-date { font-weight: 700; font-size: 14px; }
.snap-time { font-size: 12px; }
.snap-from .chan-link { background: var(--bg-2); border: 1px solid var(--line-2); padding: 2px 9px 2px 3px; border-radius: 20px; color: var(--text); }
.snap-niche { background: rgba(106, 166, 255, 0.14); border: 1px solid rgba(106, 166, 255, 0.32); color: var(--text); border-radius: 999px; padding: 3px 9px; font-size: 11px; font-weight: 700; }
.snap-count { margin-left: auto; font-size: 12px; font-family: var(--mono); }
.snap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.snap-thumb { display: block; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--bg-2); aspect-ratio: 4 / 3; cursor: zoom-in; transition: 0.12s; }
.snap-thumb:hover { border-color: var(--accent); transform: translateY(-2px); }
.snap-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }

/* structured audience data inside a snapshot */
.snap-sub { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 16px 0 8px; font-weight: 600; }
.snap-sub:first-child { margin-top: 4px; }
.chan-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chan-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 20px; padding: 3px 12px 3px 4px; }
.chan-chip .chan-link { color: var(--text); }
.chan-chip .chan-name { font-size: 12.5px; }
.chan-subs { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.snap-demo { max-width: 420px; }
.snap-demo .snap-thumb { aspect-ratio: auto; }
.snap-demo .snap-thumb img { object-fit: contain; height: auto; }
.snap-originals { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.snap-originals summary { cursor: pointer; color: var(--muted); font-size: 12px; user-select: none; }
.snap-originals summary:hover { color: var(--text); }
.snap-originals .snap-grid { margin-top: 10px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(4,7,12,0.92); z-index: 100; display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 40px; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 20px 80px rgba(0,0,0,0.6); }
.lightbox-close { position: fixed; top: 18px; right: 26px; font-size: 34px; color: #fff; cursor: pointer; line-height: 1; }

/* ---- tab cards ---- */
.tab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tab-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 16px; transition: 0.15s; display: block; }
.tab-card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.tab-card--hot { border-color: rgba(255,91,82,0.4); }
.tab-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.tab-card-niche { font-weight: 600; font-size: 15px; }
.tab-card-port { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tab-card-metrics { display: flex; gap: 14px; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.tab-card-metrics .hot-count { color: var(--hot); }
.tab-card-top { margin-top: 10px; font-size: 12px; color: var(--major); border-top: 1px solid var(--line); padding-top: 8px; }
.empty-tabs { color: var(--muted); padding: 20px 0; }
.hot-count { color: var(--hot); }

/* ---- tab page header ---- */
.back { color: var(--muted); font-size: 13px; display: inline-block; margin-bottom: 14px; }
.back:hover { color: var(--text); }
.tab-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tab-registry { display: flex; gap: 24px; }
.tab-registry > div { display: flex; flex-direction: column; }
.tab-registry span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.tab-registry strong { font-family: var(--mono); font-size: 18px; }

/* horizon toggle */
.horizon { display: flex; gap: 4px; background: var(--bg-2); padding: 3px; border-radius: 8px; border: 1px solid var(--line); }
.hbtn { padding: 5px 12px; border-radius: 6px; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.hbtn:hover { color: var(--text); }
.hbtn.is-active { background: var(--accent); color: #04120d; font-weight: 600; }

@media (max-width: 760px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .tab-header { flex-direction: column; }
}
