/* YouTube Stats — styles. Theme-aware; colours are the data-viz reference
   palette, exposed as tokens so charts and UI stay in sync in light & dark. */

:root {
  /* chart + ink tokens (light) */
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --card: #ffffff;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  /* series — categorical slots in the reference palette's fixed CVD-safe order.
     1/2 are blue+magenta (male/female, the app's original two); 3/4 add aqua+
     yellow for the 3-band age-mix trend (validated worst adjacent ΔE 47). */
  --series-1: #2a78d6; /* blue */
  --series-2: #e87ba4; /* magenta (2nd category) */
  --series-3: #1baf7a; /* aqua */
  --series-4: #eda100; /* yellow */
  /* status */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --shadow: 0 1px 2px rgba(11,11,11,.04), 0 6px 18px rgba(11,11,11,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --card: #161615;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d55181;
    --series-3: #199e70; /* aqua (dark step) */
    --series-4: #c98500; /* yellow (dark step) */
    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #d03b3b;
    --good-ink: #0ca30c;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
/* the `hidden` attribute must beat component display rules (.gate=grid, .loading=flex, …) */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 15px;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
a { color: var(--series-1); }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88em; background: color-mix(in srgb, var(--muted) 16%, transparent); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.empty { color: var(--muted); font-size: .9rem; padding: 1.5rem 0; text-align: center; }

/* ── Top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem 1.5rem; background: var(--card);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .8rem; }
.logo {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px;
  background: var(--critical); color: #fff; font-size: 15px;
}
.brand h1 { font-size: 1.15rem; }
.brand .sub { margin: 0; font-size: .8rem; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.channel-chip { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-secondary); }
.channel-chip img { width: 26px; height: 26px; border-radius: 50%; }

.range-picker { display: inline-flex; background: color-mix(in srgb, var(--muted) 12%, transparent); border-radius: 8px; padding: 3px; }
.range-picker button {
  border: 0; background: transparent; color: var(--text-secondary);
  padding: .3rem .7rem; border-radius: 6px; cursor: pointer; font: inherit; font-size: .85rem;
}
.range-picker button.active { background: var(--card); color: var(--text-primary); box-shadow: var(--shadow); font-weight: 600; }

button, .primary, .ghost { font-family: inherit; }
.primary {
  display: inline-block; background: var(--series-1); color: #fff; text-decoration: none;
  padding: .6rem 1.1rem; border-radius: 9px; font-weight: 600; border: 0; cursor: pointer;
}
.primary:hover { filter: brightness(1.06); }
.ghost {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  padding: .4rem .8rem; border-radius: 8px; cursor: pointer; font-size: .85rem;
}
.ghost:hover { color: var(--text-primary); }

/* ── Freshness banner ────────────────────────────────────────────────── */
.freshness {
  margin: 0; padding: .5rem 1.5rem; font-size: .8rem; color: var(--text-secondary);
  background: color-mix(in srgb, var(--series-1) 8%, var(--page)); border-bottom: 1px solid var(--border);
}

main { max-width: 1120px; margin: 0 auto; padding: 1.5rem; }

/* ── Connect gate ────────────────────────────────────────────────────── */
.gate { display: grid; place-items: center; min-height: 60vh; }
.gate-card { max-width: 560px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; box-shadow: var(--shadow); }
.gate-card h2 { font-size: 1.4rem; margin-bottom: .6rem; }
.gate-card p { color: var(--text-secondary); }
.gate-card .primary { margin-top: 1rem; }
.notice { margin-top: 1.2rem; padding: .8rem 1rem; border-radius: 10px; font-size: .88rem; }
.notice.warn { background: color-mix(in srgb, var(--warning) 15%, var(--card)); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); }

/* ── Panels ──────────────────────────────────────────────────────────── */
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; }
.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 780px) { .two-col { grid-template-columns: 1fr; } }

