:root {
  --bg: #f5f7fb;
  --bg-accent: #eef3ff;
  --surface: #ffffff;
  --surface-alt: #fbfcfe;
  --text: #1f2a37;
  --muted: #6b7280;
  --line: #e5e9f2;
  --primary: #3b6ff5;
  --primary-soft: #e8efff;
  --success: #2ea86a;
  --success-soft: #eaf8f1;
  --warn: #e09a2e;
  --danger: #e05a5a;
  --shadow: 0 8px 24px rgba(31, 42, 55, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 180ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, #eaf1ff 0%, transparent 70%),
    radial-gradient(800px 400px at 90% 0%, #f0f7ff 0%, transparent 70%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 24px 20px;
}

/* Header */
.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  margin-top: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5b8cff, #3b6ff5);
  box-shadow: 0 0 0 5px #eaf0ff;
  flex-shrink: 0;
}

.header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #1a2433;
}

.subtitle {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 111, 245, 0.25);
}

.btn-primary:hover {
  background: #2f63e6;
}

.btn-primary:disabled {
  background: #9bb5f5;
  cursor: default;
  box-shadow: none;
}

.btn-ghost {
  background: #fff;
  color: #4b5b70;
  border-color: #dbe3ef;
}

.btn-ghost:hover {
  background: #f7f9fc;
  border-color: #cfd9e8;
}

/* Main layout */
.main {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  color: #243246;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f3f5f9;
  color: #6b7280;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b8c2d1;
}

.status-idle {
  background: #f3f5f9;
  color: #6b7280;
}
.status-idle::before { background: #b8c2d1; }

.status-live {
  background: var(--success-soft);
  color: #1f8f58;
}
.status-live::before {
  background: #2ea86a;
  box-shadow: 0 0 0 3px rgba(46, 168, 106, 0.15);
}

.status-error {
  background: #fdeeee;
  color: #d14b4b;
}
.status-error::before { background: #e05a5a; }

.status-loading {
  background: #fff8eb;
  color: #c4871f;
}
.status-loading::before { background: #e0a33a; }

/* Camera panel */
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #1a2230;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid #dfe6f2;
}

.video,
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video {
  transform: scaleX(-1); /* 镜像，符合自拍习惯 */
}

.overlay {
  transform: scaleX(-1);
  pointer-events: none;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: #8a96a8;
  background: linear-gradient(180deg, #f7f9fc 0%, #f0f4fa 100%);
  z-index: 2;
}

.camera-placeholder.hidden {
  display: none;
}

.placeholder-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: #eaf0fa;
  color: #6b86b8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.camera-placeholder p {
  margin: 0;
  font-size: 14px;
  color: #5f6f85;
}

.camera-placeholder .placeholder-hint {
  font-size: 12px;
  color: #8d99aa;
  max-width: 280px;
  line-height: 1.6;
}

.gesture-readout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.readout-item {
  background: var(--surface-alt);
  border: 1px solid #e9edf4;
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 0;
}

.readout-label {
  display: block;
  font-size: 12px;
  color: #7a8699;
  margin-bottom: 4px;
}

.readout-value {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: #243246;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stage panel */
.mode-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #3b6ff5;
  transition: all var(--transition);
}

.mode-badge.grab {
  background: #fff3e0;
  color: #d9831f;
}

.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid #dfe6f2;
  background: #f8fafc;
}

.stage {
  display: block;
  width: 100%;
  height: 100%;
}

.stage-hint {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e3e9f2;
  border-radius: 8px;
  font-size: 12px;
  color: #5c6b80;
  box-shadow: 0 2px 8px rgba(31, 42, 55, 0.06);
  pointer-events: none;
  max-width: calc(100% - 28px);
}

.hint-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3b6ff5;
  flex-shrink: 0;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #edf0f5;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: #5b6a7d;
  line-height: 1.6;
}

.legend-icon {
  font-size: 16px;
  line-height: 1.4;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.legend-item strong {
  color: #344256;
  font-weight: 600;
}

/* Footer */
.footer {
  margin-top: 20px;
  padding: 4px 2px;
  font-size: 12px;
  color: #7b8798;
  text-align: center;
}

.footer p {
  margin: 0;
}

.footer a {
  color: #4a74d8;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 1100px) {
  .main {
    grid-template-columns: 1fr;
  }
  .stage-wrap,
  .video-wrap {
    aspect-ratio: 16 / 10;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 18px 14px 16px;
  }
  .header {
    flex-direction: column;
    align-items: stretch;
  }
  .header-actions {
    padding-top: 0;
  }
  .header h1 {
    font-size: 24px;
  }
  .gesture-readout {
    grid-template-columns: 1fr;
  }
  .legend {
    grid-template-columns: 1fr;
  }
  .stage-wrap,
  .video-wrap {
    aspect-ratio: 4 / 3;
  }
}
