:root {
  --bg: #030614;
  --panel: rgba(10, 18, 40, 0.94);
  --line: rgba(120, 170, 255, 0.18);
  --text: #e6eeff;
  --muted: #8ea0c4;
  --accent: #39d0ff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --bad: #ff5d6c;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden;
  overscroll-behavior: none; }
body { display: flex; flex-direction: column; height: 100dvh; }
button, select { font: inherit; color: var(--text); background: rgba(57, 208, 255, 0.08);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 38px; }
button:active { background: rgba(57, 208, 255, 0.25); }
button[aria-pressed="true"], button.on { background: var(--accent); color: #001018; border-color: var(--accent); }
button.danger { border-color: rgba(255, 93, 108, 0.5); color: var(--bad); }
a { color: var(--accent); }

.bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  padding-top: max(6px, env(safe-area-inset-top)); background: var(--panel);
  border-bottom: 1px solid var(--line); flex: none; }
.icon-btn { min-width: 38px; text-align: center; text-decoration: none; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center; }
a.icon-btn { border: 1px solid var(--line); border-radius: 10px; height: 38px; }
.title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title small { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.chip { padding: 6px 10px; min-height: 34px; font-size: 13px; }

.menu { position: absolute; top: 56px; right: 8px; left: 8px; z-index: 20; background: var(--panel);
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px;
  max-width: 420px; margin-left: auto; }
.menu[hidden] { display: none; }
.menu label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.menu-row { display: flex; gap: 8px; flex-wrap: wrap; }
.help { margin: 0; color: var(--muted); font-size: 12px; }

.stage { position: relative; flex: 1; overflow: hidden; touch-action: none; background: #000; }
.viewport { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#screen { display: block; image-rendering: auto; }
.cursor { position: absolute; width: 0; height: 0; pointer-events: none;
  border-left: 7px solid transparent; border-right: 7px solid transparent;
  border-bottom: 18px solid #fff; transform-origin: 50% 0; filter: drop-shadow(0 0 2px #000); }
.cursor[hidden] { display: none; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center; text-align: center; padding: 24px;
  background: rgba(3, 6, 20, 0.82); }
.overlay[hidden] { display: none; }
.overlay p { margin: 0; max-width: 320px; }

.keys { background: var(--panel); border-top: 1px solid var(--line); padding: 6px; display: grid;
  gap: 6px; flex: none; max-height: 40vh; overflow-y: auto; }
.keys[hidden] { display: none; }
.key-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.key-row button { flex: 1 0 auto; min-width: 46px; padding: 6px 8px; }

.dock { display: flex; gap: 6px; padding: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line); flex: none; overflow-x: auto; }
.dock button { flex: 1 0 auto; }
.kb-input { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0;
  border: 0; padding: 0; font-size: 16px; }

/* iPhone zooms the whole page into any field under 16px and stays zoomed (09.11). */
@media (pointer: coarse) { input, textarea, select { font-size: 16px !important; } }

/* 10.11: a camera is only watched — no PC controls meanwhile. */
/* 10.11: pan/tilt pad over the camera picture (only in camera mode). */
.ptz { display: none; }
body.camera-mode .ptz { display: grid; position: fixed; right: 16px; z-index: 5;
  bottom: calc(64px + env(safe-area-inset-bottom)); grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px); gap: 4px; }
.ptz button { border-radius: 50%; font-size: 20px; padding: 0; background: rgba(8, 14, 30, .72);
  border: 1px solid var(--line); color: #fff; touch-action: manipulation; }
.ptz button:active { background: rgba(60, 140, 255, .55); }
.ptz-up { grid-column: 2; grid-row: 1; } .ptz-left { grid-column: 1; grid-row: 2; }
.ptz-right { grid-column: 3; grid-row: 2; } .ptz-down { grid-column: 2; grid-row: 3; }
.ptz-note { grid-column: 1 / 4; grid-row: 2; align-self: center; text-align: center;
  pointer-events: none; font-size: 11px; color: #fff; text-shadow: 0 1px 2px #000; padding: 0 56px; }

body.camera-mode #modeBtn, body.camera-mode #keys, body.camera-mode #kbBtn, body.camera-mode #keysBtn, body.camera-mode #dragBtn, body.camera-mode #rightBtn, body.camera-mode #scrollUpBtn, body.camera-mode #scrollDownBtn, body.camera-mode #cursor { display: none !important; }
