:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-hover: #1f232c;
  --text: #e9ecf1;
  --muted: #9aa3b2;
  --accent: #6ea8fe;
  --radius: 14px;
  --bar-height: 3.5rem;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

.view {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

[hidden] {
  display: none !important;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--bar-height);
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #ffffff12;
}

.bar h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.filter {
  margin-left: auto;
  width: min(18rem, 42vw);
  padding: 0.4rem 0.7rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #ffffff14;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9rem;
}

.filter:focus-visible,
.icon-button:focus-visible,
.back:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

main {
  flex: 1;
  padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 3rem;
}

.grid {
  display: grid;
  gap: clamp(0.9rem, 2vw, 1.4rem);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15.5rem), 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid #ffffff10;
  border-radius: var(--radius);
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

.card:hover {
  transform: translateY(-2px);
  background: var(--surface-hover);
  border-color: color-mix(in srgb, var(--accent, #6ea8fe) 55%, transparent);
}

.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #0b0d11;
}

.thumb img,
.placeholder {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder {
  display: grid;
  place-items: center;
  color: #ffffff5c;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.15rem 0.5rem;
  color: #0b0d11;
  background: #7ee081;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.meta {
  padding: 0.75rem 0.9rem 0.9rem;
}

.meta h3 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
}

.meta p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.55rem 0 0;
  padding: 0;
  list-style: none;
}

.tags li {
  padding: 0.1rem 0.45rem;
  color: var(--muted);
  background: #ffffff0a;
  border-radius: 999px;
  font-size: 0.7rem;
}

.empty {
  margin: 3rem 0;
  color: var(--muted);
  text-align: center;
}

/* Player */

.player {
  height: 100dvh;
  overflow: hidden;
}

.player-bar {
  flex: 0 0 var(--bar-height);
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #ffffff14;
  border-radius: 999px;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.back:hover {
  background: var(--surface-hover);
}

.back .icon {
  width: 0.95rem;
  height: 0.95rem;
}

.player-bar h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.4rem;
  margin-left: auto;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid #ffffff14;
  border-radius: 999px;
  cursor: pointer;
}

/* Inline SVG icons: no font can substitute them, so they always render. */
.icon {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover {
  background: var(--surface-hover);
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
  outline: none;
}

.stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  outline: none;
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  color: var(--muted);
  background: #000;
  font-size: 0.9rem;
}

.spinner {
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid #ffffff24;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .card,
  .spinner {
    transition: none;
    animation: none;
  }
}

@media (max-width: 30rem) {
  .filter {
    width: 45vw;
  }

  .back {
    flex: 0 0 auto;
    padding: 0.4rem 0.6rem;
  }

  .player-bar h2 {
    padding: 0 0.25rem;
    font-size: 0.85rem;
  }
}
