:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #111418;
  --panel-solid: #111418;
  --panel-lift: #171b20;
  --line: rgba(226, 232, 240, 0.1);
  --line-strong: rgba(226, 232, 240, 0.18);
  --text: #e8edf3;
  --muted: #929aa4;
  --soft: #c1c8d0;
  --accent: #7aa2f7;
  --ok: #79c992;
  --warn: #d98159;
  --danger: #ef6678;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
  background: var(--bg);
}

body::before {
  content: none;
}

button,
input,
select {
  font: inherit;
}

button,
label,
select {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.shell {
  width: 100%;
  padding: 16px;
}

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

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #151a20;
  color: var(--ok);
  font-weight: 700;
}

.brand strong {
  display: block;
  font-size: 1rem;
  line-height: 1.1;
  letter-spacing: 0;
  font-weight: 650;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.top-actions,
.player-actions,
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  align-items: start;
}

.player-panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.player-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  min-height: 0;
  background: #050608;
}

.player-stage::after {
  content: none;
}

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

.idle-layer,
.status-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(5, 6, 8, 0.72);
}

.idle-badge,
.count-pill,
.health {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid rgba(226, 232, 240, 0.16);
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.06);
  color: var(--soft);
  font-size: 0.68rem;
  font-weight: 650;
}

.idle-layer h1 {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.8vw, 1.4rem);
  letter-spacing: 0;
  font-weight: 600;
}

.status-layer {
  z-index: 4;
  background: rgba(5, 6, 8, 0.78);
  color: var(--soft);
  font-weight: 650;
}

.hidden {
  display: none !important;
}

.now-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 94px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: #0f1216;
}

.now-logo,
.channel-logo,
.channel-fallback {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1116;
  color: var(--ok);
  font-weight: 700;
  overflow: hidden;
}

.now-logo img,
.channel-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
}

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.now-copy h2,
.source-card h2 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1.2;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.tool-button {
  border: 1px solid var(--line);
  background: var(--panel-lift);
  color: var(--text);
  cursor: pointer;
  transition:
    border-color 150ms ease,
    background 150ms ease;
}

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

.icon-button:hover,
.tool-button:hover {
  border-color: rgba(122, 162, 247, 0.34);
  background: #1b2027;
}

.icon-button svg,
.tool-button svg,
.search-box svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 650;
}

.tool-button.is-favorite {
  border-color: rgba(217, 129, 89, 0.42);
  color: var(--warn);
}

.control-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 112px);
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.source-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15191f;
}

.source-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 600;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.preset-button {
  display: flex;
  min-width: 0;
  min-height: 62px;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15191f;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 150ms ease,
    background 150ms ease;
}

.preset-button:hover {
  border-color: rgba(122, 162, 247, 0.3);
  background: #18202a;
}

.preset-button.is-active {
  border-color: rgba(122, 162, 247, 0.48);
  background: rgba(122, 162, 247, 0.12);
}

.preset-button span {
  overflow: hidden;
  font-size: 0.72rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preset-button strong {
  color: var(--accent);
  font-size: 0.72rem;
}

.search-box input,
select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: #0d1116;
  color: var(--text);
}

.search-box input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
}

.search-box input:focus,
select:focus {
  border-color: rgba(122, 162, 247, 0.62);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1116;
}

.tab {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 650;
}

.tab.is-active {
  background: #d7e4ff;
  color: #0c1118;
}

.filter-row {
  align-items: stretch;
  margin-bottom: 12px;
}

.search-box {
  position: relative;
  flex: 1;
}

.search-box svg {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search-box input {
  padding-left: 40px;
}

select {
  width: 132px;
  height: 44px;
  padding: 0 10px;
  color: var(--soft);
}

.channels {
  flex: 1;
  min-height: 260px;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-color: rgba(122, 162, 247, 0.45) rgba(255, 255, 255, 0.05);
}

.channel {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 66px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #15191f;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

.channel:hover {
  border-color: rgba(122, 162, 247, 0.3);
  background: #18202a;
}

.channel.is-active {
  border-color: rgba(122, 162, 247, 0.48);
  background: rgba(122, 162, 247, 0.12);
}

.channel-logo,
.channel-fallback {
  width: 48px;
  height: 48px;
}

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

.channel-title strong {
  display: block;
  overflow: hidden;
  font-size: 0.88rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-title small {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.health {
  border-color: rgba(121, 201, 146, 0.24);
  background: rgba(121, 201, 146, 0.1);
  color: var(--ok);
}

.health.offline {
  border-color: rgba(255, 79, 105, 0.28);
  background: rgba(255, 79, 105, 0.08);
  color: var(--danger);
}

.empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
}

.load-more {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  border: 1px solid rgba(122, 162, 247, 0.28);
  border-radius: 6px;
  background: rgba(122, 162, 247, 0.1);
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 650;
  transition:
    background 150ms ease;
}

.load-more:hover {
  background: rgba(122, 162, 247, 0.16);
}

.credit {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 12px 2px 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.credit a {
  color: var(--accent);
  text-decoration: none;
}

.credit #sourceLinks {
  display: inline-flex;
  gap: 5px;
}

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

  .player-panel,
  .control-panel {
    min-height: auto;
  }

  .control-panel {
    height: 620px;
  }
}

@media (max-width: 680px) {
  .shell {
    padding: 10px;
  }

  .brand small,
  .tool-button span {
    display: none;
  }

  .topbar {
    margin-bottom: 10px;
  }

  .workspace {
    gap: 10px;
  }

  .player-stage,
  .video {
    min-height: 250px;
  }

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

  .player-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .tool-button {
    flex: 1;
    justify-content: center;
  }

  .filter-row {
    flex-direction: column;
  }

  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  select {
    width: 100%;
  }

  .control-panel {
    height: 600px;
  }
}
