:root {
  color-scheme: dark;
  --bg: #121416;
  --rail: #1b1e22;
  --card: #24272c;
  --stroke: rgba(255, 255, 255, 0.08);
  --text: #f2f3f1;
  --muted: rgba(242, 243, 241, 0.58);
  --accent: #61c7b3;
  --danger: #ed6b61;
  --busy: #e6c26a;
  font-family: "SF Pro Text", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-sheet { width: min(24rem, calc(100vw - 2rem)); }
.login-sheet h1 { margin: 0.35rem 0 0.4rem; }
.login-sheet .primary { width: 100%; margin-top: 0.6rem; padding: 0.7rem; }

.app {
  display: grid;
  grid-template-columns: 20rem 1fr;
  min-height: 100%;
}

.rail {
  display: flex;
  flex-direction: column;
  background: var(--rail);
  border-right: 1px solid var(--stroke);
  padding: 1.2rem 1.1rem;
  min-height: 100vh;
}

.rail-head, .me-pass, .viewer-bar, .sheet-actions, .status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.eyebrow {
  margin: 0;
  font: 600 0.7rem/1 ui-monospace, Menlo, monospace;
  letter-spacing: 0.14em;
  color: var(--muted);
}

h1, h2 { margin: 0.2rem 0 0; font-weight: 600; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.2rem; }

.status-line { justify-content: flex-start; margin: 1rem 0 0.4rem; color: var(--muted); font-size: 0.8rem; }
.dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: rgba(255,255,255,0.25); }
.dot.on { background: var(--accent); }

.roster { list-style: none; margin: 0.4rem 0 0; padding: 0; flex: 1; overflow: auto; }
.roster-item {
  display: flex;
  align-items: stretch;
  gap: 0.15rem;
  margin: 0.2rem 0;
}
.roster-item button.roster-main {
  flex: 1;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  color: inherit;
  padding: 0.7rem 0.65rem;
  cursor: pointer;
}
.roster-item button.roster-main:hover { background: rgba(255,255,255,0.04); border-color: var(--stroke); }
.roster-item button.roster-gear {
  background: transparent;
  color: var(--muted);
  padding: 0 0.45rem;
  border-radius: 10px;
}
.roster-item button.roster-gear:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.roster .name { display: block; font-weight: 600; }
.roster .meta { display: block; margin-top: 0.15rem; color: var(--muted); font: 0.75rem ui-monospace, Menlo, monospace; }
.roster .pill { float: right; font-size: 0.68rem; color: var(--accent); }
.roster .pill.busy { color: var(--busy); }
.roster .pill.view { color: var(--muted); }
.roster-item.self .roster-main { opacity: 0.55; cursor: default; }

.empty, .muted, .label { color: var(--muted); }
.empty { font-size: 0.82rem; line-height: 1.45; margin-top: 0.8rem; }
.label { margin: 0; font-size: 0.7rem; font-weight: 600; }

.me {
  border-top: 1px solid var(--stroke);
  padding-top: 0.9rem;
  margin-top: 0.8rem;
}
.me-name { margin: 0.2rem 0 0; font-weight: 600; }
.mono { margin: 0.15rem 0 0; font: 500 0.9rem/1.3 ui-monospace, Menlo, monospace; }

.stage { position: relative; min-height: 100vh; }
.idle {
  max-width: 28rem;
  margin: 18vh auto 0;
  padding: 0 1.5rem;
}
.idle h2 { margin: 0.4rem 0 0.7rem; }

.viewer { display: flex; flex-direction: column; height: 100vh; }
.viewer-bar, .host-banner {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--stroke);
}
.host-banner { display: flex; align-items: center; justify-content: space-between; }

.screen {
  position: relative;
  flex: 1;
  background: #000;
  min-height: 0;
  outline: none;
  touch-action: none;
}
#captureVideo {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 220px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  z-index: 6;
  display: none;
  background: #000;
}
#captureVideo.on { display: block; }
#remoteVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: none;
}
#remoteVideo.live { display: block; }
#remote {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: default;
  outline: none;
  touch-action: none;
  user-select: none;
}
.screen.live-video #remote { opacity: 0; }
#remote.control, .screen { cursor: default; }
.waiting {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: rgba(255,255,255,0.55);
  pointer-events: none;
}
.waiting.hidden { display: none; }
.row-actions { display: flex; gap: 0.5rem; align-items: center; }

.banner { color: var(--danger); font-size: 0.8rem; margin: 0.4rem 0 0; }
.hidden { display: none !important; }

button { font: 600 0.85rem/1 inherit; border: 0; border-radius: 8px; cursor: pointer; }
.primary { background: var(--accent); color: #10221e; padding: 0.55rem 0.9rem; }
.danger { background: #4a2422; color: #ffd6d2; padding: 0.5rem 0.8rem; }
.ghost, .icon-btn { background: transparent; color: var(--muted); padding: 0.35rem 0.45rem; }

dialog { border: 0; padding: 0; background: transparent; }
dialog::backdrop { background: rgba(0,0,0,0.55); }
.sheet {
  width: min(24rem, calc(100vw - 2rem));
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 1.15rem;
}
.sheet label { display: block; margin: 0.7rem 0; font-size: 0.75rem; color: var(--muted); }
.sheet fieldset {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  margin: 0.8rem 0;
  padding: 0.35rem 0.75rem 0.55rem;
}
.sheet legend { color: var(--muted); font-size: 0.72rem; padding: 0 0.25rem; }
.sheet fieldset .check { margin: 0.4rem 0; }
.sheet input[type="text"], .sheet input[type="password"], .sheet input[type="url"] {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  background: rgba(0,0,0,0.28);
  color: var(--text);
  font: inherit;
}
.check { display: flex; align-items: center; gap: 0.45rem; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .rail { min-height: auto; }
  .stage { min-height: 70vh; }
}
