:root {
  --bg: #f6f5f1; --surface: #ffffff; --surface-1: #f1efe8; --text: #1f1e1b; --text-2: #5f5e5a; --muted: #888780;
  --border: rgba(0,0,0,.12); --border-strong: rgba(0,0,0,.22);
  --accent: #185fa5; --accent-bg: #e6f1fb; --on-accent: #fff;
  --success: #3b6d11; --success-bg: #eaf3de; --warning: #854f0b; --warning-bg: #faeeda; --danger: #a32d2d; --danger-bg: #fcebeb;
  --radius: 8px; --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171716; --surface: #222220; --surface-1: #2c2c2a; --text: #ecebe6; --text-2: #b4b2a9; --muted: #888780;
    --border: rgba(255,255,255,.12); --border-strong: rgba(255,255,255,.24);
    --accent: #85b7eb; --accent-bg: #0c447c; --on-accent: #042c53;
    --success: #97c459; --success-bg: #27500a; --warning: #fac775; --warning-bg: #633806; --danger: #f09595; --danger-bg: #791f1f;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
[hidden] { display: none !important; }
h1 { font-size: 20px; font-weight: 500; margin: 0 0 6px; }
h2 { font-size: 15px; font-weight: 500; margin: 4px 0 6px; }
h3 { font-size: 13px; font-weight: 500; margin: 16px 0 6px; color: var(--text-2); }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 500; }
main { padding: 16px; }
.center { display: flex; justify-content: center; padding-top: 6vh; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.narrow { width: 100%; max-width: 420px; }

label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 0 4px; }
input { width: 100%; height: 38px; padding: 0 10px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.big { height: 46px; font-size: 22px; letter-spacing: 2px; }
button { height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: transparent; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover { background: var(--surface-1); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); margin-top: 16px; }
button.primary:hover { filter: brightness(1.08); }
form button.primary { width: 100%; justify-content: center; }
.tool { height: 32px; font-size: 13px; padding: 0 12px; }
.tool.on { background: var(--success-bg); color: var(--success); border-color: transparent; }
.tool.danger { color: var(--danger); }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 6px; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: var(--radius); background: var(--surface-1); color: var(--text-2); white-space: nowrap; }
.pill.ctl { background: var(--success-bg); color: var(--success); }
.pill.req { background: var(--warning-bg); color: var(--warning); }

.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.session { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
@media (max-width: 860px) { .session { grid-template-columns: minmax(0, 1fr); } }
.stage { border: 1px solid var(--border-strong); border-radius: var(--radius); background: #000; overflow: hidden; display: flex; flex-direction: column; outline: none; }
.stage:focus-visible, .stage.controlling { box-shadow: 0 0 0 2px var(--success); }
.stagebar { display: flex; gap: 8px; align-items: center; padding: 6px 12px; font-size: 12px; color: var(--text-2); background: var(--surface); border-bottom: 1px solid var(--border); }
.screenwrap { position: relative; height: calc(100vh - 210px); min-height: 280px; }
.stage:fullscreen .screenwrap { height: 100%; flex: 1; }
.stage:fullscreen .stagebar { display: none; }
video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.stage.controlling video { cursor: default; }
.screenwaiting { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #aaa; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
#controlArea { display: inline-flex; gap: 8px; align-items: center; }

.side { padding: 14px 16px; align-self: start; }
.plist, .activity { list-style: none; margin: 0; padding: 0; }
.plist li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.plist .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; flex: none; background: var(--accent-bg); color: var(--accent); }
.av.host { background: var(--surface-1); color: var(--text-2); }
.mic { font-size: 11px; color: var(--muted); width: 16px; text-align: center; }
.mic.live { color: var(--success); }
.activity li { font-size: 12px; color: var(--text-2); padding: 2px 0; }
#inviteLink { height: 32px; font-size: 12px; }

.reqbanner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--warning-bg); color: var(--warning); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.reqbanner span { flex: 1; min-width: 200px; }
.reqbanner button { height: 30px; font-size: 13px; color: var(--warning); border-color: currentColor; }
.reqbanner button.primary { margin: 0; color: var(--on-accent); border-color: var(--accent); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: var(--radius); font-size: 14px; z-index: 10; max-width: calc(100% - 32px); }

.downloads { margin-top: 20px; padding-top: 4px; border-top: 1px solid var(--border); }
.downloads .row { flex-wrap: wrap; }
a.dl { font-size: 13px; color: var(--accent); text-decoration: none; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); }
a.dl:hover { background: var(--surface-1); }

#screenSelect { height: 24px; font: inherit; font-size: 12px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; padding: 0 4px; }

a { color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }
.full-btn { width: 100%; justify-content: center; margin-top: 8px; height: 36px; }

.stage.expanded { position: fixed; inset: 0; z-index: 20; border-radius: 0; border: 0; }
.stage.expanded .stagebar { display: none; }
.stage.expanded .screenwrap { height: auto; flex: 1; }
.exitfull { position: absolute; top: 10px; right: 10px; height: 30px; font-size: 13px; background: rgba(0,0,0,.6); color: #fff; border-color: rgba(255,255,255,.35); opacity: .55; z-index: 2; }
.exitfull:hover { opacity: 1; background: rgba(0,0,0,.8); }
