:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a; --text: #e8eaef; --muted: #9098a8;
  --accent: #4f8cff; --accent2: #3a73e0; --ok: #34c77b; --bad: #ff5d5d; --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 14px; cursor: pointer; touch-action: manipulation; }
button:hover { border-color: #3b4252; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent2); }
button.ghost { background: transparent; border-color: transparent; font-size: 20px; padding: 4px 10px; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; width: 100%; margin-top: 4px; }
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; margin: 12px 0; color: var(--muted); font-size: 14px; }
h1 { font-size: 22px; margin: 8px 0 4px; } h2 { font-size: 18px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.error { color: var(--bad); margin: 8px 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.narrow { width: min(380px, 100% - 32px); }
.center { min-height: 100%; display: flex; align-items: center; justify-content: center; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
#authForm .primary { width: 100%; margin-top: 8px; padding: 11px; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 2; }
.grow { flex: 1; }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px; }
.notice { background: #3a2f12; border: 1px solid #6b5518; color: #ffd98a; padding: 8px 12px; border-radius: 9px; margin-bottom: 12px; }
.devices { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.device { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.device .row { display: flex; align-items: center; gap: 12px; }
.device .pc { width: 42px; height: 42px; border-radius: 10px; background: var(--panel2); display: grid; place-items: center; font-size: 22px; flex: none; }
.device .name { font-weight: 600; word-break: break-word; }
.device .sub { font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #555c69; margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #34c77b33; }
.device .actions { display: flex; gap: 8px; }
.device .actions .primary { flex: 1; }
.empty { text-align: center; padding: 36px 20px; }
.tips { margin-top: 20px; } .tips summary { cursor: pointer; font-weight: 600; }
.tips table { border-collapse: collapse; margin-top: 10px; width: 100%; font-size: 14px; }
.tips th { text-align: left; padding: 12px 0 4px; color: var(--accent); }
.tips td { padding: 4px 12px 4px 0; border-top: 1px solid var(--line); } .tips td:first-child { color: var(--muted); width: 45%; }

.modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-card { width: min(440px, 100%); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.code { font: 700 34px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 4px; text-align: center; background: var(--bg);
  border: 1px dashed var(--line); border-radius: 10px; padding: 14px; margin: 14px 0; user-select: all; }
.steps { padding-left: 20px; margin: 8px 0; } .steps li { margin: 6px 0; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #222733;
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px); }

/* ---------- session ---------- */
#session { position: fixed; inset: 0; background: #000; overflow: hidden; }
#stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#canvas { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#video { display: block; width: 100%; height: 100%; background: #000; pointer-events: none; }
#stage.mouse { cursor: none; }
.status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  color: var(--muted); background: #000c; text-align: center; padding: 20px; }
.spinner { width: 34px; height: 34px; border: 3px solid #ffffff22; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toolbar { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; align-items: center;
  gap: 4px; background: #171a21e6; border: 1px solid var(--line); border-radius: 12px; padding: 4px; z-index: 10;
  backdrop-filter: blur(8px); max-width: calc(100% - 16px); }
.toolbar .tb-items { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.toolbar button { padding: 6px 10px; min-width: 38px; background: transparent; border-color: transparent; font-size: 15px; white-space: nowrap; }
.toolbar button:hover { background: var(--panel2); }
.toolbar button.on { background: var(--accent); color: #fff; }
.toolbar.collapsed .tb-items { display: none; }
.toolbar.collapsed { opacity: .55; }
.toolbar .tb-handle { min-width: 30px; padding: 6px; color: var(--muted); }
.toolbar.collapsed .tb-handle { transform: rotate(180deg); }

.sheet { position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 52px); left: 50%; transform: translateX(-50%); z-index: 11;
  width: min(620px, calc(100% - 16px)); max-height: calc(100% - 80px); overflow: auto; background: #171a21f2; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; backdrop-filter: blur(8px); }
.sheet h4 { margin: 6px 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sheet-group { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { padding: 6px 11px; font-size: 14px; }
.chips button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.stats { position: absolute; left: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 9; background: #000b; color: #cfd6e4;
  font: 12px/1.4 ui-monospace, Consolas, monospace; padding: 6px 9px; border-radius: 8px; pointer-events: none; white-space: pre; }
#kb { position: fixed; left: 0; top: 0; width: 2px; height: 2px; opacity: 0; font-size: 16px; border: 0; padding: 0; resize: none; z-index: -1; }
/* Where the remote pointer is being aimed. In trackpad mode this is the only thing that shows it,
   and it moves locally with no round trip, so a slow link no longer means waiting for the picture
   to catch up before you can click. Also used on the secure desktop, which is captured without a
   hardware cursor. The centre dot is the exact point a click lands on. */
.touch-cursor { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1px #000, 0 0 6px rgba(0,0,0,.8); pointer-events: none; z-index: 5; }
.touch-cursor::after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px;
  background: #fff; border-radius: 50%; box-shadow: 0 0 0 1px #000; }
.switch { text-align: center; margin: 14px 0 0; font-size: 14px; } a { color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); } .check input { width: auto; margin: 0; }
.table-wrap { max-height: 45vh; overflow: auto; }
table.admin { width: 100%; border-collapse: collapse; font-size: 14px; }
table.admin th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 4px; }
table.admin td { border-top: 1px solid var(--line); padding: 6px 4px; word-break: break-all; }
table.admin input { width: 90px; padding: 5px 8px; margin: 0; }

.downloads { margin-top: 20px; } .small { font-size: 13px; margin: 10px 0 0; }
.dl-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-top: 10px; }
.dl { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); color: var(--text); text-decoration: none; }
.dl:hover { border-color: var(--accent); }
.dl small { display: block; color: var(--muted); font-size: 12.5px; }
.dl-ic { font-size: 26px; }
.dl.off { opacity: .5; pointer-events: none; }

/* connect by ID, groups, orgs */
.connect-card { margin-bottom: 18px; }
.id-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.id-row input { margin: 0; flex: 1 1 200px; }
.id-row input[name=number] { font: 600 18px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 1px; flex-basis: 240px; }
.id-row button { flex: 0 0 auto; padding: 10px 22px; }
.recent { margin-top: 10px; align-items: center; }
.recent button { font-size: 13px; padding: 4px 10px; }
h3.group { font-size: 15px; margin: 22px 0 10px; } h3.group .muted { font-weight: 400; font-size: 13px; margin-left: 6px; }
.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: .5px; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line); margin-left: 4px; color: var(--muted); }
.badge.ok { color: var(--ok); border-color: #34c77b55; }
select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; margin-top: 4px; }
label select { width: 100%; }
.org { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.org .add-member { margin-top: 8px; gap: 6px; } .org .add-member input { margin: 0; } .org .add-member select { margin: 0; }
.org table.admin select { margin: 0; padding: 4px 6px; }
.row { display: flex; align-items: center; gap: 8px; }
button.link { background: none; border: 0; color: var(--accent); padding: 2px 0; }
button.link.danger { color: var(--bad); }
.modal-card { max-height: calc(100vh - 32px); overflow: auto; }
.note-line { margin: 8px 0 0; font-size: 13px; color: #ffcf8a; }
.note-line a { color: var(--accent); }
