:root {
  --bg: #0d1117; --surface: #151b23; --surface-2: #1b232e; --surface-3: #232c38;
  --border: #262e3a; --border-strong: #35404f; --text: #e6eaf0; --text-dim: #9aa6b6;
  --text-faint: #6b7787; --accent: #2f81f7; --ok: #3fb950; --warn: #d29922; --danger: #f85149;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { overflow: hidden; user-select: none; }
.sprite { display: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
input { font: inherit; }
button { font: inherit; cursor: pointer; }

/* ── lobby ── */
.lobby { min-height: 100%; display: grid; place-items: center; padding: 24px 18px calc(24px + env(safe-area-inset-bottom)); }
.lobby-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 20px; font-weight: 700; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.tagline { margin: 0; color: var(--text-dim); font-size: 14px; }
.seg { display: flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--text-dim); padding: 9px; }
.seg button.active { background: var(--accent); color: #fff; }
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
input[type=text], input[type=password] { background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 12px; color: var(--text); font-size: 16px; }
input:focus { outline: none; border-color: var(--accent); }
.primary { background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 12px 16px;
  font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.primary:active { background: #2670d8; }
.primary:disabled { opacity: .5; }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); border-radius: 9px; padding: 9px 12px; }
.small { padding: 6px 10px; font-size: 13px; }
.who { display: flex; align-items: center; gap: 11px; padding: 12px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 11px; }
.who div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.who strong { font-size: 15px; } .who small { color: var(--text-faint); font-size: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 600; text-transform: uppercase; }
.dial { display: flex; gap: 9px; margin-top: 14px; }
.dial input { flex: 1; font-family: var(--mono); font-size: 20px; text-align: center; letter-spacing: .06em; }
.dial .primary { flex: none; }
.check { flex-direction: row; align-items: center; gap: 9px; color: var(--text); margin-top: 10px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.notice { padding: 10px 12px; border-radius: 9px; font-size: 13px; border: 1px solid;
  background: rgba(47,129,247,.1); border-color: rgba(47,129,247,.35); color: #79b0ff; }
.notice.warn { background: rgba(210,153,34,.1); border-color: rgba(210,153,34,.4); color: #e3b341; }
.notice.expired { background: rgba(248,81,73,.12); border-color: rgba(248,81,73,.4); color: #ff8a82; }
.notice button { margin-top: 8px; }
.server-line { margin: 0; font-size: 12px; color: var(--text-faint); text-align: center; }
.credit { margin: 0; font-size: 11px; color: var(--text-faint); text-align: center; }

/* ── stage ── */
.stage { position: fixed; inset: 0; background: #05070a; }
#remoteVideo { width: 100%; height: 100%; object-fit: contain; background: #05070a; }
.surface { position: absolute; inset: 0; touch-action: none; }
.status { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 15px; background: rgba(5,7,10,.94); text-align: center; padding: 24px; }
.status p { color: var(--text-dim); margin: 0; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border-strong); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(13,17,23,.92) 40%); display: flex; align-items: center; gap: 10px; }
.bar-info { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-left: 4px; }
.bar-info strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-info small { font-family: var(--mono); font-size: 10px; color: var(--text-faint); }
.bar-tools { display: flex; gap: 4px; }
.tool { position: relative; width: 44px; height: 44px; border: 0; border-radius: 11px;
  background: rgba(35,44,56,.8); color: var(--text-dim); display: grid; place-items: center; }
.tool.on { background: var(--accent); color: #fff; }
.tool.danger { color: var(--danger); }
.tool:active { transform: scale(.94); }
.badge { position: absolute; top: 3px; right: 4px; min-width: 15px; font-style: normal; font-size: 10px;
  font-weight: 700; background: var(--danger); color: #fff; border-radius: 8px; padding: 0 3px; line-height: 15px; }

.keys { position: absolute; left: 0; right: 0; bottom: calc(66px + env(safe-area-inset-bottom));
  display: flex; gap: 5px; padding: 6px 8px; overflow-x: auto; background: rgba(13,17,23,.85); }
.keys button { flex: none; min-width: 42px; height: 38px; border: 1px solid var(--border-strong);
  border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 14px; padding: 0 10px; }
.keys button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
#hiddenKeyboard { position: absolute; opacity: 0; height: 1px; width: 1px; pointer-events: none; top: -50px; }

.panel { position: absolute; inset: 0; background: rgba(13,17,23,.97); display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom); }
.panel > header { display: flex; align-items: center; justify-content: space-between; padding: 14px;
  border-bottom: 1px solid var(--border); font-size: 15px; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 82%; padding: 8px 11px; border-radius: 12px; font-size: 14px; user-select: text;
  background: var(--surface-2); border: 1px solid var(--border); align-self: flex-start; word-break: break-word; white-space: pre-wrap; }
.chat-msg.mine { align-self: flex-end; background: var(--accent); border-color: var(--accent); color: #fff; }
.chat-msg .who-name { display: block; font-size: 11px; color: var(--text-faint); margin-bottom: 2px; }
.chat-msg.mine .who-name { color: rgba(255,255,255,.7); }
.chat-msg.system { align-self: center; background: transparent; border-style: dashed; color: var(--text-faint); font-size: 12px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; }
.chat-form .primary { flex: none; padding: 12px; }

.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(360px, 92%); }
.toast { background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent);
  border-radius: 9px; padding: 11px 14px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.ok { border-left-color: var(--ok); } .toast.warn { border-left-color: var(--warn); } .toast.error { border-left-color: var(--danger); }
::-webkit-scrollbar { width: 0; height: 0; }
.auth-web { display: flex; flex-direction: column; gap: 10px; }
.auth-b { justify-content: center; }
.row2 { display: flex; gap: 8px; margin-top: 10px; }
.row2 .primary { flex: 1; }
.tiny { font-size: 12px; color: var(--text-faint); text-align: center; margin: 4px 0 0; }
#otpBox { display: flex; flex-direction: column; gap: 10px; }
