/* generation flow: progress → result, and the "not enough credits" sheet */
.gf-sheet{position:fixed;inset:auto 0 0 0;margin:0 auto;width:min(100%,520px);max-width:100%;max-height:94vh;max-height:94dvh;overflow-y:auto;padding:10px 18px calc(18px + env(safe-area-inset-bottom));border:1px solid var(--line,#ffffff22);border-bottom:0;border-radius:26px 26px 0 0;background:var(--surface,#1b1c27);color:var(--text,#fff);box-sizing:border-box}
.gf-sheet[open]{animation:gf-up .24s ease-out}
.gf-sheet::backdrop{background:#000a;backdrop-filter:blur(4px)}
@keyframes gf-up{from{transform:translateY(40px);opacity:.4}to{transform:none;opacity:1}}
.gf-grab{display:block;width:40px;height:4px;border-radius:4px;background:var(--muted,#888);opacity:.5;margin:0 auto 10px}
.gf-close{position:absolute;top:16px;right:14px;width:34px;height:34px;display:grid;place-items:center;padding:0;border-radius:50%;border:1px solid var(--line,#ffffff30);background:var(--surface2,#ffffff14);color:var(--text,#fff);cursor:pointer}
.gf-close svg{width:16px;height:16px}
.gf-head{display:flex;align-items:center;gap:10px;margin:6px 48px 0 0;font-size:21px;line-height:1.2}
.gf-dot{width:9px;height:9px;border-radius:50%;background:linear-gradient(135deg,#924bfa,#e54e9e);box-shadow:0 0 10px #c43bd5}
.gf-sheet[data-state=busy] .gf-dot{animation:gf-pulse 1.1s ease-in-out infinite}
.gf-sheet[data-state=done] .gf-dot{background:#3ddc97;box-shadow:0 0 10px #3ddc97aa}
.gf-sheet[data-state=error] .gf-dot{background:#ff6b6b;box-shadow:0 0 10px #ff6b6baa}
@keyframes gf-pulse{50%{transform:scale(.6);opacity:.5}}

/* busy: the result "develops" in a glowing frame */
.gf-stage{--p:0;position:relative;display:grid;place-items:center;height:clamp(250px,78vw,340px);margin:14px 0 4px}
.gf-stage::before{content:"";position:absolute;inset:6% 14%;border-radius:50%;background:radial-gradient(closest-side,#c43bd566,#924bfa33 60%,transparent);filter:blur(18px);animation:gf-breathe 3s ease-in-out infinite}
@keyframes gf-breathe{50%{transform:scale(1.12);opacity:.7}}
.gf-frame{position:relative;height:100%;aspect-ratio:3/4;margin:0;border-radius:24px;overflow:hidden;isolation:isolate;background:#14121f;box-shadow:0 18px 40px #0009}
.gf-frame::before{content:"";position:absolute;inset:-50%;z-index:-1;background:conic-gradient(from 0deg,#924bfa,#c43bd5,#e54e9e,#ffb36b,#924bfa);animation:gf-rot 3.2s linear infinite}
.gf-frame::after{content:"";position:absolute;inset:3px;z-index:0;border-radius:21px;background:#14121f}
.gf-frame img{position:absolute;inset:3px;z-index:1;width:calc(100% - 6px);height:calc(100% - 6px);object-fit:cover;border-radius:21px;
 filter:blur(calc(22px - var(--p) * 18px)) saturate(calc(.4 + var(--p) * .9)) brightness(calc(.6 + var(--p) * .4));transform:scale(calc(1.18 - var(--p) * .16));transition:filter .3s linear,transform .3s linear}
.gf-scan{display:none;position:absolute;left:3px;right:3px;z-index:2;height:34%;border-radius:21px;background:linear-gradient(180deg,transparent,#d9b4ff22 70%,#fff8 97%,transparent);mix-blend-mode:screen;animation:gf-scan 2.4s cubic-bezier(.45,0,.55,1) infinite}
@keyframes gf-scan{0%{top:-34%}100%{top:100%}}
.gf-sparks{position:absolute;inset:3px;z-index:3;overflow:hidden;border-radius:21px;pointer-events:none}
.gf-sparks i{position:absolute;left:var(--x);bottom:-10px;width:5px;height:5px;border-radius:50%;background:#fff;box-shadow:0 0 8px 2px #e9c8ff;animation:gf-rise var(--d) ease-in var(--w) infinite}
.gf-sparks i:nth-child(3n){width:3px;height:3px;box-shadow:0 0 6px 1px #ff9ad1}
@keyframes gf-rise{0%{transform:translateY(0) scale(.4);opacity:0}20%{opacity:1}100%{transform:translateY(-330px) scale(1.2);opacity:0}}
.gf-pct{position:absolute;z-index:4;left:50%;top:50%;transform:translate(-50%,-50%);font-size:44px;font-weight:800;letter-spacing:-.02em;color:#fff;text-shadow:0 0 18px #c43bd5,0 2px 8px #0009;font-variant-numeric:tabular-nums}
.gf-play{display:none;position:absolute;z-index:4;left:50%;top:calc(50% + 38px);transform:translateX(-50%);border-left:14px solid #fffc;border-top:9px solid transparent;border-bottom:9px solid transparent;filter:drop-shadow(0 0 6px #c43bd5);animation:gf-pulse 1.4s ease-in-out infinite}
.gf-sheet[data-kind=video] .gf-play{display:block}
.gf-sheet[data-kind=video] .gf-frame{aspect-ratio:9/16}
.gf-face{position:absolute;z-index:5;left:calc(50% - min(39vw,128px) - 8px);bottom:6px;width:64px;height:64px;margin:0;border-radius:50%;overflow:hidden;border:3px solid #fff;box-shadow:0 6px 18px #0009,0 0 0 4px #924bfa55;animation:gf-float 2.6s ease-in-out infinite}
.gf-sheet[data-kind=video] .gf-face{left:calc(50% - min(22vw,96px) - 40px)}
.gf-face img{width:100%;height:100%;object-fit:cover;display:block}
.gf-face .gf-ph svg{width:28px;height:28px}
.gf-orbit{display:none}
@keyframes gf-rot{to{transform:rotate(360deg)}}
.gf-ph{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;color:#fff;font-weight:650;font-size:14px;background:linear-gradient(160deg,#3b2a66,#5a2b78 55%,#7a2f7e)}

/* step list */
.gf-steps{list-style:none;margin:6px 0 12px;padding:0;display:grid;grid-template-columns:1fr 1fr;gap:6px 10px}
.gf-steps li{display:flex;align-items:center;gap:7px;font-size:12.5px;color:var(--muted,#a6a5b6);transition:color .3s}
.gf-steps li::before{content:"";line-height:1;flex:none;width:14px;height:14px;border-radius:50%;border:1.5px solid currentColor;opacity:.6;box-sizing:border-box}
.gf-steps li.now{color:var(--text,#fff);font-weight:650}
.gf-steps li.now::before{opacity:1;border-color:#ffffff33;border-top-color:#e54e9e;border-right-color:#d9b4ff;animation:gf-rot .8s linear infinite}
.gf-steps li.ok{color:color-mix(in srgb,var(--text,#fff) 80%,transparent)}
.gf-steps li.ok::before{content:"✓";opacity:1;border:0;display:grid;place-items:center;font-size:9px;font-weight:800;color:#fff;background:linear-gradient(135deg,#924bfa,#e54e9e)}

.gf-progress{margin:8px 0 4px}
.gf-prog-text{margin:0 0 8px;font-size:15px;font-weight:650;color:color-mix(in srgb,var(--accent,#b06cff) 70%,#fff)}
.gf-bar{height:6px;border-radius:6px;background:var(--surface2,#ffffff14);overflow:hidden}
.gf-bar i{position:relative;display:block;height:100%;width:0;border-radius:inherit;background:linear-gradient(90deg,#924bfa,#c43bd5 60%,#e54e9e);transition:width .3s linear;box-shadow:0 0 12px #c43bd5}
.gf-bar i::after{content:"";position:absolute;inset:0;background:linear-gradient(90deg,transparent,#fff7,transparent);background-size:60px 100%;background-repeat:no-repeat;animation:gf-shine 1.2s linear infinite}
@keyframes gf-shine{from{background-position:-60px 0}to{background-position:calc(100% + 60px) 0}}
.gf-note{margin:10px 0 0;font-size:12.5px;color:var(--muted,#a6a5b6)}

/* result */
.gf-result{margin:14px 0 0;border-radius:22px;overflow:hidden;background:#0d0c14 repeating-conic-gradient(#ffffff0d 0 25%,transparent 0 50%) 0 0/18px 18px;animation:gf-pop .35s ease-out}
.gf-result video{display:block;width:100%;max-height:58vh;max-height:58dvh;background:#000}
.gf-result img{display:block;width:100%;max-height:58vh;max-height:58dvh;object-fit:contain}
@keyframes gf-pop{from{transform:scale(.94);opacity:0}to{transform:none;opacity:1}}
.gf-meta{display:flex;flex-direction:column;gap:2px;margin:12px 2px 2px}
.gf-meta strong{font-size:16px}
.gf-meta small{font-size:12px;color:var(--muted,#a6a5b6)}

/* error */
.gf-error{display:flex;gap:12px;align-items:flex-start;margin:16px 0 4px;padding:14px;border-radius:18px;background:#ff6b6b14;border:1px solid #ff6b6b40}
.gf-error svg{flex:none;width:24px;height:24px;color:#ff8a8a}
.gf-error p{margin:0;font-size:14px;line-height:1.45}

/* actions */
.gf-actions{display:flex;flex-direction:column;gap:10px;margin-top:16px}
.gf-row{display:flex;gap:10px}
.gf-sheet .gf-save,.gf-sheet .gf-topup{display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:50px!important;border-radius:999px!important;font-size:15px!important;text-decoration:none;box-sizing:border-box}
.gf-save svg{width:18px;height:18px}
.gf-ghost{flex:1;display:inline-flex;align-items:center;justify-content:center;gap:7px;min-height:44px;padding:0 14px;border-radius:999px;border:1px solid var(--line,#ffffff30);background:var(--surface2,#ffffff12);color:var(--text,#fff);font:inherit;font-size:14px;font-weight:600;cursor:pointer}
.gf-ghost svg{width:17px;height:17px}
.gf-wide{width:100%}

/* which parts are visible in each state */
.gf-sheet:not([data-state=busy]) .gf-stage,.gf-sheet:not([data-state=busy]) .gf-progress{display:none}
.gf-sheet:not([data-state=done]) .gf-result,.gf-sheet:not([data-state=done]) .gf-meta,.gf-sheet:not([data-state=done]) .gf-save,.gf-sheet:not([data-state=done]) .gf-row .gf-ghost:first-child{display:none}
.gf-sheet:not([data-state=error]) .gf-error{display:none}
.gf-sheet[data-state=done] .gf-wide,.gf-sheet[data-state=busy] .gf-row{display:none}
.gf-low .gf-wide{display:flex}
.gf-sheet [hidden]{display:none!important}

/* not enough credits */
.gf-low{text-align:center}
.gf-coin{width:76px;height:76px;margin:14px auto 12px;display:grid;place-items:center;border-radius:50%;background:radial-gradient(circle at 35% 30%,#d9b4ff,#924bfa 55%,#5a2b9e);box-shadow:0 0 0 8px #924bfa22,0 0 34px #c43bd588;animation:gf-float 2.6s ease-in-out infinite}
.gf-coin span{font-size:34px;filter:drop-shadow(0 2px 3px #0006)}
@keyframes gf-float{50%{transform:translateY(-5px)}}
.gf-low-title{margin:0 0 6px;font-size:21px}
.gf-low-text{margin:0 auto 14px;max-width:340px;font-size:14px;line-height:1.45;color:var(--muted,#a6a5b6)}
.gf-meter{display:flex;gap:10px;margin:0 0 16px}
.gf-meter-cell{flex:1;display:flex;flex-direction:column;gap:2px;padding:12px;border-radius:18px;background:var(--surface2,#ffffff10);border:1px solid var(--line,#ffffff22)}
.gf-meter-cell small{font-size:12px;color:var(--muted,#a6a5b6)}
.gf-meter-cell b{font-size:20px}
.gf-need{border-color:color-mix(in srgb,#c43bd5 60%,transparent);background:color-mix(in srgb,#c43bd5 14%,transparent)}
.gf-low .gf-actions,.gf-low .gf-wide{margin-top:10px}
.gf-low-note{margin:12px 0 0;font-size:12px;color:var(--muted,#a6a5b6)}

body.light .gf-sheet::backdrop{background:#2a1f4a66}
@media(prefers-reduced-motion:reduce){.gf-sheet *,.gf-sheet *::before,.gf-sheet *::after{animation:none!important}}

/* music: an equalizer instead of the picture */
.gf-eq{display:none;position:absolute;inset:3px;z-index:2;align-items:flex-end;justify-content:center;gap:5px;padding:0 14px 22%;border-radius:21px;background:radial-gradient(circle at 50% 80%,#c43bd555,transparent 70%),linear-gradient(160deg,#2a1450,#5a1f6e 60%,#7a2f7e)}
.gf-eq i{flex:1;max-width:16px;height:30%;border-radius:8px;background:linear-gradient(180deg,#e9c8ff,#c43bd5 60%,#e54e9e);box-shadow:0 0 12px #c43bd5aa;transform-origin:50% 100%;animation:gf-eq var(--d) ease-in-out var(--w) infinite alternate}
@keyframes gf-eq{from{transform:scaleY(.25)}to{transform:scaleY(1.6)}}
.gf-sheet[data-kind=music] .gf-eq{display:flex}
.gf-sheet[data-kind=music] .gf-frame img,.gf-sheet[data-kind=music] .gf-scan,.gf-sheet[data-kind=music] .gf-face,.gf-sheet[data-kind=music] .gf-sparks{display:none}
.gf-sheet[data-kind=music] .gf-frame{aspect-ratio:1/1;height:auto;width:min(66vw,250px)}
.gf-sheet[data-kind=music] .gf-pct{top:18%}
.gf-result audio{display:block;width:100%;margin:0;padding:14px;box-sizing:border-box}
.gf-result audio[hidden]{display:none}

/* notice: a job finished while the app was in the background */
.gen-toast{position:fixed;left:50%;bottom:96px;z-index:50;max-width:min(92vw,420px);padding:11px 16px;border-radius:999px;font-size:13.5px;font-weight:600;color:#fff;text-align:center;background:linear-gradient(115deg,#924bfa,#c43bd5 60%,#e54e9e);box-shadow:0 10px 30px #0008;transform:translate(-50%,20px);opacity:0;transition:transform .3s,opacity .3s}
.gen-toast.on{transform:translate(-50%,0);opacity:1}

/* five seconds to change your mind: nothing has been sent yet */
.gf-cancel{width:100%;margin-top:10px;border-color:#ff8aa8aa;color:#ffd0dc;background:#ff4f7a1a}
.gf-cancel:disabled{opacity:.6}
