/* ============================================================================
   DV 滤镜相机 · 样式
   ----------------------------------------------------------------------------
   基线：Chrome 61（Android 8.1 出厂 WebView）。
   因此：不用 flex gap（用子项 margin）、不用 aspect-ratio / clamp() / min() / max()、
        不用 inset 等逻辑属性、不用 :has() / Container Queries / dvh、
        不以 backdrop-filter 作为唯一背景方案。
   安全区：var(--safe-area-inset-*, env(safe-area-inset-*, 0px))，配合 viewport-fit=cover。
   ========================================================================== */

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

html, body { height: 100%; }

html { touch-action: manipulation; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #f2f2f4;
  background: #0b0b0d;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

#app { position: relative; width: 100%; height: 100%; }

/* ---------------------------------------------------------------- 视图容器 */

.view {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  flex-direction: column;
}
.view.is-on { display: flex; }

/* ------------------------------------------------------------------ 启动页 */

.start-box {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.logo {
  font-size: 54px;
  font-weight: 500;
  letter-spacing: 10px;
  color: #e8e0d0;
  padding-left: 10px;
}

.slogan {
  margin-top: 10px;
  font-size: 14px;
  color: #8a8a92;
}

.btn-start { margin-top: 40px; width: 210px; }

.cap-note {
  margin-top: 20px;
  font-size: 12px;
  line-height: 1.8;
  color: #77777f;
  max-width: 280px;
}
.cap-note b { color: #b9b9c2; font-weight: 500; }
.cap-note .bad { color: #e08a6a; }

.ver {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 1px;
  color: #5c5c64;
}

/* ------------------------------------------------------------------ 拍摄页 */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #000;
  overflow: hidden;
}

/* 摄像头原始画面：WebGL 不可用时它就是兜底显示 */
.cam {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
}

/* 滤镜输出画布，覆盖在摄像头画面之上 */
.preview {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
.preview.is-hidden { display: none; }

/* 前置摄像头：屏幕上做左右镜像（自拍取景要像镜子）。
   注意只翻转 .cam —— WebGL 可用时镜像已经做在渲染管线里（uMirror），
   这里再翻一次会翻回去；这一条只服务于 WebGL 不可用的 <video> 兜底显示。 */
.stage.is-front .cam { transform: scaleX(-1); }

.progress-wrap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
}

.progress {
  width: 0;
  height: 100%;
  background: #ff4d4d;
}

.hud {
  position: absolute;
  top: 16px; left: 16px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s linear;
}
.hud.is-on { opacity: 1; }

.hud-dot {
  display: block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #ff4d4d;
  margin-right: 7px;
}

.hud-time {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.tier-note {
  position: absolute;
  right: 12px; bottom: 10px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
}

.cam-error {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  background: #111114;
}
.cam-error.is-on { display: flex; }

.cam-error-text {
  font-size: 14px;
  line-height: 1.8;
  color: #b9b9c2;
  max-width: 280px;
}

.btn-inline { flex: 0 0 auto; margin-top: 20px; padding: 11px 30px; font-size: 14px; }

/* ------------------------------------------------------------ 顶部工具栏 */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  padding-top: calc(14px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
}
.topbar > * + * { margin-left: 10px; }

.chip {
  display: inline-block;
  padding: 8px 15px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.2;
  color: #f2f2f4;
  background: rgba(18, 18, 20, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  -webkit-appearance: none;
  appearance: none;
}
.chip:active { opacity: 0.65; }

.style-panel {
  position: absolute;
  left: 16px; right: 16px;
  top: 58px;
  top: calc(58px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)));
  display: none;
  padding: 8px;
  background: rgba(18, 18, 21, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
}
.style-panel.is-on { display: block; }

.style-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  text-align: left;
  color: #f2f2f4;
  background: transparent;
  border: 0;
  border-radius: 10px;
  -webkit-appearance: none;
  appearance: none;
}
.style-item + .style-item { margin-top: 4px; }
.style-item.is-cur { background: rgba(255, 255, 255, 0.12); }
.style-item:active { opacity: 0.7; }

.style-item-name { display: block; font-size: 14px; }
.style-item-note { display: block; margin-top: 2px; font-size: 12px; color: #9a9aa3; }

/* ------------------------------------------------------------ 底部操作区 */

.bottombar {
  flex: 0 0 auto;
  padding: 14px 16px 18px;
  padding-bottom: calc(18px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  background: #0b0b0d;
}

.dur-row { display: flex; justify-content: center; }
.dur-row > * + * { margin-left: 8px; }

.dur-chip {
  padding: 7px 16px;
  font-family: inherit;
  font-size: 13px;
  color: #c9c9d0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  -webkit-appearance: none;
  appearance: none;
}
.dur-chip.is-cur {
  color: #1a1a1c;
  background: #e8e0d0;
  border-color: #e8e0d0;
}
.dur-chip:active { opacity: 0.7; }

.shutter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.shutter-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 74px;
  height: 74px;
}

.btn-rec {
  position: relative;
  width: 74px; height: 74px;
  padding: 0;
  background: transparent;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  -webkit-appearance: none;
  appearance: none;
}
.btn-rec:active { opacity: 0.8; }

.rec-inner {
  display: block;
  width: 58px; height: 58px;
  margin: 0 auto;
  background: #ff4d4d;
  border-radius: 50%;
  transition: width 0.18s linear, height 0.18s linear, border-radius 0.18s linear;
}

.btn-rec.is-rec .rec-inner {
  width: 28px; height: 28px;
  border-radius: 7px;
}

.btn-rec[disabled] { opacity: 0.35; }

/* --- 手动档越过警示点后的状态：只提示，不打断录制 ---
   对应 app.js 的 updateManualWarn()。三处同时变琥珀色，是因为长录制里用户不会
   一直盯着某一处；这几个 class 由 startRec / stopRec 统一清理，不需要额外复位规则。 */
.progress.is-warn { background: #ffb020; }
.hud.is-warn .hud-dot { background: #ffb020; }
.hud.is-warn .hud-time { color: #ffb020; }
.btn-rec.is-warn .rec-inner { background: #ffb020; }

.btn-photo {
  width: 54px; height: 54px;
  padding: 0;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  -webkit-appearance: none;
  appearance: none;
}
.btn-photo:active { opacity: 0.7; }
.btn-photo[disabled] { opacity: 0.3; }

/* ------------------------------------------------------------------ 结果页 */

.result-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px 12px;
}

.result-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  background: #000;
}

.result-meta {
  flex: 0 0 auto;
  padding: 0 20px 12px;
  text-align: center;
  font-size: 13px;
  color: #9a9aa3;
}

.result-actions {
  flex: 0 0 auto;
  display: flex;
  padding: 0 16px 18px;
  padding-bottom: calc(18px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
}
.result-actions > * + * { margin-left: 9px; }

/* -------------------------------------------------------------------- 按钮 */

.btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 13px 8px;
  font-family: inherit;
  font-size: 15px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
  border-radius: 12px;
  -webkit-appearance: none;
  appearance: none;
}
.btn:active { opacity: 0.75; }
.btn:focus { outline: 2px solid rgba(232, 224, 208, 0.6); outline-offset: 2px; }
.btn[disabled] { opacity: 0.4; }

.btn-main { color: #17171a; background: #e8e0d0; }
.btn-ghost { color: #e8e0d0; background: transparent; border-color: rgba(232, 224, 208, 0.4); }

/* -------------------------------------------------------- 遮罩 / 加载 / 提示 */

.busy {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.74);
}
.busy.is-on { display: flex; }

.busy-box {
  display: flex;
  align-items: center;
  max-width: 76%;
  padding: 16px 20px;
  background: #1a1a1e;
  border-radius: 12px;
}

.busy-text { font-size: 13px; color: #e6e6ea; }

.spin {
  display: block;
  width: 16px; height: 16px;
  margin-right: 10px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: #e8e0d0;
  border-radius: 50%;
  animation: dvspin 0.8s linear infinite;
}

@keyframes dvspin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 132px;
  max-width: 78%;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.88);
  border-radius: 10px;
  opacity: 0;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity 0.22s linear;
}
.toast.is-on { opacity: 1; }

/* 横屏 / 大屏：限制内容宽度，避免拉伸 */
@media (min-height: 620px) and (min-width: 520px) {
  .bottombar { padding-left: 24px; padding-right: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .spin { animation: none; }
  .rec-inner { transition: none; }
  .hud { transition: none; }
}
