:root {
  --bg: #0d1117; --bg2: #161b22; --card: #1c2129; --line: #2a313c;
  --text: #e6edf3; --muted: #8b949e; --accent: #4f8cff; --ok: #2ea043;
  --warn: #d29922; --dead: #6e7681;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg2);
  display: flex; flex-direction: column; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 640px) { .topbar { flex-direction: row; align-items: center; } }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 17px; white-space: nowrap; }
.feed-status { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-status.ok { color: var(--ok); }
.feed-status.err { color: var(--warn); }

#searchBox {
  flex: 1; min-width: 120px; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 15px;
}
#searchBox:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.chips { display: flex; gap: 8px; padding: 10px 14px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 16px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; padding: 12px 14px 40px;
}
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }

.card {
  position: relative; display: flex; flex-direction: column; gap: 8px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
  min-height: 88px; transition: border-color .15s, transform .1s;
}
.card:focus-visible, .card:hover { border-color: var(--accent); outline: none; }
.card:active { transform: scale(.98); }
.card .logo-img {
  width: 52px; height: 52px; object-fit: contain; border-radius: 8px; background: #fff; padding: 3px;
}
.card .placeholder-logo {
  width: 52px; height: 52px; border-radius: 8px; background: var(--bg2); color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700;
}
.card-row { display: flex; gap: 10px; align-items: center; }
.card .name { font-size: 14px; font-weight: 600; line-height: 1.25; }
.card .meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.badge {
  font-size: 10.5px; padding: 2.5px 7px; border-radius: 999px;
  background: var(--bg2); border: 1px solid var(--line); color: var(--muted);
}
.badge.srcs { background: rgba(47,160,67,.15); border-color: var(--ok); color: #7ee2a8; }
.badge.fav { position: absolute; top: 8px; right: 8px; font-size: 15px; background: none; border: none; color: #f0c33c; }

.player-wrap { position: sticky; top: 0; z-index: 30; background: #000; }
.player-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
.player-title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-source { font-size: 11px; color: var(--muted); white-space: nowrap; }
.spacer { flex: 1; }
.icon-btn {
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.icon-btn:hover { border-color: var(--accent); }
.video-holder { position: relative; max-height: 62vh; background: #000; }
#video { width: 100%; max-height: 62vh; display: block; background: #000; }
/* M6-B: iframe embed (embedindia) — menggantikan <video> saat sumber tipe embed */
.embed-frame { width: 100%; height: 62vh; border: 0; display: block; background: #000; }
.embed-frame.hidden, #video.hidden { display: none; }
.overlay-warn { font-size: 12px; color: var(--muted, #9aa4b2); max-width: 480px; line-height: 1.5; }

.player-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.72);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 20px; text-align: center;
}
.overlay-msg { font-size: 14px; color: var(--text); max-width: 480px; }
.overlay-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.cta {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 12px 20px; font-size: 15px; cursor: pointer;
}
.cta.secondary { background: var(--bg2); border: 1px solid var(--line); color: var(--text); }

.empty { color: var(--muted); text-align: center; padding: 60px 20px; }

/* M8: chip unmute — muncul saat autoplay hanya bisa muted (kebijakan mobile) */
.unmute-chip {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(22, 27, 34, .92); color: var(--text);
  border: 1px solid var(--accent); border-radius: 999px;
  padding: 10px 18px; font-size: 13px; cursor: pointer; z-index: 5;
  white-space: nowrap;
}
.hidden { display: none !important; }

/* ---------- LIVE events ---------- */
.live-section { padding: 6px 14px 0; }
.live-title { font-size: 14px; color: var(--text); margin-bottom: 8px; }
.live-row {
  display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
}
.live-row::-webkit-scrollbar { display: none; }
.live-card {
  flex: 0 0 auto; min-width: 210px; max-width: 300px; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.live-card.onair { border-color: #c9302c; }
.live-card.onair:hover { border-color: #f85149; }
.live-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.live-time { font-size: 11px; color: var(--muted); }
.badge.apps { background: rgba(79,140,255,.15); border-color: var(--accent); color: #9ec3ff; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 12px; font-size: 13px; z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: 90vw;
}

/* M13: menu kualitas */
.quality-menu {
  position: absolute; right: 8px; top: 52px; z-index: 40;
  background: rgba(22, 27, 34, .97); border: 1px solid #30363d; border-radius: 10px;
  padding: 6px; max-height: 220px; overflow-y: auto; min-width: 180px;
}
.quality-menu .q-item {
  display: block; width: 100%; text-align: left; padding: 8px 12px; margin: 2px 0;
  background: none; border: 0; border-radius: 6px; color: #e6edf3; cursor: pointer; font-size: 13px;
}
.quality-menu .q-item:hover { background: #21262d; }
.quality-menu .q-item.active { background: #1f6feb33; color: #58a6ff; font-weight: 600; }
