:root {
  --bg: #0d0918;
  --bg-soft: #171029;
  --card: rgba(255, 255, 255, .045);
  --card-strong: rgba(255, 255, 255, .075);
  --line: rgba(255, 255, 255, .085);
  --text: #f3eeff;
  --muted: #a89dc5;
  --accent: #8f6fe8;
  --accent-soft: rgba(143, 111, 232, .18);
  --sweet: #ff86b8;
  --danger: #ff6b8a;
  --radius: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background:
    radial-gradient(1100px 620px at 12% -10%, rgba(143, 111, 232, .22), transparent 60%),
    radial-gradient(900px 520px at 96% 4%, rgba(255, 134, 184, .12), transparent 58%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(13, 9, 24, .72);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  border-radius: 11px;
  box-shadow: 0 6px 18px rgba(143, 111, 232, .3);
}

.brand b {
  display: block;
  font-size: 15.5px;
  letter-spacing: .04em;
}

.brand em {
  display: block;
  font-size: 11.5px;
  font-style: normal;
  color: var(--muted);
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card-strong) center/cover no-repeat;
}

button, .primary {
  font: inherit;
  border-radius: 11px;
  border: 1px solid var(--line);
  padding: 9px 15px;
  color: var(--text);
  background: var(--card);
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

button:hover, .primary:hover { background: var(--card-strong); }
button:active, .primary:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: default; }

.ghost { background: transparent; }
.danger { border-color: rgba(255, 107, 138, .4); color: #ffc2ce; }
.wide { width: 100%; }

.primary {
  background: linear-gradient(135deg, rgba(143, 111, 232, .95), rgba(255, 134, 184, .8));
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 11px 18px;
  box-shadow: 0 10px 26px rgba(143, 111, 232, .28);
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 28px 22px 40px;
  min-height: 0;
}

.panel {
  width: min(760px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  backdrop-filter: blur(18px);
  align-self: flex-start;
}

.panel.login {
  max-width: 420px;
  margin-top: 6vh;
}

.panel h1 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: .02em;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
  line-height: 1.6;
}

.panel.login .primary { width: 100%; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin: 20px 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.mail-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mail-form .row {
  display: flex;
  gap: 8px;
}

.mail-form .row input { flex: 1; min-width: 0; }

input {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, .28);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus {
  border-color: rgba(143, 111, 232, .7);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.status {
  min-height: 18px;
  font-size: 12.5px;
  color: var(--muted);
  margin: 4px 0 0;
}

.status.error { color: #ffb2c0; }

.section-head {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--muted);
  text-transform: uppercase;
}

.section-head button { margin-left: auto; }

.device-list {
  display: grid;
  gap: 10px;
}

.device {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}

.device:hover {
  background: var(--card-strong);
  border-color: rgba(143, 111, 232, .45);
}

.device:active { transform: scale(.995); }
.device[aria-disabled="true"] { opacity: .5; cursor: default; }

.device .glyph {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 19px;
  background: var(--accent-soft);
}

.device .meta { flex: 1; min-width: 0; }
.device .meta b { display: block; font-size: 14.5px; font-weight: 600; }
.device .meta small { color: var(--muted); font-size: 12px; }

.device .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4a4462;
}

.device .dot.online { background: #5ee6a8; box-shadow: 0 0 10px rgba(94, 230, 168, .7); }
.device .dot.busy { background: #ffc760; box-shadow: 0 0 10px rgba(255, 199, 96, .6); }

.empty {
  padding: 34px 10px;
  text-align: center;
  color: var(--muted);
}

.empty p { margin: 0 0 6px; font-size: 14.5px; color: var(--text); }
.empty small { font-size: 12.5px; line-height: 1.6; display: block; }

.session {
  width: min(1280px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #05030b;
  border: 1px solid var(--line);
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  cursor: crosshair;
}

.stage:fullscreen { border-radius: 0; aspect-ratio: auto; width: 100vw; height: 100vh; }

.stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #05030b;
}

.stage-status {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  color: #cfc4ea;
  background: radial-gradient(circle at 50% 50%, rgba(20, 13, 36, .5), rgba(5, 3, 11, .9));
  pointer-events: none;
  text-align: center;
  padding: 20px;
}

.stage-status[hidden] { display: none; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
}

.toolbar .spacer { flex: 1; }
.toolbar .stat { color: var(--muted); font-variant-numeric: tabular-nums; }

.dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(5, 3, 11, .66);
  backdrop-filter: blur(6px);
  padding: 20px;
}

.dialog[hidden] { display: none; }

.dialog-body {
  width: min(380px, 100%);
  background: #171029;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}

.dialog-body h3 { margin: 0 0 4px; font-size: 17px; }
.dialog-body .hint { margin: 0; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line);
}

.version {
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  padding: 2px 6px;
  border-radius: 7px;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.version:active { background: rgba(255, 255, 255, .06); }

.muted { color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(23, 16, 41, .95);
  border: 1px solid var(--line);
  font-size: 13px;
  z-index: 60;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  animation: rise .22s ease;
}

.toast[hidden] { display: none; }

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 640px) {
  main { padding: 16px 12px 26px; }
  .panel { padding: 20px; }
  .topbar { padding: 11px 14px; }
  .brand em { display: none; }
  .panel.login { margin-top: 2vh; }
  .stage { aspect-ratio: 4 / 3; }
  .toolbar { flex-wrap: wrap; }
}
