/* bias.beauty /lab/chuge ("出格"朋友圈). Lab register (site-app.css body.lab) on top of home.css + face-analysis.css.
   The film strip and grease-pencil loop from the homepage mark the chosen photo; results sit on white prints. */

.cg-kicker { margin: 0 0 14px; font: 500 12px/1.6 var(--mono); letter-spacing: .06em; color: var(--pencil); }

/* ---------- ① upload ---------- */
.cg-drop { position: relative; display: grid; place-items: center; min-height: 360px; cursor: pointer; overflow: hidden; }
body.lab .cg-drop { --k: 22px; --t: 2px; border-style: dashed; border-color: var(--hair); }
body.lab .cg-drop:hover, body.lab .cg-drop.over { border-color: var(--pencil); }
body.lab .cg-drop.has-photos { border-style: solid; border-color: var(--line); }
.cg-drop.busy { cursor: progress; }
.cg-empty { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 28px 20px; color: var(--muted); font-size: 14px; }
.cg-empty b { color: var(--ink); font-size: 17px; }
.cg-demo { width: min(210px, 56vw); height: auto; margin-bottom: 10px; }
/* the 出格 picture: a nine-grid beach photo, the person crossing the seams and waving out over the top */
.cg-art { overflow: visible; }
.cg-art .wave { transform-box: fill-box; transform-origin: 0 100%; }
.cg-drop:hover .cg-art .wave, .lab-card.is-live:hover .cg-art .wave { animation: cg-wave .5s ease-in-out infinite alternate; }
@keyframes cg-wave { from { transform: rotate(-10deg); } to { transform: rotate(8deg); } }
.cg-art .post-foot rect { fill: var(--tile); }
.cg-art .burst { stroke: var(--pencil); stroke-width: 2.4; }
@media (prefers-reduced-motion: reduce) { .cg-art .wave { animation: none !important; } }

.cg-sheet { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; width: 100%; padding: 16px; align-self: stretch; }
.cg-cell { position: relative; aspect-ratio: 1; border-radius: 3px; overflow: hidden; background: var(--photo-bg); }
.cg-cell img { display: block; width: 100%; height: 100%; object-fit: cover; animation: cg-dev .7s var(--ease) both calc(var(--i) * 60ms); }
@keyframes cg-dev { from { opacity: 0; filter: brightness(1.8) saturate(0); } }
.cg-cell i { position: absolute; left: 6px; top: 5px; font: 600 11px/1 var(--mono); font-style: normal; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.cg-cell.blank { background: transparent; border: 1px dashed var(--hair); }
.cg-cell.settled img { animation: none; }
.cg-cell.blank.add { display: grid; place-items: center; color: var(--faint); }
.cg-cell.blank.add::before { content: "+"; font: 300 28px/1 var(--sans); }
.cg-del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%;
    background: rgba(20, 20, 24, .62); color: #fff; font: 500 16px/1 var(--sans); cursor: pointer; }
.cg-del:hover, .cg-del:focus-visible { background: rgba(20, 20, 24, .85); }
.cg-del:focus-visible { outline: 2px solid var(--pencil); outline-offset: 1px; }
.cg-sheet.scanning .cg-del, .cg-drop.busy .cg-del { display: none; }
.cg-sheet.scanning .cg-cell img { filter: saturate(.5) brightness(.85); transition: filter .5s; }
.cg-sheet.scanning .cg-cell::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--pencil); box-shadow: 0 0 12px var(--pencil); animation: cg-scan 1.8s linear infinite calc(var(--i, 0) * 120ms); }
.cg-sheet.scanning .cg-cell.blank::after { content: none; }
@keyframes cg-scan { from { top: 0; } to { top: 100%; } }
.cg-stage .fa-controls { justify-content: flex-end; }

/* ---------- shared layout for ② ③ ④ ---------- */
.cg-edit, .cg-result, .cg-editor { scroll-margin-top: calc(var(--nav-h, 64px) + 8px); }   /* --nav-h is measured by lab-chuge.js; the phone nav has two rows */
.cg-board { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 48px; align-items: start; }
.cg-col { min-width: 0; }
@media (max-width: 920px) { .cg-board { grid-template-columns: 1fr; gap: 40px; } }
.cg-step { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.cg-step span { font: 500 13px/1 var(--mono); color: var(--pencil); }
.cg-step h2 { font-size: clamp(24px, 2.6vw, 32px); }
.cg-hint { margin: 0 0 16px; font-size: 14px; }

/* ---------- ② main photo ---------- */
.cg-main { position: relative; padding: 10px; text-align: center; line-height: 0; }
body.lab .cg-main { background-color: var(--photo-bg); }
/* the boxes sit on the photo itself, so the photo is sized by its own aspect ratio and never letterboxed */
.cg-pic { position: relative; display: inline-block; max-width: 100%; vertical-align: top; }
.cg-pic img { display: block; max-width: 100%; max-height: 64vh; width: auto; height: auto; }
.cg-boxes { position: absolute; inset: 0; pointer-events: none; }
.cg-box { position: absolute; pointer-events: auto; appearance: none; padding: 0; margin: 0; cursor: pointer; background: transparent;
    border: 1.5px dashed rgba(255, 255, 255, .75); border-radius: 6px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); transition: background .2s, border-color .2s; }
