/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --bg-panel: #16213e;
  --bg-card: #0f3460;
  --accent: #e2b96f;
  --accent-soft: #c9a87c;
  --accent-dim: #7a5c3e;
  --text: #e0d5c1;
  --text-dim: #8a8070;
  --danger: #e06c6c;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* === Layout === */
.app-container {
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto 1fr;
  height: 100vh;
  gap: 1px;
  background: #111;
}

.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 24px;
  background: var(--bg-panel);
  border-bottom: 1px solid #2a2a4a;
}

.title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* === Stage (Camera + Canvas) === */
.stage {
  position: relative;
  overflow: hidden;
  background: #000;
}

#video {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* 镜像 */
}

#canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: scaleX(-1); /* 镜像 */
}

/* === Loading Overlay === */
.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 30, 0.9);
  z-index: 10;
  gap: 16px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--accent-dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === No Camera Overlay === */
.no-camera-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 30, 0.92);
  z-index: 10;
  gap: 12px;
}

.no-camera-overlay .hint {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.hidden { display: none !important; }

/* === Right Panel === */
.panel {
  background: var(--bg-panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  border-left: 1px solid #2a2a4a;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  padding-bottom: 6px;
  border-bottom: 1px solid #2a2a4a;
}

/* === Gesture Display === */
.gesture-display {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius);
}

.gesture-icon { font-size: 1.5rem; }
.gesture-name { font-size: 0.9rem; font-weight: 500; }
.hand-count { font-size: 0.8rem; color: var(--text-dim); }

/* === Preset Grid === */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.preset-btn {
  padding: 10px 8px;
  border: 1px solid #3a3a5a;
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: var(--font);
  transition: all 0.2s;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.preset-btn:hover {
  border-color: var(--accent);
  background: #1a2a4a;
}

.preset-btn.active {
  border-color: var(--accent);
  background: #2a2a40;
  box-shadow: 0 0 12px rgba(226, 185, 111, 0.15);
}

.preset-btn .preset-icon { font-size: 1.2rem; }
.preset-btn .preset-label { font-size: 0.72rem; }
.preset-btn .preset-source {
  font-size: 0.6rem;
  color: var(--text-dim);
}

/* === Pan Indicator === */
.pan-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pan-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

.pan-track {
  flex: 1;
  height: 6px;
  background: linear-gradient(to right, #4a90d9, #8b6cc7, #d96a6a);
  border-radius: 3px;
  position: relative;
}

.pan-dot {
  position: absolute;
  top: -4px;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  transform: translateX(-50%);
  transition: left 0.08s ease-out;
  box-shadow: 0 0 8px rgba(226, 185, 111, 0.5);
}

/* === Volume Slider === */
.volume-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(to right, var(--accent-dim), var(--accent));
  border-radius: 3px;
  outline: none;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(226, 185, 111, 0.4);
}

.volume-value {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: right;
}

/* === Status Info === */
.status-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}
.status-label { color: var(--text-dim); }
.status-value { color: var(--accent); font-variant-numeric: tabular-nums; }

/* === Buttons === */
.btn-secondary {
  padding: 8px 20px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font);
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(226, 185, 111, 0.1);
}

/* === Responsive === */
@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .panel {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px;
    overflow-y: visible;
    border-left: none;
    border-top: 1px solid #2a2a4a;
  }
  .panel-section { min-width: 140px; }
  .preset-grid { grid-template-columns: repeat(3, 1fr); }
}
