:root {
  /* Surfaces */
  --bg: #f6f7f9;
  --bg-tint: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #eef1f6;

  /* Text */
  --text: #131620;
  --text-2: #3b4354;
  --muted: #626c7e;
  --faint: #98a1b2;

  /* Lines */
  --line: #eceef3;
  --line-2: #e2e5ec;
  --line-3: #d7dbe4;

  /* Accent — refined indigo/violet */
  --accent: #5b53f0;
  --accent-2: #7b5cff;
  --accent-ink: #4a42d8;
  --accent-soft: #efeeff;
  --accent-ring: rgba(91,83,240,.16);

  --ok: #17a34a;
  --warn: #c47d09;
  --danger: #e0345a;

  --radius: 16px;
  --radius-sm: 11px;
  --shadow-xs: 0 1px 2px rgba(19,22,32,.04);
  --shadow-sm: 0 2px 8px -2px rgba(19,22,32,.08), 0 1px 2px rgba(19,22,32,.04);
  --shadow: 0 12px 28px -10px rgba(19,22,32,.14), 0 4px 10px -4px rgba(19,22,32,.06);
  --shadow-lg: 0 24px 60px -18px rgba(19,22,32,.22), 0 8px 20px -8px rgba(19,22,32,.08);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', var(--font);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
a { color: var(--accent-ink); text-decoration: none; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.02em; }

/* soft ambient background */
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(680px 340px at 82% -8%, rgba(123,92,255,.10), transparent 60%),
    radial-gradient(620px 320px at 8% -4%, rgba(91,83,240,.07), transparent 55%);
}

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 22px 90px; }

/* ---------- Header ---------- */
header.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 0 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 19px;
  font-family: var(--display); box-shadow: 0 6px 16px -4px rgba(91,83,240,.5);
}
.brand h1 { font-size: 18px; margin: 0; letter-spacing: -.02em; }
.brand .tag { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.header-note { font-size: 12.5px; color: var(--faint); font-weight: 500; }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 34px 0 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-xs);
  color: var(--muted); font-size: 12.5px; font-weight: 500;
  padding: 6px 13px; border-radius: 100px; margin-bottom: 20px;
}
.pill .dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(23,163,74,.15); }
.hero h2 { font-size: clamp(30px, 4.6vw, 50px); margin: 0 0 14px; line-height: 1.05; font-weight: 600; }
.hero h2 .grad {
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--muted); font-size: 16px; max-width: 588px; margin: 0 auto; line-height: 1.55; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.searchbar { padding: 20px; margin-top: 30px; box-shadow: var(--shadow); }
.search-row { display: flex; gap: 10px; flex-wrap: wrap; }
.input {
  flex: 1 1 320px; min-width: 0;
  display: flex; align-items: center; gap: 11px;
  background: var(--surface); border: 1.5px solid var(--line-2); border-radius: var(--radius-sm); padding: 0 15px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.input svg { flex: 0 0 auto; color: var(--faint); }
.input input {
  flex: 1; background: transparent; border: 0; outline: 0; color: var(--text);
  font-size: 15px; font-weight: 500; padding: 15px 0; min-width: 0;
}
.input input::placeholder { color: var(--faint); font-weight: 400; }

.btn {
  border: 0; border-radius: var(--radius-sm); padding: 14px 22px; font-size: 14.5px; font-weight: 600;
  cursor: pointer; color: #fff; white-space: nowrap;
  transition: transform .07s ease, box-shadow .18s ease, filter .18s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 18px -6px rgba(91,83,240,.5);
}
.btn.primary:hover { box-shadow: 0 10px 24px -6px rgba(91,83,240,.62); filter: brightness(1.03); }
.btn.ghost { background: var(--surface); color: var(--text-2); border: 1px solid var(--line-2); box-shadow: var(--shadow-xs); }
.btn.ghost:hover { border-color: var(--line-3); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.controls-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 15px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 4px; gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px; cursor: pointer; transition: all .14s ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-xs); }
.ctl-label { font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-right: 1px; }
select.mini {
  background: var(--surface); color: var(--text); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 9px 11px; font-size: 13px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-xs);
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2398a1b2' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 28px;
}
select.mini:hover { border-color: var(--line-3); }

