/* Older browsers use this too, such as a 2019 Samsung TV's (Chromium 63):
   layout that must hold there spells out top/right/bottom/left rather than
   inset (Chromium 87), which it ignores, collapsing #stage to nothing. */
:root {
  --bg: #0b0d10;
  --panel: rgba(22, 25, 30, 0.94);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e6e8eb;
  --muted: #8b939e;
  --accent: #4cc2ff;
  --ok: #3ddc84;
  --warn: #ffb347;
  --bad: #ff5c5c;
  --radius: 10px;
  font-family: ui-sans-serif, "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body {
  font-size: 13px;
  -webkit-tap-highlight-color: transparent;
  /* no text selection, loupe or long-press callout on iOS */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
textarea, input { -webkit-user-select: text; user-select: text; }

button, select, input, textarea { font: inherit; color: inherit; }
button, select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 10px;
  height: 30px;
  cursor: pointer;
}
button:hover, select:hover { background: rgba(255, 255, 255, 0.11); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.quiet { background: transparent; color: var(--muted); }
button.on { background: rgba(76, 194, 255, .18); border-color: rgba(76, 194, 255, .45); color: #bfe8ff; }
select option { background: #1b1f25; }

/* ---- stage ---- */
#stage {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
  touch-action: none;
}
/* sized and panned from app.js (fit or 1:1, times pinch zoom) */
#screen {
  position: absolute; left: 0; top: 0;
  display: block;
  outline: none;
  touch-action: none;
  -webkit-user-drag: none;
  background: #000;
  image-rendering: auto;
}
/* Game mode while a controller plays: no pointer over the picture (app.js sets the host's cursor shape inline) */
body.nomouse #stage, body.nomouse #screen { cursor: none !important; }
#ghost {
  position: fixed; left: 0; top: 0;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1px #000, 0 0 6px rgba(0,0,0,.6);
  pointer-events: none;
  z-index: 5;
}
/* trackpad mode: an arrow whose tip is exactly where a tap will click */
#ghost.arrow {
  width: 15px; height: 22px; margin: -1px 0 0 -1px;
  border: 0; border-radius: 0; box-shadow: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 22'%3E%3Cpath d='M1 1v17l4.2-4.1 3 6.9 3-1.3-3-6.8H14z' fill='%23fff' stroke='%23000' stroke-width='1.3' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.55));
}
#ghost.arrow.ibeam {
  width: 11px; height: 22px; margin: -11px 0 0 -5.5px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 22'%3E%3Cg fill='none' stroke-linecap='round'%3E%3Cpath d='M2 1.5h7M2 20.5h7M5.5 1.5v19' stroke='%23000' stroke-width='3'/%3E%3Cpath d='M2 1.5h7M2 20.5h7M5.5 1.5v19' stroke='%23fff' stroke-width='1.2'/%3E%3C/g%3E%3C/svg%3E");
}

/* ---- toolbar ---- */
#bar {
  position: fixed; top: 8px; left: 50%;
  transform: translate(-50%, calc(-100% - 16px));
  transition: transform .18s ease;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px;
  max-width: calc(100vw - 16px);
  padding: 7px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  backdrop-filter: blur(10px);
  z-index: 20;
}
body.bar-on #bar { transform: translate(-50%, 0); }
.grp { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.host { font-weight: 600; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 17ch; }
.stats .warn { color: var(--warn); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: none; }
/* the host's displays as tabs, each with ⧉ to open it in a window of its own */
.montabs { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: rgba(0, 0, 0, .25); }
.montab { display: flex; align-items: center; border-radius: 6px; }
.montab > button { height: 24px; padding: 2px 8px; border: 0; border-radius: 6px; background: transparent; }
.montab > .mtpop { padding: 2px 6px; color: var(--muted); }
.montab.on { background: rgba(76, 194, 255, .18); }
.montab.on > .mtname { color: #bfe8ff; }
.montab.out > .mtpop { color: var(--accent); }
.dot.ok { background: var(--ok); }
.dot.ok.slow { background: var(--warn); } /* connected, but stalling, losing frames or decoding slowly */
.dot.bad { background: var(--bad); }
.slider { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.slider input { width: 84px; accent-color: var(--accent); }
.slider output { width: 2ch; color: var(--text); font-variant-numeric: tabular-nums; }

#handle {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 64px; height: 10px; padding: 0;
  border: 0; border-radius: 0 0 8px 8px;
  background: rgba(255, 255, 255, .18);
  z-index: 19;
}
body.bar-on #handle { opacity: 0; pointer-events: none; }

/* ---- dock: pinned quick buttons (draggable) ---- */
#dock {
  position: fixed; left: 0; top: 0;
  display: flex; flex-direction: column; gap: 6px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
  opacity: .85;
  touch-action: none;
  z-index: 18;
}
#dock button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 40px; height: 40px; padding: 0;
  font-size: 18px; line-height: 1;
}
#dmon span { font-size: 11px; font-weight: 600; }
#dkeys { font-size: 13px !important; font-weight: 600; }
#dkbd.nudge { border-color: var(--accent); animation: nudge 1s ease-in-out infinite; }
@keyframes nudge { 50% { background: rgba(76, 194, 255, .4); } }
/* phone held upright: the dock in a row along the bottom, below the picture */
body.portrait #dock { flex-direction: row; }
@media (pointer: fine) {
  #dock { padding: 4px; }
  #dock button { width: 34px; height: 34px; }
}


