:root {
  --bg: #0d0e12;
  --panel: #16181e;
  --panel-2: #1d2028;
  --line: #2a2e39;
  --text: #e8eaf0;
  --muted: #8b91a1;
  --accent: #ff7a59;
  --accent-ink: #1a0d08;
  --ok: #4cd08a;
  --warn: #f2b84b;
  --bad: #f0616d;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input:not([type=range]):not([type=checkbox]) {
  width: 100%;
  min-width: 0;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}
input::placeholder { color: #5d6373; }
input:not([type=range]):focus { border-color: var(--accent); outline: none; }

.btn {
  padding: 9px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: #444a5a; background: #242833; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: #ff8d70; border-color: #ff8d70; }
.btn-ghost { background: transparent; }
.btn-small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: .02em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M12 9.5v13l11-6.5z' fill='%231a0d08'/%3E%3C/svg%3E") center/100% no-repeat;
}
/* 黑橙字标：开场动画和大厅标题共用 */
.logo {
  display: flex; align-items: center; gap: .1em;
  font-weight: 800; line-height: 1; letter-spacing: .02em;
  color: #fff; white-space: nowrap;
}
.logo-box { padding: .1em .2em .12em; border-radius: .14em; background: #ff9000; color: #000; }
.brand-sm .brand-mark { width: 24px; height: 24px; border-radius: 7px; }
.brand-sm strong { font-size: 15px; }

/* ---------- 大厅 ---------- */
.lobby {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(255, 122, 89, .13), transparent 70%),
    var(--bg);
}
.lobby-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.lobby-card .brand { margin-bottom: 24px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.field em { font-style: normal; font-size: 12px; opacity: .7; }
.form-error { margin: 0 0 14px; padding: 8px 12px; border-radius: 8px; background: rgba(240, 97, 109, .12); color: var(--bad); }
.lobby-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lobby-points { margin: 24px 0 0; padding: 18px 0 0 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.lobby-points li + li { margin-top: 4px; }

/* ---------- 房间 ---------- */
.room { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 13px;
}
.chip b { color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.chip-action { padding: 2px 9px; border-radius: 999px; background: var(--panel-2); font-size: 12px; }
.chip:hover .chip-action { background: var(--accent); color: var(--accent-ink); }

.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn[data-state=online] i { background: var(--ok); }
.conn[data-state=offline] i { background: var(--bad); }

.layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  padding: 16px;
  max-width: 1680px; width: 100%; margin: 0 auto;
}
.stage { min-width: 0; }

/* ---------- 播放器 ---------- */
.shell {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 170px);
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  user-select: none;
}
.shell video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.shell:fullscreen { border-radius: 0; max-height: none; }
.shell:-webkit-full-screen { border-radius: 0; max-height: none; width: 100vw; height: 100vh; }
.shell.idle { cursor: none; }
video::cue { background: transparent; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000, 1px 1px 2px #000; }

.danmaku-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; font-size: clamp(15px, 2.1vw, 26px); }
.danmaku-layer.off { display: none; }
.danmaku {
  position: absolute; left: 100%; white-space: nowrap;
  color: #fff; font-weight: 600;
  text-shadow: 0 0 2px #000, 1px 1px 2px #000, -1px -1px 2px #000;
  animation: fly 9s linear forwards;
  will-change: transform;
}
.danmaku.mine { outline: 1px solid rgba(255, 255, 255, .55); outline-offset: 2px; border-radius: 3px; }
@keyframes fly { to { transform: translateX(calc(-100vw - 100%)); } }

.spinner {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; border: 4px solid rgba(255, 255, 255, .22); border-top-color: var(--accent);
  animation: spin 1s linear infinite; pointer-events: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center;
  background: rgba(8, 9, 12, .82);
  color: #c9cdd8;
}
.overlay p { margin: 0; max-width: 460px; overflow-wrap: anywhere; }

.controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 28px 12px 8px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .78));
  transition: opacity .2s;
}
.shell.idle .controls { opacity: 0; pointer-events: none; }

.progress { position: relative; height: 16px; cursor: pointer; touch-action: none; }
.progress::before, .progress-buffer, .progress-current {
  content: ""; position: absolute; left: 0; top: 6px; height: 4px; border-radius: 2px;
}
.progress::before { right: 0; background: rgba(255, 255, 255, .22); }
.progress-buffer { background: rgba(255, 255, 255, .38); width: 0; }
.progress-current { background: var(--accent); width: 0; }
.progress-current::after {
  content: ""; position: absolute; right: -6px; top: -4px; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; transform: scale(0); transition: transform .12s;
}
.progress:hover .progress-current::after, .progress.dragging .progress-current::after { transform: scale(1); }
.progress.live { visibility: hidden; }

