:root {
  color-scheme: dark;
  --bg: #080a12;
  --panel: rgba(18, 23, 39, 0.78);
  --panel-solid: #111827;
  --muted: #9aa4b2;
  --text: #f7f9fc;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #39d3ff;
  --accent-2: #8b5cf6;
  --hot: #ff4f7b;
  --success: #38d996;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 8%, rgba(57, 211, 255, 0.16), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(139, 92, 246, 0.18), transparent 28%),
    linear-gradient(145deg, #06070d, #0d1222 48%, #080a12);
  color: var(--text);
}

body.light {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-solid: #ffffff;
  --muted: #637083;
  --text: #111827;
  --line: rgba(15, 23, 42, 0.12);
  --shadow: 0 22px 56px rgba(15, 23, 42, 0.12);
  background: linear-gradient(145deg, #eef7ff, #f7f2ff 55%, #ffffff);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(6, 9, 18, 0.54);
  backdrop-filter: blur(24px);
}

body.light .sidebar {
  background: rgba(255, 255, 255, 0.64);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}

.brand-mark,
.channel-logo {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(57, 211, 255, 0.18);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-stack {
  display: grid;
  gap: 10px;
  margin-top: 34px;
}

.nav-item,
.segment button,
.icon-button,
.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-item {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  text-align: left;
}

.nav-item.active,
.segment button.active {
  border-color: rgba(57, 211, 255, 0.5);
  background: linear-gradient(135deg, rgba(57, 211, 255, 0.18), rgba(139, 92, 246, 0.18));
}

.signal-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 34px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.signal-card p,
.now-playing p,
.import-box p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.pulse {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 8px rgba(56, 217, 150, 0.12);
}

.main {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 0.98;
}

.top-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.search {
  display: flex;
  align-items: center;
  min-width: min(380px, 42vw);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(300px, 0.8fr);
  gap: 18px;
  align-items: stretch;
}

.player-wrap {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(57, 211, 255, 0.08), rgba(139, 92, 246, 0.1)),
    #03050b;
  box-shadow: var(--shadow);
}

.player-wrap.theater {
  position: fixed;
  inset: 18px;
  z-index: 20;
  min-height: auto;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
  object-fit: contain;
  background: #000;
}

.player-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: 28px;
  text-align: center;
  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: 42px 42px;
}

.player-empty.hidden {
  display: none;
}

.player-empty span {
  justify-self: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 79, 123, 0.14);
  color: var(--hot);
  font-weight: 900;
}

.player-empty h2 {
  margin: 16px 0 8px;
  font-size: clamp(1.7rem, 3vw, 3rem);
}

.now-playing,
.stream-form,
.import-box,
.media-tools,
.file-drop {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.now-playing {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}

.now-playing h2 {
  margin: 14px 0 0;
  font-size: 2rem;
}

.metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0;
}

.metadata span,
.card-meta span,
.section-heading > span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
}

.player-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.playlist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 800;
}

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

.secondary-button {
  border: 1px solid var(--line);
}

.controls-band {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0;
}

.segment {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment button,
select {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 8px;
}

select {
  border: 1px solid var(--line);
  background: var(--panel-solid);
  color: var(--text);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.6rem;
}

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.media-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
}

.file-drop {
  display: grid;
  gap: 7px;
  padding: 16px;
  box-shadow: none;
}

.file-drop span {
  color: var(--muted);
  line-height: 1.45;
}

.file-drop input {
  width: 100%;
  color: var(--muted);
}

.channel-card {
  display: grid;
  gap: 14px;
  min-height: 190px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.channel-card:hover {
  transform: translateY(-3px);
  border-color: rgba(57, 211, 255, 0.5);
}

.channel-card.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(57, 211, 255, 0.16), rgba(139, 92, 246, 0.13));
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mini-logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 900;
}

.live-pill {
  color: var(--hot);
  font-size: 0.76rem;
  font-weight: 900;
}

.channel-card h3 {
  margin: 0;
  font-size: 1.08rem;
}

.channel-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.schedule-list {
  display: grid;
  gap: 10px;
}

.schedule-item {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.schedule-item time {
  color: var(--accent);
  font-weight: 900;
}

.schedule-item h3 {
  margin: 0 0 4px;
}

.schedule-item p {
  margin: 0;
  color: var(--muted);
}

.stream-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.stream-form label,
.import-box {
  display: grid;
  gap: 8px;
}

.stream-form label {
  color: var(--muted);
  font-weight: 700;
}

.stream-form input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  outline: 0;
}

.stream-form input {
  min-height: 42px;
  padding: 0 12px;
}

.stream-form button {
  align-self: end;
}

.import-box {
  margin-top: 14px;
  padding: 18px;
}

.import-box h3 {
  margin: 0;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(380px, calc(100vw - 44px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-solid);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
    height: auto;
  }

  .nav-stack {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    text-align: center;
  }

  .signal-card {
    display: none;
  }

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

@media (max-width: 720px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .controls-band,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

  .filter-actions {
    justify-content: stretch;
  }

  .filter-actions > * {
    flex: 1 1 160px;
  }

  .nav-stack,
  .stream-form,
  .media-tools {
    grid-template-columns: 1fr;
  }

  .schedule-item {
    grid-template-columns: 1fr;
  }

  .player-wrap,
  video {
    min-height: 270px;
  }
}
