:root {
  --bg: #0b0e14;
  --bg2: #121722;
  --line: rgba(255, 255, 255, .12);
  --fg: #e8eef8;
  --fg2: #9aa7bb;
  --accent: #4ea1ff;
  --accent2: #1f6fe0;
  --ok: #3ddc84;
  --warn: #ffb020;
  --bad: #ff5d5d;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 14px/1.5 "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
}
body { overflow: hidden; }
#app { position: fixed; inset: 0; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.hidden { display: none !important; }
.grow { flex: 1 1 auto; }
.btn {
  appearance: none; border: 1px solid var(--line); background: rgba(255, 255, 255, .06);
  color: var(--fg); padding: 8px 14px; border-radius: 10px; font-size: 13px;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
  user-select: none; white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #4ea1ff, #2b7de0); border-color: #4ea1ff; color: #fff; font-weight: 600; }
.btn.primary:hover { background: linear-gradient(180deg, #5fadff, #3189f0); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; padding: 11px; font-size: 15px; }

/* ============ 登录 ============ */
#loginView { align-items: center; justify-content: center; background:
  radial-gradient(1000px 600px at 20% 0%, #17233a 0%, transparent 60%),
  radial-gradient(800px 500px at 100% 100%, #16283f 0%, transparent 55%), var(--bg); }
.login-card {
  width: min(360px, 90vw); background: rgba(20, 26, 38, .86); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px 26px 22px; box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  backdrop-filter: blur(14px);
}
.logo {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(140deg, #4ea1ff, #1a5fc0); font-weight: 800; letter-spacing: -.5px;
  font-size: 17px; margin-bottom: 14px;
}
.login-card h1 { margin: 0; font-size: 21px; letter-spacing: .3px; }
.login-card .sub { margin: 4px 0 20px; color: var(--fg2); font-size: 13px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--fg2); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .35); color: var(--fg); font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(78, 161, 255, .16); }
.err { min-height: 18px; margin: 10px 0 0; color: var(--bad); font-size: 12.5px; }

/* ============ 窗口选择 ============ */
#pickerView { background: var(--bg); }
.pick-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: rgba(18, 23, 34, .9);
  backdrop-filter: blur(8px); flex: 0 0 auto;
}
.brand { font-weight: 700; letter-spacing: .3px; }
.brand-dot { color: var(--accent); margin: 0 1px; }
.who { color: var(--fg2); font-size: 12.5px; }
.badge {
  font-size: 12px; padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line);
  color: var(--fg2);
}
.badge.on { color: var(--ok); border-color: rgba(61, 220, 132, .45); background: rgba(61, 220, 132, .1); }
.badge.off { color: var(--fg2); }
.badge.bad { color: var(--bad); border-color: rgba(255, 93, 93, .45); background: rgba(255, 93, 93, .1); }

.pick-body { flex: 1 1 auto; overflow: auto; padding: 16px; }
.hint { color: var(--fg2); font-size: 13px; margin: 0 0 16px; max-width: 900px; line-height: 1.7; }
.hint b { color: var(--fg); font-weight: 600; }
.empty { color: var(--fg2); text-align: center; margin: 48px 0; font-size: 13.5px; line-height: 1.8; }

.group { margin-bottom: 18px; }
.group-head {
  display: flex; align-items: center; gap: 8px; margin: 0 0 10px;
  font-size: 13px; color: var(--fg2);
}
.group-head .pc { color: var(--fg); font-weight: 600; }
.group-head .ip { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; opacity: .7; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 10px; }

.card {
  position: relative; display: flex; align-items: flex-start; gap: 10px; padding: 12px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .015));
  cursor: pointer; transition: border-color .15s, background .15s, transform .1s;
  user-select: none;
}
.card:hover { border-color: rgba(78, 161, 255, .5); }
.card.on { border-color: var(--accent); background: rgba(78, 161, 255, .12); }
.card.off { opacity: .45; cursor: not-allowed; }
.card input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--accent); flex: 0 0 auto; }
.card .meta { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.card .title {
  display: block; font-size: 13.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card .dim { display: block; font-size: 11.5px; color: var(--fg2); font-family: ui-monospace, Menlo, Consolas, monospace; }
.card .tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.card .tags:empty { display: none; }
.tag {
  font-size: 11px; padding: 1px 7px; border-radius: 20px; border: 1px solid var(--line);
  color: var(--fg2);
}
.tag.live { color: var(--ok); border-color: rgba(61, 220, 132, .4); }
.tag.warn { color: var(--warn); border-color: rgba(255, 176, 32, .4); }
.tag.lock { color: var(--warn); border-color: rgba(255, 176, 32, .4); }
.tag.you { color: var(--accent); border-color: rgba(78, 161, 255, .45); }

.pick-foot {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-top: 1px solid var(--line); background: rgba(18, 23, 34, .92);
  backdrop-filter: blur(8px); flex: 0 0 auto;
}
#pickCount { font-size: 13px; color: var(--fg2); }

/* ============ 远控 ============ */
#remoteView { background: #000; overflow: hidden; }
#screen, #fallbackImg {
  position: absolute; left: 0; top: 0; display: block; touch-action: none;
}
#fallbackImg { display: none; }
/* 切换窗口的冻结帧：位置/尺寸由 JS 与 #screen 保持完全重合 */
#freeze {
  position: absolute; left: 0; top: 0; display: none;
  pointer-events: none; transition: opacity .17s ease;
}
#freeze.show { display: block; }
#freeze.fade { opacity: 0; }
/* 有旧画面垫底时，遮罩只留中间一条提示，不整屏压黑 */
.overlay.soft { background: transparent; }
.overlay.soft .ov-title { display: none; }
.overlay.soft .ov-sub {
  padding: 7px 15px; border-radius: 20px;
  background: rgba(8, 11, 17, .62); border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(8px); box-shadow: 0 6px 22px rgba(0, 0, 0, .4);
}
.overlay {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
  gap: 6px; background: rgba(6, 9, 14, .72); pointer-events: none; padding: 24px;
  transition: opacity .3s;
}
.overlay.hidden { opacity: 0; visibility: hidden; }
.ov-title { font-size: 17px; font-weight: 700; letter-spacing: .4px; }
.ov-sub { font-size: 13px; color: #c8d3e4; max-width: 560px; line-height: 1.7; }
.ov-caps { font-size: 11.5px; color: var(--fg2); max-width: 600px; line-height: 1.6; margin-top: 6px; }

#hud {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 14px; padding: 5px 12px; border-radius: 20px;
  background: rgba(8, 11, 17, .5); border: 1px solid rgba(255, 255, 255, .1);
  backdrop-filter: blur(8px); font: 11.5px/1.4 ui-monospace, Menlo, Consolas, monospace;
  color: #cfd9e8; white-space: nowrap; pointer-events: none; opacity: .9; z-index: 30;
}
#hud span:empty { display: none; }

