/* 手机远控页面样式。
   目标：深色、克制、把注意力留给手机画面本身。 */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f242e;
  --border: #2a3040;
  --text: #e6e9ef;
  --text-dim: #8b93a5;
  --accent: #3b82f6;
  --accent-dim: #1e40af;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- 顶栏 ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.brand {
  font-weight: 600;
  letter-spacing: 0.5px;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-dim);
  font-size: 13px;
}

.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.2s;
}

.status[data-state="connecting"] .dot { background: var(--warn); }
.status[data-state="live"] .dot { background: var(--ok); }
.status[data-state="error"] .dot { background: var(--err); }
.status[data-state="live"] { color: var(--ok); }
.status[data-state="error"] { color: var(--err); }

.actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.btn {
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) { background: #262c38; border-color: #3a4356; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover:not(:disabled) { background: #2563eb; border-color: #2563eb; }

/* ---- 主区域 ---- */

.stage {
  flex: 1;
  display: flex;
  min-height: 0;
}

.viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-width: 0;
  position: relative;
  background:
    radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.06), transparent 60%),
    var(--bg);
}

/* 画面按比例缩放，永远完整可见 */
#video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  background: #000;
  /* 触摸操作时不要弹出系统的长按菜单 */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  cursor: crosshair;
}

.placeholder {
  text-align: center;
  color: var(--text-dim);
  max-width: 380px;
}

.hint-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.hint-body {
  margin: 0;
  line-height: 1.7;
  font-size: 13px;
}

/* ---- 侧栏 ---- */

.sidebar {
  width: 268px;
  flex: none;
  padding: 16px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

.keygrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.keygrid .btn { padding: 10px 8px; }

textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  margin-bottom: 8px;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
}

#sendTextBtn { width: 100%; }

.log {
  margin: 0;
  padding: 10px;
  background: #0b0d11;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 11.5px;
  line-height: 1.6;
  font-family: "Consolas", "Cascadia Mono", monospace;
  color: var(--text-dim);
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- 窄屏：侧栏挪到下方 ---- */

@media (max-width: 860px) {
  .stage { flex-direction: column; }
  .viewport { padding: 10px; }
  .sidebar {
    width: auto;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 42vh;
  }
}
