:root {
  color-scheme: dark;
  --grid-columns: 2;
  --bg: #071018;
  --panel: rgba(8, 18, 30, 0.7);
  --panel-strong: rgba(9, 18, 31, 0.92);
  --border: rgba(166, 202, 255, 0.18);
  --text: #eef4ff;
  --muted: #a7b4ce;
  --accent: #8af0d1;
  --accent-strong: #4fd8bf;
  --warning: #f59e0b;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 14%, rgba(79, 216, 191, 0.22), transparent 0 24%),
    radial-gradient(circle at 86% 12%, rgba(96, 165, 250, 0.18), transparent 0 22%),
    radial-gradient(circle at 50% 120%, rgba(14, 165, 233, 0.16), transparent 0 34%),
    linear-gradient(180deg, #03070d 0%, #071018 42%, #0b1624 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 90%);
  opacity: 0.22;
}

body::after {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.06), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 35%, rgba(0, 0, 0, 0.14));
  mix-blend-mode: screen;
  opacity: 0.55;
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.hero {
  position: relative;
  z-index: 5;
  display: block;
  margin-bottom: 28px;
}

.hero-copy,
.search-panel,
.stream-card {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(22px) saturate(135%);
  box-shadow: var(--shadow);
}

.hero-copy {
  border-radius: 28px;
  padding: 32px;
}

.eyebrow,
.card-label {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 4.6rem);
  line-height: 0.95;
}

.hero-text {
  max-width: 56ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.search-panel {
  position: relative;
  border-radius: 28px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.search-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.search-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.suggestions-panel {
  margin-top: -6px;
}

.suggestions-list {
  display: grid;
  gap: 8px;
}

.suggestion-item {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.suggestion-item:hover {
  background: rgba(138, 240, 209, 0.12);
  border-color: rgba(138, 240, 209, 0.24);
}

.settings-bar {
  position: relative;
  display: flex;
  justify-content: flex-end;
}

.settings-button,
.settings-option {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.settings-button {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.settings-button span {
  transform: translateY(-1px);
}

.settings-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(7, 16, 27, 0.94);
  backdrop-filter: blur(22px) saturate(135%);
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 20;
}

.settings-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.settings-subtitle {
  margin-top: 14px;
}

.settings-options {
  display: grid;
  gap: 8px;
}

.settings-option {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
}

.settings-option.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, #7dd3fc 100%);
  color: #04243a;
  border-color: transparent;
}

.reorder-toggle.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, #7dd3fc 100%);
  color: #04243a;
  border-color: transparent;
}

input,
button {
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(5, 12, 24, 0.82);
  color: var(--text);
  padding: 14px 16px;
}

input:focus {
  outline: 2px solid rgba(110, 231, 183, 0.35);
  outline-offset: 2px;
}

button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease;
}

.search-row > button[type="submit"] {
  min-width: 170px;
  background: linear-gradient(135deg, var(--accent) 0%, #7dd3fc 100%);
  color: #04243a;
  font-weight: 700;
}

button:hover {
  transform: translateY(-1px);
}

.results-panel {
  padding-top: 4px;
  border: 0;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
}

.results-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.results-pagination {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pagination-button {
  min-width: 120px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.pagination-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.pagination-status {
  margin: 0;
  min-width: 70px;
  color: var(--muted);
  text-align: center;
}

.result-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(9, 17, 29, 0.92), rgba(6, 13, 24, 0.86));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.result-card:hover,
.result-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(138, 240, 209, 0.32);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.result-card:focus-visible {
  outline: 2px solid rgba(138, 240, 209, 0.38);
  outline-offset: 3px;
}

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

.result-card h3 {
  margin: 0;
  padding: 14px 14px 8px;
  font-size: 1rem;
  line-height: 1.35;
}

.result-meta {
  margin: 0;
  padding: 0 14px 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stream-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.stream-card {
  min-height: 0;
  cursor: grab;
  transition:
    transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms ease,
    opacity 180ms ease,
    filter 220ms ease;
}

.stream-card.dragging,
.stream-card.drag-over {
  box-shadow: 0 0 0 2px rgba(110, 231, 183, 0.55);
}

.stream-card.dragging {
  opacity: 0.78;
  transform: scale(1.035) rotate(0.6deg);
  filter: saturate(1.08);
  box-shadow:
    0 0 0 2px rgba(110, 231, 183, 0.65),
    0 30px 70px rgba(0, 0, 0, 0.42);
  z-index: 6;
}

.stream-card.is-reordering {
  z-index: 2;
}

.stream-card.drag-over {
  transform: scale(0.985);
  box-shadow:
    0 0 0 2px rgba(110, 231, 183, 0.45),
    0 18px 34px rgba(0, 0, 0, 0.18);
}

.stream-grid.is-sorting .stream-card:not(.dragging) {
  transform: scale(0.992);
}

.stream-grid.is-sorting .stream-card:not(.dragging) .player-shell::after {
  opacity: 1;
}

.player-shell {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(79, 216, 191, 0.12), transparent 44%),
    var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.07);
  aspect-ratio: 16 / 9;
}

.player-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(138, 240, 209, 0.08), transparent 45%),
    linear-gradient(180deg, transparent, rgba(125, 211, 252, 0.08));
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.stream-drag-surface {
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: grab;
  pointer-events: none;
}

.stream-grid.is-reorder-enabled .stream-drag-surface {
  pointer-events: auto;
}

.stream-card.dragging .stream-drag-surface,
.stream-grid.is-sorting.is-reorder-enabled .stream-drag-surface {
  cursor: grabbing;
}

.stream-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(220, 38, 38, 0.92);
  color: #fff5f5;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
  opacity: 0;
  transform: translateY(-4px) scale(0.92);
  pointer-events: none;
  cursor: pointer;
  transition:
    opacity 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}
.stream-remove span {
  font-size: 1.05rem;
  line-height: 1;
  transform: translateY(-1px);
}
.stream-card:hover .stream-remove,
.stream-card:focus-within .stream-remove {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.stream-remove:hover,
.stream-remove:focus-visible {
  background: #ef4444;
}

.stream-remove:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

.stream-grid.is-sorting .player-shell iframe {
  pointer-events: none;
}

.player-shell iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.streams-empty {
  margin: 0;
  grid-column: 1 / -1;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(7, 16, 26, 0.68), rgba(5, 12, 24, 0.44));
  color: var(--muted);
  padding: 36px 20px;
  text-align: center;
}

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

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 20px;
  }

  .hero-copy,
  .search-panel,
  .results-panel {
    border-radius: 22px;
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-row button,
  .settings-button {
    width: 100%;
  }

  .results-pagination {
    justify-content: center;
  }

  .settings-bar {
    justify-content: stretch;
  }

  .settings-panel {
    left: 0;
    right: 0;
    min-width: 0;
  }
}