.controls-row { display: flex; align-items: center; gap: 6px; }
.icon-btn, .text-btn {
  flex: none; width: 34px; height: 34px; padding: 6px;
  background: none; border: 0; border-radius: 8px; color: #fff;
}
.icon-btn:hover, .text-btn:hover { background: rgba(255, 255, 255, .14); }
.icon-btn svg { width: 100%; height: 100%; fill: currentColor; display: block; }
.text-btn { font-size: 13px; font-weight: 700; opacity: .55; }
.text-btn.on { opacity: 1; }
#playBtn .ic-pause, #playBtn.playing .ic-play { display: none; }
#playBtn.playing .ic-pause { display: block; }
#muteBtn .ic-muted, #muteBtn.muted .ic-vol { display: none; }
#muteBtn.muted .ic-muted { display: block; fill: currentColor; }
.time { flex: none; margin: 0 6px; font-size: 12px; color: #fff; font-variant-numeric: tabular-nums; }
.danmaku-input {
  flex: 1; min-width: 60px;
  padding: 6px 12px !important;
  background: rgba(255, 255, 255, .12) !important;
  border-color: transparent !important;
  border-radius: 999px !important;
  color: #fff; font-size: 13px;
}
.danmaku-input::placeholder { color: rgba(255, 255, 255, .55); }
.volume { flex: none; width: 72px; accent-color: var(--accent); }
.mini-select {
  flex: none; padding: 4px 4px; background: rgba(255, 255, 255, .12); border: 0; border-radius: 6px;
  color: #fff; font-size: 12px;
}
.mini-select option { color: #000; }

/* ---------- 状态栏 ---------- */
.statusbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px;
  margin-top: 12px; padding: 12px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.now-playing { min-width: 0; flex: 1 1 220px; }
.np-label { display: block; font-size: 11px; color: var(--muted); letter-spacing: .08em; }
.np-title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-items { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 12px; color: var(--muted); }
.status-items b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.switch input:disabled + span { opacity: .5; }

/* ---------- 侧栏 ---------- */
.side {
  display: flex; flex-direction: column; min-height: 0;
  height: calc(100vh - 86px);
  position: sticky; top: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: 12px 6px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); font-size: 13px;
}
.tab i { font-style: normal; font-size: 11px; opacity: .8; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.pane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.pane.active { display: flex; }

.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px; overscroll-behavior: contain; }
.msg { margin-bottom: 8px; overflow-wrap: anywhere; }
.msg .who { color: var(--muted); margin-right: 6px; }
.msg.mine .who { color: var(--accent); }
.msg.sys { color: var(--muted); font-size: 12px; text-align: center; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }

.add-form { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.add-actions { display: flex; gap: 8px; }
.add-actions .btn-ghost { margin-left: auto; }
.playlist, .members { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.playlist { flex: 1; min-height: 0; }
.playlist li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 8px 8px 10px; border-radius: 8px;
}
.playlist li:hover { background: var(--panel-2); }
.playlist li.current { background: rgba(255, 122, 89, .12); }
.playlist li.current .pl-title { color: var(--accent); font-weight: 600; }
.pl-main { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; }
.pl-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-meta { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-del { flex: none; width: 28px; height: 28px; background: none; border: 0; border-radius: 6px; color: var(--muted); }
.pl-del:hover { background: rgba(240, 97, 109, .15); color: var(--bad); }
.empty { margin: 0; padding: 24px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.members li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #10131a;
}
.m-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.tag.host { background: rgba(255, 122, 89, .16); color: var(--accent); }
.settings { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.settings h3 { margin: 0; font-size: 13px; }
.settings small { font-weight: 400; color: var(--muted); }
.bili-form { display: grid; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.bili-row { display: flex; gap: 8px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------- 提示 ---------- */
.toasts {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 2147483647; pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  padding: 8px 16px; border-radius: 999px;
  background: rgba(30, 33, 42, .96); border: 1px solid var(--line);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .4);
  font-size: 13px; animation: toast-in .2s ease;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toast.err { border-color: var(--bad); color: #ffc2c7; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }

/* ---------- 窄屏 ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 0 0 16px; gap: 12px; }
  .shell { border-radius: 0; max-height: 60vh; }
  .statusbar { margin: 12px 12px 0; }
  .side { position: static; height: 70vh; margin: 0 12px; }
  .topbar { padding: 8px 12px; gap: 10px; }
  .brand-sm strong, .conn span, .volume, .danmaku-input { display: none; }
  .controls-row { justify-content: flex-start; }
  .time { margin-right: auto; }
}

/* ---------- 开场动画 ---------- */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  background: #000;
  animation: splash-out .4s ease 1.7s forwards;
}
.splash.skip { animation-delay: 0s; }
.splash-logo {
  font-size: clamp(34px, 10vw, 76px);
  animation: splash-pulse .3s ease-in-out 1.15s;
}
.splash-a { animation: splash-a .3s ease-out .15s both; }
.splash-b { animation: splash-b .4s cubic-bezier(.2, 1.6, .4, 1) .55s both; }
@keyframes splash-a { from { opacity: 0; transform: translateX(-.4em); } }
@keyframes splash-b { from { opacity: 0; transform: scale(.3); } }
@keyframes splash-pulse { 50% { transform: scale(1.06); } }
@keyframes splash-out { to { opacity: 0; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  .toast, .progress-current::after { animation: none; transition: none; }
  .splash { display: none; }
}

.pane[data-pane=people] { overflow-y: auto; }
.members { flex: none; }

.bili-qr { display: grid; justify-items: center; gap: 8px; padding: 8px 0; }
.bili-qr img { border-radius: 8px; background: #fff; }
.bili-manual summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.bili-manual[open] summary { margin-bottom: 8px; }
.bili-manual .hint { margin-top: 8px; }

.field-inline { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.select { width: 100%; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: 13px; }
.select:disabled { opacity: .6; }

/* ---------- 设置弹窗 ---------- */
.lobby-card { position: relative; }
.lobby-settings { position: absolute; top: 18px; right: 18px; }
.dialog {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; overflow-y: auto;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px;
}
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 20px; }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-sec { display: grid; gap: 10px; padding: 16px 20px; }
.dialog-sec + .dialog-sec { border-top: 1px solid var(--line); }
.dialog-sec h3 { margin: 0; font-size: 13px; }
.login-status { margin-left: 6px; font-weight: 400; font-size: 12px; color: var(--muted); }
.login-status.ok { color: var(--ok); }
