/* 与刘润合影 — 公共样式（暖色、简洁、移动优先） */
:root {
  --primary: #C8102E;
  --primary-dark: #A50D25;
  --primary-light: #FBE9EC;
  --bg: #FAF7F2;
  --card: #FFFFFF;
  --text: #2B2622;
  --muted: #7A736C;
  --line: #E8E1D8;
  --ok: #2E7D32;
  --warn: #B26A00;
  --warn-bg: #FFF4E0;
  --err: #B3261E;
  --err-bg: #FDECEA;
  --radius: 14px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
}
img { display: block; max-width: 100%; }
a { color: var(--primary); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.3; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: .4em 0; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.hidden { display: none !important; }
.center { text-align: center; }

/* 顶栏 */
.topbar {
  background: var(--primary); color: #fff; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar h1 { margin: 0; font-size: 18px; color: #fff; }
.topbar .user { font-size: 13px; opacity: .92; white-space: nowrap; }
.topbar a { color: #fff; }

.wrap { max-width: 640px; margin: 0 auto; padding: 14px 14px 40px; }
.wrap-wide { max-width: 1100px; }

/* 卡片 / 步骤 */
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 14px; box-shadow: 0 1px 3px rgba(60,40,20,.06);
}
.step-title { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff;
  font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.card.locked { opacity: .5; pointer-events: none; }
.card.locked .step-num { background: var(--muted); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 16px; cursor: pointer; text-decoration: none;
  -webkit-appearance: none; appearance: none; user-select: none; line-height: 1.2;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:active { background: var(--primary-dark); }
.btn-outline { border-color: var(--primary); color: var(--primary); }
.btn-danger { border-color: var(--err); color: var(--err); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 9px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* 表单 */
input[type=text], input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 70px; resize: vertical; }
label.field { display: block; margin-bottom: 10px; font-size: 14px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { margin-top: 4px; }
input[type=range] { width: 100%; accent-color: var(--primary); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); vertical-align: middle; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 1.5; padding: 6px 0; }
.check input { flex: none; margin-top: 2px; }
.radio-row { display: flex; gap: 12px; flex-wrap: wrap; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; }
.radio-row label.on { border-color: var(--primary); background: var(--primary-light); }

/* 提示块 */
.tips { background: var(--primary-light); border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.tips ul { margin: 6px 0 0; padding-left: 18px; }
.alert { border-radius: 10px; padding: 10px 14px; font-size: 14px; margin: 10px 0; }
.alert-err { background: var(--err-bg); color: var(--err); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-ok { background: #E8F5E9; color: var(--ok); }
.alert .hint { margin-top: 4px; opacity: .9; }

/* 预览 / 结果图 */
.preview { border-radius: 10px; overflow: hidden; background: #f1ece5; }
.preview img { width: 100%; height: auto; }
.result-img { width: 100%; border-radius: 10px; }

/* 模板网格 + 定位框 */
.tpl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .tpl-grid { grid-template-columns: repeat(3, 1fr); } }
.tpl {
  position: relative; border: 2px solid transparent; border-radius: 10px; overflow: hidden;
  background: #eee; cursor: pointer;
}
.tpl.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.tpl img { width: 100%; height: auto; }
.tpl .tbox {
  position: absolute; border: 2px solid #FFD400; border-radius: 4px;
  box-shadow: 0 0 0 200vmax rgba(0,0,0,.18); pointer-events: none;
}
.tpl .tbox span {
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, 4px);
  background: #FFD400; color: #3a2a00; font-size: 11px; padding: 1px 6px; border-radius: 4px; white-space: nowrap;
}
.tpl .tname {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 8px; font-size: 12px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
}
.tpl .tick { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 14px; display: none; align-items: center; justify-content: center; }
.tpl.on .tick { display: flex; }

/* 进度 */
.progress { text-align: center; padding: 20px 0; }
.spinner {
  width: 40px; height: 40px; margin: 0 auto 12px; border-radius: 50%;
  border: 4px solid var(--primary-light); border-top-color: var(--primary); animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.timer { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 600; }

/* 列表 / 表格 */
.list-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item img { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; flex: none; }
.list-item .grow { flex: 1; min-width: 0; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 500; }
.tbl-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #EEE7DE; color: var(--muted); }
.badge-male { background: #E3EEFB; color: #1E4E9A; }
.badge-female { background: #FBE3EC; color: #A8225A; }
.badge-ready { background: #E8F5E9; color: var(--ok); }
.badge-uploaded { background: var(--warn-bg); color: var(--warn); }
.badge-ok { background: #E8F5E9; color: var(--ok); }
.badge-err { background: var(--err-bg); color: var(--err); }

/* 页脚 */
.footer { text-align: center; padding: 20px 0 calc(10px + var(--sab)); font-size: 13px; color: var(--muted); }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(40px + var(--sab)); transform: translate(-50%, 20px);
  background: rgba(40,30,25,.92); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 99; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 管理端 ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; background: #fff; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tabs button {
  flex: none; min-height: 46px; padding: 0 16px; border: 0; background: none; font: inherit; font-size: 15px;
  color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer;
}
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.two-col { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .two-col { grid-template-columns: 380px 1fr; } }
.tcard { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(60,40,20,.06); display: flex; flex-direction: column; }
.tcard .cover { aspect-ratio: 5/4; background: #eee; object-fit: cover; width: 100%; }
.tcard .body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.tcard .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.faces { display: flex; gap: 8px; flex-wrap: wrap; }
.faces img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 3px solid transparent; cursor: pointer; }
.faces img.on { border-color: var(--primary); }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: #ccc; border-radius: 13px; transition: .2s; }
.switch i:before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i:before { transform: translateX(18px); }
.param { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.param .desc { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.param input[type=range] { grid-column: 1 / -1; }
.param .val { font-variant-numeric: tabular-nums; color: var(--primary); font-weight: 600; }
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { background: #fff; border-radius: 12px; padding: 14px; box-shadow: 0 1px 3px rgba(60,40,20,.06); }
.stat .k { color: var(--muted); font-size: 13px; }
.stat .v { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }

.tpl .gbadge{position:absolute;left:6px;top:6px;background:rgba(0,0,0,.55);color:#fff;font-size:11px;padding:2px 6px;border-radius:6px}
