/* 现代UI主题 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* 输入框允许文本选择和文本光标 */
input, textarea, [contenteditable] {
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  cursor: text;
}

/* 可点击元素及其所有子元素使用手型光标 */
button, button *,
a, a *,
[role="button"], [role="button"] *,
.nav-btn, .nav-btn *,
.room-card, .room-card *,
.category-item, .category-item *,
.sub-category-item, .sub-category-item *,
.clickable, .clickable * {
  cursor: pointer;
}

/* 全局按钮：去除移动端点击高亮(默认灰色矩形 tap-highlight)与焦点轮廓(默认蓝色 focus ring)，
   两者均不跟随按钮自身圆角，点击/选中时会出现正方形闪烁；所有按钮均有 hover/:active 视觉反馈 */
button {
  -webkit-tap-highlight-color: transparent;
}
button:focus {
  outline: none;
}

/* 顶栏按钮按下反馈：跟随各自圆角（50%/radius-md）的背景变化，非正方形框；
   补充 tap-highlight/focus ring 移除后的点击视觉响应（状态栏图标/播放控制/弹幕设置已有各自 :active） */
.nav-btn:active,
.back-btn:active {
  background: var(--bg-hover);
}

/* 图标按钮（搜索/收藏/设置）：点击/悬停特效改为勾勒图标线条（svg 用 currentColor 变主题色），
   取消背景色块——正方形/圆形色块差异随之消失，图形本身形状一致；与上述 hover 线条化配套 */
.mobile-search-btn:active,
.nav-extra-btn:active,
.settings-btn:active {
  background: none;
  color: var(--accent);
}

/* 图标按钮特效：
   - PC 端：hover 只变色（不放大），刷新按钮 :active 旋转
   - 手机端：无 hover（防 touch 残留），点击由 JS 加 .icon-pop 类播放 0.45s 动画
   transition 保证状态切换平滑 */
.mobile-search-btn svg, .nav-extra-btn svg, .settings-btn svg,
.chat-msg-toggle svg, .status-icon-btn svg, .room-fav-toggle svg,
.lock-view-btn svg {
  transition: transform 0.15s ease, color 0.15s ease;
}

/* PC 端 hover 特效（默认生效，手机端在下方媒体查询中覆盖）：只变色，不放大 */
.mobile-search-btn:hover svg, .nav-extra-btn:hover svg, .settings-btn:hover svg,
.chat-msg-toggle:hover svg, .status-icon-btn:hover svg, .room-fav-toggle:hover svg,
.lock-view-btn:hover svg {
  color: var(--accent);
}

@keyframes iconTouchPop {
  0%   { transform: scale(1);    color: currentColor; }
  20%  { transform: scale(1.15); color: var(--accent); }
  75%  { transform: scale(1.15); color: var(--accent); }
  100% { transform: scale(1);    color: currentColor; }
}

/* PC 端禁用类驱动动画（用 hover 反馈）；手机端在媒体查询中启用 */
.icon-pop svg {
  animation: none;
}

/* PC 端特殊：锁定按钮在视频上，hover 保持白色（覆盖统一组的 accent） */
.lock-view-btn:hover svg {
  color: #fff;
}

:root {
  --bg-primary: #f4f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f7f8fa;
  --bg-hover: #eef0f3;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #e8eaed;
  --border-light: #f0f1f3;
  --accent: #6c7ce0;
  --accent-hover: #7b8cf0;
  --accent-light: #f0f2ff;
  --accent-gradient: linear-gradient(135deg, #6c7ce0 0%, #8b9cf0 100%);
  --blue: #00aeec;
  --blue-light: #e6f7ff;
  --danger: #ff4757;
  --success: #2ed573;
  --warning: #ffa502;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  overflow: hidden;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  animation: fadeIn 0.5s ease;
}

/* 加载动画：absolute 在 page-card 内居中，不依赖高度计算，不用 transform（避免被 fadeIn 覆盖） */
.loading-centered {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  padding: 20px;
  z-index: 10;
}

/* 空状态提示：跨满整行、自然高度居中，PC/手机端一致（不随加载动画撑高） */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* 分类栏空态：紧凑显示，与分类项同高（分类栏是 flex 容器，不同于房间网格的居中空态） */
.category-list .empty-state {
  padding: 8px 14px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Toast 提示出现动画（淡入上滑） */
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 优雅的双环旋转加载器 */
.loader {
  position: relative;
  width: 48px;
  height: 48px;
}

.loader::before,
.loader::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
}

.loader::before {
  width: 100%;
  height: 100%;
  border: 3px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent);
  animation-duration: 1s;
}

.loader::after {
  width: 70%;
  height: 70%;
  top: 15%;
  left: 15%;
  border: 3px solid transparent;
  border-bottom-color: var(--accent-light);
  border-left-color: var(--accent-light);
  animation-duration: 1.5s;
  animation-direction: reverse;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 加载文字渐变动画 */
.loading-text {
  font-size: 14px;
  font-weight: 500;
  background: linear-gradient(90deg, var(--text-muted), var(--accent), var(--text-muted));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 2s ease-in-out infinite;
  letter-spacing: 1px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 脉冲点装饰 */
.loading-dots {
  display: flex;
  gap: 6px;
  margin-top: -8px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes pulse {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============ 顶部导航 ============ */
.home-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.top-nav {
  display: flex;
  align-items: center;
  padding: 0 28px 0 18px;
  min-height: 52px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 28px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 100;
}

/* 平台按钮组：与搜索框作为一组整体居中；设置按钮通过 margin-left:auto 靠右 */
.nav-platforms {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
}

.nav-search {
  flex-shrink: 0;
}

/* 右侧图标组：靠右；设置图标右边缘与下方 page-card 容器右边缘对齐(10px) */
.nav-right-icons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
  margin-right: -24px;
}

.nav-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition);
  font-weight: 500;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* PC端平台按钮显示完整名（HTML 存精简名，用伪元素追加"直播"） */
.nav-btn span::after {
  content: '直播';
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-icon-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
  flex-shrink: 0;
}

.nav-btn:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.nav-btn.active {
  color: #fff;
  background: var(--accent-gradient);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(108, 124, 224, 0.35);
}

.nav-search {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 8px 3px 12px;
  width: 220px;
  transition: var(--transition);
}

.nav-search:focus-within {
  border-color: var(--accent);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 3px rgba(108, 124, 224, 0.1);
}

.nav-search input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 12px;
  color: var(--text-primary);
}

.nav-search input::placeholder { color: var(--text-muted); }

.nav-search button {
  border: none;
  background: var(--accent);
  color: #fff;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.search-icon {
  width: 13px;
  height: 13px;
}

.nav-search button:hover { background: var(--accent-hover); }

/* ============ 主体布局 ============ */
.home-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding: 10px 0 0 10px;
  gap: 10px;
}