/* ── Funnel ──────────────────────────────────────────────────────────── */
.funnel-panel { background: linear-gradient(135deg, color-mix(in srgb, var(--series-1) 7%, var(--card)), var(--card)); }
.funnel h2 { font-size: 1.05rem; margin-bottom: .3rem; }
.funnel > p { color: var(--text-secondary); font-size: .9rem; margin: 0 0 1rem; }
.funnel-stages { display: flex; gap: .4rem; flex-wrap: wrap; }
.fstage {
  flex: 1 1 140px; min-width: 130px; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem .7rem; position: relative;
}
.fstage .k { font-weight: 650; font-size: .9rem; display: flex; align-items: center; gap: .35rem; }
.fstage .n { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.fstage .step { color: var(--series-1); font-variant-numeric: tabular-nums; font-size: .72rem; font-weight: 700; }
.funnel-note { margin-top: .9rem; font-size: .82rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: .7rem; }

/* ── Tiles ───────────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.1rem;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .15rem;
}
.tile .t-label { font-size: .8rem; color: var(--muted); display: flex; align-items: center; gap: .35rem; }
.tile .t-value { font-size: 1.85rem; font-weight: 680; letter-spacing: -0.02em; }
.tile .t-delta { font-size: .8rem; font-weight: 600; display: inline-flex; align-items: center; gap: .25rem; }
.t-delta.up { color: var(--good-ink); }
.t-delta.down { color: var(--critical); }
.t-delta.flat { color: var(--muted); }
.tile .t-verdict { margin-top: .55rem; font-size: .82rem; color: var(--text-secondary); border-top: 1px solid var(--border); padding-top: .55rem; }
.tile .t-status { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.status-good { color: var(--good-ink); }
.status-watch { color: var(--series-1); }
.status-warning { color: var(--serious); }
.status-neutral { color: var(--muted); }
.dot-status { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-status.good { background: var(--good); }
.dot-status.watch { background: var(--series-1); }
.dot-status.warning { background: var(--warning); }
.dot-status.neutral { background: var(--muted); }

/* ── Interpretation blocks ───────────────────────────────────────────── */
.interp { font-size: .88rem; }
.interp h4 { margin: 0 0 .3rem; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.interp p { margin: 0 0 .8rem; color: var(--text-secondary); }
.interp .verdict {
  border-left: 3px solid var(--series-1); padding: .5rem .8rem; border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--series-1) 6%, transparent); color: var(--text-primary);
  display: flex; gap: .5rem; align-items: flex-start;
}
.interp .verdict.good { border-color: var(--good); background: color-mix(in srgb, var(--good) 8%, transparent); }
.interp .verdict.warning { border-color: var(--serious); background: color-mix(in srgb, var(--serious) 9%, transparent); }
.interp .verdict.neutral { border-color: var(--muted); background: color-mix(in srgb, var(--muted) 8%, transparent); }
.interp .verdict .ico { flex: 0 0 auto; margin-top: .05rem; }

/* ── Charts ──────────────────────────────────────────────────────────── */
.chart { width: 100%; overflow-x: auto; }
svg.viz { width: 100%; height: auto; display: block; }
svg.viz .grid { stroke: var(--grid); stroke-width: 1; }
svg.viz .grid.ref { stroke: var(--baseline); stroke-dasharray: 3 3; }
svg.viz .axis { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }
svg.viz .end-label { fill: var(--text-secondary); font-size: 11px; font-weight: 500; }
svg.viz .crosshair { stroke: var(--baseline); stroke-width: 1; stroke-dasharray: 3 3; }
svg.viz .dot { stroke: var(--card); stroke-width: 2; }

.seg { display: inline-flex; background: color-mix(in srgb, var(--muted) 12%, transparent); border-radius: 8px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--text-secondary); padding: .3rem .7rem; border-radius: 6px; cursor: pointer; font: inherit; font-size: .82rem; }
.seg button.active { background: var(--card); color: var(--text-primary); box-shadow: var(--shadow); font-weight: 600; }

