:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1f2430;
  --accent: #3b82f6;
  --danger: #ef4444;
  --ok: #22c55e;
  --fg: #e5e7eb;
  --muted: #9ca3af;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}
header { display: flex; align-items: center; gap: 0.75rem; }
h1 { font-size: 1.2rem; margin: 0; }
h3 { font-size: 0.85rem; margin: 0 0 0.4rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.badge { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; }
.badge.idle { background: #2a2f3a; color: var(--muted); }
.badge.connecting { background: #4d3a17; color: #fbbf24; }
.badge.live { background: #12331f; color: var(--ok); }
.badge.error { background: #3a1212; color: var(--danger); }

.panel { background: var(--panel); border: 1px solid #2a2f3a; border-radius: 8px; padding: 0.85rem; }
#host-panel { border-color: #1f3a5f; }
#host-panel .host-grid { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
#host-panel input[readonly] {
  width: 9rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.06em; color: var(--ok);
}
button.ghost { background: var(--panel2); border: 1px solid #2a2f3a; color: var(--fg); }
button.ghost:hover { filter: brightness(1.15); }
#hostStatus { margin-top: 0.4rem; }
#connect-panel { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.75rem; color: var(--muted); }
input[type=text], input:not([type]) {
  background: var(--panel2); border: 1px solid #2a2f3a; color: var(--fg);
  padding: 0.5rem 0.6rem; border-radius: 6px; width: 13rem; font-size: 0.95rem;
}
button {
  background: var(--accent); color: #fff; border: 0; padding: 0.55rem 0.9rem;
  border-radius: 6px; cursor: pointer; font-size: 0.9rem;
}
button:hover { filter: brightness(1.1); }
button.danger { background: var(--danger); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.8rem; }

#session { display: flex; flex-direction: column; gap: 0.5rem; }
.stage {
  position: relative; background: #000; border-radius: 8px; overflow: hidden;
  display: flex; justify-content: center; align-items: center; min-height: 200px;
  border: 1px solid #2a2f3a;
}
#video { max-width: 100%; max-height: 70vh; display: block; cursor: crosshair; background: #000; }
/* When connected (JS adds .grabbing), hide the browser cursor so only the
   local overlay + the host's native cursor (in the video) are visible. */
#video.grabbing { cursor: none; }
#cursor {
  position: absolute; left: 0; top: 0;
  pointer-events: none; z-index: 5;
  will-change: transform; display: none;
}
#cursor svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
.toolbar { display: flex; gap: 0.5rem; align-items: center; }
#fileName { font-size: 0.82rem; }
#sendBtn { min-width: 5rem; }
#sendBtn:disabled { opacity: 0.5; cursor: default; }
#filestatus { font-size: 0.82rem; }
#filestatus.status-busy { color: #fbbf24; }
#filestatus.status-ok { color: var(--ok); font-weight: 600; }
#filestatus.status-err { color: var(--danger); }

#chat-panel { display: flex; flex-direction: column; gap: 0.4rem; }
#chatLog {
  height: 120px; overflow: auto; background: #0b0d12; border-radius: 6px;
  padding: 0.5rem; font-size: 0.82rem; line-height: 1.4;
}
.chat-msg { padding: 2px 0; white-space: pre-wrap; word-break: break-word; }
.chat-msg.me { color: var(--accent); }
.chat-msg.them { color: var(--fg); }
.chat-row { display: flex; gap: 0.5rem; }
#chatInput { flex: 1; width: auto; }
.filebtn {
  display: inline-flex; align-items: center; background: var(--panel2);
  border: 1px solid #2a2f3a; padding: 0.45rem 0.8rem; border-radius: 6px;
  cursor: pointer; color: var(--fg); font-size: 0.85rem;
}

#log {
  height: 140px; overflow: auto; background: #0b0d12; border-radius: 6px;
  padding: 0.5rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem; line-height: 1.35;
}
#log div { border-bottom: 1px solid #161a22; padding: 1px 0; white-space: pre-wrap; word-break: break-all; }
#log .err { color: var(--danger); }
#log .ok { color: var(--ok); }
