:root {
  --bg: #0b1220;
  --paper: #e8eef8;
  --muted: #93a4bd;
  --accent: #3b82f6;
  --accent-2: #93c5fd;
  --ink: #07111f;
  --panel: rgba(232, 238, 248, 0.045);
  --line: rgba(232, 238, 248, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--paper);
  font-family: Manrope, "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(59, 130, 246, 0.18), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(37, 99, 235, 0.12), transparent 50%),
    var(--bg);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
html.invite #lobby,
html.rejoin #lobby { display: none !important; }
html.invite #theater.hidden,
html.rejoin #theater.hidden { display: block !important; }
html.invite #join-modal.hidden { display: grid !important; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-weight: 700; letter-spacing: -0.02em; }
.brand em { color: var(--muted); font-style: normal; font-size: 13px; }
.mark { width: 42px; height: 42px; display: block; }
.mark svg { width: 100%; height: 100%; display: block; }

.lobby { width: min(1040px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 72px; }
.hero { max-width: 720px; margin: 52px 0 28px; }
.eyebrow {
  margin: 0 0 12px; color: var(--accent-2); letter-spacing: 0.14em;
  text-transform: uppercase; font-size: 12px; font-weight: 700;
}
.hero h1, .card h2, .now h2, .sheet-card h3, #code, .empty span {
  font-family: Manrope, "Segoe UI", sans-serif;
}
.hero h1 {
  margin: 0; font-weight: 700;
  font-size: clamp(2.4rem, 5.4vw, 4.3rem); line-height: 1.02; letter-spacing: -0.045em;
}
.lead { margin: 16px 0 0; max-width: 46ch; color: var(--muted); font-size: 1.05rem; }
.banner {
  margin: 0 0 18px; padding: 12px 14px; border-radius: 14px;
  background: rgba(59, 130, 246, 0.12); border: 1px solid rgba(147, 197, 253, 0.28);
  color: var(--accent-2);
}
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card, .side, .now, .sheet-card {
  background: #10192b; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow);
}
.card { padding: 22px; }
.card h2 { margin: 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.03em; }
.card p { margin: 6px 0 16px; color: var(--muted); }
label { display: grid; gap: 6px; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
input {
  width: 100%; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.28);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
input:focus { border-color: rgba(59, 130, 246, 0.85); }
button {
  border: 0; border-radius: 999px; padding: 12px 16px; font-weight: 700;
  background: var(--accent); color: #fff;
}
.ghost, .text, .tabs button, .cat, .more, #copy, #full, #mute, #pp, button.person {
  background: transparent; color: var(--paper); border: 1px solid var(--line);
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: not-allowed; }

.theater { width: min(1680px, calc(100% - 20px)); margin: 0 auto; padding: 12px 0 28px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.top .codebox { margin-left: auto; }
.brand.mini .mark { width: 34px; height: 34px; }
.codebox { display: flex; align-items: center; gap: 8px; }
#code {
  font-weight: 700; font-size: 1.05rem; letter-spacing: 0.12em;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(400px, 460px);
  gap: 12px;
  align-items: start;
}
.main { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.stage { min-width: 0; }
.screen {
  position: relative; aspect-ratio: 16 / 9; background: #070d18;
  border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
}
video { width: 100%; height: 100%; background: #000; object-fit: contain; }
.empty, .tap {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px;
}
.empty span { font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.empty p { margin: 8px 0 0; color: var(--muted); }
.tap {
  z-index: 2;
  border: 0; border-radius: 0; background: rgba(7, 17, 31, 0.72); color: #fff;
  font-size: 1.25rem; font-weight: 700;
}
.transport { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.vol { display: grid; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 700; min-width: 110px; }
#volume { width: 110px; accent-color: var(--accent); }
.bar { position: relative; flex: 1; height: 22px; display: grid; align-items: center; }
#buffer {
  position: absolute; left: 0; height: 4px; width: 0; border-radius: 99px;
  background: rgba(232, 238, 248, 0.28);
}
#seek { position: relative; width: 100%; accent-color: var(--accent); }
#clock { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; }
.now { margin-top: 0; padding: 12px 14px; box-shadow: none; }
.dl {
  position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 3;
  display: grid; gap: 8px; padding: 12px 14px; border-radius: 14px;
  background: rgba(7, 17, 31, 0.88); border: 1px solid rgba(147, 197, 253, 0.35);
}
.dl strong { font-size: 14px; }
.dl-track { height: 8px; border-radius: 99px; background: rgba(232, 238, 248, 0.16); overflow: hidden; }
#dl-bar { height: 100%; width: 0; border-radius: 99px; background: var(--accent); }
.now h2 { margin: 0; font-weight: 700; font-size: 1.25rem; letter-spacing: -0.03em; }
.now p { margin: 4px 0 0; color: var(--muted); }

.side {
  position: sticky;
  top: 8px;
  align-self: start;
  height: calc(100dvh - 68px);
  max-height: calc(100dvh - 68px);
  display: flex;
  flex-direction: column;
  padding: 12px;
  box-shadow: none;
}
.people { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; max-height: 132px; overflow: auto; }
.cat {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 13px; color: var(--muted);
}
button.person {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 4px 10px 4px 4px; font-size: 13px; font-weight: 650; color: var(--muted);
}
button.person.host { color: #fff; background: var(--accent); border-color: transparent; }
button.person .pass { font-size: 11px; font-weight: 700; opacity: 0.8; }
.avatar, .msg .ava {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: #1d4e89;
}
.avatar.ph, .msg .ava.ph {
  display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700;
}
.avatar-btn { display: inline-flex; align-items: center; gap: 8px; }
.avatar-btn img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.chat { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.msg { margin: 0; line-height: 1.35; display: flex; gap: 8px; align-items: flex-start; }
.msg b { font-weight: 700; }
.msg.system { color: var(--muted); font-style: italic; display: block; }
.composer { display: flex; gap: 8px; margin-top: 10px; flex-shrink: 0; }
.composer input { flex: 1; }
.composer button { padding-inline: 14px; }

.catalog { min-width: 0; }
.cat-head { display: flex; gap: 10px; align-items: center; margin: 0 0 8px; }
.tabs { display: flex; gap: 8px; }
.tabs button.on, .cat.on { background: var(--accent); color: #fff; border-color: transparent; }
.cat-head input { max-width: 280px; }
.cats { display: flex; gap: 8px; overflow: auto; padding-bottom: 8px; }
.cat { background: transparent; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 12px; }
.poster {
  display: grid; gap: 6px; padding: 0; border: 0; background: transparent; text-align: left; color: inherit;
}
.poster .art {
  aspect-ratio: 2 / 3; border-radius: 14px; background: #152033 center/cover no-repeat;
  border: 1px solid var(--line); overflow: hidden;
}
.poster .art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .art.ph {
  display: grid; place-items: center;
  background: linear-gradient(180deg, #17304f, #10192b);
}
.poster .art.ph svg { width: 46%; height: auto; }
.poster:hover .art { transform: translateY(-3px); }
.poster strong { font-size: 13px; font-weight: 650; line-height: 1.25; }
.poster em { color: var(--muted); font-style: normal; font-size: 12px; }
.more { margin-top: 14px; }

.sheet {
  position: fixed; inset: 0; background: rgba(7, 17, 31, 0.55);
  display: grid; place-items: center; padding: 18px; z-index: 6;
}
.sheet-card { width: min(640px, 100%); max-height: min(80vh, 760px); overflow: auto; padding: 18px; }
.join-card { width: min(420px, 100%); }
.join-card h3 { margin: 16px 0 6px; font-size: 1.55rem; font-weight: 700; letter-spacing: -0.03em; }
.sheet-card h3 { margin: 8px 0; font-size: 1.45rem; font-weight: 700; }
.sheet-card p { color: var(--muted); }
.join-actions { display: flex; gap: 8px; }
.eps { display: grid; gap: 8px; }
.ep {
  text-align: left; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: #e8eef8; color: var(--ink); border-radius: 999px; padding: 10px 14px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 8; font-weight: 650;
}
.toast.show { opacity: 1; }

@media (max-width: 980px) {
  .cards, .layout { grid-template-columns: 1fr; }
  .main { display: contents; }
  .stage { order: 1; }
  .side {
    order: 2;
    position: relative;
    top: auto;
    height: 420px;
    max-height: 420px;
  }
  .catalog { order: 3; }
  .top { flex-wrap: wrap; }
  .top .codebox { margin-left: 0; }
  .cat-head { flex-direction: column; align-items: stretch; }
  .cat-head input { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
