/* ===========================================================
   相机拍照 · 成片 5 : 7（标准证件照），像素档位见「输出尺寸」
   =========================================================== */

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

:root {
  --out-w: 295px;
  --out-h: 413px;

  --bg:      #0f1115;
  --panel:   #171a20;
  --panel-2: #1e232b;
  --line:    #2a2f38;
  --text:    #e9ecf1;
  --muted:   #8b93a0;
  --accent:  #4c8dff;
  --accent-h:#3d7df0;
  --danger:  #ff6b6b;
  --radius:  14px;
}

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

body {
  background: radial-gradient(1100px 560px at 50% -8%, #1a2030 0%, var(--bg) 62%);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  padding: 28px 16px 40px;
}

/* 刘海屏 / 手势条：把内容让进安全区，避免顶部标题被状态栏压住、底部工具栏顶到边缘 */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-top:    calc(28px + env(safe-area-inset-top));
    padding-right:  calc(16px + env(safe-area-inset-right));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
    padding-left:   calc(16px + env(safe-area-inset-left));
  }
}

.app {
  width: min(100%, 380px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------------------------------- 头部 */
.app__head h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: .4px;
}
.app__head .meta {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.app__head .meta b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.app__head .meta--engine { font-variant-numeric: tabular-nums; }
.app__head .meta--warn { color: #ffb35c; }

/* 引擎选择行 */
.post__label { font-size: 13px; color: var(--muted); }
.post__row.is-muted { opacity: .5; }

/* ---------------------------------- 舞台 */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* 取景框：与成片等比，视频 cover 裁剪口径 ＝ 拍照 drawImage 裁剪口径
   不加边框、不加圆角 —— 取景与成片都是干净直角，避免看起来像"相框" */
.frame {
  position: relative;
  width: min(var(--out-w), 100%);
  aspect-ratio: 295 / 413;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #05070a;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}

.frame video,
.frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frame video.mirror { transform: scaleX(-1); }

/* 让 hidden 属性始终生效（否则会被上面的 display 覆盖） */
[hidden] { display: none !important; }

/* 三分构图线 */
.grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity .18s;
}
.grid i { position: absolute; background: rgba(255, 255, 255, .14); }
.grid i:nth-child(1),
.grid i:nth-child(2) { top: 0; bottom: 0; width: 1px; }
.grid i:nth-child(1) { left: 33.333%; }
.grid i:nth-child(2) { left: 66.666%; }
.grid i:nth-child(3),
.grid i:nth-child(4) { left: 0; right: 0; height: 1px; }
.grid i:nth-child(3) { top: 33.333%; }
.grid i:nth-child(4) { top: 66.666%; }
.frame.is-result .grid { opacity: 0; }

/* 快门闪光 */
.flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.flash.on { animation: flash .28s ease-out; }
@keyframes flash {
  0%   { opacity: .85; }
  100% { opacity: 0; }
}

/* 启动 / 重试层 */
.start {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  background: rgba(8, 10, 14, .82);
}
.start__tip {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

/* 状态提示 */
.tip {
  margin: 0;
  min-height: 20px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  word-break: break-word;
}
.tip--error { color: var(--danger); }

/* ---------------------------------- 按钮 */
.btn {
  appearance: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
}
.btn:hover:not(:disabled) { background: var(--panel-2); border-color: #3a4250; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn--primary:hover:not(:disabled) { background: var(--accent-h); border-color: transparent; }

/* 快门 */
.shutter {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: transform .08s, opacity .15s;
}
.shutter::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #fff;
  transition: background .15s;
}
.shutter:hover:not(:disabled)::after { background: #dfe7ff; }
.shutter:active:not(:disabled) { transform: scale(.94); }
.shutter:disabled { opacity: .35; cursor: not-allowed; }

/* ---------------------------------- 底部操作区 */
.bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.bar--sub .btn { width: 100%; }

/* ---------------------------------- 成片后期面板 */
.post {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 13px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.post__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.post__row--range { justify-content: stretch; }
/* 面板里的下拉不许撑破窄屏 */
.post__row > .sel { max-width: 64%; min-width: 0; }

.chk {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}
.chk input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.sel {
  appearance: none;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}
.sel:focus { outline: 1px solid var(--accent); }

/* 底色选择：色块 + 下拉 */
.pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.pick__sw {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #438edb;
  border: 1px solid rgba(255, 255, 255, .3);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .22);
}
.pick__sw.is-off { background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22); }

.rng {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  font-size: 13px;
  color: var(--muted);
}
.rng input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}
.rng output {
  min-width: 26px;
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------- 窄屏 */
@media (max-width: 380px) {
  body { padding: 18px 12px 32px; }
  .btn { padding: 9px 12px; font-size: 13px; }
  .shutter { width: 58px; height: 58px; }
}