/* horizontal bars */
.hbars { display: flex; flex-direction: column; gap: .5rem; }
.hbar { display: grid; grid-template-columns: 140px 1fr auto; align-items: center; gap: .7rem; font-size: .85rem; }
.hbar-label { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: color-mix(in srgb, var(--muted) 14%, transparent); border-radius: 5px; height: 16px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 5px 4px 4px 5px; min-width: 2px; }
.hbar-val { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
@media (max-width: 560px) { .hbar { grid-template-columns: 96px 1fr auto; } }

/* paired bars */
.paired { display: flex; flex-direction: column; gap: .45rem; }
.legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--text-secondary); margin-bottom: .4rem; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }
.paired-row { display: grid; grid-template-columns: 68px 1fr; align-items: center; gap: .7rem; }
.paired-label { font-size: .82rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.paired-bars { display: flex; flex-direction: column; gap: 3px; }
.pb { display: flex; align-items: center; gap: .5rem; }
.pb-fill { height: 11px; border-radius: 3px; min-width: 2px; }
.pb span { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Subscribers block ───────────────────────────────────────────────── */
.sub-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr)); gap: .8rem; margin-bottom: 1rem; }
.sub-stat { background: color-mix(in srgb, var(--muted) 7%, transparent); border-radius: 10px; padding: .7rem .8rem; }
.sub-stat .v { font-size: 1.35rem; font-weight: 680; }
.sub-stat .l { font-size: .76rem; color: var(--muted); }
.sub-stat .v.pos { color: var(--good-ink); }
.sub-stat .v.neg { color: var(--critical); }
.split-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin-top: .3rem; }
.split-bar .seg-sub { background: var(--series-1); }
.split-bar .seg-non { background: color-mix(in srgb, var(--muted) 28%, transparent); }
.split-bar div { display: grid; place-items: center; color: #fff; font-size: .74rem; font-weight: 600; }
.split-bar .seg-non { color: var(--text-primary); }
.split-legend { display:flex; gap:1rem; font-size:.76rem; color:var(--muted); margin-top:.4rem; }

/* ── Mini tiles (engagement) ─────────────────────────────────────────── */
.mini-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1rem; }
.mini-tile { border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; }
.mini-tile .mt-top { display: flex; align-items: baseline; justify-content: space-between; }
.mini-tile .mt-val { font-size: 1.5rem; font-weight: 680; }
.mini-tile .mt-label { font-size: .82rem; color: var(--muted); }
.mini-tile .mt-verdict { margin-top: .5rem; font-size: .8rem; color: var(--text-secondary); }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { text-align: right; padding: .55rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }
td { font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: color-mix(in srgb, var(--series-1) 6%, transparent); }
tbody tr.selected { background: color-mix(in srgb, var(--series-1) 12%, transparent); }
.vid-cell { display: flex; align-items: center; gap: .6rem; max-width: 380px; }
.vid-cell img { width: 64px; height: 36px; border-radius: 5px; object-fit: cover; flex: 0 0 auto; }
.vid-cell .vt { white-space: normal; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ── Compare with your own videos ────────────────────────────────────── */
.compare-head { align-items: center; }
.compare-picker { display: inline-flex; align-items: center; gap: .5rem; }
#playlistSelect {
  font: inherit; font-size: .85rem; padding: .35rem .6rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-primary);
  max-width: 260px;
}
.compare-controls { display: flex; flex-wrap: wrap; gap: .6rem 1rem; margin-bottom: 1rem; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }
.compare-method {
  margin: .2rem 0 1rem; padding: .6rem .8rem; border-radius: 8px; line-height: 1.5;
  background: color-mix(in srgb, var(--muted) 8%, transparent);
}
svg.viz.cbars .cbar-track { fill: color-mix(in srgb, var(--muted) 12%, transparent); }
svg.viz.cbars .cbar-label { fill: var(--text-secondary); font-size: 12px; font-family: system-ui, sans-serif; }
svg.viz.cbars .cbar-label.hi { fill: var(--text-primary); font-weight: 600; }
svg.viz.cbars .cbar-val { fill: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; font-family: system-ui, sans-serif; }
#compareTable { margin-top: 1rem; }
#compareTable tbody tr { cursor: default; }
#compareTable td.num, #compareTable th.num { text-align: right; }