/* ---- stats watermark ---- */
#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 6px); left: calc(env(safe-area-inset-left, 0px) + 8px);
  padding: 2px 6px; border-radius: 4px;
  background: rgba(0, 0, 0, .35); color: rgba(255, 255, 255, .78);
  font: 11px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  pointer-events: none;
  z-index: 17;
}

/* ---- key strip: sticky modifiers, Esc, Tab, F-keys (above the soft keyboard) ---- */
#keystrip {
  position: fixed; left: 0; right: 0; top: 0;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 5px;
  padding: 6px 8px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .35);
  touch-action: none;
  z-index: 21;
}
#keystrip button { height: 38px; min-width: 44px; padding: 0 9px; font-size: 14px; }
#keystrip .gap { margin-left: 10px; }
#keystrip button.press { background: rgba(255, 255, 255, .22); }
#keystrip .latched { background: rgba(76, 194, 255, .25); border-color: rgba(76, 194, 255, .6); color: #dff3ff; }
#keystrip .locked { background: var(--accent); border-color: var(--accent); color: #04121c; font-weight: 600; }

/* ---- drive controls (touch): steering wheel bottom-left, pedals bottom-right ---- */
#drive {
  --s: min(150px, 34vmin);
  --edge-l: max(16px, env(safe-area-inset-left));
  --edge-r: max(16px, env(safe-area-inset-right));
  --edge-b: max(16px, env(safe-area-inset-bottom));
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  pointer-events: none; /* only the controls take touches; the rest stays the remote screen */
  z-index: 17;
}
#wheel, .pedal {
  position: absolute; bottom: var(--edge-b);
  pointer-events: auto; touch-action: none;
  background: rgba(22, 25, 30, .5);
  border: 1px solid rgba(255, 255, 255, .2);
  opacity: .85;
}
#wheel {
  left: var(--edge-l);
  width: var(--s); height: var(--s);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
#wheel svg { width: 74%; height: 74%; transition: transform .12s; }
#wheel.press svg { transition: none; }
.pedal {
  width: calc(var(--s) * .5);
  border-radius: 14px;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 12px;
  font-size: 14px; font-weight: 600;
}
#gas { right: var(--edge-r); height: var(--s); }
#brake { right: calc(var(--edge-r) + var(--s) * .5 + 12px); height: calc(var(--s) * .72); }
.pedal.press, #wheel.steer { background: rgba(76, 194, 255, .35); border-color: var(--accent); }

/* ---- clipboard, controller and settings panels ---- */
#clip, #padpanel, #settings {
  position: fixed; right: 12px; top: 64px;
  width: min(420px, calc(100vw - 24px));
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  z-index: 30;
}
#clip h2, #padpanel h2, #settings h2 { margin: 0 0 4px; font-size: 14px; }
/* Settings: at the top, centred across, never taller than the screen (app.js
   holds it to what the keyboard leaves), its buttons kept in view */
