: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; }

.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; }
.hidden { display: none !important; }

.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;
}