/* ============ 左侧分类栏 ============ */
.sidebar {
  scrollbar-gutter: stable;
  width: 160px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border-light);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; border-radius: 2px; }
.sidebar:hover::-webkit-scrollbar-thumb { background: var(--border); }

.category-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.category-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  overflow: hidden;
}

.category-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  transition: height 0.25s ease;
}

.category-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.category-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.category-item.active::before { height: 60%; }

.cat-icon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

/* 分类图标占位 */
.category-item .cat-emoji {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ============ 主内容区 ============ */
.main-content {
  scrollbar-gutter: stable;
  flex: 1;
  overflow-y: auto;
  padding: 0 5px 10px 0;
  position: relative;
}

.main-content::-webkit-scrollbar { width: 5px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: transparent; border-radius: 1px; }
.main-content.hover-scroll::-webkit-scrollbar-thumb,
.main-content.user-scrolling::-webkit-scrollbar-thumb { background: var(--text-muted); opacity: 0.4; }

/* ============ 统一页面卡片 ============ */
.page-card, .sub-category-area {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

/* ============ 统一页面头部 ============ */
.page-header, .sub-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

.page-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header-title, .sub-category-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 统一图标按钮 */
.icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--accent);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent-gradient);
}

.icon-btn.refresh-btn:hover {
  transform: rotate(180deg);
}

/* 刷新按钮与其他图标统一点击动画（iconTouchPop 0.45s），无瞬时旋转 */

.sub-category-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.sub-category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  transition: var(--transition);
  border: 2px solid transparent;
  font-weight: 500;
  text-align: center;
  line-height: 1.3;
}

.sub-category-item:hover {
  background: var(--accent-light);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.sub-category-item.active {
  background: linear-gradient(135deg, #fff0f5 0%, #ffe8f0 100%);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(251, 114, 153, 0.2);
  font-weight: 600;
}

.sub-cat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-tertiary);
  padding: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.sub-category-item.active .sub-cat-icon {
  box-shadow: 0 2px 8px rgba(251, 114, 153, 0.3);
}

/* ============ 房间卡片 ============ */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

/* 统一加载遮罩层：覆盖整个内容区域，分类和列表都加载完成后才隐藏 */
.home-body {
  position: relative;
}

.home-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.home-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* 加载更多提示居中 */
.loading-more {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}

/* 加载动画在列表中垂直居中（容器 flex 撑满时，loading 居中显示） */
.room-grid .loading,
.sub-category-list .loading,
.category-list .loading {
  grid-column: 1 / -1;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.room-grid:has(>.loading) {
  align-content: center;
}
/* ID 选择器权重更高，加载态时覆盖 start，让动画垂直居中 */
#homePage .room-grid:has(>.loading),
#favRoomGrid:has(>.loading),
#subGrid:has(>.loading) {
  align-content: center;
}

.room-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.room-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(251, 114, 153, 0.2);
}

/* 用户搜索结果卡片：列表项样式，避免正方形头像拉伸 */
.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border-light);
}

.user-card:hover {
  background: var(--bg-tertiary);
  border-color: rgba(251, 114, 153, 0.2);
}

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.user-status.live {
  color: var(--success);
}

.room-cover {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  overflow: hidden;
  background: var(--bg-tertiary);
}

.room-cover img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.room-card:hover .room-cover img {
  transform: scale(1.05);
}

.room-live-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  color: #fff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 6px rgba(255, 71, 87, 0.4);
}

.room-live-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

/* 未开播标签：灰色（与"未开播"徽标同色），去掉脉冲呼吸灯 */
.room-live-tag.off {
  background: linear-gradient(135deg, #909399, #a8abb2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.room-live-tag.off::before {
  animation: none;
  opacity: 0.7;
}

/* 录像/轮播标签：琥珀色（区别于红色直播中、灰色未开播） */
.room-live-tag.rec {
  background: linear-gradient(135deg, #e6a23c, #f0b463);
  box-shadow: 0 2px 6px rgba(230, 162, 60, 0.4);
}
.room-live-tag.rec::before {
  animation: none;
  opacity: 0.85;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.room-viewers {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 4px;
}

.room-info {
  padding: 12px 14px;
}

.room-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 6px;
  line-height: 1.4;
}

.room-card:hover .room-title { color: var(--accent); }

.room-owner {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.room-owner-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
}

/* ============ 播放页 ============ */
.play-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
}

.play-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px 0 10px;
  height: 52px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
  position: relative;
}

.back-btn {
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
  transition: var(--transition);
  flex-shrink: 0;
}

.back-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.play-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 400px);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 50%, var(--accent) 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleShimmer 3s linear infinite;
  letter-spacing: 0.5px;
  pointer-events: none;
}

/* 视频顶部标题 - 已移除 */
.play-title-overlay {
  display: none;
}

@keyframes titleShimmer {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

/* 手机端搜索图标按钮 - 桌面端隐藏 */
.mobile-search-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.mobile-search-btn svg {
  width: 20px;
  height: 20px;
}

/* 手机端悬浮搜索框 - 桌面端隐藏 */
.mobile-search-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  padding: 12px;
}

.mobile-search-overlay.show {
  display: block;
}

.mobile-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 8px;
  /* 与1级分类顶部对齐：top-nav 60px + sidebar 顶部 padding 12px */
  margin-top: 72px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.mobile-search-box input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.mobile-search-box input:focus {
  border-color: var(--accent);
}

.mobile-search-box button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-search-box button svg {
  width: 18px;
  height: 18px;
}

.mobile-search-close {
  background: none !important;
  color: var(--text-primary) !important;
  font-size: 14px;
  padding: 10px 8px !important;
}