/* status / errors */
.notice { margin-top: 15px; padding: 12px 15px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; display: none; }
.notice.show { display: block; }
.notice.err { background: #fff1f4; border: 1px solid #fbd0da; color: #b91c47; }
.notice.info { background: var(--accent-soft); border: 1px solid #ddd9ff; color: var(--accent-ink); }

/* channel meta */
.chan { display: none; align-items: center; gap: 14px; margin-top: 26px; }
.chan.show { display: flex; }
.chan img { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; background: var(--surface-2); border: 1px solid var(--line-2); }
.chan .cn { font-size: 18px; font-weight: 700; font-family: var(--display); letter-spacing: -.01em; }
.chan .cs { font-size: 13px; color: var(--muted); margin-top: 1px; }

/* selection toolbar */
.seltools { display: none; flex-wrap: wrap; gap: 10px; align-items: center; margin: 22px 0 4px; }
.seltools.show { display: flex; }
.quickpick { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.chip {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--muted);
  border-radius: 100px; padding: 7px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  box-shadow: var(--shadow-xs); transition: all .14s ease;
}
.chip:hover { color: var(--accent-ink); border-color: #cfcbf7; background: var(--accent-soft); }
.selcount { margin-left: auto; font-size: 13px; color: var(--muted); }
.selcount b { color: var(--text); font-weight: 700; }

/* ---------- Video grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(244px, 1fr)); gap: 16px; margin-top: 14px; }
.vcard {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; overflow: hidden;
  cursor: pointer; box-shadow: var(--shadow-xs);
  transition: border-color .15s ease, transform .12s ease, box-shadow .15s ease; position: relative;
}
.vcard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-3); }
.vcard.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring), var(--shadow); }
.vthumb { position: relative; aspect-ratio: 16/9; background: var(--surface-2); overflow: hidden; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vdur { position: absolute; right: 7px; bottom: 7px; background: rgba(19,22,32,.86); color: #fff; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.vcheck {
  position: absolute; top: 9px; left: 9px; width: 24px; height: 24px; border-radius: 8px;
  background: rgba(255,255,255,.85); border: 1.5px solid rgba(255,255,255,.9); display: grid; place-items: center;
  backdrop-filter: blur(4px); box-shadow: var(--shadow-xs); transition: all .14s ease;
}
.vcheck svg { opacity: 0; color: #fff; transition: opacity .14s ease; }
.vcard.sel .vcheck { background: var(--accent); border-color: var(--accent); }
.vcard.sel .vcheck svg { opacity: 1; }
.vbody { padding: 12px 13px 13px; }
.vtitle { font-size: 13.5px; font-weight: 600; line-height: 1.38; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.vmeta { font-size: 12px; color: var(--faint); margin-top: 7px; font-weight: 500; display: flex; gap: 8px; }
.vmeta .dot::before { content: '·'; margin-right: 8px; }

/* ---------- Generate bar ---------- */
.genbar { display: none; position: sticky; bottom: 18px; z-index: 20; margin-top: 24px; }
.genbar.show { display: block; }
.genbar-inner {
  background: rgba(255,255,255,.82); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--line-2); border-radius: 16px; padding: 13px 16px;
  display: flex; align-items: center; gap: 15px; box-shadow: var(--shadow-lg);
}
.progress { flex: 1; height: 8px; background: var(--surface-3); border-radius: 6px; overflow: hidden; display: none; }
.progress.show { display: block; }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 6px; transition: width .3s ease; }
.progtext { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }

/* ---------- Results ---------- */
.results { margin-top: 44px; display: none; }
.results.show { display: block; }
.res-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.res-head h3 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.res-stat { font-size: 13px; color: var(--muted); font-weight: 500; }
.export-toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin: 16px 0 18px; padding: 14px; box-shadow: var(--shadow-sm); }
.export-toolbar .grp { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.export-toolbar .sep { width: 1px; align-self: stretch; background: var(--line-2); margin: 2px 5px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 500; cursor: pointer; user-select: none; padding: 6px 4px; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.res-search { margin: 0 0 16px; box-shadow: var(--shadow-xs); }

.tcard { background: var(--surface); border: 1px solid var(--line-2); border-radius: 13px; margin-bottom: 11px; overflow: hidden; box-shadow: var(--shadow-xs); transition: box-shadow .15s ease, border-color .15s ease; }
.tcard:hover { box-shadow: var(--shadow-sm); }
.tcard.open { box-shadow: var(--shadow); border-color: var(--line-3); }
.tcard.fail { background: #fffafb; border-color: #f7d7de; }
.tc-head { display: flex; align-items: center; gap: 13px; padding: 14px 16px; cursor: pointer; }
.tc-num {
  flex: 0 0 auto; width: 27px; height: 27px; border-radius: 8px;
  background: var(--accent-soft); border: 1px solid #e0dcff; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700; color: var(--accent-ink); font-family: var(--display);
}
.tcard.fail .tc-num { background: #fdeef1; border-color: #f7d7de; color: var(--danger); }
.tc-main { flex: 1; min-width: 0; }
.tc-title { font-size: 14.5px; font-weight: 600; line-height: 1.3; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-sub { font-size: 12px; color: var(--faint); margin-top: 3px; font-weight: 500; }
.tc-sub.err { color: var(--danger); }
.tc-actions { display: flex; gap: 7px; flex: 0 0 auto; }
.tc-body { display: none; padding: 0 16px 16px; }
.tcard.open .tc-body { display: block; }
.tc-text {
  background: var(--bg-tint); border: 1px solid var(--line); border-radius: 10px; padding: 15px 16px;
  font-size: 14px; line-height: 1.72; color: var(--text-2); max-height: 360px; overflow-y: auto; white-space: pre-wrap;
}
.tc-text::-webkit-scrollbar { width: 10px; }
.tc-text::-webkit-scrollbar-thumb { background: var(--line-3); border-radius: 6px; border: 3px solid var(--bg-tint); }
.tc-caret { transition: transform .2s ease; color: var(--faint); flex: 0 0 auto; }
.tcard.open .tc-caret { transform: rotate(90deg); color: var(--accent); }

.mini-btn {
  background: var(--surface); border: 1px solid var(--line-2); color: var(--muted); border-radius: 9px;
  padding: 7px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
  box-shadow: var(--shadow-xs); transition: all .14s ease;
}
.mini-btn:hover { color: var(--accent-ink); border-color: #cfcbf7; background: var(--accent-soft); }
.mini-btn.copied { color: var(--ok); border-color: #bbe6c8; background: #f0fbf3; }
.mini-btn svg { width: 14px; height: 14px; }

/* ---------- Skeleton ---------- */
.skel { display: grid; grid-template-columns: repeat(auto-fill, minmax(244px, 1fr)); gap: 16px; margin-top: 14px; }
.skcard { border-radius: 14px; overflow: hidden; border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--shadow-xs); }
.skthumb { aspect-ratio: 16/9; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sh 1.4s infinite; }
.skline { height: 12px; margin: 13px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sh 1.4s infinite; }
@keyframes sh { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.spin { width: 15px; height: 15px; border: 2px solid var(--line-3); border-top-color: var(--accent); border-radius: 50%; animation: rot .7s linear infinite; }
.btn .spin, .btn.primary .spin { border-color: rgba(255,255,255,.4); border-top-color: #fff; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Coffee / donation ask ---------- */
.coffee-ask {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: space-between;
  margin-top: 22px; padding: 20px 22px; border-radius: var(--radius);
  background: linear-gradient(120deg, var(--accent-soft), #fff);
  border: 1px solid #e2ddff; box-shadow: var(--shadow-sm);
}
.coffee-h { font-family: var(--display); font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.coffee-p { font-size: 13.5px; color: var(--muted); margin-top: 4px; max-width: 520px; }
.coffee-btn { text-decoration: none; }

/* ---------- Landing / SEO sections ---------- */
.lp { margin-top: 76px; }
.lp-title { font-size: clamp(24px, 3.2vw, 32px); text-align: center; margin: 0 0 8px; }
.lp-sub { text-align: center; color: var(--muted); font-size: 15px; margin: 0 0 30px; }
.aff-note { color: var(--faint); font-size: 12.5px; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.step { background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; padding: 24px 22px; box-shadow: var(--shadow-xs); }
.step-n {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #fff;
  font-family: var(--display); font-weight: 700; font-size: 16px; box-shadow: 0 6px 14px -4px rgba(91,83,240,.5);
}
.step h3 { font-size: 17px; margin: 16px 0 7px; letter-spacing: -.01em; }
.step p { font-size: 14px; color: var(--muted); margin: 0; line-height: 1.6; }
.step p b { color: var(--text-2); font-weight: 600; }

.tool-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.tool-card {
  display: block; background: var(--surface); border: 1px solid var(--line-2); border-radius: 13px;
  padding: 18px 18px 20px; box-shadow: var(--shadow-xs); text-decoration: none;
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-3); }
.tool-name { font-family: var(--display); font-weight: 600; font-size: 15.5px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.tool-name::after { content: '↗'; margin-left: auto; color: var(--faint); font-weight: 400; }
.tool-desc { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

.faq { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.faq details {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; padding: 4px 18px;
  box-shadow: var(--shadow-xs); transition: box-shadow .15s ease;
}
.faq details[open] { box-shadow: var(--shadow-sm); }
.faq summary {
  cursor: pointer; list-style: none; padding: 15px 0; font-weight: 600; font-size: 14.5px; color: var(--text);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; font-size: 20px; color: var(--accent); font-weight: 400; transition: transform .2s ease; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0 0 16px; font-size: 14px; color: var(--muted); line-height: 1.65; }

/* ---------- Footer ---------- */
.footer { margin-top: 70px; padding-top: 26px; border-top: 1px solid var(--line-2); color: var(--muted); }
.foot-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; font-size: 13px; }
.foot-links { display: flex; gap: 20px; flex-wrap: wrap; }
.foot-links a { color: var(--muted); font-weight: 500; }
.foot-links a:hover { color: var(--accent-ink); }
.foot-fine { font-size: 12px; color: var(--faint); margin-top: 12px; }

.hidden { display: none !important; }

@media (max-width: 860px) {
  .steps { grid-template-columns: 1fr; }
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .wrap { padding: 0 16px 70px; }
  .selcount { margin-left: 0; width: 100%; }
  .tc-title { white-space: normal; }
  .header-note { display: none; }
  .tool-grid { grid-template-columns: 1fr; }
  .coffee-ask { flex-direction: column; align-items: flex-start; }
}
