:root {
  --bg: #0f172a;
  --surface: rgba(15, 23, 42, 0.78);
  --card: rgba(30, 41, 59, 0.92);
  --accent: #ff6b35;
  --accent-2: #ff3d68;
  --success: #22c55e;
  --warning: #facc15;
  --text: #f8fafc;
  --muted: #94a3b8;
  --radius: 20px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  overflow: hidden;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  background: #000;
}

/* 摄像头画布区域 */
.stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  background: #0b1120;
}

#cameraVideo {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#previewCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

/* 站位引导框 */
.guide-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 120px 14% 36px;
  transition: opacity 0.3s ease;
}

.guide-overlay.running {
  opacity: 0.25;
}

.guide-box {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 340px;
  border: 2px dashed rgba(255, 255, 255, 0.4);
  border-radius: 24px;
}

.guide-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: #4ade80;
  border-style: solid;
}
.guide-corner.tl { top: -2px; left: -2px; border-width: 4px 0 0 4px; border-top-left-radius: 14px; }
.guide-corner.tr { top: -2px; right: -2px; border-width: 4px 4px 0 0; border-top-right-radius: 14px; }
.guide-corner.bl { bottom: -2px; left: -2px; border-width: 0 0 4px 4px; border-bottom-left-radius: 14px; }
.guide-corner.br { bottom: -2px; right: -2px; border-width: 0 4px 4px 0; border-bottom-right-radius: 14px; }

.guide-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(15, 23, 42, 0.72);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: #e2e8f0;
  backdrop-filter: blur(8px);
}

/* 顶部栏 */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 12px) + 10px) 14px 10px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.75) 0%, transparent 100%);
  z-index: 10;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(10px);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
}

.rec-dot.recording {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  animation: pulseDot 1s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.25); }
}

.top-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
}
.icon-btn:active { transform: scale(0.93); }

/* 计数与计时悬浮卡 */
.hud-stats {
  position: absolute;
  top: calc(env(safe-area-inset-top, 12px) + 60px);
  left: 14px;
  right: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  z-index: 8;
  pointer-events: none;
}

.stat-card {
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 18px;
  padding: 10px 14px;
  text-align: center;
}

.stat-label {
  font-size: 12px;
  color: #cbd5e1;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 38px;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.count-card .stat-value {
  color: #fde047;
  transition: transform 0.12s ease;
}

.count-card .stat-value.pop {
  transform: scale(1.22);
}

.time-card .stat-value {
  color: #ffffff;
}

.time-card .stat-value.urgent {
  color: #f87171;
}

/* 实时波形小窗 */
.wave-panel {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 4px 6px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(8px);
  z-index: 8;
}

.wave-tag {
  font-size: 10px;
  color: #94a3b8;
  margin-top: -2px;
}

/* 3-2-1 倒计时 */
.countdown-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.countdown-number {
  font-size: 128px;
  font-weight: 900;
  color: #fde047;
  text-shadow: 0 8px 30px rgba(255, 107, 53, 0.65);
  animation: countPop 0.8s ease;
}

.countdown-sub {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

@keyframes countPop {
  0% { transform: scale(0.4); opacity: 0; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* 鼓励气泡 */
.cheer-toast {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #ff7a3d, #ff3d68);
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  padding: 12px 26px;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(255, 61, 104, 0.45);
  z-index: 15;
  pointer-events: none;
  animation: cheerUp 1.3s ease forwards;
}

@keyframes cheerUp {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  80% { opacity: 1; transform: translate(-50%, -65%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(0.95); }
}

/* 相机启动蒙层 */
.camera-prompt {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top, #1e293b 0%, #0f172a 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
}

.prompt-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  padding: 32px 24px;
}

.prompt-icon {
  font-size: 56px;
  margin-bottom: 8px;
}

.prompt-card h1 {
  margin: 0 0 10px;
  font-size: 26px;
}

.prompt-card p {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.6;
  color: #cbd5e1;
}

.prompt-tip {
  margin-top: 14px;
  font-size: 12px;
  color: #fca5a5;
  min-height: 18px;
  line-height: 1.5;
}

/* 底部控制面板 */
.control-dock {
  background: #0f172a;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 16px calc(env(safe-area-inset-bottom, 12px) + 12px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 12;
}

.mode-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-chip {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(30, 41, 59, 0.8);
  color: #cbd5e1;
  padding: 9px 6px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.mode-chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
}

.sub-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  color: #cbd5e1;
}

.mini-chip {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(30, 41, 59, 0.9);
  color: #e2e8f0;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.mini-chip.active {
  background: #fde047;
  color: #0f172a;
  border-color: transparent;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-action-btn {
  flex: 1;
  height: 54px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 61, 104, 0.35);
}

.main-action-btn.running {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35);
}

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

.side-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(30, 41, 59, 0.95);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.side-btn:active { transform: scale(0.94); }

/* 按钮通用样式 */
.primary-btn {
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 13px 20px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}
.primary-btn.large { width: 100%; padding: 15px 24px; font-size: 17px; border-radius: 999px; }
.primary-btn.full { width: 100%; margin-top: 14px; }

.secondary-btn {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 13px 20px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
}

.ghost-btn {
  border: none;
  border-radius: 14px;
  background: transparent;
  color: #cbd5e1;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 12px;
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  max-height: 90dvh;
  overflow-y: auto;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 26px;
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-header h2 {
  margin: 0;
  font-size: 19px;
}

.close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

/* 结算弹窗 */
.result-badge {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 14px;
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.res-item {
  background: rgba(15, 23, 42, 0.65);
  border-radius: 16px;
  padding: 12px 6px;
  text-align: center;
}

.res-num {
  display: block;
  font-size: 26px;
  font-weight: 800;
  color: #fde047;
}

.res-lbl {
  font-size: 12px;
  color: #94a3b8;
}

.record-note {
  text-align: center;
  background: rgba(250, 204, 21, 0.16);
  color: #fde047;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

.video-preview-wrap {
  margin-bottom: 14px;
}

#recordedVideo {
  width: 100%;
  max-height: 36dvh;
  border-radius: 16px;
  background: #000;
  display: block;
}

.video-meta {
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 6px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* 设置项 */
.setting-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.setting-title {
  font-size: 14px;
  font-weight: 600;
}

.setting-desc {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.select-input, .text-input {
  background: #0f172a;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  max-width: 155px;
}

.toggle {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

/* 历史记录 */
.pb-banner {
  background: linear-gradient(135deg, rgba(255, 107, 53, 0.2), rgba(255, 61, 104, 0.2));
  border: 1px solid rgba(255, 107, 53, 0.35);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.pb-banner strong {
  font-size: 20px;
  color: #fde047;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 45dvh;
  overflow-y: auto;
  margin-bottom: 14px;
}

.history-item {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 14px;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-main {
  font-size: 14px;
  font-weight: 700;
}

.history-sub {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.history-count {
  font-size: 20px;
  font-weight: 800;
  color: #fde047;
}

.history-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.danger-link {
  background: none;
  border: none;
  color: #f87171;
  font-size: 13px;
  cursor: pointer;
}

.hidden {
  display: none !important;
}
