:root {
  --blue: #185FA5;
  --blue-light: #E6F1FB;
  --teal: #0F6E56;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
/* HTML [hidden] 在 CSS 里被任意 class 覆盖就会失效（display:flex 会赢过 UA 的 display:none），
   这里加一条兜底，确保点开非"搜索"Tab 时表单真的消失 */
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  padding-bottom: 84px;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--blue);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,.12);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.brand-icon { width: 26px; height: 26px; border-radius: 6px; background: #fff; }
.tabs { display: flex; gap: 6px; }
.tab {
  flex: 1; padding: 8px 4px; border: none; border-radius: 8px;
  background: rgba(255,255,255,.16); color: #fff; font-size: 14px; cursor: pointer;
}
.tab.active { background: #fff; color: var(--blue); font-weight: 600; }

.content { padding: 12px; max-width: 720px; margin: 0 auto; }

.search-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.search-form input, .search-form select {
  width: 100%; padding: 12px; font-size: 15px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; color: var(--text);
}
.search-form .row { display: flex; gap: 8px; }
.search-form .row > * { flex: 1; }
.primary {
  padding: 13px; border: none; border-radius: 10px; background: var(--blue); color: #fff;
  font-size: 16px; font-weight: 600; cursor: pointer;
}

.status { color: var(--muted); font-size: 13px; padding: 6px 2px 10px; }

.results { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

/* 华语 Tab：地区分组头 */
.group-header {
  display: flex; align-items: center; justify-content: space-between;
  margin: 14px 4px 2px;
  padding: 8px 12px;
  background: linear-gradient(90deg, var(--blue-light), transparent);
  border-left: 3px solid var(--blue);
  border-radius: 0 8px 8px 0;
}
.group-header:first-child { margin-top: 4px; }
.group-title { font-size: 14px; font-weight: 600; color: var(--blue); }
.group-count { font-size: 12px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; padding: 10px 2px; color: var(--muted); font-size: 12px; }
.foot a { color: var(--blue); text-decoration: none; white-space: nowrap; }

.card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
}
.card .logo {
  width: 48px; height: 48px; border-radius: 8px; object-fit: cover;
  background: var(--blue-light); flex-shrink: 0;
}
.card .info { flex: 1; min-width: 0; }
.card .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 码率行：编码格式 + 码率单独成行，做成小标签，窄屏也不被截断 */
.card .meta.codec {
  display: inline-block;
  white-space: normal;
  word-break: break-word;
  margin-top: 4px;
  padding: 2px 8px;
  background: var(--blue-light);
  color: var(--blue);
  border: 1px solid #cfe3f7;
  border-radius: 999px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  letter-spacing: .2px;
}
.card .actions { display: flex; gap: 6px; flex-shrink: 0; }
.card .actions button {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: 8px 12px; font-size: 14px; cursor: pointer;
}
.card .actions .play { background: var(--blue); color: #fff; border-color: var(--blue); }
.card .actions .fav { font-size: 18px; color: #f0a500; }
.card .actions .share { font-size: 16px; }

/* 分享二维码弹窗 */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }
.qr-modal {
  position: relative; width: 100%; max-width: 320px;
  background: #fff; border-radius: 16px; padding: 22px 20px 18px;
  text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.qr-close {
  position: absolute; top: 10px; right: 12px;
  border: none; background: transparent; font-size: 18px; color: var(--muted); cursor: pointer;
}
.qr-title { font-size: 16px; font-weight: 600; color: var(--text); }
.qr-name { font-size: 13px; color: var(--muted); margin: 4px 0 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-img {
  width: 220px; height: 220px; margin: 0 auto; display: block;
  image-rendering: pixelated; background: #fff; border: 1px solid var(--border); border-radius: 8px;
}
.qr-hint { font-size: 12px; color: var(--muted); margin: 14px 0 10px; }
.qr-url {
  display: block; font-size: 11px; color: var(--blue); word-break: break-all;
  text-decoration: none; margin-bottom: 12px;
}
.qr-copy {
  width: 100%; border: none; border-radius: 10px; padding: 11px;
  background: var(--blue); color: #fff; font-size: 15px; cursor: pointer;
}
.qr-copy:active { opacity: .85; }

/* ===== 底部 Dock：投屏舞台 + 迷你控件 ===== */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #fff;
  box-shadow: 0 -2px 14px rgba(0,0,0,.12);
}
.dock.hidden { display: none; }

/* 投屏舞台。展开时必须真实可见且有尺寸，
   否则浏览器不会往 video 控件栏注入投屏按钮。 */
.cast-stage { background: #0b1420; }
.cast-stage.folded { display: none; }

.cast-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 6px; background: #0b1420;
}
.cast-tip { flex: 1; min-width: 0; font-size: 11.5px; line-height: 1.35; color: #9fc4e8; }
.cast-tip.warn { color: #ffca6b; }
.cast-fold {
  flex-shrink: 0; width: 26px; height: 26px;
  border: 1px solid rgba(255,255,255,.18); border-radius: 7px;
  background: rgba(255,255,255,.08); color: #cfe3f7;
  font-size: 13px; line-height: 1; cursor: pointer;
}

.cast-video-wrap { width: 100%; background: #000; display: flex; align-items: center; justify-content: center; }
/* 尺寸不能太小：控件栏要放得下浏览器注入的投屏图标 */
.cast-video-wrap video {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(34vh, 230px);
  min-height: 150px;
  display: block; background: #000; object-fit: contain;
}

.cast-actions {
  display: flex; gap: 6px; padding: 7px 10px;
  background: #0b1420; overflow-x: auto; scrollbar-width: none;
}
.cast-actions::-webkit-scrollbar { display: none; }
.cast-mini {
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,.18); border-radius: 8px;
  background: rgba(255,255,255,.08); color: #dbeafe;
  padding: 7px 11px; font-size: 12.5px; cursor: pointer;
}
.cast-mini.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.cast-mini:active { opacity: .8; }
.cast-mini[hidden] { display: none; }

/* 投屏帮助弹窗 */
.help-modal { max-width: 340px; text-align: left; }
.help-modal .qr-title { text-align: center; margin-bottom: 12px; }
.help-list { margin: 0 0 16px; padding-left: 20px; }
.help-list li { font-size: 13px; line-height: 1.65; color: var(--text); margin-bottom: 8px; }
.help-list b { color: var(--blue); }

.player {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-top: 1px solid var(--border);
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
}
.player.hidden { display: none; }
.p-btn.ghost { background: var(--blue-light); color: var(--blue); }
.p-btn.hidden { display: none; }
.p-logo { width: 42px; height: 42px; border-radius: 8px; background: var(--blue-light); flex-shrink: 0; }
.p-info { flex: 1; min-width: 0; }
.p-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-state { font-size: 12px; color: var(--muted); }
.p-btn {
  width: 42px; height: 42px; border: none; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.p-vol { width: 70px; flex-shrink: 0; }
