:root {
  --bg: #0B1020;
  --bg-2: #131A2F;
  --surface: #1B2240;
  --surface-2: #232B4D;
  --text: #E6E9F2;
  --text-dim: #9CA3BA;
  --text-mute: #6B7290;
  --border: #2A3158;
  --brand: #6366F1;
  --accent: #A78BFA;
  --grad-1: #4F46E5;
  --grad-2: #7C3AED;
  --grad-3: #EC4899;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(0,0,0,0.35);
  --maxw: 1280px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(139,92,246,0.15), transparent 60%),
              radial-gradient(800px 400px at 0% 10%, rgba(79,70,229,0.18), transparent 60%),
              var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--text); }
img { display: block; max-width: 100%; }
h1, h2, h3, h4, h5 { letter-spacing: -0.01em; line-height: 1.2; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.dot { color: var(--text-mute); margin: 0 6px; }
.muted { color: var(--text-dim); }
.muted-link { color: var(--text-dim); font-size: 0.95rem; }
.muted-link:hover { color: var(--text); }
.grad-text {
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2), var(--grad-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.section-title { font-size: 1.6rem; font-weight: 700; margin: 0 0 24px; letter-spacing: -0.02em; }
.back-link { display: inline-block; color: var(--text-dim); font-size: 0.95rem; margin-bottom: 16px; }
.back-link:hover { color: var(--text); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex; align-items: center; gap: 24px; padding-top: 14px; padding-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; letter-spacing: -0.03em; font-size: 1.25rem; }
.brand-logo { font-size: 1.4rem; filter: drop-shadow(0 0 8px rgba(167,139,250,0.5)); }
.topnav { display: flex; gap: 14px; align-items: center; flex: 1; }
.chan-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px; color: white; font-weight: 600; font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(99,102,241,0.3);
}
.search-form { display: flex; gap: 8px; }
.search-form input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  width: 280px;
  outline: none;
}
.search-form input:focus { border-color: var(--accent); }
.search-form button {
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2));
  color: white; border: 0; padding: 8px 18px; border-radius: 10px; font-weight: 600;
  cursor: pointer;
}

/* ---------- Hub hero ---------- */
.hub-hero { padding: 90px 0 60px; }
.hub-hero h1 { font-size: clamp(2.4rem, 5vw, 4rem); font-weight: 800; margin: 0 0 18px; letter-spacing: -0.03em; }
.lede { font-size: 1.15rem; color: var(--text-dim); max-width: 700px; margin: 0 0 28px; }
.hero-search { display: flex; gap: 10px; max-width: 560px; }
.hero-search input {
  flex: 1; padding: 14px 18px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); color: var(--text); font-size: 1rem; outline: none;
}
.hero-search input:focus { border-color: var(--accent); }
.hero-search button {
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2)); color: white;
  border: 0; padding: 0 22px; border-radius: 12px; font-weight: 600; cursor: pointer;
}

/* ---------- Channels grid ---------- */
.channels-section { padding: 40px 0 60px; }
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 22px;
}
.channel-card {
  display: block;
  position: relative;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 15%, var(--surface)), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}
.channel-card::before {
  content: '';
  position: absolute; inset: -2px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  z-index: -1; border-radius: var(--radius); opacity: 0;
  transition: opacity 0.2s;
}
.channel-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 12px 32px rgba(0,0,0,0.4); }
.chan-card-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.chan-emoji { font-size: 2.2rem; line-height: 1; }
.chan-meta h3 { margin: 0; font-size: 1.35rem; font-weight: 700; }
.chan-handle { color: var(--text-dim); font-size: 0.88rem; }
.chan-desc { margin: 0 0 16px; color: var(--text-dim); font-size: 0.96rem; }
.chan-stats { display: flex; gap: 8px; color: var(--text-dim); font-size: 0.92rem; }
.chan-stats strong { color: var(--text); font-weight: 700; }
.chan-cta { display: block; margin-top: 16px; color: var(--accent); font-weight: 600; }

/* ---------- How section ---------- */
.how-section { padding: 30px 0 80px; }
.how-steps { list-style: none; padding: 0; max-width: 760px; margin: 0; counter-reset: step; }
.how-steps li {
  position: relative; padding: 18px 18px 18px 64px; margin-bottom: 12px;
  background: var(--surface); border-radius: 12px; border: 1px solid var(--border);
  counter-increment: step;
}
.how-steps li::before {
  content: counter(step);
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--grad-1), var(--grad-2));
  color: white; display: grid; place-items: center; font-weight: 700;
}

/* ---------- Channel home ---------- */
.channel-hero { padding: 50px 0 30px; border-bottom: 1px solid var(--border); }
.ch-handle { color: var(--text-dim); font-size: 0.92rem; }
.channel-hero h1 { font-size: 2.8rem; margin: 8px 0 12px; letter-spacing: -0.03em; }
.ch-stats { display: flex; gap: 8px; align-items: center; color: var(--text-dim); margin-top: 14px; }
.ch-stats strong { color: var(--text); }

