:root {
  --bg: #090909;
  --bg-soft: #111111;
  --surface: rgba(16, 16, 16, 0.82);
  --surface-strong: rgba(24, 24, 24, 0.94);
  --border: rgba(255, 255, 255, 0.1);
  --text: #f5f5f5;
  --muted: #b1b1b1;
  --accent: #ff5a2f;
  --accent-strong: #ff7b38;
  --accent-cool: #ffd166;
  --success: #55d99f;
  --danger: #ff6767;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
  --radius-lg: 28px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Barlow", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 90, 47, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 209, 102, 0.1), transparent 24%),
    linear-gradient(180deg, #0c0c0d 0%, #090909 45%, #121212 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 92%);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 24px auto;
  display: grid;
  gap: 20px;
}

.hero,
.player-panel,
.playlist-panel,
.footer {
  border: 1px solid var(--border);
  background: rgba(16, 16, 16, 0.82);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--radius-lg) + 6px);
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto auto;
  gap: 20px;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -40% auto;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 90, 47, 0.22), transparent 70%);
}

.hero-copy,
.hero-actions,
.hero-stats {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-cool);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero h1,
.panel-heading h2,
.playlist-header h2,
.empty-state h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw, 4.1rem);
  line-height: 0.98;
  max-width: 12ch;
}

.hero-text,
.panel-note,
.empty-state p,
.footer p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: flex-end;
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  padding: 14px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.button:hover,
.tool-button:hover,
.channel-card:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
}

.button-ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 18px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.09);
  text-align: center;
}

.stat-card span {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.stat-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(320px, 0.95fr);
  gap: 20px;
  align-items: start;
}

.player-panel,
.playlist-panel {
  border-radius: var(--radius-lg);
  padding: 20px;
}

.panel-heading,
.playlist-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.badge,
.results-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}

.badge-muted {
  color: var(--muted);
}

.badge[data-tone="success"],
.status-text[data-tone="success"] {
  color: var(--success);
}

.badge[data-tone="warning"],
.status-text[data-tone="warning"] {
  color: var(--accent-cool);
}

.badge[data-tone="error"],
.status-text[data-tone="error"] {
  color: var(--danger);
}

.video-stage {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border-radius: calc(var(--radius-lg) - 8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 90, 47, 0.14), transparent 25%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    #050505;
}

#videoPlayer {
  width: 100%;
  height: 100%;
  min-height: 520px;
  display: block;
  background: transparent;
}

.spinner-overlay,
.empty-state {
  position: absolute;
  inset: 0;
}

.spinner-overlay {
  display: grid;
  place-items: center;
  background: rgba(4, 4, 4, 0.7);
  z-index: 2;
}

.spinner {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  animation: spin 0.95s linear infinite;
}

.empty-state {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 10px;
  padding: clamp(24px, 5vw, 48px);
  z-index: 1;
}

.empty-kicker {
  margin: 0;
  color: var(--accent-cool);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.82rem;
  font-weight: 700;
}

.player-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.toolbar-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tool-button {
  padding: 11px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.tool-button:hover,
.tool-button:focus-visible,
.button:focus-visible,
.search-field input:focus,
.filter-field select:focus,
.channel-card:focus-visible {
  outline: none;
  border-color: rgba(255, 122, 56, 0.75);
  box-shadow: 0 0 0 4px rgba(255, 90, 47, 0.12);
}

.status-text {
  margin: 0;
  color: var(--muted);
  text-align: right;
  line-height: 1.45;
}

.playlist-tools {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(150px, 0.85fr);
  gap: 12px;
  margin-bottom: 16px;
}

.search-field,
.filter-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.search-field input,
.filter-field select {
  width: 100%;
  padding: 14px 16px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.channel-list {
  display: grid;
  gap: 12px;
  max-height: 760px;
  overflow: auto;
  padding-right: 4px;
}

.channel-card,
.channel-empty {
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
}

.channel-card {
  width: 100%;
  padding: 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.channel-card.is-active {
  background: linear-gradient(135deg, rgba(255, 90, 47, 0.14), rgba(255, 255, 255, 0.03));
  border-color: rgba(255, 122, 56, 0.45);
}

.channel-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px;
}

.channel-logo.is-fallback {
  display: grid;
  place-items: center;
  color: var(--accent-cool);
  font-weight: 800;
  font-size: 1rem;
}

.channel-copy {
  min-width: 0;
}

.channel-name {
  display: block;
  font-size: 1.02rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quality-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.12);
  color: var(--accent-cool);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.channel-empty {
  padding: 18px;
  color: var(--muted);
}

.footer {
  border-radius: 22px;
  padding: 18px 22px;
}

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

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

  .hero-actions {
    justify-content: flex-start;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 18px, 100%);
    margin: 10px auto 18px;
    gap: 14px;
  }

  .hero,
  .player-panel,
  .playlist-panel,
  .footer {
    padding: 16px;
    border-radius: 22px;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .playlist-header,
  .player-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .badge-row,
  .toolbar-buttons {
    width: 100%;
  }

  .toolbar-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tool-button,
  .button {
    width: 100%;
  }

  .playlist-tools {
    grid-template-columns: 1fr;
  }

  .channel-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .quality-chip {
    grid-column: 2;
    justify-self: start;
  }

  .video-stage,
  #videoPlayer {
    min-height: 280px;
  }
}
