:root {
  --bg: #f4f7fb;
  --sidebar: #0f1b2d;
  --sidebar-text: #c9d4e5;
  --card: #ffffff;
  --text: #1b2433;
  --muted: #66758b;
  --line: #e4ebf3;
  --primary: #2f80ed;
  --primary-dark: #1b6ad6;
  --danger: #e14d4d;
  --ok: #1aa05a;
  --shadow: 0 10px 30px rgba(22, 40, 70, 0.08);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
code { background: #eef3f9; padding: 1px 6px; border-radius: 4px; }

.app { display: flex; min-height: 100%; }
.sidebar {
  width: 220px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; color: #fff; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #2f80ed, #56ccf2);
  display: grid; place-items: center; font-weight: 800;
}
.brand-name { font-weight: 700; }
.brand-sub { font-size: 12px; opacity: 0.7; }
.nav-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 6px;
}
.nav-item[hidden] { display: none; }
.nav-item.active, .nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-foot { margin-top: auto; font-size: 12px; opacity: 0.55; line-height: 1.4; }
html.embed .sidebar { display: none; }
html.embed .app { min-height: 100%; }
html.embed .main { padding: 18px 22px 28px; }
html.embed .id-card { display: none; }
html.embed .home-grid { grid-template-columns: 1fr; }
.cam-video {
  width: 100%;
  max-height: 360px;
  background: #0b1022;
  border-radius: 12px;
  margin: 8px 0 12px;
}
.cam-qr {
  display: block;
  width: 180px;
  height: 180px;
  margin: 12px 0;
  background: #fff;
  padding: 8px;
  border-radius: 12px;
}

.main { flex: 1; padding: 28px 36px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 24px; }
.hidden { display: none !important; }

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  background: #e8edf4;
  color: var(--muted);
}
.pill.online { background: #e5f7ec; color: var(--ok); }
.pill.busy { background: #e8f1fd; color: var(--primary); }

.home-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 20px; }
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.card-kicker { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.id-label { color: var(--muted); font-size: 13px; }
.device-id { font-size: 40px; letter-spacing: 2px; font-weight: 700; margin: 6px 0 18px; }
.password { font-size: 28px; font-weight: 600; letter-spacing: 1px; }
.pass-row { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.pass-actions { display: flex; gap: 8px; align-items: center; }
.id-combo, .secret-wrap { position: relative; }
.id-combo input, .secret-wrap input { padding-right: 42px; }
.combo-toggle, .secret-wrap .peek, .pass-actions .peek {
  border: 0; background: #eef4fc; color: var(--primary);
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.combo-toggle, .secret-wrap .peek {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
}
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 8;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); max-height: 240px; overflow: auto;
}
.combo-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; cursor: pointer; color: inherit; font: inherit;
}
.combo-item:hover { background: #eef4fc; }
.combo-item strong { display: block; }
.combo-item span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.combo-empty { padding: 12px; color: var(--muted); font-size: 13px; }
.secret-text { letter-spacing: 2px; }
.pass-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.pass-tools .ghost { width: auto; }
.inline-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin: 0; }
.inline-label select {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fff;
}
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal {
  position: fixed; inset: 0; background: rgba(15, 27, 45, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 20;
}
.modal-card {
  background: #fff; border-radius: 16px; padding: 28px; width: min(420px, 92vw);
  box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 8px; }
.incoming-id { font-size: 28px; font-weight: 700; letter-spacing: 1px; margin: 8px 0 12px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .primary { margin-top: 0; }
.hosting-banner {
  color: #22e6c8; font-size: 15px; padding: 24px; text-align: center;
}

label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 13px; }
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,128,237,0.15); }

.primary, .ghost, .danger {
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}
.primary { width: 100%; margin-top: 18px; background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.ghost { background: #eef4fc; color: var(--primary); }
.danger { background: var(--danger); color: #fff; }
.error { color: var(--danger); font-size: 13px; }
.recents { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.recent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
}
.recent-row strong { display: block; }
.recent-actions { display: flex; gap: 8px; flex-shrink: 0; }
.recent-actions .ghost { width: auto; margin-top: 0; }

.stage {
  background: #0b1220;
  border-radius: 16px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.screen-wrap { position: relative; display: inline-block; line-height: 0; }
#screen {
  max-width: 100%;
  max-height: 68vh;
  background: #111;
  cursor: none;
  outline: none;
  display: block;
  object-fit: contain;
}
.remote-cursor {
  position: absolute;
  width: 14px; height: 14px;
  margin-left: -7px; margin-top: -7px;
  border: 2px solid #22e6c8;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(34, 230, 200, 0.9), 0 0 2px #000;
  pointer-events: none;
  z-index: 3;
}
.remote-cursor::after {
  content: "";
  position: absolute; left: 5px; top: 5px;
  width: 2px; height: 2px; background: #22e6c8; border-radius: 50%;
}
.cursor-coord {
  position: absolute;
  transform: translate(12px, 12px);
  padding: 2px 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: #0b1220;
  background: rgba(34, 230, 200, 0.92);
  border-radius: 5px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 3;
}
.remote-cursor.hidden, .cursor-coord.hidden { display: none; }
.stage-hint { color: #8ea0b8; font-size: 12px; margin-top: 10px; }
.session-meta { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: 13px; }
.nav-bar { display: flex; gap: 10px; margin: 0 0 10px; flex-wrap: wrap; }
.nav-bar.hidden { display: none; }
.nav-bar button {
  padding: 8px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid #4a5a85; background: #2a3352;
  color: #ffffff; font-size: 14px; font-weight: 600;
}
.nav-bar button:hover { background: #3f6fe0; border-color: #5b8cff; }
.nav-bar button:active { transform: translateY(1px); background: #2f56b0; }

.dropzone {
  margin-top: 12px;
  border: 1.5px dashed #b9c8da;
  border-radius: 12px;
  padding: 36px;
  text-align: center;
  color: var(--muted);
  background: #f8fbff;
  cursor: pointer;
}
.file-list { list-style: none; padding: 0; }
.file-list li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

.chat-card { display: flex; flex-direction: column; height: 520px; }
.chat-log { flex: 1; overflow: auto; background: #f7f9fc; border-radius: 10px; padding: 12px; }
.chat-line { margin: 8px 0; }
.chat-line .who { color: var(--muted); font-size: 12px; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; }
.chat-form .primary { width: auto; margin-top: 0; }
.bullets { color: var(--muted); line-height: 1.8; }

@media (max-width: 960px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .home-grid { grid-template-columns: 1fr; }
  .device-id { font-size: 28px; }
}