.play-header-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  margin-right: -24px;
}

.site-tag {
  height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  background: var(--accent-light);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
}

.play-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  padding: 10px;
  gap: 10px;
}

/* ============ 视频区域 ============ */
.video-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.video-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  background: #000;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-wrapper.web-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999;
  border-radius: 0;
  border: none;
}

/* 原生全屏（requestFullscreen）：清除圆角/边框/边距，避免四周白边 */
.video-wrapper:fullscreen,
.video-wrapper:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  border-radius: 0 !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  background: #000 !important;
}

/* 全屏/网页全屏下视频始终填满容器并等比缩放居中，覆盖手机竖屏的 height:auto（避免竖屏视频在全屏容器中溢出/方向错乱） */
.video-wrapper:fullscreen #videoPlayer,
.video-wrapper:-webkit-full-screen #videoPlayer,
.video-wrapper.web-fullscreen #videoPlayer {
  height: 100% !important;
  width: 100% !important;
  object-fit: contain;
}

/* 竖屏视频原生全屏（Android wrapper 全屏 / iOS video 全屏）：沿用上方 contain（完整等比显示、不裁切画面）；
   Android 由 screen.orientation.lock('portrait') 保持竖屏方向，无需长宽调换 */

/* 手机端竖屏视频网页全屏：竖向铺满（cover），消除黑边；仅竖屏视频生效，横屏视频仍保持 contain */
.video-area.video-vertical .video-wrapper.web-fullscreen #videoPlayer {
  object-fit: cover;
}

/* PC 端全屏/网页全屏下隐藏鼠标指针：由 JS 在隐藏工具条时添加 cursor-hidden 类 */
/* 需用 !important 覆盖 * { cursor: default } 通配规则对子元素的影响 */
.video-wrapper.cursor-hidden,
.video-wrapper.cursor-hidden * {
  cursor: none !important;
}

.player-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #fff;
  z-index: 10;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.player-error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.8);
  padding: 20px 28px;
  border-radius: var(--radius-md);
  color: #fff;
  text-align: center;
  z-index: 10;
  /* 提示词整体居中 */
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ============ 弹幕层 ============ */
.danmaku-layer {
  position: absolute;
  top: 5px;
  left: 0;
  width: 100%;
  height: calc(100% - 5px);
  pointer-events: none;
  overflow: hidden;
  z-index: 10; /* 在视频上面 */
  contain: strict;

}

.danmaku-item {
  position: absolute;
  white-space: nowrap;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  /* 单层细阴影：保证浅色弹幕可读性，同时减少栅格化纹理层数（双层阴影纹理约为3倍） */
  text-shadow: 1px 1px 1px rgba(0,0,0,0.7);
  /* will-change 由 JS 在动画期间临时设置、回收时清除，避免常驻合成层 */
  opacity: 0.95;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0.5px;
  backface-visibility: hidden;
  contain: content;
  transform: translateZ(0);
}

/* 弹幕移动 + 首尾淡入淡出动画：由浏览器合成器驱动（JS 每帧零 transform/opacity 写入）
   起点 --danmu-from（容器右侧外，px），终点 -100%（弹幕自身宽度，屏幕左侧外）
   线性匀速，与原先 JS 计算的位移路径一致；首尾 0.4s 淡入淡出近似为 4%/96% 关键帧
   淡入淡出并入 CSS 后，主线程不再逐帧写 style.opacity */
@keyframes danmaku-move {
  0%   { transform: translate3d(var(--danmu-from, 0px), 0, 0); opacity: 0; }
  4%   { opacity: 1; }
  96%  { opacity: 1; }
  100% { transform: translate3d(-100%, 0, 0); opacity: 0; }
}

/* ============ 控制栏 ============ */
.control-bar {
  display: flex;
  align-items: center;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 0;
  gap: 12px;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 20;
  pointer-events: none;
}

.video-wrapper.control-visible .control-bar {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* 播放器内房间标题：显示时机和工具条一致 */
.player-room-title {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 9px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
  color: #fff;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 15;
  pointer-events: none;
}

.video-wrapper.control-visible .player-room-title {
  opacity: 1;
  transform: translateY(0);
}

/* 未开播：标题和锁定按钮彻底隐藏（只保留提示词） */
.video-wrapper.not-live .player-room-title {
  display: none !important;
}
.video-wrapper.not-live .lock-view-btn {
  display: none !important;
}

/* 锁定观看按钮：左边中间 */
.lock-view-btn {
  position: absolute;
  left: -100px; /* 更远一点 */
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  background: none; /* 与其他图标统一：去掉半透明圆形背景 */
  border: none;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 40; /* 在弹幕层上面，工具条旁边 */
  transition: left 0.8s cubic-bezier(0.25, 0.1, 0.25, 1); /* 再慢一点 */
  pointer-events: none;
  display: flex;
}

/* 全屏 + 工具条可见时，显示按钮 */
.video-area.fullscreen .video-wrapper.control-visible .lock-view-btn,
.video-wrapper.web-fullscreen.control-visible .lock-view-btn {
  left: 36px; /* 左移到36 */
  pointer-events: auto;
}

/* 锁定状态：点击屏幕时显示（由JS控制） */
.lock-view-btn.locked.show {
  left: 36px !important;
  pointer-events: auto !important;
}

.lock-view-btn svg {
  width: 22px;
  height: 22px;
}

.lock-view-btn.locked {
  /* 去掉选中背景色，和普通状态一样 */
  color: rgba(255, 255, 255, 0.9);
}

.lock-view-btn svg {
  width: 18px;
  height: 18px;
}

/* 锁定观看模式：只隐藏工具条和标题 */
.video-wrapper.view-locked .player-controls,
.video-wrapper.view-locked .player-room-title {
  opacity: 0 !important;
  pointer-events: none !important;
}

.ctrl-left, .ctrl-right {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.ctrl-center {
  flex: 1;
  display: flex;
  align-items: center;
}

.ctrl-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.85);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.ctrl-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.ctrl-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
  transform: scale(1.1);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.ctrl-time {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  font-family: monospace;
  min-width: 50px;
}

.ctrl-progress {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  transition: height 0.2s;
}

.ctrl-progress:hover { height: 6px; }

.ctrl-buffered {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
}

.ctrl-played {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 2px;
}

.ctrl-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.ctrl-progress:hover .ctrl-thumb { opacity: 1; }

.ctrl-select-wrap {
  position: relative;
}

.ctrl-select-btn {
  background: rgba(0, 0, 0, 0.5);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}

.ctrl-select-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
}

