* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0e1116; --panel: #171c24; --line: #262d38; --fg: #e6e9ef;
  --muted: #8a93a3; --accent: #3b82f6; --ok: #22c55e; --danger: #ef4444;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg); color: var(--fg); -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit; color: var(--fg); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
  cursor: pointer; transition: .15s;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
.hidden { display: none !important; }

/* ---- 로그인 ---- */
body.auth { display: grid; place-items: center; padding: 20px; }
.card {
  width: 100%; max-width: 360px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 28px;
}
.card h1 { font-size: 24px; text-align: center; }
.card .sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 20px; }
.authtabs { display: flex; gap: 6px; margin-bottom: 16px; }
.authtabs button { flex: 1; background: transparent; }
.authtabs button.on { background: var(--accent); border-color: var(--accent); }
#form { display: flex; flex-direction: column; gap: 10px; }
input {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }
#form #submit { background: var(--accent); border-color: var(--accent); padding: 11px; font-weight: 600; }
.msg { color: var(--danger); font-size: 13px; text-align: center; min-height: 18px; margin-top: 12px; }

/* ---- 헤더 ---- */
#bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; }
.who { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }

/* ---- 기기 목록 ---- */
.view { padding: 18px; max-width: 760px; margin: 0 auto; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.devices { display: grid; gap: 10px; }
.device {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.device .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.device.online .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.device .name { font-weight: 600; }
.device .meta { color: var(--muted); font-size: 12px; }
.device .grow { flex: 1; min-width: 0; }
.device .connect { background: var(--accent); border-color: var(--accent); }
.device button.icon { background: transparent; padding: 6px 8px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 18px; line-height: 1.6; }

/* ---- 원격 화면 ---- */
#remote { padding: 0; max-width: none; }
#stage {
  position: relative; width: 100%; height: calc(100vh - 52px - 52px);
  background: #000; overflow: hidden; touch-action: none;
}
#screen { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
#remoteVideo {
  position: absolute; right: 12px; bottom: 12px; width: 180px; max-width: 40vw;
  border-radius: 10px; border: 2px solid var(--accent); background: #000; z-index: 5;
}
.status {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 15px; pointer-events: none;
}
#toolbar {
  display: flex; gap: 8px; padding: 9px 12px; background: var(--panel);
  border-top: 1px solid var(--line); overflow-x: auto; align-items: center;
}
#toolbar button { white-space: nowrap; }
#kbd { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
