:root {
  --bg: #0f1419;
  --panel: #182029;
  --line: #2a3644;
  --text: #e6edf3;
  --muted: #8b98a7;
  --accent: #2f81f7;
  --danger: #e5534b;
  --ok: #3fb950;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.view { display: none; height: 100%; }
.view.active { display: flex; }

/* ---------- connect ---------- */
#connectView { flex-direction: column; align-items: center; justify-content: center; padding: 20px; }
.card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; }
.brand { font-size: 22px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.logo { color: var(--accent); font-size: 26px; }
.sub { color: var(--muted); font-size: 14px; margin: 8px 0 20px; line-height: 1.5; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
input { display: block; width: 100%; margin-top: 6px; padding: 12px; font-size: 18px; letter-spacing: .5px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; outline: none; }
input:focus { border-color: var(--accent); }
.primary { background: var(--accent); border: 0; border-radius: 8px; padding: 12px 16px; font-weight: 600; color: #fff; }
#connectBtn { width: 100%; font-size: 16px; margin-top: 6px; }
#connectBtn:disabled { opacity: .6; }
.status { min-height: 20px; font-size: 14px; color: var(--muted); margin: 12px 0 0; text-align: center; }
.status.err { color: var(--danger); }
.recent { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.recent button { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.foot { color: var(--muted); font-size: 12px; margin-top: 16px; }
.foot a { color: var(--muted); }

/* ---------- remote ---------- */
#remoteView { flex-direction: column; }
.bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line); }
.bar button, .navbar button, .textbar button { background: transparent; border: 1px solid var(--line); border-radius: 8px; min-width: 38px; height: 34px; }
.bar .danger { border-color: var(--danger); color: var(--danger); }
.peer { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.stats { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
.spacer { flex: 1; }

.stage { flex: 1; position: relative; min-height: 0; background: #000; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#screen { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.overlay { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.waiting { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.dot { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  background: rgba(47,129,247,.45); border: 2px solid rgba(255,255,255,.8); pointer-events: none; animation: fade .5s forwards; }
@keyframes fade { to { opacity: 0; transform: scale(1.6); } }

.navbar { display: flex; justify-content: space-around; padding: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line); }
.navbar button { min-width: 52px; font-size: 16px; }
.textbar { display: flex; gap: 6px; padding: 6px; background: var(--panel); border-top: 1px solid var(--line); }
.textbar input { margin: 0; font-size: 15px; padding: 8px; }
.textbar .primary { padding: 0 14px; height: 34px; white-space: nowrap; flex-shrink: 0; }
.textbar button { flex-shrink: 0; }

:fullscreen .bar, :fullscreen .navbar { opacity: .9; }

/* ---------- PC host mode ---------- */
.pcbar { display: none; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--line); }
.pcbar button { background: transparent; border: 1px solid var(--line); border-radius: 8px; height: 34px; padding: 0 12px; font-size: 13px; }
body.pc-mode .navbar { display: none; }
body.pc-mode .pcbar { display: flex; }
body.pc-mode .overlay { cursor: default; }

.waiting.notice { background: rgba(0,0,0,.72); color: #ffd479; padding: 24px; text-align: center; line-height: 1.6; font-size: 15px; }

/* ---------- favorites ---------- */
.favsempty { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.favrow { display: flex; gap: 6px; margin-top: 6px; }
.favgo { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; text-align: left; }
.favgo b { font-size: 14px; color: var(--text); }
.favgo span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.favbtn { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; width: 38px; font-size: 15px; color: var(--muted); }
/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: rgba(20,24,28,.95); color: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: 86vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
