:root {
  --clr-bg: #ffffff;
  --clr-surface: #fafafa;
  --clr-border: #e0e0e0;
  --clr-text: #212121;
  --clr-muted: #757575;
  --clr-primary: #7c3aed;
  --clr-accent: #a78bfa;
  --radius-md: 16px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --gap: clamp(1rem, 2vw, 1.5rem);
  --font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;

  --fs-h1: clamp(26px, 3.4vw, 32px);
  --fs-section: 20px;
  --fs-video-title: 15px;
  --fs-live-title: 15px;
  --fs-news-title: 16px;
  --fs-faq-q: 15px;
  --fs-meta: 13px;
  --fs-body: 15px;
  --fs-small: 13px;

  --lh-body: 1.7;
  --lh-tight: 1.45;

  --space-xs: 6px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 56px;
  --space-3xl: 80px;

  --shadow-header: 0 1px 8px rgba(0, 0, 0, .06);
  --shadow-hover: 0 4px 16px rgba(0, 0, 0, .07);
  --badge-dark: rgba(0, 0, 0, .75);
  --hero-text-soft: rgba(255, 255, 255, .86);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-base);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--clr-text);
  background: var(--clr-bg);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 2px;
}

/* ============ Header ============ */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--clr-border);
  height: 64px;
}

header.is-scrolled { box-shadow: var(--shadow-header); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  height: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.logo {
  font-size: 20px;
  font-weight: 800;
  color: var(--clr-primary);
  text-decoration: none;
  letter-spacing: .3px;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-main {
  display: flex;
  gap: 24px;
}

.nav-main a {
  font-size: 15px;
  color: var(--clr-text);
  text-decoration: none;
  padding: 6px 0;
  transition: color .2s;
}

.nav-main a:hover { color: var(--clr-primary); }

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-pill);
  background: var(--clr-surface);
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  font-size: 14px;
  width: 140px;
  color: var(--clr-text);
  font-family: var(--font-base);
}

.search-box input::placeholder { color: var(--clr-muted); }

.search-count {
  font-size: var(--fs-meta);
  color: var(--clr-muted);
  white-space: nowrap;
}

.menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--clr-text);
  cursor: pointer;
  transition: background .2s;
}

.menu-btn:hover { background: var(--clr-surface); }

/* ============ Layout ============ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.layout-three {
  display: grid;
  grid-template-columns: 200px 1fr 280px;
  gap: var(--gap);
  padding: var(--gap) 0;
  align-items: start;
}

.sidebar-left,
.sidebar-right {
  position: sticky;
  top: 80px;
  height: fit-content;
}

.main-content { min-width: 0; }

/* ============ Section title ============ */
.section-title {
  display: flex;
  align-items: center;
  font-size: var(--fs-section);
  font-weight: 700;
  margin: 0 0 var(--space-md);
  line-height: 1.3;
}

.section-title::before {
  content: "";
  width: 3px;
  height: 16px;
  margin-right: 10px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--clr-primary), var(--clr-accent));
  flex: 0 0 auto;
}

.section { margin-top: var(--space-xl); }

/* ============ Hero ============ */
.hero-banner {
  background: linear-gradient(135deg, var(--clr-primary) 0%, var(--clr-accent) 100%);
  border-radius: var(--radius-md);
  padding: 3rem 2rem;
  color: #fff;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: center;
  margin-bottom: var(--gap);
  overflow: hidden;
  animation: fadeUp .5s ease both;
}

.hero-text h1 {
  font-size: var(--fs-h1);
  font-weight: 800;
  line-height: 1.3;
  margin: 0 0 14px;
}

.hero-text p {
  font-size: 15px;
  line-height: 1.8;
  color: var(--hero-text-soft);
  margin: 0 0 24px;
  max-width: 52ch;
}

.btn-hero {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 24px;
  border-radius: var(--radius-pill);
  background: #fff;
  color: var(--clr-primary);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: transform .2s, opacity .2s;
}

.btn-hero:hover { transform: translateY(-1px); opacity: .94; }