/* ── Momentum ────────────────────────────────────────────────────────── */
#momTable { margin-top: 1rem; }
#momTable tbody tr { cursor: default; }
#momTable td.win-active { color: var(--text-primary); font-weight: 680; }
#momTable th.win-active { color: var(--text-primary); }
.pace-up { color: var(--good-ink); }
.pace-down { color: var(--critical); }
.mom-new {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--good-ink); border: 1px solid currentColor; border-radius: 999px;
  padding: .05rem .45rem;
}

/* ── Revenue ─────────────────────────────────────────────────────────── */
.rev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 1rem; margin-bottom: 1rem; }
.rev-tile { border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; }
.rev-tile .rv { font-size: 1.5rem; font-weight: 680; }
.rev-tile .rl { font-size: .8rem; color: var(--muted); }

.audience-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 2rem; }
@media (max-width: 780px) { .audience-grid { grid-template-columns: 1fr; } }
.audience-grid h3 { font-size: .9rem; margin-bottom: .6rem; }

/* Sub-block header inside a panel (e.g. the demographics-over-time toggle) */
.subhead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 1.6rem 0 .8rem; }
.subhead h3 { font-size: .95rem; margin: 0; }
.demo-video-block { margin-top: 1.4rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.demo-video-block h3 { font-size: .92rem; margin: 0 0 .2rem; }

/* ── Page tabs (Dashboard / Trends by type) ──────────────────────────── */
.tabs { display: flex; gap: .3rem; margin: 0 auto 1.2rem; max-width: 1120px; padding: 0 1.5rem; }
.tab-btn {
  appearance: none; border: none; background: transparent; cursor: pointer;
  font: inherit; font-size: .92rem; font-weight: 600; color: var(--muted);
  padding: .55rem .9rem; border-radius: 9px 9px 0 0; border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: var(--text-secondary); background: color-mix(in srgb, var(--series-1) 6%, transparent); }
.tab-btn.active { color: var(--series-1); border-bottom-color: var(--series-1); }

/* ── Trends-by-type small-multiples grid ─────────────────────────────── */
.trend-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.2rem 1.6rem; }
.trend-cell { min-width: 0; }
.trend-cell h4 { font-size: .85rem; margin: 0 0 .1rem; color: var(--text-primary); }
.trend-cell .tc-latest { font-size: .76rem; color: var(--muted); margin: 0 0 .3rem; font-variant-numeric: tabular-nums; }
.trend-picker { display: flex; align-items: center; gap: .5rem; }
.trend-picker select { padding: .4rem .6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text-primary); font: inherit; font-size: .88rem; }

/* ── Followers tab: view + horizon toggles ────────────────────────────── */
.fol-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.fol-controls .seg button { font-size: .82rem; }

