* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0e1013; color: #e8eaee; font: 15px -apple-system, system-ui, sans-serif; overscroll-behavior: none; }
.hidden { display: none !important; }
.muted { color: #8b93a0; font-size: 13px; }
.err { color: #ff8d84; font-size: 13px; min-height: 1em; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- home ---------- */
#home { padding: calc(env(safe-area-inset-top) + 14px) 16px 16px; overflow-y: auto; gap: 12px; }
.home-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.home-head h1 { font-size: 22px; margin: 0; }
.pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: #123a22; color: #5bd58a; }
.pill.mid { background: #33301a; color: #e8cf6a; }
.pill.bad { background: #3a1a18; color: #ff8d84; }
.pill.dim { background: #1d2026; color: #8b93a0; font-weight: 500; }
.card { background: #171a20; border: 1px solid #262b34; border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 14px; margin: 0 0 8px; color: #aeb6c2; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.row.center { justify-content: center; }
.lbl { width: 84px; color: #8b93a0; font-size: 13px; }
input, .btn { font-size: 16px; }
input { background: #10131a; border: 1px solid #2c3340; color: #fff; border-radius: 8px; padding: 10px 12px; flex: 1; min-width: 0; }
.btn { background: #2f6fed; color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 700; }
.btn.ghost { background: #262b34; }
.btn:active { opacity: .8; }
.host-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.host { background: #171a20; border: 1px solid #262b34; border-radius: 14px; padding: 14px; display: flex; align-items: center; gap: 12px; }
.host .dot { width: 10px; height: 10px; border-radius: 50%; background: #555; flex: none; }
.host.online .dot { background: #47d97e; }
.host .hname { font-weight: 700; }
.host .hsub { color: #8b93a0; font-size: 12px; }
.host .hgo { margin-left: auto; }
.host button.hforget { background: none; border: none; color: #6b7280; font-size: 18px; padding: 6px; }
.snip-k { font-weight: 700; flex: 0 0 auto; }
.snip-v { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.snip-del { background: none; border: none; color: #6b7280; font-size: 16px; padding: 4px 6px; }

/* ---------- dialogs ---------- */
dialog { background: #171a20; color: #e8eaee; border: 1px solid #2c3340; border-radius: 16px; padding: 18px; width: min(90vw, 340px); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 10px; font-size: 16px; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 14px; color: #aeb6c2; margin: 10px 0; }
.menu { display: flex; flex-direction: column; gap: 6px; }
.menu-it { background: #1d222b; border: 0; color: #e8eaee; padding: 13px; border-radius: 10px; font-size: 15px; text-align: left; }
.menu-lbl { display: block; }
.menu-sub { display: block; color: #8b93a0; font-size: 12px; margin-top: 3px; line-height: 1.35; }
.menu-it.danger { color: #ff8d84; }
.menu-it.ghost { color: #8b93a0; background: none; }

/* ---------- session ---------- */
#session { background: #000; touch-action: none; }
#stage { position: absolute; inset: 0; overflow: hidden; }
#videoWrap { position: absolute; inset: 0; transform-origin: 0 0; }
#video { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
/* Semi-transparent white dot with a blue glow; the dot centre is the exact click point. */
#remoteCursor { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.55); margin: -5px 0 0 -5px; pointer-events: none; z-index: 5; box-shadow: 0 0 10px 3px rgba(47,111,237,.95); }

#statusBar { position: absolute; top: 0; left: 0; right: 0; display: flex; gap: 8px; align-items: center; padding: calc(env(safe-area-inset-top) + 6px) 10px 6px; background: linear-gradient(rgba(0,0,0,.75), rgba(0,0,0,0)); z-index: 20; }
.sb-btn { background: rgba(30,34,42,.85); color: #cfd5de; border: 0; border-radius: 8px; padding: 7px 11px; font-size: 15px; }
.spacer { flex: 1; }

#toolbar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 6px; padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.8)); z-index: 20; overflow-x: auto; }
.tb-btn { background: rgba(30,34,42,.9); color: #e8eaee; border: 1px solid #2c3340; border-radius: 10px; padding: 9px 13px; font-size: 14px; font-weight: 600; white-space: nowrap; }
/* phone widths: compress so ALL toolbar buttons fit without sideways scrolling */
@media (max-width: 440px) {
  #toolbar { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .tb-btn { padding: 8px 8px; font-size: 12.5px; }
}
.tb-btn.active { background: #2f6fed; border-color: #2f6fed; }

/* overlay */
.overlay { position: absolute; inset: 0; background: rgba(6,8,10,.82); display: flex; align-items: center; justify-content: center; z-index: 30; }
.overlay-box { text-align: center; padding: 24px; max-width: 320px; }
#overlayMsg { font-size: 17px; font-weight: 700; margin: 12px 0 4px; }
.spin { width: 34px; height: 34px; border: 3px solid #2c3340; border-top-color: #2f6fed; border-radius: 50%; margin: 0 auto; animation: spin 0.9s linear infinite; }
.spin.paused { animation: none; border-top-color: #ff8d84; }
@keyframes spin { to { transform: rotate(360deg); } }

/* legend */
.legend { position: absolute; top: 60px; right: 10px; background: rgba(14,16,19,.92); border: 1px solid #2c3340; border-radius: 12px; padding: 12px 34px 12px 14px; font-size: 12.5px; color: #aeb6c2; z-index: 25; line-height: 1.75; max-height: 70vh; overflow-y: auto; }
#legendClose { position: absolute; top: 6px; right: 6px; background: none; border: none; color: #aeb6c2; font-size: 16px; padding: 4px 8px; }

/* keybar (layer B) */
#keybar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #14171c; border-top: 1px solid #262b34; padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px); }
.kb-hide { position: absolute; top: -29px; right: 10px; height: 29px; background: #14171c; border: 1px solid #262b34; border-bottom: none; border-radius: 9px 9px 0 0; color: #aeb6c2; font-size: 13px; font-weight: 600; padding: 4px 16px; }
#keybar .kb-row { display: flex; gap: 4px; margin: 4px 0; overflow-x: auto; }
.kb { flex: 1 0 auto; min-width: 40px; background: #1f242d; border: 1px solid #2c3340; color: #e8eaee; border-radius: 7px; padding: 9px 8px; font-size: 13.5px; text-align: center; font-weight: 600; }
.kb:active { background: #2b3341; }
.kb.armed { background: #2f6fed; border-color: #2f6fed; }
.kb.locked { background: #7a3fe0; border-color: #7a3fe0; }
.kb.danger { color: #ff8d84; }
.kb.small { font-size: 12px; min-width: 34px; }

/* hidden input for iOS keyboard: visually hidden but focusable, above keybar */
#hiddenInput { position: fixed; left: 8px; bottom: 4px; width: 40vw; height: 30px; opacity: 0.02; z-index: 39; border: none; background: #000; color: #fff; caret-color: transparent; }

#toasts { position: fixed; top: calc(env(safe-area-inset-top) + 52px); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 60; pointer-events: none; }
.toast { background: #1d222b; border: 1px solid #2c3340; border-radius: 10px; padding: 9px 14px; font-size: 13.5px; max-width: 86vw; }
.toast.err { border-color: #b3372f; color: #ffb3ad; }
.toast.warn { border-color: #8a7a22; color: #e8cf6a; }
