:root {
  --bg: #0b0d12;
  --panel: #141821;
  --line: #232936;
  --text: #e6e9ef;
  --dim: #8b93a5;
  --live: #ff2d55;
  --ok: #22c55e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: .02em;
}

.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--dim);
}

.meta .warn { color: #f59e0b; }

.meta button {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: #1d2330;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}

.meta button:hover { background: #262e3e; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  padding: 16px 20px 8px;
  align-items: start;
}

.tile { min-width: 0; }

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .15s ease;
}

.tile[data-live="1"] .screen { border-color: #3a2a33; }

.tile.big {
  grid-column: 1 / -1;
}

.tile.big .screen { aspect-ratio: 16 / 9; max-height: 78vh; }

.tile.big .screen video { object-fit: contain; }

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

/* 离线封面 */
.cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #0f131b;
  transition: opacity .2s ease;
}

.cover.hide { opacity: 0; pointer-events: none; }

.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: .28;
  filter: saturate(.6);
}

.cover-text {
  position: relative;
  font-size: 12px;
  color: var(--dim);
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(11, 13, 18, .7);
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 徽标 */
.badge {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(11, 13, 18, .72);
  border: 1px solid var(--line);
  color: var(--dim);
}

.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5b6376;
}

.badge.on {
  color: #fff;
  background: rgba(255, 45, 85, .92);
  border-color: transparent;
}

.badge.on .dot {
  background: #fff;
  animation: pulse 1.4s ease-in-out infinite;
}

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

.viewers {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 11px;
  color: var(--text);
  background: rgba(11, 13, 18, .72);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
}

.viewers:empty { display: none; }

/* 底部信息层 */
.overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 22px 10px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, .82), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.handle {
  display: inline-block;
  max-width: 100%;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  pointer-events: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.handle:hover { text-decoration: underline; }

.title {
  font-size: 11px;
  color: #c9cfdb;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 悬浮控件 */
.ctrls {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .15s ease;
}

.screen:hover .ctrls { opacity: 1; }

.ctrls button {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(11, 13, 18, .78);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ctrls button:hover { background: #262e3e; }
/* 评论面板 */
.chat {
  position: absolute;
  top: 36px;
  right: 8px;
  bottom: 46px;
  width: min(54%, 320px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
  overflow: hidden;
  padding: 6px 8px;
  border-radius: 8px;
  background: linear-gradient(to left, rgba(0, 0, 0, .58), rgba(0, 0, 0, .12));
  pointer-events: none;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity .15s ease, transform .15s ease;
}

.chat.on { opacity: 1; transform: none; }

.chat-empty {
  font-size: 11px;
  color: #9aa3b5;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .9);
}

.chat-line {
  font-size: 12px;
  line-height: 1.35;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .9);
  word-break: break-word;
  animation: chatIn .2s ease;
}

.chat-line .u { color: #7dd3fc; margin-right: 4px; }
.chat-line.gift .u { color: #fbbf24; }
.chat-line.gift .t { color: #fde68a; }

@keyframes chatIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.ctrls button.on { border-color: var(--ok); color: var(--ok); }

.foot {
  margin: 4px 20px 24px;
  font-size: 11px;
  color: #5b6376;
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; padding: 12px; }
  .ctrls { opacity: 1; }
}
