:root {
  --bg: #0e1116;
  --bg2: #161b22;
  --card: #1c232d;
  --card2: #232c38;
  --line: #2a323d;
  --txt: #e8edf3;
  --sub: #97a3b2;
  --accent: #ff4d4f;
  --accent2: #3b82f6;
  --ok: #2ecc71;
  --bad: #6b7682;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: rgba(14,17,22,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; font-weight: 800; letter-spacing: .5px; }
.brand span { background: linear-gradient(90deg,#ff4d4f,#ff7a45); -webkit-background-clip: text; background-clip: text; color: transparent; }
.country-bar {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--line); color: var(--txt);
  padding: 7px 12px; border-radius: 999px; font-size: 14px; cursor: pointer;
}
.country-bar .cf { font-size: 18px; line-height: 1; }
.country-bar .curname { font-weight: 600; }
.country-bar .chev { color: var(--sub); font-size: 11px; }

/* ---------- 筛选栏 ---------- */
.filterbar {
  position: sticky; top: 53px; z-index: 15;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: rgba(14,17,22,.92);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(10px);
}
.chips { display: flex; gap: 8px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 13px; border-radius: 999px;
  background: var(--card); color: var(--sub); font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); white-space: nowrap;
}
.chip.sel { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.toggle { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--sub); cursor: pointer; }
.toggle input { accent-color: var(--accent); }

/* ---------- 频道列表 ---------- */
.list {
  display: flex; flex-direction: column; gap: 9px;
  padding: 14px; max-width: 760px; margin: 0 auto;
}
.state { text-align: center; color: var(--sub); padding: 40px 10px; }
.spin {
  display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -3px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ch {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; cursor: pointer; transition: transform .1s, border-color .12s;
}
.ch:active { transform: scale(.99); }
.ch.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,77,79,.22); }
.ch .avatar {
  position: relative; flex: 0 0 44px; width: 44px; height: 44px; border-radius: 10px;
  overflow: hidden; background: linear-gradient(135deg,#2b3543,#3a2630);
  display: flex; align-items: center; justify-content: center;
}
.ch .avatar .letter {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
}
.ch .avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 4px; }
.ch .info { flex: 1; min-width: 0; }
.ch .nm { font-size: 15px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch .sub { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 5px; }
.ch .tag { font-size: 11px; color: var(--sub); background: var(--card2); border-radius: 5px; padding: 2px 7px; white-space: nowrap; }
.ch .tag.type { color: #fff; font-weight: 700; }
.ch .tag.type.t-hls { background: #2563eb; }
.ch .tag.type.t-dash { background: #7c3aed; }
.ch .tag.type.t-embed { background: #ea580c; }
.ch .tag.type.t-direct { background: #2ecc71; }
.ch .tag.status { color: #cdd7e2; }
.ch .tag.status.ok { color: #fff; background: rgba(46,204,113,.2); border: 1px solid rgba(46,204,113,.5); }
.ch .tag.region { color: #cdd7e2; }
.ch .play { flex: 0 0 auto; color: var(--sub); font-size: 16px; }

/* ---------- 国家弹层 ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-height: 82vh; display: flex; flex-direction: column;
  background: var(--bg2); border-top-left-radius: 18px; border-top-right-radius: 18px;
  transform: translateY(100%); transition: transform .25s; padding-bottom: env(safe-area-inset-bottom);
}
.sheet.show { transform: translateY(0); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-weight: 700; border-bottom: 1px solid var(--line); }
.sheet-head .x { background: none; border: none; color: var(--sub); font-size: 18px; cursor: pointer; }
.search { margin: 12px 16px 6px; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--txt); font-size: 15px; outline: none; }
.popular { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.popular::-webkit-scrollbar { display: none; }
.popular .pc { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 3px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; cursor: pointer; color: var(--txt); }
.popular .pc .pf { font-size: 20px; }
.popular .pc .pnm { font-size: 12px; }
.country-grid { overflow-y: auto; padding: 12px 16px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.cc { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; text-align: center; }
.cc.sel { border-color: var(--accent); background: #2a1f22; }
.cc .cf { font-size: 24px; line-height: 1; }
.cc .cn { line-height: 1.15; }
.cc .cn-zh { font-size: 12px; font-weight: 600; color: var(--txt); }
.cc .cn-en { font-size: 10px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cc.sel .cn-zh { color: var(--accent); }

/* ---------- 播放弹层 ---------- */
.player-overlay {
  position: fixed; inset: 0; z-index: 50; background: #000;
  display: none; flex-direction: column;
}
.player-overlay.show { display: flex; }
.player-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #0b0d11; }
.player-head .x { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
.player-head .ptitle { flex: 1; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-head .ext { color: #8ab4ff; font-size: 13px; text-decoration: none; }
.player-stage { flex: 1; position: relative; background: #000; display: flex; align-items: center; justify-content: center; min-height: 0; }
.player-stage video, .player-stage iframe { width: 100%; height: 100%; border: 0; background: #000; display: block; }
.player-loading { position: absolute; color: #98a2b0; font-size: 14px; display: flex; align-items: center; }
.player-meta { background: #0b0d11; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid #1c222b; }
.player-meta .row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.player-meta .mtag { font-size: 12px; color: #c3ccd8; background: #1a2029; border-radius: 6px; padding: 3px 8px; }
.player-meta .mname { font-size: 16px; font-weight: 700; }
.player-meta .mnet { font-size: 13px; color: #98a2b0; margin-top: 3px; }

/* 桌面端：播放层居中卡片 */
@media (min-width: 760px) {
  .player-overlay { background: rgba(0,0,0,.82); }
  .player-overlay.show { display: flex; align-items: center; justify-content: center; }
  .player-overlay { padding: 26px; }
  .player-overlay > .player-head,
  .player-overlay > .player-stage,
  .player-overlay > .player-meta {
    width: min(980px, 94vw); margin: 0 auto;
  }
  .player-head { border-radius: 14px 14px 0 0; }
  .player-stage {
    aspect-ratio: 16/9; border-radius: 0; overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
  }
  .player-meta { border-radius: 0 0 14px 14px; border-top: none; }
}
