/* The YouTube page (Insights, 2026-10-24) + its charts (js/charts/line.js, scatter.js) + the GA4 card (also on the
   Dashboard). Same tokens as shadcn.css; dark is the default, light through :root[data-theme="light"]. */
:root[data-theme] { --yt-clicks: #ffbf00; --yt-dot: #fe0000; }
:root[data-theme="light"] { --yt-clicks: #d97706; --yt-dot: #e00000; }

.icon--logo { object-fit: contain; }
.yt-view > * + * { margin-top: 14px; }
.yt-title { display: inline-flex; align-items: center; }

/* ---------- top cards */
.yt-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)) repeat(2, minmax(0, 1.45fr)); }
.yt-kpi { min-width: 0; }
.yt-kpi .kpi__sub { overflow-wrap: anywhere; }
.yt-kpi .trend { margin-left: 0; }
button.yt-best { text-align: left; font: inherit; color: inherit; border: 0; }
.yt-best:hover { box-shadow: 0 0 0 1px var(--line-strong), var(--card-shadow); }
.yt-best:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.yt-best__body { display: flex; align-items: center; gap: 10px; min-width: 0; }
.yt-best__text { display: grid; gap: 2px; min-width: 0; }
.yt-best__title { font: 600 13.5px/1.3 var(--f-body); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumb--best { width: 76px; border-radius: 5px; }
.thumb--mini { width: 56px; border-radius: 4px; }
.yt-best.is-empty { opacity: 0.8; }
@media (max-width: 1400px) { .yt-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } .yt-best { grid-column: span 2; } }
@media (max-width: 760px) { .yt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .yt-best { grid-column: 1 / -1; } }

