:root {
  --bg: #0c0f12;
  --surface: #14181d;
  --surface-2: #1a2026;
  --surface-3: #222a31;
  --line: #2b333b;
  --line-soft: #20272e;
  --text: #f2f4f5;
  --muted: #9aa4ad;
  --accent: #35c493;
  --accent-strong: #18a878;
  --warning: #f0b34f;
  --danger: #ef6b67;
  --max: 1440px;
  --radius: 8px;
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
body, button, input { font: inherit; letter-spacing: 0; }
button, input { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(12, 15, 18, .96);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(12px);
}
.topbar-row {
  width: min(var(--max), 100%);
  min-height: 58px;
  margin: 0 auto;
  padding: 10px 16px;
  display: grid;
  grid-template-columns: auto minmax(180px, 440px);
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #4a5f58;
  border-radius: 7px;
  background: #20352f;
  color: #8de7c6;
  font-size: 15px;
}
.search {
  height: 38px;
  display: grid;
  grid-template-columns: 1fr 38px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.search:focus-within { border-color: #4d7568; }
.search input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 11px;
  border: 0;
  outline: 0;
  background: transparent;
}
.search input::placeholder { color: #7e8891; }
.search button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-left: 1px solid var(--line-soft);
  background: var(--surface-2);
  color: var(--muted);
}
.search button:hover { color: var(--text); background: var(--surface-3); }
.search svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.category-nav {
  width: min(var(--max), 100%);
  height: 42px;
  margin: 0 auto;
  padding: 0 16px 9px;
  display: flex;
  align-items: end;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }
.nav-item {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: #c6f5e4; background: #203a32; }

.main { width: min(var(--max), 100%); margin: 0 auto; padding: 18px 16px 48px; }
.page-head {
  min-height: 40px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.page-head h1 { margin: 0; font-size: 19px; line-height: 1.3; font-weight: 680; }
.page-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }

.video-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 10px;
}
.video-card { min-width: 0; cursor: pointer; }
.poster {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface);
}
.poster::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #252c32;
  transform: translateX(-100%);
  animation: poster-loading 1.25s ease-in-out infinite;
}
.poster.loaded::after, .poster.failed::after { display: none; }
@keyframes poster-loading { 55%, 100% { transform: translateX(100%); } }
.poster img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .18s ease; }
.poster.loaded img { opacity: 1; }
.poster-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: #74808a;
  font-size: 13px;
  background: var(--surface-2);
}
.poster.failed .poster-placeholder { display: grid; }
.duration {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 3px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: 11px;
  line-height: 1.2;
}
.video-card:hover .poster { border-color: #4d675f; }
.card-title {
  margin: 8px 1px 0;
  min-height: 38px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 560;
}
.card-meta {
  margin: 4px 1px 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}
.card-meta span:last-child { text-align: right; }

.pager { margin-top: 28px; display: flex; align-items: center; justify-content: center; gap: 9px; }
.button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.button:hover:not(:disabled) { border-color: #50615b; background: var(--surface-3); }
.button.primary { border-color: #247a5c; background: #176b4f; }
.button.primary:hover:not(:disabled) { background: #167759; }

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}
.detail-main { min-width: 0; }
.player-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
}
.art-player { width: 100%; height: 100%; }
.player-feedback {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.player-feedback.error { pointer-events: auto; }
.feedback-label {
  max-width: calc(100% - 32px);
  padding: 8px 11px;
  border-radius: 6px;
  background: rgba(10, 12, 14, .84);
  color: #fff;
  font-size: 13px;
  text-align: center;
}
.feedback-label .button { margin-top: 10px; }
.feedback-loading { display: inline-flex; align-items: center; gap: 8px; }
.feedback-loading .loader { width: 18px; height: 18px; }
.player-feedback[hidden] { display: none; }
.detail-copy { padding: 15px 2px 0; }
.detail-copy h1 { margin: 0; font-size: 20px; line-height: 1.45; font-weight: 680; }
.detail-meta { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12px; }
.tag-list { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  height: 27px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #bdc5cb;
  background: var(--surface);
  font-size: 12px;
}
.description { margin: 13px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; white-space: pre-wrap; }

.related-panel {
  min-width: 0;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  border-left: 1px solid var(--line-soft);
  padding-left: 16px;
  scrollbar-color: #46515a transparent;
  scrollbar-width: thin;
}
.related-title { margin: 0 0 10px; font-size: 15px; font-weight: 650; }
.related-list { display: grid; gap: 10px; }
.related-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 9px;
  min-width: 0;
  cursor: pointer;
}
.related-poster { aspect-ratio: 3 / 4; overflow: hidden; border-radius: 6px; background: var(--surface-2); }
.related-poster img { width: 100%; height: 100%; object-fit: cover; }
.related-name {
  margin: 1px 0 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 560;
}
.related-meta { margin-top: 6px; color: var(--muted); font-size: 11px; }

.page-loading, .empty-state, .error-state {
  min-height: 48vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}
.loader {
  width: 28px;
  height: 28px;
  border: 2px solid #303841;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state strong { color: var(--text); font-size: 15px; }
.error-state p { max-width: 420px; margin: 0; font-size: 13px; line-height: 1.6; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 80;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 9px 12px;
  border: 1px solid #48545d;
  border-radius: 7px;
  background: #20262c;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

@media (min-width: 620px) {
  .video-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px 13px; }
}
@media (min-width: 900px) {
  .video-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 1240px) {
  .video-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 19px 14px; }
}
@media (max-width: 860px) {
  .detail-layout { grid-template-columns: 1fr; }
  .related-panel {
    max-height: none;
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    padding: 15px 0 0;
  }
  .related-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  .related-item { grid-template-columns: 72px minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .topbar-row { grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 9px 11px; }
  .brand > span:last-child { display: none; }
  .category-nav { padding-left: 11px; padding-right: 11px; }
  .main { padding: 14px 11px 40px; }
  .page-head { align-items: start; flex-direction: column; gap: 3px; }
  .page-meta { white-space: normal; }
  .card-meta span:last-child { display: none; }
  .detail-copy h1 { font-size: 18px; }
  .related-list { grid-template-columns: 1fr; }
  .related-item { grid-template-columns: 82px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