#settings {
  top: calc(env(safe-area-inset-top, 0px) + 12px); left: 50%; right: auto; bottom: auto;
  transform: translateX(-50%);
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow-y: auto;
}
#settings .row {
  position: sticky; bottom: -14px;
  margin: 10px -14px -14px; padding: 10px 14px;
  background: var(--panel);
}
/* a short, wide screen (a phone held sideways): two settings to a line */
@media (max-height: 520px) and (min-width: 560px) {
  #settings { width: min(720px, calc(100vw - 24px)); }
  #settings .setgrid { grid-template-columns: auto 1fr auto 1fr; }
}
#conninfo { font-variant-numeric: tabular-nums; }
.updrow { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; padding: 8px 10px; border-radius: 7px; background: rgba(76, 194, 255, .12); border: 1px solid rgba(76, 194, 255, .35); color: #bfe8ff; line-height: 1.4; }
.updrow > span { flex: 1; overflow-wrap: anywhere; }
.updrow > button { flex: none; }
.verrow { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; color: var(--muted); line-height: 1.4; }
.verrow > span { flex: 1; overflow-wrap: anywhere; }
.verrow > button { flex: none; }
#conninfo:empty { display: none; }
.setgrid { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; }
.setrow { display: contents; }
.setrow > span:first-child { color: var(--muted); white-space: nowrap; }
.setrow select { max-width: 100%; min-width: 0; } /* a long host speaker name shortens its menu, not the labels */
.setrow > select, .setrow > button, .setrow > .slider, .setrow > .btns, .setrow > input[type=checkbox], .setrow > .check { justify-self: start; }
.setrow > .check { margin: 0; }
/* the settings' tabs, like the toolbar's display tabs */
.settabs { display: flex; gap: 2px; padding: 2px; margin: 6px 0 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(0, 0, 0, .25); }
.settabs > button { flex: 1; height: 28px; padding: 2px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); white-space: nowrap; }
.settabs > button[aria-selected="true"] { background: rgba(76, 194, 255, .18); color: #bfe8ff; }
/* a heading or note inside a tab spans its columns */
.setsub, .setnote { grid-column: 1 / -1; margin: 0; }
.setsub { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.setrow .btns { display: flex; gap: 6px; }
/* a choice this host or browser doesn't offer takes its label with it */
.setrow:has(> select[hidden], > button[hidden]) { display: none; }
#hvolval { width: 3ch; }
#padpanel { max-height: calc(100vh - 80px); overflow-y: auto; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.pad { padding: 10px 0; border-top: 1px solid var(--line); }
.padname { font-weight: 600; overflow-wrap: anywhere; }
.padinfo { margin-top: 2px; color: var(--muted); }
.padinfo.warnline { color: var(--warn); }
.padlive { margin-top: 4px; color: var(--muted); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11px; overflow-wrap: anywhere; }
.padstep { margin: 10px 0 0; padding: 8px 10px; border-radius: 7px; background: rgba(76, 194, 255, .12); border: 1px solid rgba(76, 194, 255, .35); color: #bfe8ff; font-size: 14px; }
.hint { margin: 0 0 10px; color: var(--muted); line-height: 1.45; }
#cliptext {
  width: 100%; height: 150px; resize: vertical;
  padding: 8px; border-radius: 7px;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px;
}
.row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* ---- files: this device on the left, the host on the right (one pane on a phone) ---- */
#filesback { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(8, 10, 12, .55); z-index: 29; }
#files {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column;
  width: min(1000px, calc(100vw - 24px));
  height: min(640px, calc(100vh - 24px)); height: min(640px, calc(100dvh - 24px));
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  z-index: 30;
}
.fhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fhead h2 { margin: 0; font-size: 14px; }
.fpanes { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fpane { display: flex; flex-direction: column; min-width: 0; min-height: 0; gap: 6px; }
.fbar, .ffoot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fgrow { flex: 1; }
.fsort { padding: 4px 6px; max-width: 9.5em; }
.fpath {
  padding: 5px 8px; border-radius: 7px; min-height: 1.4em;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
input.fpath { color: var(--text); }
input.fpath[hidden] { display: none; }
div.fpath:empty { display: none; }
/* breadcrumbs: each folder above the one shown, to go back to */
.fcrumbs { display: flex; align-items: center; gap: 2px; padding: 3px 4px; overflow-x: auto; text-overflow: clip; scrollbar-width: none; }
.fcrumbs[hidden] { display: none; }
.fcrumbs::-webkit-scrollbar { display: none; }
.fcrumbs.fedit { cursor: text; }
.fcrumb { flex: none; padding: 2px 6px; border: 0; border-radius: 5px; background: transparent; color: var(--text); cursor: pointer; }
.fcrumb:hover { background: rgba(255, 255, 255, .1); }
.fcur { flex: none; padding: 2px 6px; color: var(--text); font-weight: 600; }
.fsep { flex: none; color: var(--muted); }
#files.touch .fcrumb, #files.touch .fcur { padding: 6px 8px; }
.flist {
  flex: 1; min-height: 0; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 7px; background: rgba(0, 0, 0, .22);
  user-select: none; -webkit-user-select: none;
}
.flist:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.flist.drop, .frow.drop { background: rgba(76, 194, 255, .16); box-shadow: inset 0 0 0 1px var(--accent); }
.frow { display: grid; grid-template-columns: 1.4em 1fr auto auto; gap: 8px; align-items: center; padding: 4px 8px; cursor: default; }
.frow:hover { background: rgba(255, 255, 255, .05); }
.frow.sel { background: rgba(76, 194, 255, .22); color: #dff3ff; }
/* a folder with photos or videos: rows tall enough for a picture of each */
.flist.thumbs .frow { grid-template-columns: 44px 1fr auto auto; padding-top: 3px; padding-bottom: 3px; }
.flist.thumbs .ficon { height: 44px; display: flex; align-items: center; justify-content: center; font-size: 1.4em; }
.ficon img { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; display: block; -webkit-touch-callout: none; }
/* a thumbnail held: the file bigger, until a tap */
#fpreview {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 39; background: rgba(0, 0, 0, .9);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  -webkit-user-select: none; user-select: none;
}
#fpreview img { min-height: 0; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; -webkit-touch-callout: none; }
#fpreview img:not([src]), #fpreview img[src=""] { display: none; }
.fpcap { color: #fff; font-size: 13px; text-align: center; line-height: 1.4; overflow-wrap: anywhere; }
.fpcap b { font-weight: 600; }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fsize, .fdate { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
.fsize { text-align: right; min-width: 6ch; }
.fempty { padding: 16px; color: var(--muted); line-height: 1.45; }
.fempty button { margin-top: 10px; }
#fhcopied {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 6px 8px; border-radius: 7px;
  background: rgba(76, 194, 255, .12); border: 1px solid rgba(76, 194, 255, .35);
}
#fhcopied[hidden] { display: none; }
#fhcopied span { flex: 1; min-width: 8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* a phone: filling the screen, rows big enough to tap; in a browser the
   host's pane alone, in the app this phone's above the host's while upright */
#files.full { background: var(--bg); width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; border: 0; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
#files.full .frow { grid-template-columns: 1.4em 1fr auto; }
#files.full .flist.thumbs .frow { grid-template-columns: 44px 1fr auto; }
#files.full .fdate { display: none; }
#files.touch .frow { padding: 10px 8px; }
#files.touch .flist.thumbs .frow { padding: 4px 8px; }
#files.one .fpanes, #files.stack .fpanes { grid-template-columns: 1fr; }
#files.stack .fpanes { grid-template-rows: 1fr 1fr; gap: 10px; }
#files.one #flpane, #files.one #fhget { display: none; }
#fonehint { margin: 0 0 8px; font-size: 13px; }
/* a row dragged by a finger, under it */
.fghost {
  position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none;
  margin: -44px 0 0 -20px; padding: 6px 10px; max-width: 60vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 7px; background: var(--accent); color: #04121c; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
#dropzone {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 38;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 12, .6);
}
#dropzone[hidden] { display: none; }
#dropzone div { padding: 28px 36px; border: 2px dashed var(--accent); border-radius: 14px; background: var(--panel); font-size: 16px; pointer-events: none; }
#xfers {
  position: fixed; right: 12px; bottom: 12px; z-index: 36;
  display: flex; flex-direction: column; gap: 6px;
  width: min(360px, calc(100vw - 24px)); max-height: 40vh; overflow-y: auto;
}
#xfers[hidden] { display: none; }
.xfer {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center;
  padding: 8px 10px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.xname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xfer button { grid-row: 1 / span 3; grid-column: 2; padding: 2px 8px; }
.xbar { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.xbar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.xinfo { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.xfer.ok .xbar i { background: var(--ok); }
.xfer.bad { border-color: var(--bad); }
.xfer.bad .xinfo { color: var(--bad); }

/* ---- controller menu: centred, big enough to read from the couch ---- */
#padmenu {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column;
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .6);
  z-index: 35;
}
#padmenu h2 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
#pmlist { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
#pmlist button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none;
  height: 48px; padding: 0 14px;
  font-size: 17px; text-align: left;
}
#pmlist button.sel { background: rgba(76, 194, 255, .22); border-color: var(--accent); color: #dff3ff; }
.pmval { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pmlist button.sel .pmval { color: #bfe8ff; }
.pmfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.pmfoot .hint { margin: 0; }

/* ---- messages ---- */
#banner, #toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  padding: 8px 14px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--line);
  z-index: 25; max-width: calc(100vw - 24px); text-align: center;
}
#banner { bottom: 18px; border-color: var(--warn); color: var(--warn); }
#toast { bottom: 64px; z-index: 37; } /* above the Files panel */

#overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 10, 12, .72);
  z-index: 40;
}
#overlay.off { display: none; }
.card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 22px 26px; min-width: 240px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.card p { margin: 0; text-align: center; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#ime {
  position: fixed; left: 0; bottom: 0;
  width: 1px; height: 1px; opacity: 0;
  border: 0; padding: 0; resize: none;
}

/* ---- login ---- */
body.login { display: flex; align-items: center; justify-content: center; }
.login-card {
  display: flex; flex-direction: column; gap: 12px;
  width: min(340px, calc(100vw - 32px));
  padding: 28px;
  background: #13161b; border: 1px solid var(--line); border-radius: 16px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-card .sub { margin: -4px 0 6px; color: var(--muted); line-height: 1.45; }
.login-card input {
  height: 44px; padding: 0 14px;
  font-size: 18px; letter-spacing: .2em;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 9px;
}
.login-card .remember { margin: -2px 0 2px; color: var(--muted); font-size: 14px; cursor: pointer; }
.login-card .remember input { height: auto; padding: 0; margin: 0; accent-color: var(--accent); }
.login-card button { height: 42px; background: var(--accent); color: #04121c; border: 0; font-weight: 600; }
.login-card button:hover { background: #7ad3ff; }
.login-card button:disabled { opacity: .6; }
/* the logo and wordmark, as brand/lockup-dark.svg */
.brand { display: block; height: 34px; width: auto; }
.login-card h1 .brand { margin-bottom: 6px; }
.err { margin: 0; min-height: 1.2em; color: var(--bad); }
.setup-link { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
a { color: var(--accent); }

/* ---- device setup page (scrolls, unlike the viewer) ---- */
html:has(body.page), body.page { overflow: auto; height: auto; }
.setup {
  max-width: 680px; margin: 0 auto;
  padding: 32px 18px calc(40px + env(safe-area-inset-bottom));
  font-size: 15px; line-height: 1.55;
}
.setup h1 { margin: 12px 0 4px; font-size: 22px; }
.setup h2 { margin: 28px 0 8px; font-size: 17px; }
.setup h3 { margin: 18px 0 4px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.setup .sub { color: var(--muted); margin: 0 0 8px; }
.setup ol { margin: 4px 0; padding-left: 22px; }
.setup li { margin: 3px 0; }
.setup code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; word-break: break-all; }
.setup .hint { font-size: 13px; }
.setup section { border-top: 1px solid var(--line); margin-top: 22px; }
a.btn {
  display: inline-block; padding: 9px 16px; border-radius: 9px;
  background: var(--accent); color: #04121c; font-weight: 600; text-decoration: none;
}
a.btn.quiet { background: rgba(255, 255, 255, .08); color: var(--text); border: 1px solid var(--line); }
.warn { margin: 0; color: var(--warn); line-height: 1.45; }

@media (max-width: 640px) {
  #bar { top: 4px; gap: 6px; width: calc(100vw - 8px); max-width: none; }
  .stats { display: none; }
  .slider input { width: 64px; }
  #clip, #padpanel { top: auto; bottom: 12px; }
}

/* ---- signing in through the rendezvous (remote.js) ---- */
.remote-auth {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.remote-auth[hidden] { display: none; }
