:root {
  --bg: #070b14;
  --bg2: #0d1526;
  --card: rgba(18, 27, 46, .82);
  --line: rgba(148, 163, 184, .16);
  --tx: #e8eefc;
  --muted: #94a3b8;
  --accent: #22d3ee;
  --accent2: #6366f1;
  --danger: #f43f5e;
  --ok: #22c55e;
  --radius: 14px;
  --bar-h: 52px;
}

* { box-sizing: border-box; }

/* 关键：#app 用的是 display:flex，会覆盖浏览器对 [hidden] 的默认 display:none，
   导致隐藏状态下仍铺满全屏挡住登录页点击 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 700px at 15% -10%, #14304d 0%, transparent 55%),
    radial-gradient(900px 600px at 110% 10%, #2a1e55 0%, transparent 50%),
    var(--bg);
  color: var(--tx);
  font: 14px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- 登录 */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.card {
  width: min(420px, 100%);
  padding: 30px 28px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .05);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .3px;
}
.brand span { color: var(--tx); }

.sub {
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .5px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(6, 11, 22, .75);
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 17px;
  letter-spacing: 3px;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, .14);
}
.field input::placeholder { letter-spacing: 0; color: #5b6b85; font-size: 14px; }

button {
  cursor: pointer;
  padding: 9px 14px;
  background: rgba(148, 163, 184, .1);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: background .15s, border-color .15s, transform .06s;
  white-space: nowrap;
}
button:hover { background: rgba(148, 163, 184, .18); border-color: rgba(148, 163, 184, .3); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }

button.primary {
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  color: #041016;
  background: linear-gradient(135deg, var(--accent), #38bdf8 45%, var(--accent2));
  border: none;
  border-radius: 11px;
  box-shadow: 0 10px 24px rgba(34, 211, 238, .22);
}
button.primary:hover { filter: brightness(1.06); }
button.danger { color: #ffd7de; border-color: rgba(244, 63, 94, .38); background: rgba(244, 63, 94, .14); }
button.danger:hover { background: rgba(244, 63, 94, .24); }

.msg {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
}
.msg.ok { color: var(--ok); }

.tip {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  color: #6b7c96;
  font-size: 12px;
  line-height: 1.6;
}

/* ---------------------------------------------------------------- 远控界面 */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #05080f;
}

.bar {
  flex: 0 0 auto;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: rgba(10, 16, 28, .94);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
  height: calc(var(--bar-h) + env(safe-area-inset-top));
}
.host { display: flex; align-items: center; gap: 8px; min-width: 0; }
.host #hostName {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 26vw;
}
.muted { color: var(--muted); font-size: 12px; }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #64748b;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, .16);
}
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); animation: pulse 2s infinite; }
.dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
@keyframes pulse { 50% { opacity: .45; } }

.stats {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.actions select {
  padding: 8px 10px;
  background: rgba(148, 163, 184, .1);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.actions button { padding: 8px 11px; }

#stage {
  position: relative;
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, .012) 1px, transparent 1px) 0 0 / 100% 28px,
    #05080f;
  touch-action: none;
}

#screen {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  background: #000;
  cursor: default;
  outline: none;
  box-shadow: 0 0 0 1px rgba(148, 163, 184, .14), 0 20px 60px rgba(0, 0, 0, .6);
}
#stage:fullscreen #screen { box-shadow: none; }
#screen:focus { cursor: none; }

.hint {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  padding: 9px 16px;
  background: rgba(8, 14, 26, .88);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12.5px;
  pointer-events: none;
  transition: opacity .3s;
}
.hint.gone { opacity: 0; }

.offline {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(5, 8, 15, .82);
  backdrop-filter: blur(3px);
  z-index: 5;
}
.offline[hidden] { display: none; }
.offline p { margin: 0; color: var(--muted); }
.spinner {
  width: 30px; height: 30px;
  border: 3px solid rgba(148, 163, 184, .22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 6, 12, .72);
  backdrop-filter: blur(4px);
  z-index: 50;
}
.modal[hidden] { display: none; }
.modalBox {
  width: min(520px, 100%);
  padding: 22px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
}
.modalBox h2 { margin: 0 0 6px; font-size: 17px; }
.modalDesc { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.modalBox textarea {
  width: 100%;
  padding: 12px;
  background: rgba(4, 8, 16, .8);
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: vertical;
  outline: none;
  line-height: 1.6;
}
.modalBox textarea:focus { border-color: var(--accent); }
.modalBox textarea[hidden] { display: none; }
.modalActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.modalActions .grow { margin-right: auto; }

.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(80vw, 420px);
  padding: 10px 16px;
  background: rgba(15, 24, 41, .96);
  border: 1px solid rgba(34, 211, 238, .35);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .5);
  color: #dbeafe;
  font-size: 13px;
  text-align: center;
  animation: toastIn .18s ease-out;
  transition: opacity .3s, transform .3s;
}
.toast.out { opacity: 0; transform: translate(-50%, -8px); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px); } }

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(148, 163, 184, .1);
  font: 12px/1.6 ui-monospace, Consolas, monospace;
}
.helpList { margin: 0; padding-left: 18px; color: #c7d2e5; font-size: 13px; line-height: 1.9; }

/* ---------------------------------------------------------------- 小屏 */
@media (max-width: 720px) {
  :root { --bar-h: 46px; }
  .bar { gap: 8px; padding: 0 8px; }
  .stats { display: none; }
  .host #hostName { max-width: 30vw; }
  .actions button { padding: 7px 9px; font-size: 12.5px; }
  .actions select { padding: 7px 6px; font-size: 12.5px; }
  .actions #btnFull, .actions #btnHelp { display: none; }
}