/* ── Demographics tab: two-toggle head + by-video over-index list ─────── */
.demo-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.demo-vlist { display: flex; flex-direction: column; }
.demo-vrow { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; align-items: center; padding: .6rem 0; border-top: 1px solid var(--border); }
.demo-vrow:first-child { border-top: 0; }
.demo-vrow .vid-cell { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.demo-vrow .vid-cell img { width: 72px; height: 40px; object-fit: cover; border-radius: 6px; flex: none; }
.demo-vrow .vt { font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.demo-vrow .skews { display: flex; flex-wrap: wrap; gap: .3rem .6rem; justify-content: flex-end; }
.cut { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .25rem; }
.cut-l { font-size: .64rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-right: .1rem; }
.skew-chip {
  display: inline-flex; align-items: baseline; gap: .25rem; font-size: .78rem;
  background: color-mix(in srgb, var(--series-1) 12%, transparent);
  color: var(--text-primary); border: 1px solid color-mix(in srgb, var(--series-1) 30%, transparent);
  padding: .15rem .45rem; border-radius: 999px; white-space: nowrap;
}
.skew-chip b { color: var(--good-ink); font-variant-numeric: tabular-nums; }
@media (max-width: 620px) {
  .demo-vrow { grid-template-columns: 1fr; gap: .4rem; }
  .demo-vrow .skews { justify-content: flex-start; }
}

/* ── Retention overlay (last-N videos of one type) ───────────────────── */
.ret-controls { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.ret-controls .seg button { font-size: .82rem; }
#retPlaylistSelect {
  font: inherit; font-size: .85rem; padding: .35rem .6rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card); color: var(--text-primary); max-width: 260px;
}
.ret-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 820px) { .ret-layout { grid-template-columns: 1fr; } }
.ret-list { display: flex; flex-direction: column; gap: .4rem; max-height: 440px; overflow-y: auto; padding-right: .3rem; }
.ret-vid {
  display: grid; grid-template-columns: 88px 1fr; gap: .6rem; align-items: center;
  text-align: left; cursor: pointer; font: inherit; width: 100%;
  background: var(--card); border: 1px solid var(--border); border-radius: 9px; padding: .4rem;
}
.ret-vid:hover:not(:disabled) { border-color: color-mix(in srgb, var(--series-1) 45%, var(--border)); background: color-mix(in srgb, var(--series-1) 5%, var(--card)); }
.ret-vid.selected { border-color: var(--series-1); box-shadow: 0 0 0 1px var(--series-1) inset; }
.ret-vid:disabled { opacity: .5; cursor: default; }
.rv-thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: 5px; overflow: hidden;
  background: color-mix(in srgb, var(--muted) 14%, transparent);
}
.rv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rv-main { min-width: 0; }
.rv-title { font-size: .82rem; font-weight: 600; color: var(--text-primary); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rv-meta { font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: .15rem; }

/* ── AI summary ──────────────────────────────────────────────────────── */
.insight-panel { background: linear-gradient(135deg, color-mix(in srgb, var(--series-1) 9%, var(--card)), var(--card)); }
.primary.sm { padding: .45rem .9rem; font-size: .85rem; }
.insight-body { min-height: 2rem; }
.insight-text { font-size: 1.02rem; line-height: 1.6; color: var(--text-primary); margin: 0; }
.insight-meta { margin-top: .7rem; }

/* ── Callout ─────────────────────────────────────────────────────────── */
.callout { background: color-mix(in srgb, var(--warning) 8%, var(--card)); border-color: color-mix(in srgb, var(--warning) 30%, var(--border)); }
.callout h2 { font-size: 1rem; margin-bottom: .5rem; }
.callout p { color: var(--text-secondary); font-size: .9rem; margin: 0; }

/* ── Loading / misc ──────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; gap: .6rem; justify-content: center; padding: 3rem; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--grid); border-top-color: var(--series-1); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.foot { max-width: 1120px; margin: 1rem auto 3rem; padding: 0 1.5rem; }
.foot p { font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 1rem; }

/* ── Tooltip (shared) ────────────────────────────────────────────────── */
.viz-tip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--card);
  border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow);
  padding: .5rem .7rem; font-size: .8rem; color: var(--text-primary); max-width: 260px;
}
.viz-tip .tip-title { font-weight: 650; margin-bottom: .2rem; }
.viz-tip .tip-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .35rem; vertical-align: 0; }

/* ── Video library ───────────────────────────────────────────────────── */
.videos-controls { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.videos-controls .seg button { font-size: .82rem; }
.vid-count { margin: 0 0 1rem; }
.vid-list { display: flex; flex-direction: column; gap: 1rem; }
.vid-card {
  display: grid; grid-template-columns: 200px 1fr; gap: 1.1rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: .9rem; align-items: start;
}
.vc-thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 8px;
  overflow: hidden; background: color-mix(in srgb, var(--muted) 14%, transparent);
}
.vc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vc-noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 1.4rem; }
.vc-dur {
  position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.82); color: #fff;
  font-size: .72rem; font-weight: 600; padding: .05rem .3rem; border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.vc-main { min-width: 0; }
.vc-title { font-size: 1rem; line-height: 1.3; margin: 0 0 .35rem; }
.vc-title a { color: var(--text-primary); text-decoration: none; }
.vc-title a:hover { color: var(--series-1); }
.vc-meta {
  display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .82rem; color: var(--muted);
  font-variant-numeric: tabular-nums; margin-bottom: .7rem;
}
.vc-meta strong { color: var(--text-primary); }
.vc-summary { border-top: 1px solid var(--border); padding-top: .7rem; }
.vc-text { font-size: .92rem; line-height: 1.55; }
.vc-summary .insight-meta { margin-top: .5rem; }
.loading.sm { padding: .6rem 0; justify-content: flex-start; font-size: .85rem; }
@media (max-width: 620px) {
  .vid-card { grid-template-columns: 1fr; }
  .vc-thumb { max-width: 260px; }
}

