/* BlueSky Remote — fixed, non-zoomable outer frame (Tyson's standing rule):
   the page itself never scrolls or rubber-bands; only inner panes scroll. */
:root {
  --bg: #0b0f17; --panel: #131a26; --panel2: #1b2534; --line: #263247;
  --text: #e7edf5; --muted: #8ea0ba; --accent: #3d7dff; --accent2: #22d3ee;
  --good: #34d399; --bad: #f87171; --warn: #fbbf24; --radius: 12px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; touch-action: manipulation;
  overscroll-behavior: none;
}
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
a { color: var(--accent2); }
button {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); padding: 9px 14px;
  border-radius: 10px; transition: .15s;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--bad); border-color: #4a2530; }
button:disabled { opacity: .5; cursor: default; }
input, textarea {
  font: inherit; width: 100%; background: #0c1220; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.pill { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); }
.pill.on { color: var(--good); border-color: #1d4a3a; background: #0e2a20; }
.pill.off { color: var(--muted); }

/* top bar */
header {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--line); background: var(--panel); flex: 0 0 auto;
}
.logo { font-weight: 700; letter-spacing: .3px; }
.logo b { color: var(--accent2); }
header .spacer { flex: 1; }

main { flex: 1; min-height: 0; overflow-y: auto; padding: 22px; }
.wrap { max-width: 920px; margin: 0 auto; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 4px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.device { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.device h4 { margin: 0; font-size: 17px; }
.device .meta { font-size: 13px; color: var(--muted); }
.device .actions { margin-top: auto; display: flex; gap: 8px; }

/* auth screen */
.center { display: grid; place-items: center; height: 100%; }
.auth { width: min(400px, 92vw); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.err { color: var(--bad); font-size: 14px; min-height: 18px; margin-top: 6px; }

code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
pre.cmd { background: #0c1220; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-x: auto; font-size: 13px; }
.codebig { font-size: 34px; letter-spacing: 6px; font-weight: 700; color: var(--accent2); text-align: center; }

/* viewer / remote screen */
#viewer { position: fixed; inset: 0; background: #000; display: none; flex-direction: column; z-index: 50; }
#viewer.show { display: flex; }
#viewer .vbar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: rgba(15,20,30,.92); border-bottom: 1px solid var(--line); flex: 0 0 auto; }
#viewer .stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; }
#remoteVideo { max-width: 100%; max-height: 100%; touch-action: none; outline: none; }
.status { font-size: 13px; color: var(--muted); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 200; }

/* ---- expanded viewer ---- */
#viewer .vbar { gap: 6px; overflow-x: auto; white-space: nowrap; scrollbar-width: thin; }
#viewer .vbar::-webkit-scrollbar { height: 6px; }
#viewer .vbar button { padding: 7px 10px; }
.vname { font-size: 14px; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; }
.vspace { flex: 1; }
.mini { padding: 6px 8px; border-radius: 8px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-size: 13px; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.chk input { width: auto; }
button.ghost.active { border-color: var(--accent); color: var(--accent2); }
#vStage { position: relative; }
.statsbox { position: absolute; top: 10px; left: 10px; background: rgba(8,12,20,.85); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 12px/1.5 ui-monospace, monospace; color: var(--good); pointer-events: none; }
.popup { position: absolute; top: 6px; right: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: grid; gap: 6px; z-index: 60; }
.popup button { text-align: left; }
.keygrab { position: absolute; opacity: 0; height: 1px; width: 1px; bottom: 0; left: 0; }
.vstatus { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; color: var(--muted); background: rgba(8,12,20,.7); padding: 3px 10px; border-radius: 999px; }
.vpanel { position: absolute; top: 50px; right: 0; bottom: 0; width: min(340px, 86vw); background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; z-index: 55; }
.vpanel-head { display: flex; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.vpanel-head span { flex: 1; font-weight: 600; }
.chatlog { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chatlog .msg { background: var(--panel2); padding: 7px 10px; border-radius: 10px; max-width: 85%; font-size: 14px; }
.chatlog .msg.me { align-self: flex-end; background: var(--accent); color: #fff; }
.xfers { padding: 0 12px; display: flex; flex-direction: column; gap: 6px; }
.xfer { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.xfer .bar { height: 5px; background: #0c1220; border-radius: 3px; margin-top: 5px; overflow: hidden; }
.xfer .bar i { display: block; height: 100%; background: var(--accent2); width: 0; }
.vpanel-foot { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line); }
.vpanel-foot input { flex: 1; }

/* fit modes for the remote video */
#remoteVideo.fit { max-width: 100%; max-height: 100%; width: auto; height: auto; }
#remoteVideo.actual { max-width: none; max-height: none; width: auto; height: auto; }
#remoteVideo.stretch { width: 100%; height: 100%; object-fit: fill; max-width: none; max-height: none; }
#vStage.scroll { overflow: auto; place-items: start; }

/* dashboard extras */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 260px; }
.group-h { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 18px 0 8px; }
.tag { display: inline-block; font-size: 11px; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin-right: 4px; color: var(--muted); }
.tag.sel { color: var(--accent2); border-color: var(--accent); }
.sysinfo { font-size: 12px; color: var(--muted); }
.menu { position: absolute; right: 14px; top: 52px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 6px; display: grid; gap: 2px; z-index: 120; min-width: 190px; }
.menu button { text-align: left; background: transparent; border: none; padding: 9px 12px; border-radius: 8px; }
.menu button:hover { background: var(--panel); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