.ctrl-select-panel {
  display: none;
  position: absolute;
  bottom: 42px;
  left: 0;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 6px 0;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.ctrl-select-panel.show {
  display: block;
}

.ctrl-select-option {
  padding: 8px 14px;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.ctrl-select-option:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.ctrl-select-option.active {
  color: var(--accent);
  background: rgba(255,255,255,0.05);
}

.volume-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.volume-slider {
  display: none;
  position: absolute;
  bottom: 42px;
  right: 0;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 12px 8px;
  z-index: 200;
  width: 36px;
  height: 120px;
  align-items: center;
  justify-content: center;
}

.volume-slider.show {
  display: flex;
}

.volume-slider input {
  -webkit-appearance: none;
  appearance: none;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 6px;
  height: 100px;
  background: transparent;
  cursor: pointer;
}
/* 竖条轨道：半透明灰，避免 appearance:none 后露出浏览器默认白色 */
.volume-slider input::-webkit-slider-runnable-track {
  width: 6px;
  height: 100px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 3px;
}
.volume-slider input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  margin-left: -4px; /* (14-6)/2，水平居中 */
}
.volume-slider input::-moz-range-track {
  width: 6px;
  height: 100px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 3px;
}
.volume-slider input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: none;
  border-radius: 50%;
  background: #fff;
}

/* 弹幕设置 */
.danmaku-settings-wrap {
  position: relative;
}

.danmaku-settings-panel {
  display: none;
  position: absolute;
  bottom: 42px;
  right: 0;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 12px;
  min-width: 145px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.danmaku-settings-panel.show {
  display: block;
}

.dms-item {
  margin-bottom: 12px;
}

.dms-item:last-child {
  margin-bottom: 0;
}

/* 字体大小和弹幕速度同一行显示 */
.dms-row {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
}

.dms-row .dms-item {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
}

.dms-label {
  display: block;
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 6px;
}

.dms-options {
  display: flex;
  gap: 4px;
}

/* 加减按钮式设置（字体大小、弹幕速度、显示区域） */
.dms-slider {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dms-btn {
  width: 28px;
  height: 24px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.8);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}

.dms-btn:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.25);
}

.dms-btn:active {
  transform: scale(0.95);
}

.dms-value {
  width: 50px;
  height: 24px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

.dms-opt {
  flex: 1;
  padding: 4px 4px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.7);
  border-radius: 5px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.dms-opt:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.dms-opt.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ============ 右侧聊天栏 ============ */
.chat-sidebar {
  width: 300px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}

.chat-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* 聊天消息开关 */
.chat-msg-toggle {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  transition: all 0.2s;
  padding: 0;
}

.chat-msg-toggle svg {
  width: 16px;
  height: 16px;
}

.chat-msg-toggle.off {
  color: var(--text-muted);
}

/* 状态栏通用图标按钮（收藏等） */
.status-icon-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
  margin-right: 4px;
}

.status-icon-btn svg {
  width: 16px;
  height: 16px;
}

.status-icon-btn.faved {
  color: #ff4757;
}

.status-icon-btn.faved svg {
  fill: #ff4757;
}

/* 图标按钮：去除移动端点击高亮(-webkit-tap-highlight-color 默认灰矩形)与焦点方形轮廓(outline)，
   两者均不跟随按钮自身圆角（4px/50%），导致点击/选中时显示正方形特效 */
.chat-msg-toggle,
.status-icon-btn,
.room-fav-toggle {
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

/* 主播卡片 */
.streamer-card {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
  align-items: flex-start;
  position: relative;
}

.streamer-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
}

.streamer-avatar-wrap img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.live-badge {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #ff4757, #ff6b81);
  color: #fff;
  font-size: 10px;
  padding: 1px 10px;
  border-radius: 8px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(255,71,87,0.4);
}

/* 未开播状态徽标：灰色 */
.live-badge.off {
  background: linear-gradient(135deg, #909399, #a8abb2);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* 录像/轮播状态徽标：琥珀色（区别于红色直播中、灰色未开播） */
.live-badge.rec {
  background: linear-gradient(135deg, #e6a23c, #f0b463);
  box-shadow: 0 1px 4px rgba(230,162,60,0.4);
}

.streamer-info-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  padding-left: 0;
  margin-left: 0;
  padding-right: 32px;
}

.streamer-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 0;
  padding-left: 0;
  min-width: 0;
}

.streamer-name > span:first-child {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.streamer-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  /* 标签左边对齐到头像位置 */
  margin-left: 0;
  padding-left: 0;
}

.streamer-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  /* 统计信息左边对齐到头像位置 */
  margin-left: 0;
  padding-left: 0;
}

/* 播放页收藏按钮（固定在卡片右上角） */
.room-fav-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s ease;
  position: absolute;
  top: 14px;
  right: 20px;
}

.room-fav-toggle svg {
  width: 18px;
  height: 18px;
}

.room-fav-toggle.faved {
  color: #ff4757;
}

