:root {
  color-scheme: dark;
  --bg: #101214;
  --surface: #181b1e;
  --surface-strong: #202428;
  --line: #30353a;
  --text: #f5f7f8;
  --muted: #979fa7;
  --accent: #26b36a;
  --accent-soft: rgba(38, 179, 106, 0.14);
  --focus: #8adbb0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 100% 64px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(1640px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 28px 32px;
}

.site-header {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  aspect-ratio: 1;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  color: #07110b;
  background: var(--accent);
  border-radius: 6px;
}

.brand-mark svg {
  width: 22px;
  fill: currentColor;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  width: min(320px, 35vw);
  height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: border-color 160ms ease, background 160ms ease;
}

.search-box:focus-within {
  background: var(--surface-strong);
  border-color: var(--focus);
}

.search-box svg {
  width: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-box input {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.search-box input::placeholder {
  color: #747c84;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 410px);
  gap: 30px;
  padding-top: 28px;
}

.watch-area {
  min-width: 0;
}

.player-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #050606;
  border: 1px solid #2a2e31;
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
}

.player-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
  z-index: 1;
}

.player-placeholder[hidden] {
  display: none;
}

.loader {
  width: 18px;
  aspect-ratio: 1;
  border: 2px solid #384047;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.video-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0 16px;
  border-bottom: 1px solid var(--line);
}

.video-heading > div:first-child {
  min-width: 0;
}

.eyebrow,
.playlist-kicker {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.28;
  letter-spacing: 0;
}

.video-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.icon-button {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.icon-button:hover:not(:disabled) {
  background: var(--surface-strong);
  border-color: #51585f;
}

.icon-button:disabled {
  color: #555d64;
  cursor: not-allowed;
}

.icon-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.collection-description {
  max-width: 860px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.playlist-panel {
  height: calc(100vh - 138px);
  min-height: 520px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.playlist-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.playlist-header > div:first-child {
  display: grid;
}

.playlist-header strong {
  font-size: 15px;
}

.unit-filter {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: #111416;
  border: 1px solid #2a2f33;
  border-radius: 6px;
}

.filter-button {
  min-width: 34px;
  height: 28px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.filter-button:hover {
  color: var(--text);
}

.filter-button.is-active {
  color: #07110b;
  background: var(--accent);
  font-weight: 700;
}

.playlist {
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  scrollbar-color: #444b51 transparent;
  scrollbar-width: thin;
}

.video-item {
  width: 100%;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.video-item:hover {
  background: var(--surface-strong);
}

.video-item.is-active {
  background: var(--accent-soft);
  border-color: rgba(38, 179, 106, 0.34);
}

.thumbnail-wrap {
  position: relative;
  width: 128px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #0b0d0e;
  border-radius: 4px;
}

.thumbnail-label {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #d6eee0;
  background:
    linear-gradient(135deg, rgba(38, 179, 106, 0.24), transparent 62%),
    #242b28;
  font-size: 24px;
  font-weight: 800;
}

.duration {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 2px 5px;
  color: #fff;
  background: rgba(0, 0, 0, 0.76);
  border-radius: 3px;
  font-size: 10px;
  line-height: 1.3;
}

.playing-indicator {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(5, 17, 10, 0.72);
}

.is-active .playing-indicator {
  display: flex;
}

.playing-indicator i {
  width: 3px;
  height: 16px;
  background: var(--accent);
  animation: equalize 800ms ease-in-out infinite alternate;
}

.playing-indicator i:nth-child(2) { animation-delay: -400ms; }
.playing-indicator i:nth-child(3) { animation-delay: -200ms; }

@keyframes equalize {
  from { transform: scaleY(0.35); }
  to { transform: scaleY(1); }
}

.video-copy {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 5px;
}

.video-number,
.video-file {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.video-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.is-active .video-title,
.is-active .video-number {
  color: var(--accent);
}

.empty-state {
  padding: 64px 20px;
  color: var(--muted);
  text-align: center;
}

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

@media (max-width: 1040px) {
  h1 {
    font-size: 28px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .playlist-panel {
    height: auto;
    min-height: 0;
  }

  .playlist {
    max-height: 620px;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 22px;
  }

  .app-shell {
    padding: 0 14px 22px;
  }

  .site-header {
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 16px 0;
  }

  .search-box {
    width: 100%;
  }

  .content-grid {
    gap: 22px;
    padding-top: 16px;
  }

  .video-heading {
    padding-top: 18px;
  }

  .collection-description {
    display: none;
  }

  .playlist-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .unit-filter {
    width: 100%;
  }

  .filter-button {
    flex: 1;
  }

  .video-item {
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    padding: 8px;
  }

  .thumbnail-wrap {
    width: 112px;
  }
}

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