.btn-hero svg { width: 20px; height: 20px; fill: currentColor; }

.hero-thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
  display: block;
}

/* ============ Video grid ============ */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
}

.video-card {
  background: #fff;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  animation: fadeUp .45s ease both;
}

.video-card:nth-child(1) { animation-delay: .02s; }
.video-card:nth-child(2) { animation-delay: .06s; }
.video-card:nth-child(3) { animation-delay: .1s; }
.video-card:nth-child(4) { animation-delay: .14s; }
.video-card:nth-child(5) { animation-delay: .18s; }
.video-card:nth-child(6) { animation-delay: .22s; }
.video-card:nth-child(7) { animation-delay: .26s; }
.video-card:nth-child(8) { animation-delay: .3s; }

.video-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.video-thumb {
  position: relative;
  display: block;
}

.video-thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.duration-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--badge-dark);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

.duration-badge svg { width: 12px; height: 12px; }

.video-info { padding: 12px 14px 14px; }

.video-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 2.9em;
  min-height: 2.9em;
  font-size: var(--fs-video-title);
  font-weight: 600;
  line-height: var(--lh-tight);
  margin: 0 0 10px;
}

.video-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.uploader-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
}

.uploader-avatar img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.uploader-info { min-width: 0; }

.uploader-name {
  font-size: 13px;
  color: var(--clr-text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-stats {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--clr-muted);
}

.video-stats span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.video-stats svg { width: 12px; height: 12px; }

/* ============ Live ============ */
.live-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
}

.live-card {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #fff;
  transition: transform .2s, box-shadow .2s;
}

.live-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.live-thumb {
  position: relative;
  display: block;
}

.live-thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.live-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--clr-primary);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
}

.live-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #fff;
  animation: livePulse 1.4s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); }
}

.live-viewers {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--badge-dark);
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.live-info { padding: 10px 12px 12px; }

.live-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: var(--fs-live-title);
  font-weight: 600;
  line-height: var(--lh-tight);
  margin: 0 0 6px;
}

.live-anchor {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-meta);
  color: var(--clr-muted);
}

.live-anchor img {
  width: 24px;
  height: 24px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  flex: 0 0 auto;
}

.live-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--clr-muted);
}

/* ============ News ============ */
.news-list { display: block; }

.news-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--clr-border);
}

.news-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.news-item time {
  font-size: 12px;
  color: var(--clr-muted);
  display: block;
  margin-bottom: 6px;
}

.news-title {
  font-size: var(--fs-news-title);
  font-weight: 700;
  margin: 0 0 6px;
  line-height: 1.5;
}

.news-excerpt {
  font-size: 14px;
  line-height: 1.75;
  color: var(--clr-muted);
  margin: 0;
}

.news-item p {
  font-size: 14px;
  line-height: 1.75;
  color: var(--clr-muted);
  margin: 0;
}

/* ============ FAQ ============ */
.faq-list {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.faq-item + .faq-item { border-top: 1px solid var(--clr-border); }

.faq-q {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  font-size: var(--fs-faq-q);
  font-weight: 600;
  cursor: pointer;
}

.faq-q::after {
  content: "+";
  font-size: 18px;
  font-weight: 400;
  color: var(--clr-muted);
  transition: transform .25s;
  flex: 0 0 auto;
}

.faq-item.open .faq-q::after { transform: rotate(45deg); }

.faq-a {
  display: none;
  padding: 0 16px 16px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--clr-muted);
}

.faq-item.open .faq-a { display: block; }

/* ============ About / tags ============ */
#about p {
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  margin: 0 0 var(--space-md);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: var(--space-lg);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  font-size: var(--fs-small);
  color: var(--clr-text);
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s;
}

.tag:hover {
  background: #fff;
  color: var(--clr-primary);
  border-color: var(--clr-accent);
}

/* ============ Left sidebar ============ */
.sidebar-card {
  background: #fff;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.sidebar-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
}

.category-list { display: block; }

.category-list a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--clr-text);
  text-decoration: none;
  transition: background .18s, color .18s;
}

.category-list a:hover {
  background: var(--clr-surface);
  color: var(--clr-primary);
}

