:root {
  --bg: #0e1116;
  --panel: #161a22;
  --panel-2: #1d2230;
  --line: #2a3142;
  --text: #e8ecf3;
  --muted: #8d97ab;
  --accent: #4c8dff;
  --accent-2: #3a74db;
  --ok: #33c27f;
  --warn: #f2a33a;
  --err: #ff6b6b;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 14px; }
p { margin: 6px 0; line-height: 1.5; }
.muted { color: var(--muted); }
.tiny { font-size: 12.5px; display: block; margin-top: 6px; }
.error { color: var(--err); min-height: 1.2em; font-size: 14px; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.screen { min-height: 100%; }
.center { display: grid; place-items: center; padding: 24px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.narrow { width: min(380px, 100%); }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand.small { margin: 0; gap: 10px; }
.brand img { border-radius: 10px; }

.field { display: grid; gap: 6px; margin: 12px 0; font-size: 14px; color: var(--muted); }
.field input, .field select {
  font: inherit; font-size: 16px; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }

.btn {
  font: inherit; font-size: 15px; color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: #3a4358; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.tiny-btn { padding: 4px 10px; font-size: 13px; }
.row { display: flex; gap: 10px; margin-top: 16px; }
.row.end { justify-content: flex-end; }
.row.center { justify-content: center; }

.topbar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: rgba(14,17,22,.92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar .actions { display: flex; gap: 8px; }
.list-wrap { max-width: 640px; margin: 0 auto; padding: 16px; }
.host-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.host {
  display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.host:hover { border-color: #3a4358; }
.host .pc-ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--panel-2); }
.host .pc-ic svg { width: 22px; height: 22px; stroke: var(--muted); fill: none; stroke-width: 1.8; }
.host .meta { flex: 1; min-width: 0; }
.host .name { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.host .sub { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5b6375; display: inline-block; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(51,194,127,.18); }
.host .more { background: none; border: 0; color: var(--muted); font-size: 20px; padding: 6px 10px; cursor: pointer; border-radius: 8px; }
.host .more:hover { background: var(--panel-2); }
.host.off { opacity: .72; }
.empty { text-align: center; padding: 48px 12px; }
.foot { text-align: center; font-size: 12px; padding: 24px; }

dialog.sheet {
  border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text);
  padding: 22px; width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.steps { padding-left: 20px; margin: 0; display: grid; gap: 14px; line-height: 1.5; }
.kv { display: grid; grid-template-columns: 84px 1fr auto; gap: 8px; align-items: center; margin-top: 8px; }
.kv span { color: var(--muted); font-size: 13px; }
.kv code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; overflow-wrap: anywhere; font-size: 14px; }
.kv code.big { font-size: 20px; letter-spacing: .08em; font-weight: 700; }

/* viewer */
.viewer { position: fixed; inset: 0; background: #000; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: default; }
.stage.hide-cursor { cursor: none; }
#screen { position: absolute; left: 0; top: 0; transform-origin: 0 0; image-rendering: auto; background: #111; }
.local-cursor {
  position: absolute; left: 0; top: 0; width: 18px; height: 18px; pointer-events: none; z-index: 3;
  border: 2px solid #fff; border-radius: 50%; background: rgba(76,141,255,.35); box-shadow: 0 0 0 1px rgba(0,0,0,.6);
  transform: translate(-50%, -50%);
}
.toolbar {
  position: absolute; top: env(safe-area-inset-top); left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 4px; padding: 4px; max-width: calc(100% - 12px); overflow-x: auto;
  background: rgba(22,26,34,.88); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 12px 12px;
  backdrop-filter: blur(8px); scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.tb {
  flex: none; height: 34px; min-width: 34px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent;
  color: var(--text); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font: inherit; font-size: 13px;
}
.tb:hover, .tb.on { background: var(--panel-2); }
.tb svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tb .kbtxt { font-size: 12px; white-space: nowrap; }
.stats { font-size: 11.5px; color: var(--muted); padding: 0 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.warn { background: rgba(242,163,58,.18); color: var(--warn); }
.tb-show {
  position: absolute; top: env(safe-area-inset-top); left: 50%; transform: translateX(-50%); z-index: 5;
  width: 56px; height: 22px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px;
  background: rgba(22,26,34,.75); color: var(--text); display: grid; place-items: center; cursor: pointer;
}
.tb-show svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.keybar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(22,26,34,.95); border-top: 1px solid var(--line); display: grid; gap: 6px;
}
.keyrow { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.keyrow::-webkit-scrollbar { display: none; }
.keyrow button {
  flex: 1 0 auto; min-width: 42px; height: 38px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.keyrow button.on { background: var(--accent); border-color: var(--accent); }
.kbd-input {
  position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0;
  font-size: 16px; resize: none; z-index: -1; caret-color: transparent;
}

.overlay { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(0,0,0,.55); padding: 20px; text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20;
  background: #242a38; color: var(--text); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
.toast.error { border-color: rgba(255,107,107,.5); }
.toast.warn { border-color: rgba(242,163,58,.5); }

.kbtxt.short { display: none; }
body.kbd-open .toast { bottom: calc(110px + env(safe-area-inset-bottom)); }
@media (max-width: 520px) {
  .topbar h1 { font-size: 18px; }
  .btn { padding: 9px 12px; }
  #modeLabel { display: none; }
  .wide-only { display: none; }
  .kbtxt { display: none; }
  .kbtxt.short { display: inline; }
}
.spacer { flex: 1; }
.btn.danger { color: var(--err); border-color: rgba(255,107,107,.35); }
