:root {
  --bg: #0b0c10;
  --panel: #14161d;
  --panel-2: #191c25;
  --line: #262a36;
  --text: #e8e9ee;
  --muted: #9aa0b1;
  --accent: #f4b942;
  --accent-ink: #201703;
  --good: #48d18a;
  --warn: #f5b942;
  --bad: #ff6b6b;
  --radius: 14px;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
/* A class-level `display` beats the UA rule for [hidden], which silently left the
   "Join playback" overlay covering a playing video. Force it. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 78% -10%, #1b1b2b 0%, transparent 60%), var(--bg);
  color: var(--text);
  overflow: hidden;
}

button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

/* ---------------- top bar ---------------- */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 12, 16, 0.86);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: 0.2px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.roomchip { color: var(--muted); font-size: 12.5px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 999px; }
.roomchip b { color: var(--text); letter-spacing: 0.6px; }
.people { display: flex; gap: 6px; flex: 1; overflow: hidden; }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #0b0c10;
  background: #8d93ff; position: relative; flex: none;
}
.avatar.host { background: var(--accent); }
.avatar.host::after {
  content: "★"; position: absolute; top: -7px; right: -5px; font-size: 9px; color: var(--accent);
}
.topright { display: flex; align-items: center; gap: 10px; }
.conn { font-size: 11.5px; color: var(--muted); }
.conn.live { color: var(--good); }
.conn.down { color: var(--bad); }