.streamer-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-cat {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 10px;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.streamer-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  width: 100%;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.stat-icon { width: 14px; height: 14px; flex-shrink: 0; }
.stat-value { font-weight: 600; color: var(--text-primary); font-size: 12px; white-space: nowrap; }

/* 弹幕状态栏 */
.danmaku-status-bar {
  display: flex;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--border-light);
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.2;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 6px rgba(46, 213, 115, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 6px rgba(255, 71, 87, 0.5);
}

.status-dot.connecting {
  background: var(--warning);
  box-shadow: 0 0 6px rgba(255, 165, 2, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

.status-text {
  color: var(--text-secondary);
  font-weight: 500;
}

.status-spacer { flex: 1; }
.status-count-icon { font-size: 13px; }
/* 计数位于开关按钮左侧（HTML 顺序：spacer→count→toggle），数字右对齐贴住开关：
   计数位数变化时宽度由 spacer 吸收，开关位置恒定、间距恒为 gap(8px)，无固定宽度留白 */
.status-count-num { font-weight: 700; color: var(--accent); text-align: right; flex-shrink: 0; }

/* 聊天列表 */
.chat-list-header {
  padding: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-light);
}

.chat-list {
  scrollbar-gutter: stable;
  /* 不用 scroll-behavior: smooth：高频消息下程序滚动(smooth)动画会被"删头部→scrollTop钳制"打断，
     导致自动滚动失效；自动滚动由 JS 贴底状态机瞬时定位（视觉等效内容上推） */
  flex: 1;
  overflow-y: auto;
  padding: 10px 5px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-list::-webkit-scrollbar { width: 5px; }
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb { background: transparent; border-radius: 1px; }
.chat-list.hover-scroll::-webkit-scrollbar-thumb,
.chat-list.user-scrolling::-webkit-scrollbar-thumb { background: var(--text-muted); opacity: 0.4; }

.chat-item {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.02);
}

.chat-item:hover { background: var(--bg-tertiary); }

.chat-user {
  color: var(--text-muted);
  font-weight: normal;
  margin-right: 4px;
}

.chat-user::after {
  content: ':';
  color: var(--text-muted);
  margin-right: 2px;
}

.chat-content {
  color: var(--text-primary);
}

/* B站弹幕表情图片：随字体大小自适应，垂直居中 */
.chat-emote {
  height: 1.4em;
  max-width: 4em;
  vertical-align: middle;
  display: inline-block;
  object-fit: contain;
  margin: 0 1px;
}

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .chat-sidebar { width: 280px; }
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

@media (max-width: 768px) {
  /* 手机端：无 hover 特效（防 touch 残留），点击由 .icon-pop 类驱动动画 */
  .mobile-search-btn:hover svg, .nav-extra-btn:hover svg, .settings-btn:hover svg,
  .chat-msg-toggle:hover svg, .status-icon-btn:hover svg, .room-fav-toggle:hover svg,
  .lock-view-btn:hover svg, .icon-btn:hover svg {
    transform: none;
    color: inherit;
  }
  .mobile-search-btn:active svg, .nav-extra-btn:active svg, .settings-btn:active svg,
  .chat-msg-toggle:active svg, .status-icon-btn:active svg, .room-fav-toggle:active svg,
  .lock-view-btn:active svg, .icon-btn:active svg {
    transform: none;
  }
  .icon-pop svg {
    animation: iconTouchPop 0.45s ease;
  }
  .icon-btn:hover {
    background: var(--bg-secondary);
    color: var(--accent);
    border-color: var(--border);
  }
  .icon-btn.refresh-btn:hover {
    transform: none;
  }
  .icon-btn.refresh-btn:active {
    transform: none;
  }
  .room-fav-toggle:hover {
    background: none;
  }
  .top-nav { padding: 0 14px; gap: 12px; }
  .nav-icon { width: 16px; height: 16px; }
  .nav-search { width: 160px; }
  .sidebar { width: 140px; }
  .main-content { padding: 0 5px 10px 0; }
  .play-body { flex-direction: column; padding: 10px; }
  .chat-sidebar { width: 100%; height: auto; }
  .video-wrapper { min-height: 240px; }
  .room-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .user-card { padding: 8px 10px; gap: 8px; }
  .user-avatar { width: 36px; height: 36px; }
  .user-name { font-size: 12px; }
  .user-status { font-size: 11px; }
}

@media (max-width: 480px) {
  .room-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .user-card { padding: 6px 8px; gap: 6px; }
  .user-avatar { width: 32px; height: 32px; }
  .user-name { font-size: 11px; }
  .user-status { font-size: 10px; }
  .control-bar { padding: 8px 10px; gap: 6px; }
  .ctrl-select { font-size: 11px; padding: 3px 4px; }
}

/* 设置按钮 */
/* 房间页设置按钮：与主页设置按钮(homeSettingsBtn/.nav-extra-btn)完全一致的圆形无边框图标样式，
   保证主页→房间切换时按钮外观与位置无变化 */
.settings-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  margin-left: 4px;
  box-sizing: border-box;
}
.settings-icon {
  width: 20px;
  height: 20px;
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
}
.modal-content {
  background: #ffffff;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid #e8e8e8;
}
.modal-header h3 {
  margin: 0;
  color: #333;
  font-size: 16px;
}
.modal-close {
  background: none;
  border: none;
  color: #999;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: #333; }
.modal-body {
  padding: 20px;
}
.modal-body p {
  color: var(--text-secondary);
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #e8e8e8;
}
.settings-status {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  text-align: left;
  animation: statusIn 0.25s ease;
}
.settings-status.success {
  color: #27ae60;
}
.settings-status.error {
  color: #e74c3c;
}
/* 进行中状态：灰色 + 转圈动画 */
.settings-status.busy {
  color: var(--text-muted);
}
.settings-status.busy::before {
  content: '';
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -1px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes statusIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
/* 面板操作按钮进行中禁用态 */
.btn-busy {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.setting-item {
  margin-bottom: 12px;
}
.setting-item:last-child {
  margin-bottom: 0;
}
.setting-label {
  display: block;
  color: var(--text-primary);
  font-size: 13px;
  margin-bottom: 5px;
  font-weight: 500;
}
.setting-textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: monospace;
  resize: vertical;
  box-sizing: border-box;
}
.setting-textarea:focus {
  outline: none;
  border-color: #6c5ce7;
  background: var(--bg-tertiary);
}
.setting-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 3px;
}
.settings-section {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}
.settings-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}
.settings-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 10px 0;
}

/* 设置页签 */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  padding: 2px;
  background: var(--bg-tertiary);
  border-radius: 6px;
}
.settings-tab {
  flex: 1;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.settings-tab.active {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.settings-tab-content {
  display: none;
  min-height: 260px;
}
.settings-tab-content.active {
  display: block;
}
/* 平台行选中态 */
.platform-row {
  cursor: pointer;
  border-radius: 5px;
  padding: 6px 10px;
  margin: 0 -10px;
  transition: background 0.15s;
}
.platform-row:hover {
  background: rgba(0,0,0,0.05);
}
.platform-row.selected {
  background: rgba(108,92,231,0.1);
  box-shadow: inset 3px 0 0 #6c5ce7;
}
.platform-row.selected .setting-label {
  font-weight: 600;
  color: #6c5ce7;
}
.setting-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  box-sizing: border-box;
}
.setting-input:focus {
  outline: none;
  border-color: #6c5ce7;
  background: var(--bg-tertiary);
}
.login-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 8px;
  font-size: 13px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}