/* ---------- scatter + side column */
.yt-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.yt-grid > .card, .yt-side > .card { margin-top: 0; }
.yt-side { display: grid; gap: 14px; min-width: 0; }
@media (max-width: 1100px) { .yt-grid { grid-template-columns: minmax(0, 1fr); } }
.yt-nolink { border: 1px solid color-mix(in srgb, var(--yt-clicks) 45%, transparent); }
.yt-nolink.is-ok { border-color: var(--line); }
.yt-nolink .card__title { display: inline-flex; align-items: center; gap: 8px; }
.yt-nolink .card__title .icon { width: 16px; height: 16px; color: var(--lime-ink); }
.yt-warn { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--yt-clicks); color: #1a1100; font: 800 12px var(--f-mono); }
.yt-nolink__hint { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.yt-nolink__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.yt-nolink__list li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.yt-nolink__text { display: grid; min-width: 0; flex: 1; font-size: 13px; }
.yt-nolink__text a { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.yt-nolink__text a:hover { text-decoration: underline; }
.yt-copy { flex: none; gap: 5px; }
.yt-copy .icon { width: 14px; height: 14px; }

/* ---------- GA4 card */
.ga4c { gap: 6px; }
.ga4c__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chip-state { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; border: 1px dashed var(--dash); color: var(--muted); font: 600 11px var(--f-body); }
.chip-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--dash); }
.chip-state.is-on { border-style: solid; border-color: var(--lime); color: var(--lime-ink); }
.chip-state.is-on::before { background: var(--lime); }
.ga4c__nums { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.ga4c__nums b { font-size: 16px; }
.dash-ga4 { margin: 0 0 16px; }
.dash-ga4 .ga4c--compact { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 16px; }
.dash-ga4 .ga4c--compact .ga4c__head { grid-row: span 2; flex-direction: column; align-items: flex-start; }
@media (max-width: 640px) { .dash-ga4 .ga4c--compact { grid-template-columns: minmax(0, 1fr); } .dash-ga4 .ga4c--compact .ga4c__head { grid-row: auto; flex-direction: row; } }

/* ---------- the ranked table */
.yt-table-card .card__head { flex-wrap: wrap; gap: 10px; }
.yt-sort { display: inline-flex; align-items: center; gap: 8px; }
.yt-sort .select { min-width: 210px; }
.yt-wrap { border-radius: 12px; box-shadow: 0 0 0 1px var(--line); }
table.yt-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--paper); }
table.yt-table th { position: sticky; top: 0; z-index: 1; padding: 10px 10px; text-align: left; font: 600 11.5px var(--f-body); color: var(--muted); border-bottom: 1px solid var(--line); background: var(--paper); white-space: nowrap; vertical-align: bottom; }
.yt-th { display: inline-grid; text-align: inherit; }
.yt-th small { font: 500 10.5px var(--f-body); color: var(--muted); font-style: italic; }
.th-num .yt-th { text-align: right; }
table.yt-table td { padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; }
table.yt-table tbody tr:last-child td { border-bottom: 0; }
.yt-row { cursor: pointer; }
.yt-row:hover td { background: var(--hover); }
.yt-row.is-open td { background: var(--paper-2); border-bottom-color: transparent; }
.yt-row.is-nolink .yt-clicks { color: var(--muted); }
.yt-clicks { font-weight: 650; }
.muted-num { color: var(--ink-2); }
.yt-vid { min-width: 340px; }
.yt-vid__in { display: flex; align-items: center; gap: 10px; min-width: 0; }
.yt-rank { width: 18px; flex: none; text-align: right; color: var(--muted); font-size: 12px; }
.yt-toggle { display: inline-grid; place-items: center; width: 26px; height: 26px; flex: none; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink-2); cursor: pointer; padding: 0; }
.yt-toggle:hover { border-color: var(--line-strong); color: var(--ink); }
.yt-toggle:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.yt-toggle__chev { font: 700 16px/1 var(--f-body); transition: transform 0.2s var(--ease); }
.yt-toggle[aria-expanded="true"] .yt-toggle__chev { transform: rotate(90deg); }
.yt-vid__text { display: grid; gap: 3px; min-width: 0; }
.yt-vid__title { font-weight: 600; line-height: 1.3; }
.yt-vid__title a { color: inherit; text-decoration: none; }
.yt-vid__title a:hover { text-decoration: underline; }
.yt-vid__tags { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.yt-notyet { color: var(--muted); font-style: italic; font-size: 12.5px; }
.yt-sub td { padding-top: 6px; padding-bottom: 6px; font-size: 12.5px; color: var(--ink-2); background: color-mix(in srgb, var(--paper-2) 55%, transparent); }
.yt-sub__what { padding-left: 64px !important; }
.yt-sub__in { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
@media (min-width: 761px) { .yt-sub__in { flex-wrap: nowrap; white-space: nowrap; } }
.yt-sub__arrow { color: var(--muted); }
.yt-sub__slug { font-size: 11.5px; }
.yt-detail > td { padding: 0 !important; background: var(--paper-2); }
.yt-detail__grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; padding: 14px 16px 18px; }
.yt-detail__label { margin: 0 0 8px; color: var(--muted); font: 600 11.5px var(--f-body); letter-spacing: 0.04em; text-transform: uppercase; }
.yt-detail__links { display: grid; align-content: start; gap: 10px; min-width: 0; }
.yt-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.yt-link { display: grid; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--paper); box-shadow: 0 0 0 1px var(--line); min-width: 0; }
.yt-link--none p { margin: 0; font-size: 13px; }
.yt-link__head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; }
.yt-link__n { margin-left: auto; color: var(--muted); font-size: 12px; }
.yt-link__n b { color: var(--ink); }
.yt-link__note { margin: 0; font-size: 12px; }
.yt-link__urls { display: grid; gap: 6px; }
.yt-url { display: flex; align-items: center; gap: 8px; min-width: 0; }
.yt-url__k { flex: none; width: 70px; color: var(--muted); font-size: 11.5px; }
.yt-url__v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 500 12px var(--f-mono); padding: 4px 8px; border-radius: 6px; background: var(--paper-2); }
@media (max-width: 1100px) { .yt-detail__grid { grid-template-columns: minmax(0, 1fr); } }