button.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px;
}
button.ghost:hover { border-color: #3a4050; background: #171a22; }
button.ghost.small { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
button.primary {
  background: var(--accent); color: var(--accent-ink); border: 0;
  border-radius: 10px; padding: 8px 14px; font-weight: 650;
}
button.primary:hover { filter: brightness(1.06); }

/* ---------------- layout ---------------- */
.layout {
  height: calc(100% - 52px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
}
.stage { display: flex; flex-direction: column; min-width: 0; padding: 14px 14px 10px; gap: 10px; }
.screen {
  position: relative; flex: 1; min-height: 0;
  background: #000; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line);
  display: grid; place-items: center;
}
.screen video, .screen iframe { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.screen iframe.yt { }
.empty { text-align: center; color: var(--muted); padding: 30px; max-width: 420px; }
.emptyIcon { font-size: 42px; margin-bottom: 8px; }
.empty h1 { font-size: 19px; color: var(--text); margin: 0 0 6px; font-weight: 620; }
.empty p { margin: 0; font-size: 13.5px; line-height: 1.5; }

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(4, 5, 8, 0.72); backdrop-filter: blur(2px);
}
.overlay button {
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 12px; padding: 14px 22px; font-weight: 700; font-size: 15px;
}

/* transport */
.transport { display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.playbtn {
  width: 38px; height: 38px; border-radius: 50%; border: 0; flex: none;
  background: var(--accent); color: var(--accent-ink); font-size: 15px;
  display: grid; place-items: center;
}
.playbtn:disabled { opacity: 0.35; }
.t { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: center; }
#seekBar { flex: 1; accent-color: var(--accent); height: 4px; }
.drift {
  font-size: 11.5px; padding: 3px 9px; border-radius: 999px; min-width: 74px; text-align: center;
  border: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums;
}
.drift.good { color: var(--good); border-color: rgba(72, 209, 138, 0.35); }
.drift.warn { color: var(--warn); border-color: rgba(245, 185, 66, 0.35); }
.drift.bad { color: var(--bad); border-color: rgba(255, 107, 107, 0.4); }

.nowplaying { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px 2px; }
.npText { display: flex; align-items: center; gap: 9px; min-width: 0; }
.npText #npTitle { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px;
  padding: 3px 7px; border-radius: 6px; background: var(--panel-2);
  color: var(--muted); border: 1px solid var(--line); flex: none;
}
.npRight { display: flex; gap: 8px; align-items: center; }
.npRight select {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 6px; font-size: 12px;
}

/* ---------------- sidebar ---------------- */
.side {
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; padding: 10px 10px 0; gap: 4px; }
.tabs button {
  flex: 1; background: transparent; color: var(--muted); border: 0;
  border-bottom: 2px solid transparent; padding: 8px 4px 9px; font-size: 12.5px; border-radius: 8px 8px 0 0;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); background: #171a22; }
.panes { flex: 1; min-height: 0; overflow: auto; padding: 12px; }
.pane { display: none; }
.pane.active { display: block; }
.searchrow { display: flex; gap: 8px; }
.searchrow input {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 9px 11px; font-size: 13px;
}
.searchrow input:focus { outline: none; border-color: #3d4457; }
.hint { font-size: 11.5px; color: var(--muted); margin: 12px 2px 8px; letter-spacing: 0.3px; }
.note { font-size: 11.5px; line-height: 1.5; color: var(--muted); margin: 10px 2px 0; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.card {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; text-align: left; padding: 0; color: var(--text); display: block;
}
.card:hover { border-color: #3d4457; }
.card img { width: 100%; aspect-ratio: 2/3; object-fit: cover; display: block; background: #101219; }
.card .ct { padding: 6px 7px 8px; }
.card .cn { font-size: 11.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .cs { font-size: 10px; color: var(--muted); margin-top: 3px; }

.chat { border-top: 1px solid var(--line); padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.chatlog { max-height: 132px; overflow: auto; display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.chatlog .m { color: var(--text); line-height: 1.35; }
.chatlog .m b { color: var(--accent); font-weight: 620; }
.chatlog .m.sys { color: var(--muted); font-style: italic; }
.chatrow { display: flex; gap: 8px; }
.chatrow input {
  flex: 1; min-width: 0; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); border-radius: 9px; padding: 8px 10px; font-size: 12.5px;
}

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #232735; border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 12.5px; z-index: 50;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

@media (max-width: 900px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .stage { height: 62vh; }
  .side { border-left: 0; border-top: 1px solid var(--line); max-height: 38vh; }
  .grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- sign-in gate --- */
.gate { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(8, 9, 13, 0.94); backdrop-filter: blur(6px); }
.gatecard { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; display: grid; gap: 12px; }
.gatebrand { font-weight: 600; letter-spacing: 0.3px; display: flex; gap: 8px; align-items: center; font-size: 15px; }
.gatemuted { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; }
.gatemsg { font-size: 11.5px; color: var(--muted); margin: 0; min-height: 14px; line-height: 1.45; }
.gatemsg.err { color: #ff8080; }
.gatefoot { font-size: 10.5px; color: var(--muted); margin: 4px 0 0; line-height: 1.5; }
.primary.big { display: block; width: 100%; text-align: center; padding: 11px 14px; font-size: 13.5px; text-decoration: none; }
.field { display: grid; gap: 5px; font-size: 11px; color: var(--muted); letter-spacing: 0.3px; }
.field input { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 9px 11px; font-size: 13px; }
.field input:focus { outline: none; border-color: #3d4457; }

/* --- library browsing --- */
.segments { display: flex; gap: 6px; margin-top: 9px; }
.segments button { flex: 1; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 9px; padding: 6px 8px; font-size: 11px; cursor: pointer; }
.segments button.active { color: var(--text); border-color: #4b5568; background: #1b1f2a; }
.browsebar { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.browsebar .crumb { font-size: 11.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
select.small { max-width: 150px; font-size: 11px; }
.card .progress { height: 3px; background: #262b38; }
.card .progress > i { display: block; height: 100%; background: #7aa2ff; }

.npRight select, .npRight button { white-space: nowrap; }
.card .cn { word-break: break-word; }

.browsebar button { white-space: nowrap; flex: 0 0 auto; }
.browsebar { min-width: 0; }
#meChip { font-size: 11px; color: var(--muted); margin-right: 8px; }
@media (max-width: 720px) { #meChip { display: none; } }