.topics-section { padding: 40px 0 80px; }
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 22px;
}
.topic-card {
  display: block; overflow: hidden; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s;
}
.topic-card:hover { transform: translateY(-3px); border-color: var(--tcolor); }
.thumb-stack {
  position: relative; height: 160px; display: grid;
  grid-template-columns: 2fr 1fr 1fr; gap: 2px;
}
.thumb-stack img { width: 100%; height: 100%; object-fit: cover; }
.topic-card-body { padding: 16px 18px 20px; }
.topic-card-body h3 { margin: 0 0 6px; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.topic-emoji { font-size: 1.3rem; }
.count-pill {
  margin-left: auto; background: var(--tcolor); color: white;
  border-radius: 999px; padding: 2px 10px; font-size: 0.78rem; font-weight: 700;
}
.topic-desc { margin: 6px 0 10px; color: var(--text-dim); font-size: 0.92rem; }
.topic-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 2px 10px; border-radius: 999px; font-size: 0.78rem;
}

/* ---------- Topic page ---------- */
.topic-head { padding: 40px 0 20px; }
.topic-head h1 { font-size: 2.4rem; margin: 6px 0 12px; letter-spacing: -0.02em; }
.th-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-dim); }

.workflow-section { padding: 30px 0; }
.mermaid-host {
  background: white; border-radius: var(--radius);
  padding: 24px; overflow-x: auto;
  box-shadow: var(--shadow);
}
.workflow-caption { color: var(--text-dim); margin: 14px 0 0; font-size: 0.95rem; max-width: 760px; }

.takeaways-section { padding: 30px 0; }
.takeaways-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.takeaway-card {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border-left: 4px solid var(--tcolor, var(--accent));
  padding: 16px 18px; border-radius: 12px;
  color: var(--text); font-size: 0.96rem; line-height: 1.55;
}

.videos-section { padding: 30px 0 80px; }
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}
.video-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; color: var(--text);
  transition: transform 0.15s, border-color 0.15s;
}
.video-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.video-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.video-card-body { padding: 14px 16px 16px; }
.video-card-body h4 { margin: 0 0 8px; font-size: 1rem; line-height: 1.35; }
.video-takeaway { margin: 0 0 8px; color: var(--text-dim); font-size: 0.88rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.video-meta { color: var(--text-mute); font-size: 0.82rem; }

/* ---------- Video page ---------- */
.video-page { padding: 30px 0 80px; }
.video-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 36px;
}
@media (max-width: 960px) { .video-layout { grid-template-columns: 1fr; } }
.video-embed {
  position: relative; padding-bottom: 56.25%; height: 0;
  border-radius: var(--radius); overflow: hidden; background: black;
}
.video-embed iframe {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0;
}
.video-main h1 { font-size: 1.9rem; margin: 22px 0 6px; }
.orig-title { margin: 4px 0 12px; color: var(--text-dim); font-size: 0.92rem; }
.orig-title span { color: var(--text-mute); }
.video-meta-strip { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--text-dim); font-size: 0.92rem; margin: 8px 0 22px; }
.takeaway-box {
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 25%, var(--surface)), var(--surface));
  border: 1px solid var(--border); border-left: 4px solid var(--accent);
  padding: 18px 22px; border-radius: 12px; margin-bottom: 24px;
}
.tk-label { color: var(--accent); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.takeaway-box p { margin: 6px 0 0; font-size: 1.05rem; line-height: 1.55; }
.summary-section h2 { font-size: 1.25rem; margin: 24px 0 12px; }
.bullet-list { padding-left: 22px; margin: 0; }
.bullet-list li { margin-bottom: 8px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 22px; }
.desc-details { margin-top: 24px; }
.desc-details summary { cursor: pointer; color: var(--text-dim); }
.desc-details pre { white-space: pre-wrap; background: var(--surface); padding: 14px 18px; border-radius: 12px; color: var(--text-dim); font-size: 0.88rem; }
.video-side h3 { font-size: 1.05rem; margin: 0 0 14px; color: var(--text-dim); }
.related-list { display: flex; flex-direction: column; gap: 12px; }
.related-item {
  display: grid; grid-template-columns: 120px 1fr; gap: 12px;
  color: var(--text); padding: 8px; border-radius: 10px;
  transition: background 0.15s;
}
.related-item:hover { background: var(--surface); }
.related-item img { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; }
.related-item h5 { margin: 0 0 4px; font-size: 0.88rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.related-item span { color: var(--text-mute); font-size: 0.78rem; }

/* ---------- Search ---------- */
.search-results { padding: 40px 0 80px; }
.search-results h1 { font-size: 2.2rem; margin: 0 0 6px; }
.search-results h1 em { color: var(--accent); font-style: normal; }
.search-channel-group { margin-top: 28px; }
.search-channel-group h2 { display: flex; gap: 12px; align-items: baseline; }
.search-list { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.search-result {
  display: grid; grid-template-columns: 180px 1fr; gap: 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.search-result:hover { border-color: var(--accent); transform: translateY(-2px); }
.search-result img { width: 180px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; }
.search-result h3 { margin: 0 0 6px; font-size: 1.05rem; }
.result-takeaway { margin: 0 0 6px; color: var(--text-dim); }
.snippet { margin: 6px 0; color: var(--text-dim); font-size: 0.9rem; line-height: 1.55; }
.snippet mark { background: rgba(167,139,250,0.3); color: var(--text); padding: 1px 4px; border-radius: 4px; }
.result-meta { color: var(--text-mute); font-size: 0.85rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0; color: var(--text-mute); font-size: 0.88rem;
  margin-top: 40px;
}

/* small */
@media (max-width: 760px) {
  .site-header .wrap { flex-wrap: wrap; }
  .search-form input { width: 100%; }
  .search-form { flex: 1; }
  .topnav { order: 3; flex-basis: 100%; }
  .search-result { grid-template-columns: 1fr; }
  .search-result img { width: 100%; }
}
