:root {
  color-scheme: dark;
  --bg: #03050a;
  --bg-soft: #070b13;
  --panel: rgba(9, 14, 26, .72);
  --panel-strong: rgba(10, 17, 32, .9);
  --line: rgba(142, 184, 255, .16);
  --line-strong: rgba(232, 190, 91, .35);
  --text: #eef5ff;
  --muted: #8ea1bd;
  --blue: #0a8dff;
  --blue-2: #53c6ff;
  --gold: #e5b64f;
  --gold-2: #ffdf85;
  --danger: #ff4c6f;
  --shadow: 0 30px 100px rgba(0,0,0,.55);
  --radius: 24px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(10, 141, 255, .24), transparent 31rem),
    radial-gradient(circle at 100% 20%, rgba(229, 182, 79, .14), transparent 28rem),
    linear-gradient(145deg, #020308 0%, #07101c 46%, #03050a 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.7), transparent);
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1760px, 100%);
  margin: 0 auto;
  padding: 22px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: 0 0 24px rgba(10, 141, 255, .3), 0 0 42px rgba(229, 182, 79, .12);
}

.brand-title {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.04em;
  background: linear-gradient(90deg, #eff8ff, #4ab9ff 45%, #f1c86d 75%, #fff0bd);
  -webkit-background-clip: text;
  color: transparent;
}

.brand-subtitle {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 9, 17, .72);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  color: #dceaff;
  white-space: nowrap;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #37e38a;
  box-shadow: 0 0 16px rgba(55, 227, 138, .8);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(420px, 1fr) minmax(350px, 460px);
  grid-template-areas:
    "setup player browser";
  gap: 18px;
  align-items: start;
}

.panel, .video-card, .now-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(12, 20, 38, .82), rgba(4, 7, 13, .72));
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.06);
  border-radius: var(--radius);
}

.setup-panel {
  grid-area: setup;
  padding: 20px;
  position: sticky;
  top: 18px;
}

.panel-title-row, .browser-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 26px; letter-spacing: -.04em; }
h2 { font-size: 23px; letter-spacing: -.035em; }
p { color: var(--muted); margin-top: 6px; font-size: 14px; line-height: 1.45; }

.input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.input-wrap, .search-wrap {
  display: grid;
  gap: 8px;
}

.input-wrap span, .search-wrap span {
  color: #c7d6ec;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
}

input[type="url"], input[type="search"] {
  width: 100%;
  min-height: 48px;
  color: var(--text);
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(126, 167, 255, .2);
  border-radius: 16px;
  outline: none;
  padding: 0 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

input:focus {
  border-color: rgba(83, 198, 255, .7);
  box-shadow: 0 0 0 4px rgba(10, 141, 255, .12);
}

.primary-btn, .ghost-btn, .file-btn {
  min-height: 48px;
  border: 0;
  border-radius: 16px;
  padding: 0 18px;
  color: #06111d;
  font-weight: 850;
  background: linear-gradient(135deg, var(--blue-2), var(--blue) 45%, var(--gold));
  box-shadow: 0 14px 36px rgba(10, 141, 255, .25), inset 0 1px 0 rgba(255,255,255,.25);
}

.ghost-btn, .file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #eaf4ff;
  border: 1px solid var(--line);
  background: rgba(8, 13, 24, .7);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}

.ghost-btn:hover, .file-btn:hover, .round-btn:hover, .channel-item:hover, .category-btn:hover {
  border-color: rgba(229, 182, 79, .55);
  transform: translateY(-1px);
}

.ghost-btn.danger { color: #ffd7df; }
.file-btn input { display: none; }

.import-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 14px;
  color: #d8e7ff;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(0,0,0,.2);
}

.toggle-row input { accent-color: var(--gold); }

.player-stage {
  grid-area: player;
  display: grid;
  gap: 18px;
}

.video-card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #000;
}

video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.player-overlay {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 20px;
  background: rgba(3, 6, 12, .68);
  backdrop-filter: blur(16px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.player-overlay.is-hidden {
  opacity: 0;
  transform: translateY(10px);
}

.play-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 18px;
  color: #06111d;
  background: linear-gradient(135deg, #f8d984, #bd8629);
  box-shadow: 0 0 30px rgba(229, 182, 79, .32);
}

.player-overlay strong, .player-overlay span { display: block; }
.player-overlay span { margin-top: 4px; color: var(--muted); font-size: 13px; }

.now-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px;
}

.channel-identity {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.channel-identity img, .channel-logo {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  object-fit: contain;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
}

#currentTitle {
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#currentGroup, .channel-group { color: var(--muted); }

.player-actions { display: flex; gap: 10px; }
.round-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 26, .75);
  color: #f0f6ff;
  font-weight: 900;
  font-size: 22px;
}

.browser-panel {
  grid-area: browser;
  padding: 18px;
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  min-height: 520px;
}

.category-strip {
  display: flex;
  gap: 9px;
  overflow-x: auto;
  padding: 14px 1px 12px;
  scrollbar-width: thin;
}

.category-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #dce9ff;
  background: rgba(4, 9, 18, .7);
  padding: 10px 13px;
}

.category-btn.active {
  color: #06111d;
  background: linear-gradient(135deg, var(--blue-2), var(--gold));
  border-color: transparent;
  font-weight: 900;
}

.channel-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.channel-item {
  width: 100%;
  display: grid;
  grid-template-columns: 52px 1fr 28px;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 10px;
  border: 1px solid rgba(142, 184, 255, .12);
  border-radius: 18px;
  color: var(--text);
  background: rgba(2, 6, 12, .52);
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.channel-item.active {
  border-color: rgba(83, 198, 255, .8);
  background: linear-gradient(135deg, rgba(10, 141, 255, .18), rgba(229, 182, 79, .1));
}

.channel-main { min-width: 0; }
.channel-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}
.channel-group { display: block; margin-top: 4px; font-size: 12px; }
.channel-fav { color: var(--gold); text-align: center; font-size: 20px; }

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "setup setup"
      "player browser";
  }
  .setup-panel { position: static; }
}

@media (max-width: 820px) {
  .app-shell { padding: 14px; }
  .topbar { align-items: flex-start; }
  .brand-logo { width: 52px; height: 52px; border-radius: 16px; }
  .brand-subtitle { font-size: 11px; }
  .status-pill { display: none; }
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "setup"
      "player"
      "browser";
  }
  .browser-panel { position: static; max-height: none; min-height: 420px; }
  .video-card { border-radius: 20px; }
  .player-overlay { left: 12px; right: 12px; bottom: 12px; padding: 12px; }
  .now-card { align-items: flex-start; }
  .player-actions { flex-shrink: 0; }
  h1 { font-size: 22px; }
}
