* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #0f0f0f;
  color: #e0e0e0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: #1a1a2e;
  border-bottom: 1px solid #2a2a3e;
}
header h1 { color: #e94560; font-size: 1.4rem; }
#search {
  flex: 1;
  max-width: 400px;
  padding: 0.5rem 1rem;
  background: #0f0f0f;
  border: 1px solid #333;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 0.9rem;
}
#search:focus { outline: none; border-color: #e94560; }
header button {
  padding: 0.5rem 1rem;
  background: #16213e;
  border: 1px solid #333;
  border-radius: 4px;
  color: #e0e0e0;
  cursor: pointer;
  font-size: 0.85rem;
}
header button:hover { background: #1a1a4e; border-color: #e94560; }

#layout { display: flex; flex: 1; overflow: hidden; min-height: 0; }

#ad-sidebar {
  width: 180px;
  flex-shrink: 0;
  padding: 0 0.5rem;
}

#sidebar {
  width: 220px;
  background: #16213e;
  border-right: 1px solid #2a2a3e;
  overflow-y: auto;
  padding: 1rem;
  flex-shrink: 0;
  /* Mobile: hidden off-screen by default */
  transition: transform 0.25s ease;
}

/* ─ Hamburger button ────────────────────────── */
#btn-burger {
  display: none;
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  flex-shrink: 0;
}

/* ─ Backdrop ────────────────────────────── */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}
#sidebar-backdrop.visible { display: block; }

/* ─ Mobile: sidebar becomes a fixed overlay ──────────── */
@media (max-width: 767px) {
  #btn-burger { display: block; }

  /* Header wraps: logo+burger on top, search full width below */
  header {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }
  header h1 { flex: 1; font-size: 1.1rem; }
  #btn-burger { order: 2; }
  #btn-favorites { display: none; }  /* accessible in sidebar on mobile */
  #search {
    order: 3;
    flex: 1 1 100%;  /* full-width second row */
    max-width: 100%;
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
  }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    width: 260px;
    padding-top: 3.5rem;
  }
  #sidebar.open { transform: translateX(0); }

  /* Full-width grid on mobile */
  #layout { overflow-x: hidden; }
  #channels {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    padding: 0;
  }
  main { padding: 0.75rem; padding-bottom: 70px; }
  .channel-card { min-height: 100px; }
  .channel-card img { width: 60px; height: 60px; }
}

#sidebar h3 { margin-bottom: 0.75rem; color: #888; font-size: 0.8rem; text-transform: uppercase; }
#categories { list-style: none; }
#categories li {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.85rem;
  color: #aaa;
}
#categories li:hover { background: #1a1a4e; color: #fff; }
#categories li.active { background: #e94560; color: #fff; }

main { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 1.5rem; min-height: 0; }

#channels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}
.channel-card {
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  padding: 0.75rem;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, transform 0.1s;
  /* Fixed height prevents the grid from reflowing as icons load in */
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.channel-card:hover {
  border-color: #e94560;
  transform: translateY(-2px);
}
.channel-card img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 4px;
  background: #111827;
}
/* No logo: just a plain dark square, no animation */
.channel-card img[src=""],
.channel-card img:not([src]) {
  background: #1a1a2e;
}
.channel-card .name {
  font-size: 0.8rem;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#player-overlay.hidden { display: none; }
#player-container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}
#video {
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 6px;
  display: block;
}
#player-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}
#now-playing { flex: 1; color: #e0e0e0; font-size: 0.95rem; }
#player-controls button {
  padding: 0.5rem 1rem;
  background: #16213e;
  border: 1px solid #333;
  border-radius: 4px;
  color: #e0e0e0;
  cursor: pointer;
}
#player-controls button:hover { border-color: #e94560; }
#btn-close { background: #e94560; border-color: #e94560; }
#loading { text-align: center; padding: 3rem; color: #888; }
