:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --panel: #101828;
  --text: #e6eaff;
  --muted: #9fb0d0;
  --border: #22324f;
  --accent: #6ea8ff;
  --bad: #ff6b6b;
  --good: #2dd4bf;
}

html, body {
  height: 100%;
  margin: 0;
  background: radial-gradient(1200px 600px at 20% 0%, #12234a 0%, var(--bg) 60%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { color: #c8d6ff; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 24, 40, 0.65);
}
.brand { font-weight: 700; letter-spacing: 0.2px; }
.topbarRight { display: flex; gap: 10px; align-items: center; }
.link { padding: 6px 8px; border-radius: 8px; border: 1px solid transparent; }
.link:hover { border-color: rgba(110, 168, 255, 0.45); }

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 14px;
  padding: 14px 16px 24px;
  max-width: 1180px;
  margin: 0 auto;
}

.card, .videoCard, .chatCard {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(16, 24, 40, 0.75);
}
.card { padding: 16px; max-width: 520px; margin: 36px auto; }
.card.wide { max-width: 900px; }

h1 { margin: 0 0 10px; font-size: 20px; }
h2 { margin: 16px 0 8px; font-size: 16px; }

label { display: block; margin: 10px 0; }
input {
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 22, 0.65);
  color: var(--text);
}
button {
  border: 1px solid var(--border);
  background: rgba(16, 24, 40, 0.75);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { border-color: rgba(110, 168, 255, 0.6); }
button.ghost { background: transparent; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); margin: 10px 0; }

.videoCard { overflow: hidden; }
.videoHeader {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.5);
  color: var(--muted);
  font-size: 12px;
}

video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: block;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px 12px;
}
.chip {
  border: 1px solid var(--border);
  background: rgba(16, 24, 40, 0.6);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
}

.chatCard { display: flex; flex-direction: column; overflow: hidden; }
.chatHeader { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.08); font-weight: 650; }
.chatLog { padding: 10px 12px; height: 520px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 8px; line-height: 1.3; }
.msg .who { color: #c8d6ff; font-weight: 650; }
.msg .when { color: var(--muted); font-size: 11px; margin-left: 6px; }
.chatForm { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.chatForm input { margin-top: 0; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .chatLog { height: 360px; }
}

/* Currently Watching Section */
.viewersSection {
  border-top: 1px solid var(--border);
  background: rgba(10, 14, 22, 0.45);
  padding: 12px 16px;
  margin-top: 8px;
}

.viewersHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.viewerCountBadge {
  background: var(--accent);
  color: var(--bg);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.viewersGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-height: 120px;
  overflow-y: auto;
  padding-right: 4px;
}

.viewersGrid::-webkit-scrollbar {
  width: 6px;
}

.viewersGrid::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.viewersGrid::-webkit-scrollbar-thumb {
  background: rgba(110, 168, 255, 0.3);
  border-radius: 3px;
}

.viewersGrid::-webkit-scrollbar-thumb:hover {
  background: rgba(110, 168, 255, 0.5);
}

.viewerBtn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(16, 24, 40, 0.7);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s ease;
  min-width: 140px;
  max-width: 200px;
  flex: 1 0 auto;
}

.viewerBtn:hover {
  border-color: var(--accent);
  background: rgba(110, 168, 255, 0.1);
  transform: translateY(-1px);
}

.viewerAvatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6ea8ff, #2dd4bf);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.viewerName {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty state */
.viewersGrid:empty::before {
  content: "No viewers yet";
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
  padding: 8px 0;
  width: 100%;
  text-align: center;
}

/* Responsive adjustments */
@media (max-width: 980px) {
  .viewersGrid {
    max-height: 100px;
  }
  
  .viewerBtn {
    min-width: 120px;
  }
}

@media (max-width: 768px) {
  .viewersSection {
    padding: 10px 12px;
  }
  
  .viewersGrid {
    max-height: 80px;
  }
  
  .viewerBtn {
    min-width: 100px;
    padding: 6px 10px;
  }
  
  .viewerAvatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  
  .viewerName {
    font-size: 12px;
  }
}

/* Active viewer indicator */
.viewerBtn.active {
  border-color: var(--good);
  background: rgba(45, 212, 191, 0.1);
}

.viewerBtn.active .viewerAvatar {
  background: linear-gradient(135deg, #2dd4bf, #22c55e);
}

/* Viewer status dot */
.viewerStatus {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  margin-left: auto;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.2);
}

.viewerBtn:hover .viewerStatus {
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.3);
}
