/* ============================================================
   Pilates Landmark — 深色主题 / 响应式（桌面 · 平板 · 手机）
   ============================================================ */

:root {
  --bg: #0b0e14;
  --surface: #141926;
  --surface-2: #1b2233;
  --border: #242e45;
  --text: #e8edf7;
  --muted: #8b96ad;
  --accent: #2dd4bf;
  --accent-dim: rgba(45, 212, 191, 0.14);
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 20, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.logo {
  color: var(--accent);
  font-size: 18px;
  transform: translateY(1px);
}

.brand h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
}

.subtitle {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  flex-shrink: 0;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(45, 212, 191, 0.35);
  white-space: nowrap;
}

.pill.error {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

/* ---------- 布局 ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.stage-area {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
}

/* ---------- 舞台 ---------- */

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100%;
  background: #05070b;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.stage video,
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain; /* 画布与视频同比例，contain 后完全对齐 */
}

.stage video.mirrored {
  transform: scaleX(-1);
}

/* HUD 信息条（画布左上角） */

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 6px;
  z-index: 3;
}

.chip {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(10, 14, 22, 0.72);
  border: 1px solid var(--border);
  color: var(--text);
  backdrop-filter: blur(4px);
}

.chip.warn { color: #fbbf24; }
.chip.ok { color: var(--accent); }

/* 未开启摄像头时的引导层 */

.placeholder {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(45, 212, 191, 0.06), transparent 65%),
    #05070b;
}

.ph-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.ph-desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.ph-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- 控制面板 ---------- */

.panel {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding-right: 2px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  flex-shrink: 0;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.unit { color: var(--muted); font-weight: 400; text-transform: none; }

.row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.row:last-child { margin-bottom: 0; }

/* 按钮 */

.btn {
  flex: 1;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover:not(:disabled) { border-color: var(--accent); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #04211c;
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn.danger {
  background: transparent;
  border-color: rgba(248, 113, 113, 0.5);
  color: var(--danger);
}

.btn.big { padding: 12px 28px; font-size: 15px; }

/* 下拉 */

.select {
  width: 100%;
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
}

/* 开关行 */

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  cursor: pointer;
  user-select: none;
}

.toggle-row input {
  appearance: none;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
  margin: 0;
}

.toggle-row input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}

.toggle-row input:checked {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle-row input:checked::after {
  transform: translateX(16px);
  background: var(--accent);
}

/* 分段选择（模型） */

.seg {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.seg-btn {
  flex: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  padding: 7px 4px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn.active {
  background: var(--accent);
  color: #04211c;
  font-weight: 600;
}

.seg-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* 角度网格 */

.angle-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.angle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
}

.angle-item .name { color: var(--muted); }

.angle-item .val {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
}

.angle-item .val.na { color: var(--muted); font-weight: 400; }

/* 世界坐标表 */

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

#world-table table { width: 100%; border-collapse: collapse; }

#world-table th,
#world-table td {
  text-align: right;
  padding: 3px 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#world-table th {
  color: var(--muted);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

#world-table td:first-child,
#world-table th:first-child { text-align: left; }

/* 侧视建议 */

.tips ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12.5px;
}

.tips li { margin: 4px 0; }

/* Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: #1b2233;
  border: 1px solid var(--danger);
  color: var(--text);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: min(90vw, 480px);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* ---------- 响应式：窄屏（手机 / 竖屏平板） ---------- */

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 58vh) auto;
    overflow-y: auto;
  }

  .panel { overflow: visible; }

  .subtitle { display: none; }

  .stage { border-radius: var(--radius); }
}