/* ── Q&A prep ─────────────────────────────────────────────────────────── */
/* Video picker: a compact clickable list of the list's videos. */
.qna-vid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .7rem; }
.qna-vid {
  display: grid; grid-template-columns: 128px 1fr; gap: .8rem; align-items: center;
  text-align: left; cursor: pointer; font: inherit;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: .55rem;
}
.qna-vid:hover { border-color: color-mix(in srgb, var(--series-1) 45%, var(--border)); background: color-mix(in srgb, var(--series-1) 5%, var(--card)); }
.qna-vid.selected { border-color: var(--series-1); box-shadow: 0 0 0 1px var(--series-1) inset; }
.qv-thumb {
  position: relative; display: block; aspect-ratio: 16 / 9; border-radius: 6px;
  overflow: hidden; background: color-mix(in srgb, var(--muted) 14%, transparent);
}
.qv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.qv-thumb .vc-noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.qv-main { min-width: 0; }
.qv-title { display: block; font-size: .9rem; font-weight: 600; color: var(--text-primary); line-height: 1.3; margin-bottom: .2rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qv-meta { display: block; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.qv-meta strong { color: var(--text-primary); }

/* Clustered questions: each is a disclosure that opens to its commenters. */
.qna-intro { margin: 0 0 .8rem; }
.qna-q-list { display: flex; flex-direction: column; gap: .55rem; }
.qna-q { border: 1px solid var(--border); border-radius: 10px; background: var(--card); overflow: hidden; }
.qna-q[open] { border-color: color-mix(in srgb, var(--series-1) 40%, var(--border)); }
.qna-q > summary {
  display: flex; align-items: center; gap: .7rem; cursor: pointer; list-style: none;
  padding: .7rem .85rem; font-weight: 600; color: var(--text-primary);
}
.qna-q > summary::-webkit-details-marker { display: none; }
.qna-q > summary:hover { background: color-mix(in srgb, var(--series-1) 5%, transparent); }
.qq-rank {
  flex: 0 0 auto; width: 1.5rem; height: 1.5rem; display: grid; place-items: center;
  border-radius: 50%; background: color-mix(in srgb, var(--series-1) 15%, transparent);
  color: var(--series-1); font-size: .8rem; font-weight: 700;
}
.qq-text { flex: 1 1 auto; line-height: 1.4; }
.qq-count {
  flex: 0 0 auto; min-width: 1.7rem; text-align: center; padding: .1rem .45rem; border-radius: 20px;
  background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--text-secondary);
  font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.qq-members { padding: .2rem .85rem .8rem; display: flex; flex-direction: column; gap: .7rem; border-top: 1px solid var(--border); }

/* A commenter row — reused by the cluster members and the full-thread list. */
.qna-member, .qna-comment { display: grid; grid-template-columns: 32px 1fr; gap: .6rem; align-items: start; }
.qna-member { padding-top: .7rem; }
.qm-av { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; display: block; }
.qm-noav { display: grid; place-items: center; background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
.qm-body { min-width: 0; }
.qm-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .6rem; margin-bottom: .15rem; }
.qm-author { font-weight: 600; font-size: .85rem; color: var(--text-primary); }
.qm-likes { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.qm-text { font-size: .88rem; line-height: 1.5; color: var(--text-secondary); white-space: pre-wrap; overflow-wrap: anywhere; }

/* Extract-questions trigger (above the comments) + the comment thread below. */
.qna-extract { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.qna-comments-head { display: flex; align-items: baseline; gap: .6rem; margin-top: 1.4rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.qna-comments-head h3 { margin: 0; font-size: .95rem; }
.qna-comment-list { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; max-height: 640px; overflow-y: auto; padding-right: .3rem; }
.qm-date, .qm-replies { font-variant-numeric: tabular-nums; }
@media (max-width: 620px) {
  .qna-vid-list { grid-template-columns: 1fr; }
}
