:root {
  --bg: #f5f5f8; --panel: #ffffff; --line: #e7e7ee;
  --ink: #1b1b2b; --ink-soft: #5c5c70; --ink-faint: #9a9aae;
  --accent: #5b5bd6; --accent-deep: #4a4ac2; --accent-soft: #eef0fd;
  --danger: #d6554b; --stage: #0e1116;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  --shadow: 0 1px 2px rgba(27,27,43,.04), 0 4px 16px rgba(27,27,43,.06);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--ink-faint); }
.err { color: var(--danger); min-height: 18px; margin: 4px 0; font-size: 13px; }
.spacer { flex: 1; }

.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 11px; padding: 9px 14px; cursor: pointer; transition: all .12s; box-shadow: var(--shadow); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(91,91,214,.3); }
.btn.primary:hover { background: var(--accent-deep); }
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; box-shadow: none; }
.btn.ghost:hover { border-color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.wide { width: 100%; }

/* login */
.login { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 340px; display: flex; flex-direction: column; gap: 10px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 36px 30px; box-shadow: 0 10px 40px rgba(27,27,43,.1); }
.logo-lg { width: 54px; height: 54px; border-radius: 15px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: 24px; margin: 0 auto; }
.login-box h1 { margin: 8px 0 0; font-size: 21px; }
.login-box .muted { margin: 0 0 10px; font-size: 13px; }
.login-box input { padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg); }
.login-foot { position: fixed; bottom: 16px; left: 0; right: 0; text-align: center; color: var(--ink-faint); font-size: 11.5px; }

/* console */
.console { height: 100%; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; color: #fff; padding: 13px 20px;
  background: linear-gradient(135deg, #6a6ae0 0%, var(--accent) 55%, var(--accent-deep) 100%);
  box-shadow: 0 2px 12px rgba(74,74,194,.28); }
.logo { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.2); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); display: grid; place-items: center; font-family: var(--mono); font-weight: 700; }
.brand-name { font-weight: 650; font-size: 15.5px; }
.brand-sub { font-size: 11px; color: #e0e0fb; }
.conn-state { font-size: 12px; color: #e3e3fb; }

.stage-bar { padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.connect-inline { display: flex; align-items: center; gap: 10px; }
.connect-inline label { font-size: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .5px; }
.connect-inline input { font-family: var(--mono); font-size: 15px; letter-spacing: 2px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); width: 170px; }
.session-bar { display: flex; align-items: center; gap: 12px; }
.who { font-weight: 600; font-size: 14px; }
.meta { font-size: 12px; color: var(--ink-soft); font-family: var(--mono); }

.stage { flex: 1; margin: 14px 18px; border-radius: 16px; overflow: hidden; background: var(--stage);
  position: relative; display: grid; place-items: center; border: 1px solid #fff; box-shadow: 0 0 0 1px var(--line), var(--shadow); }
#video { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--stage); }
.stage.controlling #video { cursor: none; }
.ring { position: absolute; inset: 0; border: 2px solid #c6881f; border-radius: 16px; pointer-events: none; opacity: 0; transition: opacity .15s; }
.stage.controlling .ring { opacity: 1; }
.ctl-flag { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #c6881f;
  color: #241802; font-size: 11.5px; font-weight: 600; padding: 4px 12px; border-radius: 999px; opacity: 0; transition: opacity .15s; }
.stage.controlling .ctl-flag { opacity: 1; }
.stat { position: absolute; bottom: 12px; right: 14px; font-family: var(--mono); font-size: 11px; color: #cfd8e3; background: rgba(0,0,0,.45); padding: 3px 8px; border-radius: 6px; }
.empty { text-align: center; color: #a9b4c0; max-width: 420px; padding: 20px; }
.empty h3 { color: #e4e9ef; margin: 0 0 8px; font-size: 17px; }
.empty p { margin: 0; font-size: 13px; line-height: 1.6; }

.foot { padding: 9px 18px; border-top: 1px solid var(--line); background: var(--panel); color: var(--ink-faint); font-size: 11.5px; text-align: center; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 11px; font-size: 13.5px; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

@media (max-width: 620px) {
  .connect-inline input { width: 120px; }
  .stage { margin: 12px; }
}