#toast {
  position: absolute; left: 50%; bottom: 92px; transform: translate(-50%, 10px);
  max-width: min(86vw, 560px); padding: 9px 16px; border-radius: 20px;
  background: rgba(20, 26, 38, .94); border: 1px solid var(--line);
  font-size: 13px; text-align: center; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 60; line-height: 1.5;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- 半透明控制器（左下角） ---- */
.ctl {
  position: absolute; left: 14px; bottom: 14px; z-index: 50;
  display: flex; align-items: flex-end; gap: 8px; max-width: min(94vw, 980px);
  padding: 9px 11px; border-radius: 16px;
  background: rgba(10, 14, 21, .42);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(12px) saturate(1.25);
  box-shadow: 0 10px 34px rgba(0, 0, 0, .48);
  opacity: .93; transition: opacity .18s, padding .2s, border-radius .2s;
  user-select: none;
}
.ctl:hover { opacity: 1; }
.ctl.min { padding: 5px 7px; border-radius: 22px; }
.ctl.min .ctl-main { display: none; }
.ctl-main { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.ctl-min {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .08);
  color: #e8eef8; font-size: 11px; line-height: 1;
}
.ctl.min .ctl-min { border: 0; background: transparent; width: 30px; height: 30px; font-size: 15px; }
.ctl-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ctl-chips { max-height: 76px; overflow: auto; }

/* 当前窗口不透明度 1，其余半透明 —— 一眼看出在看哪个 */
.chip {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .07);
  color: #dfe7f3; font-size: 12px; cursor: pointer; max-width: 190px;
  opacity: .48; transition: opacity .15s, background .15s, border-color .15s, transform .1s;
}
.chip:hover { opacity: .85; }
.chip.on {
  opacity: 1; border-color: var(--accent); background: rgba(78, 161, 255, .24);
  box-shadow: 0 0 0 1px rgba(78, 161, 255, .5), 0 0 16px rgba(78, 161, 255, .28);
}
.chip .idx {
  font: 10.5px/1 ui-monospace, Menlo, Consolas, monospace; opacity: .8;
  background: rgba(255, 255, 255, .12); border-radius: 5px; padding: 2px 4px;
}
.chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 122px; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }
.chip .dot.mine { background: var(--ok); }
/* 采集不到画面的窗口：留在控制器里但明确不可切，避免点进去一屏黑 */
.chip.dead { opacity: .28; cursor: not-allowed; }
.chip.dead:hover { opacity: .35; }

.ctl-btn {
  padding: 5px 11px; border-radius: 9px; cursor: pointer; font-size: 12px;
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .08);
  color: #e8eef8; transition: background .15s;
}
.ctl-btn:hover { background: rgba(255, 255, 255, .16); }
.ctl-btn.take { border-color: rgba(255, 176, 32, .6); background: rgba(255, 176, 32, .18); color: #ffd98a; }

.float {
  position: absolute; right: 14px; bottom: 14px; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(10, 14, 21, .55);
  color: #e8eef8; font-size: 17px; cursor: pointer; z-index: 49; display: none;
  backdrop-filter: blur(10px); opacity: .8;
}

/* ---- 手机虚拟按键条 ---- */
.keybar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; gap: 6px; padding: 8px 10px; overflow-x: auto;
  background: rgba(8, 11, 17, .82); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-overflow-scrolling: touch;
}
.keybar button {
  flex: 0 0 auto; min-width: 42px; padding: 9px 11px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .08); color: var(--fg);
  font-size: 12.5px;
}

#ime { position: absolute; left: -9999px; top: 0; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 640px) {
  .pick-body { padding: 12px; }
  .cards { grid-template-columns: 1fr; }
  .ctl { left: 8px; right: 8px; bottom: 8px; max-width: none; padding: 7px 9px; }
  .chip { max-width: 140px; padding: 5px 8px; }
  .chip .nm { max-width: 82px; }
  #hud { gap: 9px; font-size: 10.5px; padding: 4px 9px; top: 6px; }
  #toast { bottom: 104px; }
}
