/*
  YouTube channel tree (/tools/youtube-channel-tree).

  The widget keeps its own dark palette in every site theme, like the other
  free tools; the tree itself is drawn on a cream canvas. Everything is scoped
  under .ct-tool (the widget) and .ct-about (the text below it), so nothing
  here touches the page chrome around them.
*/
.ct-tool {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaef;
  --muted: #9aa1ad;
  --accent: #4f8cff;
  --bad: #ff8a8a;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  min-width: 0;
}
.ct-tool *, .ct-tool *::before, .ct-tool *::after { box-sizing: border-box; }
.ct-tool a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.ct-tool input:focus-visible, .ct-tool button:focus-visible, .ct-tool summary:focus-visible, .ct-tool a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ct-form label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 0.78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.ct-form__row { display: flex; gap: 10px; }
.ct-form input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
}
.ct-form input::placeholder { color: #6b7280; }
.ct-hint { margin: 8px 0 0; color: var(--muted); font-size: 0.82rem; }

.ct-btn {
  height: 36px;
  padding: 0 14px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.ct-btn:hover { border-color: #3d4452; }
.ct-btn--primary { height: 44px; padding: 0 18px; background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; font-size: 0.95rem; }
.ct-btn--primary:hover { background: #3f7cf0; border-color: #3f7cf0; }
.ct-btn:disabled { opacity: .6; cursor: progress; }

.ct-status { min-height: 1.4em; margin: 10px 0 0; color: var(--muted); font-size: 0.88rem; }
.ct-status.is-error { color: var(--bad); }

.ct-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; justify-content: space-between; margin: 8px 0 12px; }
.ct-head__text { min-width: 0; }
.ct-badge { display: inline-block; margin: 0 0 6px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.75rem; }
.ct-badge[hidden] { display: none; }
.ct-title { margin: 0; color: var(--text); font-size: 1.35rem; line-height: 1.25; overflow-wrap: anywhere; }
.ct-title a { text-decoration: none; }
.ct-title a:hover { text-decoration: underline; }
.ct-sub, .ct-asof { margin: 4px 0 0; color: var(--muted); font-size: 0.88rem; }
.ct-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ct-actions [hidden] { display: none; }

.ct-stage {
  position: relative;
  height: clamp(440px, 72vh, 760px);
  overflow: hidden;
  border-radius: 12px;
  background: #f4f0e6;
  touch-action: manipulation;
}
.ct-stage canvas { display: block; width: 100%; height: 100%; }

.ct-tip {
  position: absolute;
  z-index: 2;
  max-width: 290px;
  padding: 10px 12px;
  background: #fff;
  color: #2b2a26;
  border: 1px solid #e2dccd;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(60, 45, 20, .16);
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
}
.ct-tip[hidden] { display: none; }
.ct-tip.is-pinned { pointer-events: auto; }
.ct-tip__title { margin-bottom: 4px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.ct-tip__date { margin-bottom: 8px; color: #8a8476; font-size: 12px; }
.ct-tip table { width: 100%; border-collapse: collapse; }
.ct-tip td { padding: 2px 0; }
.ct-tip td:last-child { padding-left: 12px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.ct-tip__hot { display: inline-block; margin-top: 8px; padding: 2px 7px; border-radius: 999px; background: #fdecd9; color: #a24e0e; font-size: 11px; font-weight: 600; }
.ct-tool .ct-tip__link { display: block; margin-top: 8px; color: #a24e0e; font-weight: 600; }

.ct-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; color: var(--muted); font-size: 0.85rem; }
.ct-legend b { color: var(--text); font-weight: 600; }

.ct-list { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.ct-list summary { color: var(--text); font-size: 0.9rem; cursor: pointer; }
.ct-list__wrap { max-height: 420px; margin-top: 10px; overflow: auto; }
.ct-list__table { width: 100%; border-collapse: collapse; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.ct-list__table th, .ct-list__table td { padding: 6px 8px; border-top: 1px solid var(--line); text-align: right; vertical-align: top; }
.ct-list__table th:nth-child(2), .ct-list__table td:nth-child(2) { text-align: left; }
.ct-list__table thead th { position: sticky; top: 0; background: var(--bg); color: var(--muted); font-weight: 600; border-top: 0; }
.ct-list__table td:nth-child(3) { white-space: nowrap; }

.ct-note { margin: 16px 0 0; color: var(--muted); font-size: 0.85rem; }
.ct-note a { color: var(--muted); }

.ct-about { max-width: 760px; margin-top: 36px; }
.ct-about h2 { margin: 0 0 12px; color: var(--cw-text); font-size: 20px; line-height: 1.3; }
.ct-about p { margin: 0 0 12px; color: var(--cw-muted); font-size: 15px; line-height: 1.7; }
.ct-about a { color: var(--cw-text); text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 640px) {
  .ct-tool { padding: 14px; border-radius: 12px; }
  .ct-form__row { flex-direction: column; }
  .ct-form input { flex: none; }
  .ct-btn--primary { width: 100%; }
  .ct-stage { height: clamp(420px, 68vh, 600px); }
  .ct-list__table th:nth-child(3), .ct-list__table td:nth-child(3) { display: none; }
}
