:root {
  --bg: #0f172a; --card: #1e293b; --line: #334155; --text: #e2e8f0; --muted: #94a3b8;
  --accent: #ef4444; --accent2: #f97316; --ok: #22c55e; --danger: #dc2626;
  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; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
body:not(.android) .android-only, body.android .pc-only { display: none !important; }
.card p { margin: 8px 0 0; }

/* ---------- Home ---------- */
#home { max-width: 520px; margin: 0 auto; padding: 20px 16px 40px; }
.brand { display: flex; align-items: center; gap: 10px; margin: 8px 0 18px; }
.brand h1 { font-size: 24px; margin: 0; letter-spacing: .3px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.card h2 { font-size: 16px; margin: 0 0 12px; }
label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
label input:not([type=checkbox]) { display: block; width: 100%; margin-top: 5px; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #0b1222; font-size: 17px; outline: none; }
label input:focus { border-color: var(--accent2); }
#devId { letter-spacing: 2px; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
button { cursor: pointer; border: 1px solid var(--line); background: #273449; border-radius: 10px; padding: 9px 14px; }
button:hover { filter: brightness(1.15); }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; font-weight: 600; width: 100%; padding: 13px; }
dialog button.primary { width: auto; }
button.ghost { background: transparent; }
button.danger { background: var(--danger); border-color: var(--danger); }
.msg { min-height: 1.2em; margin: 10px 0 0; color: var(--accent2); }
.muted { color: var(--muted); } .small { font-size: 13px; }
a { color: var(--accent2); }

#deviceList { list-style: none; margin: 0; padding: 0; }
#deviceList li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
#deviceList li:first-child { border-top: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #64748b; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dev-info { flex: 1; min-width: 0; }
.dev-info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-info span { color: var(--muted); font-size: 13px; letter-spacing: 1px; }

/* ---------- Session ---------- */
#session { position: fixed; inset: 0; background: #000; }
#stage { position: absolute; inset: 0; overflow: auto; touch-action: none; display: grid; place-items: center; }
#stage.actual { place-items: start; }
#screen { background: #111; outline: none; image-rendering: auto; touch-action: none; cursor: default; }
#stage.fit #screen { max-width: 100vw; max-height: 100dvh; width: auto; height: auto; object-fit: contain; }
#cursorDot { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  border: 2px solid #fff; background: rgba(239,68,68,.7); pointer-events: none; display: none; z-index: 2; }

#toolbar { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 6px; align-items: center; max-width: calc(100vw - 16px);
  background: rgba(15,23,42,.92); border: 1px solid var(--line); border-radius: 12px; padding: 6px; backdrop-filter: blur(6px); }
#tbItems { display: flex; gap: 6px; align-items: center; overflow-x: auto; scrollbar-width: none; }
#tbItems::-webkit-scrollbar { display: none; }
#toolbar.collapsed #tbItems { display: none; }
#toolbar button, #toolbar select { padding: 7px 10px; font-size: 13px; white-space: nowrap; border-radius: 8px; background: #273449; border: 1px solid var(--line); }
#stats { font-size: 12px; color: var(--muted); white-space: nowrap; padding: 0 4px; font-variant-numeric: tabular-nums; }

#kbInput { position: fixed; left: -1000px; bottom: 0; width: 10px; height: 10px; opacity: 0; }
#sessionMsg { position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; color: #fff;
  font-size: 18px; text-align: center; padding: 20px; background: rgba(0,0,0,.6); }

dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog textarea { width: 100%; background: #0b1222; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 10px; }