/* phones: every video is a card (thead hidden: sort with the select) */
@media (max-width: 760px) {
  .yt-wrap { box-shadow: none; overflow: visible; }
  table.yt-table, table.yt-table tbody, table.yt-table tr, table.yt-table td { display: block; width: 100%; }
  table.yt-table { background: none; }
  table.yt-table thead { display: none; }
  .yt-sort { width: 100%; }
  .yt-sort .select { flex: 1; min-width: 0; }
  table.yt-table tr.yt-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; margin-top: 10px; padding: 12px; border-radius: 14px; background: var(--paper); box-shadow: 0 0 0 1px var(--line); }
  table.yt-table tr.yt-row.is-open { border-radius: 14px 14px 0 0; }
  table.yt-table tr.yt-row td { padding: 0; border: 0; background: none !important; display: grid; gap: 1px; text-align: left; font-size: 13px; white-space: normal; }
  table.yt-table tr.yt-row td[data-label]::before { content: attr(data-label); color: var(--muted); font: 600 10px var(--f-body); letter-spacing: 0.03em; text-transform: uppercase; }
  table.yt-table tr.yt-row td.yt-vid { grid-column: 1 / -1; display: block; min-width: 0; }
  table.yt-table tr.yt-row td.yt-vid::before { content: none; }
  .yt-vid .thumb--row { width: 84px; }
  .yt-rank { display: none; }
  table.yt-table tr.yt-sub { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px 10px; padding: 8px 12px; margin: 0; border-radius: 0; background: color-mix(in srgb, var(--paper-2) 70%, var(--paper)); box-shadow: 0 0 0 1px var(--line); }
  table.yt-table tr.yt-sub td { padding: 0; border: 0; background: none; display: grid; gap: 1px; font-size: 12px; text-align: left; }
  table.yt-table tr.yt-sub td[data-label]::before { content: attr(data-label); color: var(--muted); font: 600 9.5px var(--f-body); letter-spacing: 0.03em; text-transform: uppercase; }
  table.yt-table tr.yt-sub td.yt-sub__what { grid-column: 1 / -1; display: block; padding-left: 0 !important; }
  table.yt-table tr.yt-sub td.yt-sub__what::before { content: none; }
  table.yt-table tr.yt-sub td.yt-sub__blank { display: none; }
  table.yt-table tr.yt-detail { margin: 0; }
  table.yt-table tr.yt-detail > td { border-radius: 0 0 14px 14px; box-shadow: 0 0 0 1px var(--line); }
  .yt-detail__grid { padding: 12px; }
  .yt-link__n { margin-left: 0; width: 100%; }
  .yt-url__k { width: 58px; }
}

/* ---------- charts: two-axis line (video detail) + scatter (views vs clicks) */
.lc, .sc { position: relative; }
.lc__chart, .sc__chart { outline: none; border-radius: 8px; }
.lc__chart:focus-visible { box-shadow: 0 0 0 2px var(--ring); }
.lc__svg, .sc__svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.lc__grid line { stroke: var(--line); stroke-width: 1; }
.lc__grid .sc__vline { stroke-dasharray: 2 4; }
.lc__tick { font: 500 10.5px var(--f-mono); fill: var(--muted); font-variant-numeric: tabular-nums; }
.lc__tick--a { fill: color-mix(in srgb, var(--red) 70%, var(--muted)); }
.lc__tick--b { fill: color-mix(in srgb, var(--yt-clicks) 75%, var(--muted)); }
.sc__axis { font-family: var(--f-body); }
.lc__area { opacity: 0.12; }
.lc__line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.lc__line--b { stroke-width: 2; }
.lc__guide { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; }
.lc__hit { fill: transparent; cursor: crosshair; }
.lc__legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 6px; font-size: 12px; color: var(--ink-2); }
.lc__legend > span { display: inline-flex; align-items: center; gap: 6px; }
.lc__key { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.lc__key--line { width: 14px; height: 3px; border-radius: 2px; margin-right: 0; }
.sc__avg { fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 5 5; }
.sc__pt { cursor: pointer; outline: none; }
.sc__halo { fill: var(--yt-dot); opacity: 0; transition: opacity 0.2s var(--ease); }
.sc__dot { fill: color-mix(in srgb, var(--yt-dot) 55%, var(--paper)); stroke: var(--paper); stroke-width: 2; }
.sc__pt.is-above .sc__dot { fill: var(--yt-dot); }
.sc__pt.is-nolink .sc__dot { fill: var(--paper); stroke: var(--dash); stroke-width: 2; stroke-dasharray: 3 2; }
.sc__lbl { font: 550 11.5px var(--f-body); fill: var(--ink-2); paint-order: stroke; stroke: var(--paper); stroke-width: 3px; stroke-linejoin: round; }
.sc.is-hover .sc__pt:not(.is-on) { opacity: 0.45; }
.sc__pt.is-on .sc__halo, .sc__pt:focus-visible .sc__halo { opacity: 0.18; }
.sc__pt:focus-visible .sc__dot { stroke: var(--ink); }
.sc__key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: color-mix(in srgb, var(--yt-dot) 55%, var(--paper)); }
.sc__key--above { background: var(--yt-dot); }
.sc__key--none { background: none; border: 1.5px dashed var(--dash); }
.sc__key--avg { width: 16px; height: 0; border-radius: 0; background: none; border-top: 1.5px dashed var(--muted); }
@keyframes sc-pop { from { opacity: 0; transform: scale(0.4); } }
.sc__pt { transform-box: fill-box; transform-origin: center; animation: sc-pop 0.45s var(--ease) both; animation-delay: calc(var(--i) * 60ms); }
@media (prefers-reduced-motion: reduce) { .sc__pt { animation: none; } .yt-toggle__chev, .sc__halo { transition: none; } }
@media (max-width: 640px) { .lc__tick, .sc__lbl { font-size: 10px; } }
