:root {
  --bg: #fff7f7; --card: #ffffff; --ink: #2c2428; --sub: #7a6b72; --line: #f0dfe2;
  --pink: #e8728f; --pink-d: #d1527a; --pink-l: #fde6ec; --ok: #2e9d6b; --warn: #c0722a;
  --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, "PingFang TC", "Noto Sans TC", sans-serif; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
body { position: fixed; inset: 0; overflow: hidden; }
#video { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; left: 0; top: 0; }
#app { position: absolute; inset: 0; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--bg); }
.screen.active { display: flex; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--sat) + 14px) 14px 16px; }
.spacer { height: 110px; }
h1 { font-size: 26px; margin: 4px 0 4px; letter-spacing: .5px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.hero p { color: var(--sub); margin: 0 0 14px; }
.card { background: var(--card); border-radius: 18px; padding: 14px; margin: 0 0 12px; box-shadow: 0 2px 10px rgba(180, 100, 120, .08); }
.card[hidden] { display: none; }
.label { font-size: 13px; color: var(--sub); margin: 10px 0 6px; }
.note { font-size: 13px; color: var(--sub); margin: 8px 0 0; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; margin-top: 12px; }
.row.gap { gap: 8px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.tight { gap: 6px; }
.chip { border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 7px 13px; font-size: 14px; }
.chips.small .chip { padding: 3px 10px; font-size: 12px; }
.chip.on { background: var(--pink-l); border-color: var(--pink); color: var(--pink-d); font-weight: 600; }
.chip.static { background: #faf3f4; border-color: transparent; color: var(--sub); }
button { font: inherit; }
.primary, .secondary { border: 0; border-radius: 14px; padding: 14px 18px; font-size: 17px; font-weight: 600; }
.primary { background: linear-gradient(135deg, #f08aa3, var(--pink-d)); color: #fff; box-shadow: 0 6px 16px rgba(209, 82, 122, .3); }
.primary.small { padding: 10px 18px; font-size: 15px; }
.primary:active { transform: scale(.98); }
.secondary { background: #fff; color: var(--pink-d); border: 1.5px solid var(--pink); }
.mini { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--ink); }
.mini.light { background: rgba(255, 255, 255, .92); border-color: transparent; }
.textbtn { background: none; border: 0; color: var(--pink-d); font-size: 16px; padding: 4px 0; }
.cta { padding: 10px 14px calc(var(--sab) + 12px); background: linear-gradient(to top, var(--bg) 70%, rgba(255, 247, 247, 0)); position: absolute; left: 0; right: 0; bottom: 0; }
.cta .primary { width: 100%; }
.cta.two { display: flex; gap: 10px; }
.cta.two .secondary { flex: 1; }
.cta.two .primary { flex: 2; }
.topline { display: flex; flex-direction: column; margin-bottom: 8px; }

/* 鏡頭舞台 */
#cv { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: none; background: #1b1518; }
.stage { position: absolute; inset: 0; background: #1b1518; }
.stage #cv { display: block; }
.topbar { position: absolute; left: 0; right: 0; top: 0; padding: calc(var(--sat) + 8px) 10px 8px; display: flex; align-items: center; gap: 8px; z-index: 5; }
.round { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(20, 14, 18, .55); color: #fff; font-size: 20px; line-height: 1; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.statuschips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; justify-content: flex-end; }
.sc { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: rgba(20, 14, 18, .55); color: #fff; }
.sc.ok { background: rgba(46, 157, 107, .85); }
.sc.bad { background: rgba(192, 114, 42, .9); }
.stepdots { flex: 1; display: flex; gap: 3px; align-items: center; }
.stepdots i { flex: 1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .35); }
.stepdots i.done { background: #fff; }
.stepdots i.cur { background: var(--pink); height: 6px; }
.scan-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 16px calc(var(--sab) + 16px); background: linear-gradient(to top, rgba(20, 14, 18, .78), rgba(20, 14, 18, 0)); color: #fff; z-index: 4; }
.hint { text-align: center; font-size: 17px; font-weight: 600; margin-bottom: 10px; min-height: 26px; text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .3); overflow: hidden; margin: 0 auto 12px; max-width: 420px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f6a2b8, #fff); transition: width .2s; }
.bar.thin { height: 6px; background: #f1e3e6; margin: 0 0 6px; max-width: none; }
.bar.thin i { background: linear-gradient(90deg, #f6a2b8, var(--pink-d)); }
.bar.ok i { background: var(--ok); }
.wb { position: absolute; inset: 0; z-index: 8; background: rgba(15, 10, 13, .7); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 16px; }
.wb[hidden] { display: none; }
.wb-box { width: 62vw; height: 62vw; max-width: 280px; max-height: 280px; border: 3px dashed #fff; border-radius: 12px; }

/* 化妝指引底部面板 */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; background: #fff; border-radius: 22px 22px 0 0; box-shadow: 0 -6px 24px rgba(0, 0, 0, .18); max-height: 52vh; display: flex; flex-direction: column; transition: max-height .25s; padding-bottom: var(--sab); }
.sheet.min { max-height: 128px; }
.sheet.min .sheet-body { overflow: hidden; }
.handle { width: 44px; height: 5px; border-radius: 3px; background: #e3d3d7; margin: 8px auto 4px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 2px 16px 6px; flex: 1; min-height: 0; -webkit-user-select: text; user-select: text; }
.sheet-head h2 { font-size: 20px; margin: 0 0 6px; }
.count { font-size: 12px; color: var(--pink-d); font-weight: 700; letter-spacing: 1px; }
.steps { padding-left: 18px; margin: 8px 0 4px; font-size: 15px; }
.steps li { margin-bottom: 7px; }
.colors { display: flex; gap: 10px; margin: 8px 0 2px; flex-wrap: wrap; }
.colors .sw { display: flex; align-items: center; gap: 6px; border: 1.5px solid var(--line); border-radius: 999px; padding: 4px 10px 4px 4px; background: #fff; font-size: 13px; }
.colors .sw i { width: 24px; height: 24px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .12); display: block; }
.colors .sw.on { border-color: var(--pink); background: var(--pink-l); font-weight: 600; }
.hintbox { background: #fff7e8; border: 1px solid #f2dcb0; color: #7a5a1a; border-radius: 12px; padding: 8px 10px; font-size: 14px; margin-top: 6px; }
.detect { padding: 4px 16px 0; }
.status { font-size: 14px; color: var(--sub); min-height: 22px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status.ok { color: var(--ok); font-weight: 600; }
.status.warn { color: var(--warn); font-weight: 600; }
.status button { border: 0; background: none; color: var(--pink-d); font-size: 14px; }
.nav { display: flex; gap: 10px; padding: 8px 14px 12px; }
.nav .secondary { flex: 1; padding: 12px; }
.nav .primary { flex: 2; padding: 12px; }
.gtoast { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--sat) + 56px); background: rgba(20, 14, 18, .75); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 14px; z-index: 7; max-width: 90%; text-align: center; }
.gtoast[hidden] { display: none; }
.menu { position: absolute; z-index: 9; right: 10px; top: calc(var(--sat) + 52px); background: #fff; border-radius: 16px; padding: 12px 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, .25); display: flex; flex-direction: column; gap: 12px; max-width: 86%; }
.menu[hidden] { display: none; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.switch input { width: 20px; height: 20px; accent-color: var(--pink-d); flex: none; }

/* 結果頁 */
.photo { padding: 0; overflow: hidden; position: relative; }
.photo img { width: 100%; display: block; max-height: 46vh; object-fit: cover; object-position: center 25%; }
.warn { background: #fff4e1; color: #7a5a1a; font-size: 13px; padding: 8px 12px; }
.warn[hidden] { display: none; }
.big { font-size: 22px; font-weight: 700; margin: 2px 0 8px; }
.probs { display: grid; gap: 5px; margin: 8px 0; }
.prob { display: grid; grid-template-columns: 74px 1fr 38px; gap: 8px; align-items: center; font-size: 13px; }
.prob b { height: 8px; border-radius: 4px; background: #f3e6e9; display: block; overflow: hidden; }
.prob b i { display: block; height: 100%; background: var(--pink); }
.skinrow { display: flex; gap: 14px; align-items: center; }
.skindot { width: 62px; height: 62px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--line); flex: none; }
.pal { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-size: 14px; }
.pal i { width: 20px; height: 20px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0, 0, 0, .12); }
.plan-item { padding: 8px 0; border-bottom: 1px solid #f6eaec; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.plan-item:last-child { border-bottom: 0; }
.plan-item small { color: var(--sub); display: block; }
.skipnote { background: #faf3f4; border-radius: 10px; padding: 8px 10px; font-size: 13px; color: var(--sub); margin-top: 8px; }
.depths { display: flex; gap: 6px; margin: 6px 0; }
.depths button { flex: 1; height: 34px; border-radius: 8px; border: 2px solid transparent; }
.depths button.on { border-color: var(--pink-d); }
.kv { display: flex; flex-wrap: wrap; gap: 6px; }
.kv span { background: #faf3f4; border-radius: 10px; padding: 4px 10px; font-size: 13px; }
.kv span b { color: var(--pink-d); font-weight: 600; margin-left: 4px; }

/* 前後對比 */
.ba { position: relative; width: 100%; aspect-ratio: 3 / 4; border-radius: 14px; overflow: hidden; background: #eee; }
.ba img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#ba-clip { position: absolute; inset: 0; width: 50%; overflow: hidden; border-right: 2px solid #fff; }
#ba-clip img { width: auto; max-width: none; height: 100%; aspect-ratio: 3 / 4; }
#ba-range { position: absolute; left: 0; right: 0; bottom: 8px; width: 90%; margin: 0 5%; accent-color: #fff; }
.fb { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f6eaec; gap: 8px; }
.fb:last-child { border-bottom: 0; }
.fb .l { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.fb .l i { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .12); }
.fb .r button { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 18px; margin-left: 6px; }
.fb .r button.on { background: var(--pink-l); border-color: var(--pink); }
.loading { position: absolute; inset: 0; z-index: 20; background: rgba(255, 247, 247, .94); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--sub); }
.loading[hidden] { display: none; }
.spin { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--pink-l); border-top-color: var(--pink-d); animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.toast { position: absolute; z-index: 30; left: 50%; bottom: calc(var(--sab) + 90px); transform: translateX(-50%); background: rgba(30, 20, 26, .88); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; max-width: 88%; text-align: center; }
.toast[hidden] { display: none; }

/* 化妝指引:鏡頭在上、面板在下,面板不遮住臉 */
#s-guide .stage { position: relative; flex: 1 1 0; min-height: 0; }
#s-guide .sheet { position: relative; flex: none; max-height: 46vh; }
#s-guide .sheet.min { max-height: 132px; }
