* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-dark: #07131f;
  --bg-panel: #0b1b2b;
  --bg-card: #102438;
  --bg-card-hover: #16324d;
  --accent-blue: #2395e8;
  --accent-glow: rgba(35, 149, 232, 0.35);
  --text-main: #f0f6fc;
  --text-muted: #8fa6bc;
  --border-subtle: #1b3650;
  --badge-green-bg: #0f3a2e;
  --badge-green-text: #34d399;
}

html, body {
  height: 100%;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

/* Top Bar */
.topbar {
  height: 44px;
  background: #06101a;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-weight: 700;
  font-size: 15px;
}

.brand-left, .brand-right {
  color: #38bdf8;
  letter-spacing: 0.8px;
}

.net-stats {
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.net-stats .dot {
  color: var(--text-muted);
}

/* Main Split Layout */
.app-container {
  display: flex;
  height: calc(100vh - 44px);
  width: 100%;
}

/* Left Player Section */
.player-section {
  width: 49%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #050d16;
  border-right: 1px solid var(--border-subtle);
  padding: 12px;
}

.video-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.status-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 13, 22, 0.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  color: #e2e8f0;
  z-index: 5;
}

.status-overlay.hidden {
  display: none;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(56, 189, 248, 0.25);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Bottom Controls under Player */
.now-playing-bar {
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.channel-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.np-logo {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  object-fit: contain;
  background: #0d2136;
  padding: 3px;
}

.np-logo.hidden {
  display: none;
}

.np-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
}

.np-category {
  font-size: 12.5px;
  color: var(--text-muted);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.ctrl-btn, .ctrl-select {
  background: #102438;
  color: #e2e8f0;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.ctrl-btn:hover, .ctrl-btn:focus, .ctrl-select:focus {
  border-color: var(--accent-blue);
  background: #173450;
}

.live-badge {
  background: var(--badge-green-bg);
  color: var(--badge-green-text);
  border: 1px solid rgba(52, 211, 153, 0.25);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* Right Browser Section */
.browser-section {
  width: 51%;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  padding: 12px 14px;
  overflow: hidden;
}

.search-bar-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

#searchInput {
  flex: 1;
  background: #081523;
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 8px 12px;
  color: #fff;
  font-size: 13.5px;
  outline: none;
}

#searchInput:focus {
  border-color: var(--accent-blue);
}

.action-btn {
  background: #102438;
  color: #e2e8f0;
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.action-btn.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

/* Category Pills */
.category-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 8px;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  white-space: nowrap;
  background: #102438;
  color: #cbd5e1;
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.cat-pill.active {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: var(--accent-blue);
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* 2-Column Channel Grid */
.channel-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  align-content: start;
  padding-right: 4px;
}

.channel-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  min-height: 64px;
}

.channel-card:hover, .channel-card:focus {
  background: var(--bg-card-hover);
  border-color: #38bdf8;
  outline: none;
}

.channel-card.active {
  background: #143656;
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8, 0 0 14px var(--accent-glow);
}

.card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.card-logo {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #091827;
  object-fit: contain;
  padding: 3px;
  flex-shrink: 0;
}

.card-info {
  min-width: 0;
  flex: 1;
}

.card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.fav-star {
  background: none;
  border: none;
  color: #64748b;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

.fav-star.starred {
  color: #fbbf24;
}

/* Portrait Mobile / Narrow Screen Responsive */
@media (max-width: 820px) {
  .player-section { width: 48%; padding: 8px; }
  .browser-section { width: 52%; padding: 8px; }
  .channel-grid { grid-template-columns: 1fr; }
}