.status-dot.online {
  background: #00b894;
}
.status-dot.offline {
  background: #e17055;
}
.status-text {
  color: var(--text-secondary);
}
.setting-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.btn-sm {
  padding: 2px 8px;
  font-size: 10px;
}
.btn-primary {
  background: #6c5ce7;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
}
.btn-primary:hover { background: #5b4bd6; }
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
}

/* ============ 夜间模式 ============ */
body.dark-theme {
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --bg-tertiary: #252525;
  --bg-hover: #2a2a2a;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-muted: #707070;
  --border: #333333;
  --border-light: #2a2a2a;
  --accent: #7c8cf0;
  --accent-hover: #8b9cf0;
  --accent-light: #2a2d4a;
  --accent-gradient: linear-gradient(135deg, #7c8cf0 0%, #9baaf0 100%);
  --blue: #4fc3f7;
  --blue-light: #1a2a3a;
  --danger: #ff6b7a;
  --success: #69db9a;
  --warning: #ffb74d;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

body.dark-theme .room-card,
body.dark-theme .sidebar,
body.dark-theme .chat-panel,
body.dark-theme .room-info-card,
body.dark-theme .settings-panel,
body.dark-theme .top-nav,
body.dark-theme .play-header,
body.dark-theme .modal-content {
  background: var(--bg-secondary);
}

body.dark-theme .modal-header,
body.dark-theme .modal-footer {
  border-color: var(--border);
}

body.dark-theme .modal-header h3,
body.dark-theme .modal-close {
  color: var(--text-primary);
}

body.dark-theme .room-card:hover {
  background: var(--bg-hover);
}

body.dark-theme .category-item:hover,
body.dark-theme .category-item.active {
  background: var(--accent-light);
}

body.dark-theme .chat-item {
  border-bottom-color: var(--border-light);
  background: rgba(255, 255, 255, 0.03);
}

body.dark-theme .chat-item:hover {
  background: var(--bg-hover);
}

body.dark-theme input,
body.dark-theme textarea {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border);
}

body.dark-theme .control-bar {
  background: rgba(0, 0, 0, 0.7);
}

body.dark-theme .player-loading,
body.dark-theme .player-error {
  background: rgba(0, 0, 0, 0.8);
  color: var(--text-primary);
}

/* 导航栏额外按钮（收藏、设置） */
.nav-extra-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.nav-extra-btn svg {
  width: 20px;
  height: 20px;
}

/* 收藏页面填满剩余高度 */
#favPage {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#favPage .page-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

/* 二级房间列表卡片撑满剩余高度，加载动画时与收藏页一致覆盖整个可视区 */
#roomHeader {
  height: 100%;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

#roomHeader .room-grid {
  align-items: start;
  align-content: start;
}

/* 搜索结果页：与收藏页/二级列表同款撑满 */
#searchPage {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#searchPage .page-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

#searchGrid {
  align-items: start;
  align-content: start;
}

/* 推荐页：与收藏/搜索/二级列表同款撑满 */
#homePage {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#homePage .page-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

#homePage .room-grid {
  align-items: start;
  align-content: start;
}

/* 二级房间列表页：与收藏/搜索同款撑满，独立 subGrid 滚动 */
#subPage {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#subPage .page-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

#subGrid {
  align-items: start;
  align-content: start;
}

#favRoomGrid {
  align-items: start;
  align-content: start;
}

/* 收藏卡片删除按钮 */
.fav-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
}

/* 页面头部右侧按钮组 */
.page-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-card:hover .fav-delete-btn {
  opacity: 1;
}

.fav-delete-btn:hover {
  background: #ff4757;
}

/* 顶部额外按钮位置调整 */
.nav-extra-btn {
  margin-right: 0;
}

.nav-extra-btn:last-child {
  margin-right: 0;
}

/* 房间平台标签（左下角） */
.room-platform-tag {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

/* 播放页收藏按钮（在用户名后面） */
.room-fav-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  margin-left: 6px;
  border-radius: 50%;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  vertical-align: middle;
}

.room-fav-toggle.faved {
  color: #ff4757;
}

.room-fav-toggle svg {
  width: 16px;
  height: 16px;
}

/* 手机端房间信息卡片：桌面端隐藏 */
#streamerCardMobile {
  display: none;
}

/* 手机端收藏按钮固定卡片右上角：right/top 与卡片 padding(8px/10px) 统一 */
#streamerCardMobile {
  position: relative;
}