.cg-box.on { border: 2px solid var(--pencil); background: rgba(114, 27, 255, .08); box-shadow: 0 0 0 1px rgba(255, 255, 255, .6); }
.cg-box i { position: absolute; left: -2px; top: -2px; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; border-radius: 6px 0 6px 0;
    font: 700 12px/1 var(--mono); font-style: normal; color: #fff; background: rgba(23, 21, 28, .55); }
.cg-box.on i { background: var(--pencil); }
/* objects (lanterns, balloons) the matting picked up: amber and dashed, off unless tapped */
.cg-box.obj { border: 1.5px dashed rgba(255, 196, 61, .85); }
.cg-box:not(.obj) { z-index: 1; } /* where boxes overlap a tap means the person; objects also have chips below */
.cg-box.obj.on { border: 2px dashed #ffb21a; background: rgba(255, 178, 26, .1); }
.cg-box.obj.on i { background: #e69500; }
.cg-busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; font: 600 14px var(--sans); color: var(--ink);
    background: color-mix(in srgb, var(--surface) 62%, transparent); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 3; }
.cg-busy[hidden] { display: none; }
.cg-busy i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--pencil); animation: spin .8s linear infinite; }

.cg-strip { list-style: none; margin: 14px 0 0; padding: 4px 2px 10px; display: flex; gap: 10px; overflow-x: auto; scrollbar-width: thin; }
.cg-strip button { position: relative; display: block; width: 68px; height: 68px; padding: 0; border: 1px solid var(--line); border-radius: 4px; overflow: visible; background: var(--photo-bg); cursor: pointer; }
.cg-strip img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 3px; opacity: .72; transition: opacity .2s; }
.cg-strip button:hover img, .cg-strip button.on img { opacity: 1; }
.cg-strip button.on::after { content: ""; position: absolute; inset: -7px -6px; background: var(--loop-you) center / 100% 100% no-repeat; pointer-events: none; }
.cg-rec { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); font: 600 10px/1.5 var(--sans); color: #fff; background: var(--pencil); padding: 0 6px; border-radius: 999px; white-space: nowrap; }