/* ============ Right sidebar / rank ============ */
.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--clr-border);
  margin-bottom: 10px;
}

.tab-btn {
  background: none;
  border: none;
  font-family: var(--font-base);
  font-size: var(--fs-meta);
  padding: 6px 10px;
  color: var(--clr-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .2s, border-color .2s;
}

.tab-btn.active {
  color: var(--clr-primary);
  border-bottom-color: var(--clr-primary);
}

.rank-list { display: block; }

.rank-item {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  align-items: flex-start;
}

.rank-num {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--clr-surface);
  color: var(--clr-muted);
}

.rank-item:nth-child(-n+3) .rank-num {
  background: var(--clr-primary);
  color: #fff;
}

.rank-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-decoration: none;
  color: var(--clr-text);
}

.rank-title:hover { color: var(--clr-primary); }

.rank-value {
  font-size: 12px;
  color: var(--clr-muted);
  margin-left: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}

.rank-meta {
  font-size: 12px;
  color: var(--clr-muted);
}

/* ============ Footer ============ */
.site-footer {
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  margin-top: calc(var(--gap) * 2);
  padding-top: 2.5rem;
}

.footer-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.footer-col h4 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-col a {
  font-size: 13px;
  color: var(--clr-muted);
  text-decoration: none;
  transition: color .2s;
}

.footer-col a:hover { color: var(--clr-primary); }

.footer-bottom {
  border-top: 1px solid var(--clr-border);
  margin-top: 2rem;
  padding: 16px 1rem;
  text-align: center;
}

.footer-bottom p {
  font-size: 13px;
  color: var(--clr-muted);
  line-height: 1.6;
  margin: 0;
}

.footer-bottom p + p { margin-top: 6px; }

.footer-bottom a {
  color: var(--clr-muted);
  text-decoration: none;
  transition: color .2s;
}

.footer-bottom a:hover { color: var(--clr-primary); }

.friend-links {
  padding: 14px 1rem 20px;
  font-size: 13px;
  line-height: 2;
  color: var(--clr-muted);
  text-align: center;
  border-top: 1px solid var(--clr-border);
}

.friend-links a {
  color: var(--clr-muted);
  text-decoration: none;
  margin: 0 6px;
  transition: color .2s;
}

.friend-links a:hover { color: var(--clr-primary); }

/* ============ Utility ============ */
.cat-scroll {
  display: none;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0;
  -webkit-overflow-scrolling: touch;
}

.cat-scroll a {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  font-size: 13px;
  color: var(--clr-text);
  text-decoration: none;
  white-space: nowrap;
}

.cat-scroll::-webkit-scrollbar { display: none; }

.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--clr-primary);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
  z-index: 90;
}

.to-top.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ============ Animation ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ============ Responsive ============ */
@media (max-width: 1200px) {
  .layout-three { grid-template-columns: 1fr 280px; }
  aside.sidebar-left { display: none; }
}

@media (max-width: 768px) {
  .header-inner { padding: 0 1rem; }
  .logo { max-width: 150px; font-size: 16px; }
  .search-box { display: none; }
  .layout-three { grid-template-columns: 1fr; }
  aside.sidebar-right { display: none; }
  .hero-banner {
    grid-template-columns: 1fr;
    padding: 2rem 1.25rem;
  }
  .hero-thumb { order: -1; }
  .hero-text h1 { font-size: 24px; }
  .nav-main { display: none; }
  .menu-btn { display: flex; }
  .video-grid { grid-template-columns: repeat(2, 1fr); }
  .video-title { font-size: 13px; }
  .footer-cols { grid-template-columns: 1fr 1fr; }
  .cat-scroll { display: flex; }
  .section { margin-top: var(--space-xl); }
  .section-title { font-size: 18px; }
  .container { padding: 0 1rem; }
  .friend-links { padding: 14px 1rem 20px; }
}

@media (max-width: 380px) {
  .video-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .video-card, .hero-banner { animation: none; opacity: 1; transform: none; }
  .live-badge::before { animation: none; }
}