:root {
  --bg: #0e0e12;
  --bg-2: #16161d;
  --bg-3: #1f1f29;
  --line: #2a2a36;
  --text: #ecedf1;
  --muted: #9aa0ad;
  --primary: #ff4d6d;
  --primary-2: #c9184a;
  --ok: #46d369;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #14141b, #0e0e12);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; }
.brand-text h1 { font-size: 17px; margin: 0; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--muted); }
.search { margin-left: auto; flex: 1; max-width: 420px; }
.search input {
  width: 100%; padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
  font-size: 14px; outline: none;
}
.search input:focus { border-color: var(--primary); }

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; background: var(--bg-2);
  border-bottom: 1px solid var(--line); position: sticky; top: 63px; z-index: 15;
}
.pill {
  border: 1px solid var(--line); background: var(--bg-3); color: var(--text);
  padding: 9px 14px; border-radius: 999px; font-size: 13px; cursor: pointer;
  transition: .15s; white-space: nowrap;
}
.pill:hover { border-color: var(--primary); }
.pill.ghost { background: transparent; }
.country-pill { font-weight: 600; }
.cats { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.cats-hint { color: var(--muted); font-size: 12px; align-self: center; }
.chip {
  border: 1px solid var(--line); background: var(--bg-3); color: var(--muted);
  padding: 7px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  transition: .15s; user-select: none;
}
.chip:hover { color: var(--text); border-color: #3a3a48; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.toolbar-right { display: flex; align-items: center; gap: 10px; }
.count { color: var(--muted); font-size: 12.5px; }

/* ---------- 频道网格 ---------- */
.grid {
  display: grid; gap: 14px; padding: 18px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; transition: .15s; position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
}
.card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: var(--shadow); }
.card .logo {
  width: 64px; height: 64px; object-fit: contain; border-radius: 12px;
  background: #fff; padding: 4px;
}
.card .logo-fallback {
  width: 64px; height: 64px; border-radius: 12px; background: var(--bg-3);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; color: var(--primary);
}
.card .name { font-size: 13.5px; line-height: 1.3; font-weight: 600; }
.card .tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.card .tag { font-size: 10.5px; color: var(--muted); background: var(--bg-3); padding: 2px 7px; border-radius: 6px; }
.card .badge-live { position: absolute; top: 8px; right: 8px; font-size: 10px; color: var(--ok); border: 1px solid var(--ok); padding: 1px 6px; border-radius: 6px; }
.card.dead { opacity: .62; }
.card .badge-dead { display: inline-block; margin-left: 4px; font-size: 10px; color: #fff; background: #b3261e; padding: 1px 6px; border-radius: 6px; }

.placeholder { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 60px 20px; }
.placeholder .ph-icon { font-size: 46px; margin-bottom: 12px; }
.placeholder .ph-sub { font-size: 12px; opacity: .7; margin-top: 8px; }

/* ---------- 弹层（国家选择） ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; width: min(560px, 100%); max-height: 80vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-search { margin: 14px 18px 8px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); outline: none; }
.country-list { overflow-y: auto; padding: 8px 10px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.country-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 13.5px; }
.country-item:hover { background: var(--bg-3); }
.country-item .code { margin-left: auto; color: var(--muted); font-size: 11px; }

.icon-btn { background: transparent; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { color: var(--text); background: var(--bg-3); }

/* ---------- 播放器 ---------- */
.player { position: fixed; inset: 0; background: #000; z-index: 80; display: flex; flex-direction: column; }
.player[hidden] { display: none; }
.player-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: #0a0a0d; }
.player-title { font-size: 14px; font-weight: 600; }
.player-actions { display: flex; gap: 8px; }
.player-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; background: #000; }
.player-stage video { width: 100%; height: 100%; max-height: 100%; object-fit: contain; background: #000; }
.player-status { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); color: #fff; background: rgba(0,0,0,.55); padding: 10px 16px; border-radius: 10px; font-size: 13px; pointer-events: none; }
.player:fullscreen .player-stage { height: 100vh; }
.player:fullscreen { background: #000; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bg-3); border: 1px solid var(--line); color: var(--text); padding: 10px 18px; border-radius: 999px; font-size: 13px; z-index: 100; box-shadow: var(--shadow); }
.toast[hidden] { display: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; max-width: 100%; flex-basis: 100%; }
  .brand-sub { display: none; }
  .toolbar { top: 0; position: static; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; padding: 12px; }
  .card .logo, .card .logo-fallback { width: 52px; height: 52px; }
  .card .name { font-size: 12px; }
  .country-list { grid-template-columns: 1fr; }
}