/* 视频自适应 */
#videoPlayer {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ============ 手机端适配 ============ */
@media (max-width: 768px) {
  body {
    font-size: 12px;
  }

  /* 顶部导航：平台按钮 + 搜索图标 + 夜间模式在同一行 */
  .top-nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    padding: 10px 12px 10px 8px;
    gap: 6px;
    height: auto !important;
    min-height: 52px;
    overflow: visible;
  }

  .nav-platforms {
    display: flex !important;
    gap: 2px;
    flex: 1;
    order: 1;
    flex-shrink: 1;
    min-width: 0;
    position: static !important;
    transform: none !important;
  }

  .nav-btn {
    padding: 6px 2px;
    font-size: 14px;
    flex: 1;
    min-width: 0;
    text-align: center;
    justify-content: center;
  }

  .nav-btn span {
    display: block;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 手机端只显示精简名（哔哩/斗鱼/虎牙/抖音/快手） */
  .nav-btn span::after {
    content: none;
  }

  /* 手机端隐藏原来的搜索框 */
  .nav-search {
    display: none !important;
  }

  /* 手机端右侧图标组：搜索 -> 收藏 -> 设置；设置图标右边缘与下方 page-card 容器右边缘对齐(8px) */
  .nav-right-icons {
    display: flex;
    align-items: center;
    order: 2;
    flex-shrink: 0;
    gap: 2px;
    margin-right: -10px;
  }

  /* 手机端显示搜索图标按钮 */
  .mobile-search-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 6px;
  }

  .mobile-search-btn svg {
    width: 18px;
    height: 18px;
  }

  /* 手机端额外按钮（收藏、设置） */
  .nav-extra-btn {
    position: static !important;
    transform: none !important;
    flex-shrink: 0;
    padding: 6px;
  }

  .nav-extra-btn svg {
    width: 18px;
    height: 18px;
  }


  /* 首页布局：侧边栏改为顶部横向滚动 */
  .home-body {
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
    padding: 0;
    gap: 0;
  }

  .sidebar {
    display: block !important;
    width: 100%;
    height: auto;
    min-height: 40px;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    padding: 10px 0;
    margin-top: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  /* 手机端去掉分类选中时的左侧竖条 */
  .category-item::before {
    display: none !important;
  }

  /* 手机端一级分类不显示 emoji 图标 */
  .category-item .cat-emoji {
    display: none;
  }

  .category-list {
    display: flex !important;
    flex-direction: row;
    padding: 0 8px;
    gap: 4px;
    white-space: nowrap;
    width: max-content;
    min-width: 100%;
  }

  .category-item {
    padding: 6px 14px;
    font-size: 12px;
    flex-shrink: 0;
    display: inline-flex;
    position: static;
  }

  .category-list .loading {
    padding: 10px 20px;
  }

  .main-content {
  scrollbar-gutter: stable;
    padding: 8px 3px 8px 8px;
    overflow-y: auto;
  }

  .main-content::-webkit-scrollbar { width: 5px; }
  .main-content::-webkit-scrollbar-track { background: transparent; }
  .main-content::-webkit-scrollbar-thumb { background: transparent; }
  .main-content.user-scrolling::-webkit-scrollbar-thumb { background: var(--text-muted); opacity: 0.5; }

  /* 房间网格：手机端2列 */
  .room-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .room-card {
    border-radius: var(--radius-sm);
  }

  .room-cover {
    aspect-ratio: 16/9;
  }

  .room-title {
    font-size: 12px;
    -webkit-line-clamp: 1;
  }

  .room-anchor {
    font-size: 11px;
  }

  .room-viewers {
    font-size: 10px;
    padding: 2px 6px;
  }

  /* 播放页布局：房间信息在上，视频在中，聊天在下 */
  .play-view {
    height: 100dvh !important;
    min-height: 100dvh;
    overflow: hidden;
  }

  .play-body {
    flex-direction: column;
    height: 0;
    min-height: 0;
    flex: 1 !important;
    overflow: hidden !important;
    padding: 8px 0;
    gap: 8px;
    display: flex;
  }

  /* 手机端显示独立的房间信息卡片 */
  #streamerCardMobile {
    display: flex;
    width: calc(100% - 16px) !important;
    margin: 0 8px;
    padding: 10px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    flex-shrink: 0;
    box-sizing: border-box;
  }

  /* 隐藏聊天面板中的房间信息卡片 */
  .chat-sidebar .streamer-card {
    display: none;
  }

  /* 播放器容器：边框在外层，高度根据视频自动适应 */
  .video-area {
    width: calc(100% - 16px) !important;
    margin: 0 8px;
    height: auto !important;
    min-height: 0;
    max-height: none !important;
    flex: none !important;
    display: block !important;
    flex-shrink: 0;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
    background: #000;
  }

  /* 竖屏视频（JS 添加 .video-vertical）：容器不撑满，高度由 JS 计算——
     优先视频自然高度（容器贴合视频、无黑边），剩余空间不足时才收缩到可用高度（保留统一间距） */
  .video-area.video-vertical {
    flex: none !important;
    height: auto;
  }
  .video-area.video-vertical #videoPlayer {
    height: 100% !important;
  }

  .video-wrapper {
    border-radius: 0;
    border: none;
    box-shadow: none;
    width: 100% !important;
    height: 100% !important;
    min-height: 0;
    flex: none !important;
    display: block !important;
    position: relative;
    overflow: hidden;
    background: #000;
    box-sizing: border-box;
  }

  /* 视频宽度100%，高度自动按比例适应 */
  #videoPlayer {
    width: 100% !important;
    height: auto !important;
    object-fit: contain;
    display: block;
  }

  /* 聊天面板：flex:1 填满剩余高度，内部滚动 */
  .chat-sidebar {
    width: calc(100% - 16px) !important;
    margin: 0 8px;
    height: auto;
    min-height: 0;
    max-height: none;
    flex: 1 !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    flex-shrink: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  .chat-list-header {
    padding: 0 8px;
  }

  /* 聊天列表：gutter 预留滚动条槽(5px)，padding-right 3px 使消息块右边缘 = 3+5 = 8px，与左边缘(8px)及状态栏(8px)对齐 */
  .chat-list {
    scrollbar-gutter: stable;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 8px 3px 8px 8px;
  }

  /* 手机端聊天框状态条与消息块边缘(8px)对齐（chat-header 为居中标题不受此影响） */
  .chat-header { padding: 10px 16px; }
  /* 显式固定高度 + border-box：内容区几何不随浏览器对 padding/border 的计算差异变化，保证 flex 垂直居中基准一致 */
  /* padding 上7下13：内容区中心相对容器中心上移 3px，补偿部分 WebView 渲染该状态栏时的整体偏下观感
     （容器 45px、内容区 25px 不变，仅 flex 居中的基准上移，边框与布局流均不受影响） */
  .danmaku-status-bar {
    /* 底部比顶部多 6px：视觉中心上移 3px，补偿文字 glyph 在行盒内偏下的偏移 */
    padding: 6px 8px 12px 8px;
    height: 42px;
    box-sizing: border-box;
    flex-shrink: 0;
  }
  /* 收窄 line box 至字号：glyph 在行盒内的位置由字体 metrics 决定，line-height 1.2 时行盒 15px、glyph 可能偏下；
     line-height 1 让行盒贴近 glyph，消除字体造成的视觉偏移，文字与图标在同一垂直基准 */
  .danmaku-status-bar .status-text,
  .danmaku-status-bar .status-count-num {
    line-height: 1;
  }
  /* 清除个别 WebView 给 button 的 UA 默认间距，避免图标整体下移 */
  .danmaku-status-bar .chat-msg-toggle {
    margin: 0;
  }
  /* 强制状态栏子项成为块级 flex：部分 WebView（老版本 WKWebView/Android WebView）不会对 flex 容器内的
     inline 子项（span）做 blockify，仍按基线对齐导致文字与图标整体偏下；显式 display 消除该渲染差异 */
  .danmaku-status-bar > * {
    display: flex;
    align-items: center;
  }

  .chat-list::-webkit-scrollbar { width: 5px; }
  .chat-list::-webkit-scrollbar-thumb { background: transparent; }
  .chat-list.user-scrolling::-webkit-scrollbar-thumb { background: var(--text-muted); opacity: 0.5; }

  /* 竖屏专用：简化弹幕状态卡片（显示在播放器上方） */
  .vertical-danmaku-card {
    width: calc(100% - 16px) !important;
    margin: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    padding: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    flex-shrink: 0;
  }

  /* 去掉竖屏卡片内部状态栏的底部横线 */
  .vertical-danmaku-card .danmaku-status-bar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: none;
    padding: 10px 8px;
  }

  /* 竖屏模式下聊天消息开关按钮不可点击 */
  .chat-msg-toggle.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
  }

  /* 手机端缩小"直播中"标签 */
  .room-live-tag {
    font-size: 10px;
    padding: 2px 6px;
    top: 6px;
    left: 6px;
  }

  .room-live-tag::before {
    width: 5px;
    height: 5px;
  }

  /* 播放页头部 */
  .play-header {
    padding: 10px 8px;
    flex-wrap: nowrap;
    gap: 8px;
    height: auto;
    min-height: 52px;
    justify-content: space-between;
    position: relative;
  }

  /* 手机端标题：在返回键和右侧按钮之间，过长截断 */
  .play-title {
    position: static;
    transform: none;
    flex: 1;
    width: auto;
    min-width: 0;
    font-size: 14px;
    text-align: left;
    margin: 0 8px;
  }

  .play-header-right {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    margin-right: -6px;
  }

  .site-tag {
    padding: 0 8px;
    font-size: 12px;
    height: 24px;
  }

  .settings-btn {
    padding: 6px;
  }

  .settings-btn svg {
    width: 18px;
    height: 18px;
  }

  .back-btn {
    padding: 0 10px;
    font-size: 13px;
    flex-shrink: 0;
  }

  /* 控制栏 - 手机端确保按钮显示完整 */
  .control-bar {
    padding: 6px 8px;
    gap: 4px;
    flex-wrap: nowrap;
  }

  .ctrl-left,
  .ctrl-right {
    gap: 4px;
    flex-shrink: 0;
  }

  .ctrl-center {
    flex: 1;
    min-width: 0;
    padding: 0 4px;
  }

  .ctrl-btn {
    padding: 5px;
    min-width: 28px;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .ctrl-btn svg {
    width: 16px;
    height: 16px;
  }

  .ctrl-select-btn {
    min-width: 40px;
    font-size: 11px;
    padding: 4px 6px;
  }

  /* 手机端隐藏网页全屏按钮（所有模式下都隐藏，包括全屏） */
  #webFullscreenBtn {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  /* 手机端画质/线路面板：限制最大高度，内部滚动，避免被播放器截断 */
  .ctrl-select-panel {
    max-height: 40vh;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  /* 手机端非全屏模式下隐藏弹幕设置按钮图标 */
  .danmaku-settings-wrap {
    display: none !important;
  }
  /* 只有全屏模式下才显示弹幕设置按钮 */
  .video-wrapper.fullscreen .danmaku-settings-wrap,
  .video-wrapper.web-fullscreen .danmaku-settings-wrap {
    display: block !important;
  }

  /* 手机端非全屏模式下隐藏弹幕设置面板，只有全屏时才显示 */
  .danmaku-settings-panel.show {
    display: none !important;
  }
  .video-wrapper.fullscreen .danmaku-settings-panel.show,
  .video-wrapper.web-fullscreen .danmaku-settings-panel.show {
    display: block !important;
  }

  .ctrl-time {
    font-size: 11px;
    min-width: 40px;
  }

  /* 弹幕设置面板 */
  .danmaku-settings-panel {
    right: 10px;
    left: 10px;
    bottom: 50px;
    padding: 12px;
  }

  .dms-opt {
    padding: 4px 10px;
    font-size: 12px;
  }

  /* 聊天面板：与 768px 段保持一致，gutter(5px)+padding-right(3px)+chat-item(8px)=16px 与状态栏对齐 */
  .chat-list {
  scrollbar-gutter: stable;
    padding: 8px 3px 8px 8px;
    flex: 1;
    overflow-y: auto;
  }

  .chat-list::-webkit-scrollbar { width: 5px; }
  .chat-list::-webkit-scrollbar-thumb { background: transparent; }
  .chat-list.user-scrolling::-webkit-scrollbar-thumb { background: var(--text-muted); opacity: 0.5; }

  .chat-item {
    padding: 6px 8px;
    font-size: 14px;
  }

  .chat-user {
    font-size: 14px;
  }

  /* 设置弹窗 */
  .modal-content {
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    scrollbar-gutter: stable;
  }

  .setting-textarea {
    font-size: 12px;
  }
}

/* 超小屏幕适配 */
@media (max-width: 480px) {
  .room-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .nav-btn {
    font-size: 14px;
    padding: 6px 4px;
  }

  .video-area {
    max-height: none;
  }

  .chat-sidebar {
    height: auto;
  }

  /* 手机端房间信息收藏按钮：固定卡片右上角（right/top 与卡片 padding 统一），
      streamer-info-text 已有 padding-right:32px 预留位，不遮挡名字 */
  .streamer-name {
    flex-wrap: nowrap;
    width: 100%;
  }

  #streamerCardMobile .room-fav-toggle {
    position: absolute;
    top: 10px;
    right: 8px;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    color: var(--text-primary) !important;
    background: var(--bg-secondary);
    border-radius: 50%;
    margin-left: 0;
  }

  .room-fav-toggle svg {
    width: 20px !important;
    height: 20px !important;
  }
}

/* 平板适配 */
@media (min-width: 769px) and (max-width: 1024px) {
  .room-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .sidebar {
    width: 140px;
  }

  .category-item {
    font-size: 12px;
    padding: 8px 12px;
  }
}