.cg-subjects { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.cg-subjects button { position: relative; width: 64px; height: 76px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer; opacity: .45; transition: opacity .2s, border-color .2s; }
.cg-subjects button.on { opacity: 1; border-color: var(--pencil); }
.cg-cut { display: block; width: 100%; height: 100%; border-radius: 3px;
    background: repeating-conic-gradient(var(--tile) 0% 25%, var(--surface) 0% 50%) 0 0 / 10px 10px; }
.cg-cut img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cg-subjects i { position: absolute; right: -6px; top: -6px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%;
    font: 700 11px/1 var(--mono); font-style: normal; color: #fff; background: var(--hair); }
.cg-subjects button.on i { background: var(--pencil); }
.cg-subjects button.obj { border-style: dashed; }
.cg-subjects button.obj.on { border-color: #e69500; }
.cg-subjects button.obj.on i { background: #e69500; }
.cg-subjects small { position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%); font: 600 10px/1.5 var(--sans); padding: 0 5px; border-radius: 999px; color: #fff; background: #e69500; white-space: nowrap; }
.cg-none { font-size: 14px; color: var(--muted); }

/* ---------- ③ style + head ---------- */

.cg-head { margin-top: 26px; }
.cg-head label { display: flex; justify-content: space-between; font: 600 15px var(--sans); }
.cg-head output { font: 600 13px var(--mono); color: var(--pencil); }
.cg-head input[type="range"] { width: 100%; margin: 12px 0 2px; accent-color: #721bff; }
.cg-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); }
.cg-go { margin-top: 26px; width: 100%; }

/* ---------- ④ result ---------- */
.cg-tabs { margin: 6px 0 16px; }
.cg-tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 2px 8px rgba(20, 20, 31, .12); }
.cg-view { position: relative; }
.cg-moments, .cg-xhs { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 18px; }
.cg-moments[hidden], .cg-xhs[hidden] { display: none; }

/* a stand-in for a WeChat Moments post: avatar, name, a line of text, the 3×3 grid at the real gap ratio */
.cg-post { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 10px; max-width: 460px; }
.cg-avatar { width: 42px; height: 42px; border-radius: 5px; background: url("/assets/bias-apple-touch-icon.png?v=20260819-1") center / cover, var(--tile); }
.cg-post-body b { display: block; font-size: 15px; color: #576b95; }
.cg-post-body p { margin: 2px 0 8px; font-size: 15px; }
.cg-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.cg-pic-wrap { position: relative; }
.cg-grid-wrap { width: min(100%, 330px); }
/* "adjust it yourself" floats on the picture itself, so nobody has to find it below */
.cg-fab { position: absolute; left: 50%; bottom: 10px; z-index: 2; display: flex; gap: 2px; padding: 4px; transform: translateX(-50%);
    border-radius: 999px; background: rgba(20, 20, 26, .78); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 4px 16px rgba(0, 0, 0, .22); }
.cg-fab button { appearance: none; border: 0; background: transparent; color: #fff; font: 600 13px var(--sans); white-space: nowrap; padding: 8px 12px; border-radius: 999px; cursor: pointer; }
.cg-fab button span { margin-right: 5px; }
.cg-fab button:hover, .cg-fab button:focus-visible { background: rgba(255, 255, 255, .16); outline: none; }
.cg-fab button:disabled { opacity: .5; cursor: progress; }
@media (prefers-reduced-motion: no-preference) {
    .cg-fab { animation: fab-in .5s cubic-bezier(.2, .8, .2, 1) .6s both, fab-ping 1.6s ease-out 1.2s 2; }
}
@keyframes fab-in { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes fab-ping { 0% { box-shadow: 0 4px 16px rgba(0, 0, 0, .22), 0 0 0 0 rgba(114, 27, 255, .55); } 100% { box-shadow: 0 4px 16px rgba(0, 0, 0, .22), 0 0 0 14px rgba(114, 27, 255, 0); } }
.cg-tile { position: relative; aspect-ratio: 1; background: var(--photo-bg); }
.cg-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cg-tile i { position: absolute; left: 4px; top: 4px; min-width: 16px; height: 16px; padding: 0 4px; display: grid; place-items: center; border-radius: 3px;
    font: 700 10px/1 var(--mono); font-style: normal; color: #fff; background: rgba(23, 21, 28, .55); }
.cg-time { display: block; margin-top: 8px; font-size: 12px; color: var(--faint); }
.cg-gap { margin-top: 16px; }
.cg-gap button { padding: 5px 12px; font-size: 13px; }

.cg-xhs img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; background: var(--photo-bg); }
.cg-notice { margin: 14px 0 0; font-size: 14px; color: var(--muted); line-height: 1.6; }
.cg-notice:empty { display: none; }

/* ---------- ⑤ save ---------- */
.cg-save { display: grid; gap: 10px; margin-top: 6px; }
.cg-save .btn { width: 100%; gap: 8px; text-decoration: none; }
.cg-save .btn small { font-weight: 500; font-size: 12.5px; opacity: .75; }
.cg-single { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.cg-single a { display: inline-grid; place-items: center; min-width: 26px; height: 26px; margin: 2px 2px 0 0; border: 1px solid var(--line); border-radius: 4px;
    font: 600 12px var(--mono); color: var(--ink); text-decoration: none; }
.cg-single a:hover { border-color: var(--pencil); color: var(--pencil); }
.cg-single.err { color: var(--bad); }
.cg-tip { margin: 0; font-size: 14px; line-height: 1.6; }
.cg-long { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 14px; }
.cg-long img { display: block; width: 100%; height: auto; border-radius: 4px; background: var(--photo-bg); -webkit-touch-callout: default; }
.cg-long span { display: block; margin-top: 4px; font: 500 12px var(--mono); color: var(--muted); }
.cg-howto { margin: 22px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.cg-howto b { color: var(--ink); }
.cg-again { margin-top: 22px; }
.cg-result .honest { margin-top: 26px; }

@media (max-width: 640px) {
    .cg-drop { min-height: 300px; }
    .cg-sheet { padding: 10px; gap: 4px; }
    .cg-moments, .cg-xhs { padding: 12px; }
}

/* ---------- /lab: the list of experiments ---------- */
.lab-hub { padding: 64px 0 96px; border-top: 0; }
.lab-head { margin-bottom: 44px; }
.lab-head .lead { margin: 12px 0 0; font-size: 18px; color: var(--muted); }
.lab-group { margin: 0 0 14px; font: 500 13px/1.6 var(--mono); letter-spacing: .06em; color: var(--pencil); }
.lab-grid { list-style: none; margin: 0 0 52px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.lab-grid > li { display: flex; }
.lab-card { position: relative; display: grid; gap: 6px; align-content: start; width: 100%; padding: 22px; color: var(--ink); text-decoration: none; transition: border-color .2s; }
body.lab a.lab-card:hover { border-color: var(--pencil); }
.lab-no { font: 500 12px/1 var(--mono); color: var(--faint); }
.lab-art { width: min(100%, 230px); height: auto; margin: 10px 0 14px; }
.lab-name { font-size: 19px; }
.lab-say { font-size: 14px; line-height: 1.6; color: var(--muted); }
.lab-meta { margin-top: 4px; font: 500 12px/1.6 var(--mono); color: var(--faint); }
.lab-go { margin-top: 10px; font-size: 14px; font-weight: 600; color: var(--pencil); }
.lab-soon .lab-card { place-items: center; align-content: center; text-align: center; color: var(--faint); border-style: dashed; min-height: 180px; }
.lab-soon .lab-name { font-size: 15px; font-weight: 600; }
.lab-plus { font: 300 36px/1 var(--sans); }
.lab-app .lab-card { padding: 18px 20px; }
.lab-app .lab-go { margin-top: 4px; font-size: 13px; }
@media (max-width: 640px) {
    .lab-hub { padding: 40px 0 64px; }
    .lab-grid { grid-template-columns: 1fr; gap: 12px; }
    .lab-app { grid-template-columns: 1fr 1fr; }
    .lab-soon .lab-card { min-height: 0; padding: 14px 18px; grid-auto-flow: column; justify-content: center; gap: 10px; }
    .lab-plus { font-size: 22px; }
}
.cg-kicker a { color: inherit; text-decoration: none; }
.cg-kicker a:hover { text-decoration: underline; }

/* ---------- guide: "怎么玩" dialog, photo tips, first-time step hints ---------- */
.cg-how { appearance: none; display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; padding: 6px 14px 6px 6px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--ink); font: 600 14px/1.4 var(--sans); cursor: pointer; transition: border-color .2s; }
.cg-how span { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--pencil); color: #fff; font: 700 13px/1 var(--mono); }
.cg-how:hover { border-color: var(--pencil); }
.cg-how-link { appearance: none; padding: 0; border: 0; background: none; color: var(--pencil); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.cg-tips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.cg-tips span { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; line-height: 1.6; }
.cg-tips .ok { background: color-mix(in srgb, #1f9d6b 12%, transparent); color: #17865b; }
.cg-tips .no { background: color-mix(in srgb, #d9534f 11%, transparent); color: #c4423e; }
.cg-tips .ok::before { content: "✓"; font-weight: 700; }
.cg-tips .no::before { content: "✕"; font-weight: 700; }

.cg-coach { position: relative; display: flex; align-items: flex-start; gap: 10px; margin: 0 0 12px; padding: 10px 12px; border-radius: 12px;
    background: var(--pencil); color: #fff; font-size: 14px; line-height: 1.55; animation: cg-coach-in .45s var(--ease) both; }
.cg-coach::after { content: ""; position: absolute; left: 22px; bottom: -6px; width: 12px; height: 12px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
.cg-coach b { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: var(--pencil); font: 700 12px/1 var(--mono); }
.cg-coach span { flex: 1; padding-top: 1px; }
.cg-coach button { flex: none; appearance: none; align-self: center; padding: 3px 10px; border: 1px solid rgba(255, 255, 255, .55); border-radius: 999px; background: transparent; color: #fff; font: 600 12px/1.5 var(--sans); cursor: pointer; }
.cg-coach button:hover { background: rgba(255, 255, 255, .14); }
@keyframes cg-coach-in { from { opacity: 0; transform: translateY(6px); } }

.cg-guide { width: min(94vw, 720px); max-height: 92vh; padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
    box-shadow: 0 30px 80px -30px rgba(20, 20, 31, .45); }
.cg-guide::backdrop { background: rgba(13, 11, 18, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.cg-guide[open] { animation: cg-coach-in .35s var(--ease); }
.cg-guide-in { padding: 22px 24px 22px; }
.cg-guide-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.cg-guide-head h2 { margin: 0; font-size: 22px; }
.cg-guide-x { appearance: none; width: 34px; height: 34px; flex: none; border: 0; border-radius: 50%; background: var(--tile); color: var(--ink); font: 400 22px/1 var(--sans); cursor: pointer; }
.cg-guide-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; counter-reset: g; }
.cg-guide-steps li { position: relative; display: grid; gap: 4px; align-content: start; padding: 12px 14px 14px; border-radius: 12px; background: var(--tile); counter-increment: g; }
.cg-guide-steps li::before { content: counter(g); position: absolute; left: 12px; top: 12px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
    background: var(--pencil); color: #fff; font: 700 12px/1 var(--mono); }
.cg-guide-steps svg { width: 100%; max-width: 220px; height: auto; justify-self: center; margin: 4px 0 6px; }
.cg-guide-steps b { font-size: 16px; }
.cg-guide-steps span { font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.cg-guide-steps em { font-style: normal; color: var(--ink); font-weight: 600; }
.cg-guide-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }
/* guide drawings */
.cg-guide svg .ph { fill: var(--surface); stroke: var(--hair); }
.cg-guide svg .sk { fill: color-mix(in srgb, var(--pencil) 55%, var(--surface)); }
.cg-guide svg .good { fill: #1f9d6b; } .cg-guide svg .bad { fill: #d9534f; }
.cg-guide svg .mark { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cg-guide svg .box { fill: none; stroke: var(--pencil); stroke-width: 2.2; stroke-dasharray: 5 4; }
.cg-guide svg .hand { fill: var(--surface); stroke: var(--ink); stroke-width: 1.8; stroke-linejoin: round; }
.cg-guide svg .gr rect { fill: color-mix(in srgb, #5aa6e6 30%, var(--surface)); }
.cg-guide svg .gr.n rect { fill: var(--surface); stroke: var(--hair); }
.cg-guide svg .fr { fill: color-mix(in srgb, #5aa6e6 60%, var(--surface)); }
.cg-guide svg .pp { fill: var(--pencil); }
.cg-guide svg .num text { fill: var(--pencil); font: 700 13px var(--mono); text-anchor: middle; }
@media (max-width: 640px) {
    .cg-guide-in { padding: 18px 16px 16px; }
    .cg-guide-head h2 { font-size: 19px; }
    .cg-guide-steps { grid-template-columns: 1fr; }
    .cg-guide-steps li { grid-template-columns: 96px 1fr; column-gap: 12px; }
    .cg-guide-steps svg { grid-row: span 2; margin: 18px 0 0; }
    .cg-guide-row .btn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .cg-coach, .cg-guide[open] { animation: none; } }

/* guide drawings act out their step in a 4.2 s loop; the resting state is the finished picture,
   so with reduced motion (no animation) every drawing still reads correctly */
.cg-guide svg g, .cg-guide svg path, .cg-guide svg rect, .cg-guide svg circle { transform-box: fill-box; }
.cg-guide svg .a-ripple { fill: none; stroke: var(--pencil); stroke-width: 2; opacity: 0; transform-origin: center; }
.cg-guide svg .fr-edge { fill: color-mix(in srgb, #5aa6e6 60%, var(--surface)); }
@media (prefers-reduced-motion: no-preference) {
    .cg-guide[open] .a-ok { transform-origin: center; animation: g-pop 4.2s infinite; }
    .cg-guide[open] .a-no { transform-origin: center; animation: g-pop 4.2s infinite 1.1s both; }
    .cg-guide[open] .a-bad { transform-origin: 50% 100%; animation: g-shake 4.2s infinite; }
    .cg-guide[open] .a-ants { animation: g-ants .9s linear infinite, g-pick 4.2s infinite; }
    .cg-guide[open] .a-hand { transform-origin: 20% 0; animation: g-tap 4.2s infinite; }
    .cg-guide[open] .a-ripple { animation: g-ripple 4.2s infinite; }
    .cg-guide[open] .a-grow { transform-origin: 50% 100%; animation: g-grow 4.2s infinite; }
    .cg-guide[open] .a-pop { animation: g-rise 4.2s infinite; }
    .cg-guide[open] .gr.n rect { animation: g-lit 4.2s infinite both; animation-delay: calc(var(--k) * .26s); }
    .cg-guide[open] .num text { animation: g-lit-t 4.2s infinite both; animation-delay: calc(var(--k) * .26s); }
}
@keyframes g-pop { 0%, 8% { transform: scale(0); opacity: 0; } 16% { transform: scale(1.25); opacity: 1; } 22%, 84% { transform: scale(1); opacity: 1; } 92%, 100% { transform: scale(0); opacity: 0; } }
@keyframes g-shake { 0%, 26%, 40%, 100% { transform: none; } 29% { transform: rotate(-4deg); } 32% { transform: rotate(4deg); } 35% { transform: rotate(-3deg); } 38% { transform: rotate(2deg); } }
@keyframes g-ants { to { stroke-dashoffset: -18; } }
@keyframes g-pick { 0%, 44% { fill: transparent; } 50%, 82% { fill: color-mix(in srgb, var(--pencil) 22%, transparent); } 90%, 100% { fill: transparent; } }
@keyframes g-tap { 0% { transform: translate(16px, 26px); opacity: 0; } 14% { opacity: 1; } 38% { transform: translate(-14px, 0); } 44% { transform: translate(-14px, 0) scale(.86); } 52%, 80% { transform: translate(-14px, 0) scale(1); opacity: 1; } 94%, 100% { transform: translate(16px, 26px); opacity: 0; } }
@keyframes g-ripple { 0%, 43% { transform: scale(.3); opacity: 0; } 46% { opacity: .9; } 62%, 100% { transform: scale(2.2); opacity: 0; } }
@keyframes g-grow { 0%, 8% { transform: scale(.42); } 34%, 84% { transform: scale(1); } 96%, 100% { transform: scale(.42); } }
@keyframes g-rise { 0%, 42% { transform: translateY(20px); opacity: 0; } 50% { opacity: 1; } 58% { transform: translateY(-3px); } 64%, 86% { transform: none; opacity: 1; } 96%, 100% { transform: translateY(20px); opacity: 0; } }
@keyframes g-lit { 0% { fill: var(--surface); } 5%, 46% { fill: color-mix(in srgb, var(--pencil) 78%, var(--surface)); } 58%, 100% { fill: var(--surface); } }
@keyframes g-lit-t { 0% { fill: var(--pencil); } 5%, 46% { fill: #fff; } 58%, 100% { fill: var(--pencil); } }

/* ---------- editor: move / scale the person, swap / blank / replace background cells ---------- */
.cg-ed-entry { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; }
.cg-ed-entry .btn span { margin-right: 6px; }
.cg-ed-entry-t { font-size: 14px; font-weight: 600; color: var(--muted); }
.cg-ed-more { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--muted); }
.cg-editor { display: grid; gap: 10px; }
/* the mode switch is fused to the canvas's bottom edge, like a photo editor's tool bar */
.cg-ed-stage { width: min(100%, 520px); }
.cg-ed-stage .cg-canvas { width: 100%; border-radius: 6px 6px 0 0; }
.cg-ed-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 6px 6px; background: var(--well); }
.cg-ed-mode button { appearance: none; border: 0; background: transparent; color: var(--muted); font: 600 15px var(--sans); padding: 11px 8px; border-radius: 4px; cursor: pointer; transition: background .2s, color .2s; }
.cg-ed-mode button span { margin-right: 6px; }
.cg-ed-mode button[aria-checked="true"] { background: var(--pencil); color: #fff; }
.cg-ed-mode button:focus-visible { outline: 2px solid var(--pencil); outline-offset: 2px; }
.cg-ed-hint { margin: 0; font-size: 13px; color: var(--muted); }
.cg-canvas { --t: 0.32452; --s: 0.33774; position: relative; width: min(100%, 520px); aspect-ratio: 1; overflow: hidden; border-radius: 6px;
    background: #fff; box-shadow: 0 0 0 1px var(--line); touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; outline: none; }
.cg-canvas:focus-visible { box-shadow: 0 0 0 2px var(--pencil); }
.cg-canvas.grabbing { cursor: grabbing; }
.cg-canvas.cells-mode { cursor: default; }
.ed-cells { position: absolute; inset: 0; }
/* 胶囊拼图: three pills showing the main photo (moved with the person), round photo cells on the left */
.ed-pills { position: absolute; inset: 0; pointer-events: none; }
.ed-pill { position: absolute; overflow: hidden; border-radius: 999px; background: #f3f3f5; }
.ed-pill img { position: absolute; max-width: none; height: auto; }
.ed-cell.round { border-radius: 50%; }
.ed-cell.round .n { left: 50%; top: 8%; transform: translateX(-50%); }
.ed-cell.round .x { top: 8%; right: 8%; }
.ed-cell.round.sel::after, .ed-cell.round.drop::after { border-radius: 50%; }
.ed-cell { position: absolute; overflow: hidden; background: #f3f3f5; }
.ed-cell img { position: absolute; max-width: none; pointer-events: none; }
.ed-cell.blank { background: #fff; outline: 1px dashed rgba(0, 0, 0, .18); outline-offset: -1px; }
.ed-cell .n { position: absolute; left: 5px; top: 4px; font: 600 11px/1 var(--mono); color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); z-index: 1; }
.ed-cell.blank .n { color: rgba(0, 0, 0, .35); text-shadow: none; }
.ed-cell .plus { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(0, 0, 0, .3); font: 300 26px/1 var(--sans); }
.ed-cell .x { position: absolute; top: 4px; right: 4px; z-index: 2; display: none; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
    background: rgba(20, 20, 24, .66); color: #fff; font: 500 15px/1 var(--sans); cursor: pointer; }
.cells-mode .ed-cell .x { display: grid; }
.cells-mode .ed-cell { cursor: grab; }
/* drawn above the cell's photo (an inset shadow on the cell itself would sit under the img) */
.ed-cell.sel::after, .ed-cell.drop::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; box-shadow: inset 0 0 0 3px var(--pencil); }
.ed-cell.drop::after { box-shadow: inset 0 0 0 3px #1f9d6b; }
.ed-cell.lift { opacity: .45; }
.ed-clip { position: absolute; inset: 0; pointer-events: none; }
.ed-person { position: absolute; max-width: none; height: auto; filter: drop-shadow(0 6px 10px rgba(15, 18, 24, .28)); transition: opacity .2s; }
.cells-mode .ed-person { opacity: .4; }
.ed-seams { position: absolute; inset: 0; pointer-events: none; }
.ed-seams i { position: absolute; background: repeating-linear-gradient(45deg, rgba(114, 27, 255, .28) 0 4px, rgba(255, 255, 255, .5) 4px 8px); }
.ed-seams .v1, .ed-seams .v2 { top: 0; bottom: 0; width: calc((var(--s) - var(--t)) * 100%); }
.ed-seams .v1 { left: calc(var(--t) * 100%); } .ed-seams .v2 { left: calc((var(--s) + var(--t)) * 100%); }
.ed-seams .h1, .ed-seams .h2 { left: 0; right: 0; height: calc((var(--s) - var(--t)) * 100%); }
.ed-seams .h1 { top: calc(var(--t) * 100%); } .ed-seams .h2 { top: calc((var(--s) + var(--t)) * 100%); }
.ed-ghost { position: fixed; z-index: 50; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; pointer-events: none; opacity: .9;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .35); transform: translate(-50%, -50%) rotate(-4deg); background: #fff; }
.ed-ghost img { width: 100%; height: 100%; object-fit: cover; }
.cg-ed-size { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; width: min(100%, 520px); font-size: 14px; }
.cg-ed-size input { width: 100%; accent-color: var(--pencil); }
.cg-ed-crop { display: grid; gap: 8px; width: min(100%, 520px); padding: 10px 12px 12px; border-radius: 8px; background: var(--tile); }
.cg-ed-crop-t { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.ed-crop-frame { position: relative; justify-self: center; max-width: 100%; overflow: hidden; border-radius: 4px; touch-action: none; user-select: none;
    -webkit-user-select: none; cursor: crosshair; outline: none; }
.ed-crop-frame:focus-visible { box-shadow: 0 0 0 2px var(--pencil); }
.ed-crop-frame img { display: block; max-width: 100%; max-height: 240px; width: auto; height: auto; pointer-events: none; }
.ed-crop-dim { position: absolute; inset: 0; background: rgba(15, 18, 24, .58); pointer-events: none; }
.ed-crop-box { position: absolute; outline: 2px solid #fff; outline-offset: -1px; cursor: grab; }
.ed-crop-box i { position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(90deg, transparent calc(100% / 3 - .5px), rgba(255, 255, 255, .45) calc(100% / 3 - .5px) calc(100% / 3 + .5px), transparent calc(100% / 3 + .5px) calc(200% / 3 - .5px), rgba(255, 255, 255, .45) calc(200% / 3 - .5px) calc(200% / 3 + .5px), transparent calc(200% / 3 + .5px)),
        linear-gradient(180deg, transparent calc(100% / 3 - .5px), rgba(255, 255, 255, .45) calc(100% / 3 - .5px) calc(100% / 3 + .5px), transparent calc(100% / 3 + .5px) calc(200% / 3 - .5px), rgba(255, 255, 255, .45) calc(200% / 3 - .5px) calc(200% / 3 + .5px), transparent calc(200% / 3 + .5px)); }
.ed-crop-frame.grabbing, .ed-crop-frame.grabbing .ed-crop-box { cursor: grabbing; }
.cg-ed-tray { display: grid; gap: 6px; width: min(100%, 520px); }
.cg-ed-tray-t { font-size: 12.5px; color: var(--muted); }
.ed-tray { list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.ed-tray button { position: relative; display: block; width: 58px; height: 58px; padding: 0; border: 0; border-radius: 6px; overflow: hidden; cursor: grab; touch-action: none; background: var(--tile); }
.ed-tray img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.ed-tray .meh img { opacity: .55; }
.ed-tray small { position: absolute; left: 3px; bottom: 3px; padding: 0 5px; border-radius: 999px; background: rgba(20, 20, 24, .72); color: #fff; font: 600 10px/1.6 var(--sans); pointer-events: none; }
.ed-tray em { position: absolute; right: 3px; top: 3px; padding: 0 5px; border-radius: 999px; background: var(--pencil); color: #fff; font: 600 10px/1.6 var(--sans); font-style: normal; pointer-events: none; }
.ed-tray em.main { background: rgba(20, 20, 24, .72); }
.ed-tray em:empty { display: none; }
.ed-tray button:focus-visible { outline: 2px solid var(--pencil); outline-offset: 2px; }
/* "＋" comes first so it is never scrolled out of sight */
.ed-tray .ed-add { display: grid; place-content: center; gap: 1px; flex: none; cursor: pointer; touch-action: manipulation; background: var(--surface);
    border: 1.5px dashed var(--pencil); color: var(--pencil); font: 600 11px/1.2 var(--sans); }
.ed-tray .ed-add b { font-size: 22px; line-height: 1; font-weight: 500; }
.ed-tray .ed-add:hover { background: var(--you-wash, rgba(114, 27, 255, .08)); }
.ed-tray .ed-add:disabled { opacity: .55; cursor: progress; }
.ed-tray .ed-add.busy b { width: 16px; height: 16px; margin: 3px auto; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--pencil); font-size: 0; animation: spin .8s linear infinite; }
.ed-tray .fresh button:not(.ed-add) { box-shadow: 0 0 0 2px var(--pencil); }
.cg-ed-warn { margin: 0; min-height: 1.4em; font-size: 13px; color: #c4423e; }
.cg-ed-status { margin: 0; }
.cg-ed-status:empty { display: none; }
.cg-ed-actions { display: flex; align-items: center; gap: 10px; width: min(100%, 520px); }
/* on a phone 取消 / 完成 stay on screen however far the tray or crop panel pushes them */
@media (max-width: 920px) {
    .cg-ed-actions { position: sticky; bottom: 0; z-index: 5; width: auto; margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--paper) 94%, transparent); border-top: 1px solid var(--line); }
}
.cg-ed-actions .sp { flex: 1; }
@media (max-width: 640px) { .cg-ed-actions .btn { padding-inline: 14px; } }

/* ---------- effect picker (before choosing photos) ---------- */
.cg-fx { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 18px; }
@media (max-width: 1100px) { .cg-fx { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cg-fx-card { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: start; text-align: left; padding: 10px; border: 1px solid var(--line); border-radius: 6px;
    background: var(--surface); color: var(--ink); cursor: pointer; font: inherit; transition: border-color .2s, background .2s; }
.cg-fx-card:hover { border-color: var(--hair); }
.cg-fx-card[aria-checked="true"] { border-color: var(--pencil); box-shadow: inset 0 0 0 .5px var(--pencil); background: var(--you-wash); }
.cg-fx-card:focus-visible { outline: 2px solid var(--pencil); outline-offset: 2px; }
.cg-fx-card:disabled { opacity: .55; cursor: progress; }
.cg-fx-card > svg { width: 52px; height: 52px; }
/* animated icons: each one shows what the effect does, looping every 4.2 s; reduced motion shows the end state */
.fx-ic { overflow: visible; }
.fx-ic .p { fill: var(--pencil); }
.fx-ic .t1 { fill: #cfe8fb; } .fx-ic .t2 { fill: #cdebd5; } .fx-ic .t3 { fill: #fde3c4; } .fx-ic .t4 { fill: #e2dcf7; }
/* 人走出九宫格: the person grows out of cell 1 and spans down the column */
.fx-span .who { transform-box: view-box; transform-origin: 14px 0; }
/* 朋友圈连拼: the person pops up out of the frame in the middle cell */
.fx-mo .frame-bg { fill: var(--surface); }
.fx-mo .frame { fill: none; stroke: var(--pencil); stroke-width: 2; }
/* 整图九宫格: one picture, cut by the seams into nine, which drift apart and back */
.fx-sl .pc { transform-box: fill-box; transform-origin: center; }
.fx-sl .whole { opacity: 0; }
/* 胶囊拼图: the three round photos pop in one by one, then the person rises out of the pills */
.fx-pl .dot { transform-box: fill-box; transform-origin: center; }
@media (prefers-reduced-motion: no-preference) {
    .fx-pl .dot { animation: fx-dot 4.2s cubic-bezier(.3, .7, .2, 1) infinite; }
    .fx-pl .d2 { animation-delay: .18s; } .fx-pl .d3 { animation-delay: .36s; }
    .fx-pl .who { animation: fx-rise 4.2s cubic-bezier(.3, .7, .2, 1) infinite; }
    .fx-span .who { animation: fx-grow 4.2s cubic-bezier(.3, .7, .2, 1) infinite; }
    .fx-mo .who { animation: fx-pop 4.2s cubic-bezier(.3, .7, .2, 1) infinite; }
    .fx-mo .frame { animation: fx-frame 4.2s ease-out infinite; }
    .fx-sl .whole { animation: fx-whole 4.2s ease-in-out infinite; }
    .fx-sl .pc { animation: fx-split 4.2s cubic-bezier(.4, 0, .2, 1) infinite; }
}
@keyframes fx-grow { 0%, 14% { transform: scale(.3); } 46%, 84% { transform: scale(1); } 100% { transform: scale(.3); } }
@keyframes fx-pop { 0%, 14% { transform: translateY(26px); } 38% { transform: translateY(-3px); } 46%, 84% { transform: translateY(0); } 100% { transform: translateY(26px); } }
@keyframes fx-frame { 0%, 28% { stroke-width: 2; } 36% { stroke-width: 3.2; } 50%, 100% { stroke-width: 2; } }
@keyframes fx-dot { 0%, 4% { transform: scale(0); } 20%, 86% { transform: scale(1); } 96%, 100% { transform: scale(0); } }
@keyframes fx-rise { 0%, 28% { transform: translateY(44px); } 46% { transform: translateY(-3px); } 54%, 86% { transform: translateY(0); } 100% { transform: translateY(44px); } }
@keyframes fx-whole { 0%, 20% { opacity: 1; } 32%, 88% { opacity: 0; } 100% { opacity: 1; } }
@keyframes fx-split { 0%, 34% { transform: none; } 52%, 74% { transform: translate(calc(var(--dx) * 2.5px), calc(var(--dy) * 2.5px)) scale(.86); } 88%, 100% { transform: none; } }
.cg-fx-card span { display: grid; gap: 2px; min-width: 0; }
.cg-fx-card b { font-size: 14px; }
.cg-fx-card small { font-size: 12px; line-height: 1.45; color: var(--muted); }
.cg-fx-card em { font-style: normal; font-size: 11.5px; line-height: 1.45; color: var(--pencil); }
@media (max-width: 480px) {
    .cg-fx { grid-template-columns: 1fr; gap: 6px; }
    .cg-fx-card { grid-template-columns: 44px minmax(0, 1fr); gap: 10px; padding: 9px; }
    .cg-fx-card > svg { width: 44px; height: 44px; }
}
/* the floating 自己调整 buttons: one per effect when only one kind of adjustment makes sense */
.cg-result[data-fx="slice"] .cg-fab [data-open="cells"] { display: none; }
