:root { --bg:#0f1220; --panel:#181c30; --line:#2b3150; --text:#eef0ff; --muted:#a6abc8; --pri:#5b7cfa; --acc:#ff6fa7; --err:#ff8080; --ok:#7be3a4; --blue:#6fb0ff; --green:#5fe08a; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: #9fb4ff; }
[hidden] { display: none !important; }
.small { font-size: .78rem; color: var(--muted); }
.btn { min-height: 34px; padding: .3rem .65rem; border-radius: 8px; border: 1px solid var(--line); background: #232845; color: var(--text); font: inherit; font-size: .85rem; cursor: pointer; touch-action: manipulation; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--pri); border-color: var(--pri); font-weight: 600; }
.btn.accent { background: #3a2140; border-color: var(--acc); }
.error { color: var(--err); margin: .3rem 0; } .ok { color: var(--ok); margin: .3rem 0; }
.empty { color: var(--muted); }
/* price labels: real xAI cost in blue, double in green */
.price { white-space: nowrap; font-weight: 700; }
.p-real { color: var(--blue); font-weight: 700; }
.p-dbl { color: var(--green); font-weight: 700; margin-left: .35em; }

/* app shell: preview on the left (large), dense control dock on the right, one screen */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .35rem .8rem; background: #12162a; border-bottom: 1px solid var(--line); height: 42px; }
.brand { font-weight: 700; }
.account { display: flex; align-items: center; gap: .7rem; margin-left: auto; }
.balance { background: #1f2c1f; border: 1px solid #3c6b44; padding: .2rem .7rem; border-radius: 999px; white-space: nowrap; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: .6rem; padding: .6rem; height: calc(100vh - 42px); }
.stage { min-width: 0; display: flex; flex-direction: column; gap: .4rem; min-height: 0; }
.dock { min-width: 0; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .5rem; display: flex; flex-direction: column; gap: .5rem; scrollbar-width: thin; }
.dock-sec { display: grid; gap: .35rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }
.dock-sec h3 { margin: 0; font-size: .85rem; } .dock-sec h4 { margin: .3rem 0 0; font-size: .8rem; color: var(--muted); }
.moderation-note { font-size: .66rem; line-height: 1.25; color: var(--muted); background: #1d2038; border-left: 3px solid #e0b44a; padding: .3rem .5rem; border-radius: 6px; margin: 0; }
.upload-btn { display: inline-flex; align-items: center; position: relative; overflow: hidden; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-btn[aria-disabled="true"] { opacity: .45; }
.thumbs { display: flex; gap: .4rem; flex-wrap: wrap; min-height: 56px; border: 1px dashed var(--line); border-radius: 8px; padding: .3rem; align-items: center; }
.thumb { width: 52px; height: 52px; padding: 0; border-radius: 6px; border: 3px solid transparent; background: #000; overflow: hidden; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb[aria-selected="true"] { border-color: var(--acc); }
.preview-box { position: relative; flex: 1 1 auto; min-height: 300px; background: #0b0d18; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; overflow: hidden; }
#editor { width: 100%; height: 100%; padding: 8px; }
#editor-inner { width: 100%; height: 100%; }
#editor img { display: block; max-width: 100%; }
#result { position: relative; display: grid; place-items: center; width: 100%; height: 100%; padding: .4rem; }
#result-img { max-width: 100%; max-height: calc(100vh - 220px); border-radius: 8px; }
.badge { position: absolute; top: .6rem; left: .6rem; background: var(--acc); color: #1a0010; font-weight: 700; padding: .15rem .6rem; border-radius: 999px; z-index: 2; font-size: .8rem; }
#back-btn { position: absolute; top: .6rem; right: .6rem; z-index: 2; }
.view-result { position: absolute; top: .6rem; right: .6rem; z-index: 4; }
.small-btn { min-height: 28px; padding: .15rem .6rem; font-size: .8rem; }
.busy { position: absolute; inset: 0; background: rgba(8,10,20,.75); display: grid; place-content: center; text-align: center; z-index: 5; }
.spinner { width: 36px; height: 36px; border: 4px solid #444b77; border-top-color: var(--acc); border-radius: 50%; margin: 0 auto .5rem; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.edits-box { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: .35rem .5rem; background: #12162a; }
.edit-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem; }
.edit-item { display: inline-flex; align-items: center; gap: .25rem; background: #2a2150; border: 1px solid var(--acc); border-radius: 999px; padding: .1rem .2rem .1rem .6rem; font-size: .8rem; }
.edit-remove { border: 0; background: #4a2a5e; color: var(--text); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }
#reset-original { margin-left: auto; }
#regenerate { margin-left: 0; }
.row, .transform-row, .bg-row { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.sliders { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.slider { display: grid; gap: 0; font-size: .8rem; }
.slider span { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); }
input[type=range] { width: 100%; height: 30px; margin: 0; accent-color: var(--acc); touch-action: pan-y; }
input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; }
.transform-row .btn { flex: 1 1 140px; }
.bg-thumb { margin: 0; text-align: center; }
.bg-thumb img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; border: 2px solid var(--line); display: block; }
.bg-thumb figcaption { font-size: .62rem; color: var(--muted); }
.presets { display: grid; gap: .3rem; }
.preset-row { display: grid; grid-template-columns: 1fr auto; gap: .3rem; align-items: center; }
.preset-select { min-height: 32px; border-radius: 8px; background: #232845; color: var(--text); border: 1px solid var(--line); padding: 0 .4rem; font: inherit; font-size: .82rem; min-width: 0; }
.faceswap, .figures { border-top: 1px solid var(--line); padding-top: .3rem; }
.check { display: flex; gap: .4rem; align-items: center; }
.check input { width: 18px; height: 18px; }
.small-thumbs { display: flex; gap: .3rem; flex-wrap: wrap; align-items: center; }
.fig-thumb { position: relative; width: 40px; height: 40px; border-radius: 6px; overflow: hidden; border: 2px solid var(--line); cursor: pointer; }
.fig-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fig-thumb input { position: absolute; top: 1px; right: 1px; width: 16px; height: 16px; }
.btn.big { width: 100%; min-height: 42px; font-size: 1rem; }
.busy-inline { display: flex; align-items: center; gap: .5rem; }
.busy-inline .spinner { width: 18px; height: 18px; margin: 0; border-width: 3px; }
.gallery-box { border: 1px solid var(--line); border-radius: 10px; padding: .5rem; background: #0b0d18; }
.gallery-box h3 { margin: 0 0 .3rem; font-size: .85rem; }
.gallery { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.gallery-item { display: flex; gap: .5rem; align-items: center; }
.gallery-thumb img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; display: block; border: 1px solid var(--line); }
.gallery-meta { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.gallery-meta .small { flex-basis: 100%; }
.gallery-meta .btn { text-decoration: none; display: inline-flex; align-items: center; }
.footer { text-align: center; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: grid; place-items: center; z-index: 20; padding: 1rem; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem; max-width: 520px; display: grid; gap: .5rem; }
.modal-card h2 { margin: 0; }
.terms { max-width: 760px; margin: 0 auto; padding: 1.5rem 1rem 3rem; font-size: 1rem; }
.terms-page { overflow: auto; } 
/* cropper handles (mouse + touch) */
.cropper-point.point-ne, .cropper-point.point-nw, .cropper-point.point-se, .cropper-point.point-sw { width: 14px; height: 14px; opacity: .9; border-radius: 50%; }
.cropper-point.point-ne { right: -7px; top: -7px; } .cropper-point.point-nw { left: -7px; top: -7px; }
.cropper-point.point-sw { left: -7px; bottom: -7px; } .cropper-point.point-se { right: -7px; bottom: -7px; }
.cropper-point.point-se::before { display: none; }
@media (pointer: coarse) { .cropper-point { width: 16px !important; height: 16px !important; opacity: .9; } input[type=range] { height: 36px; } }
/* phones: big preview on top, compact controls underneath */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  .layout { grid-template-columns: 1fr; height: auto; padding: .4rem; }
  .dock { overflow: visible; }
  .preview-box { min-height: 52vh; flex: none; }
  #result-img { max-height: 50vh; }
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.final-bar { position: sticky; bottom: -.5rem; z-index: 3; background: var(--panel); padding: .3rem 0; display: grid; gap: .25rem; }
.final-section { border-bottom: 0; }
.dock-sec h3 .small { font-weight: 400; }
.final-bar .btn.primary { background: #1a2760; border-color: var(--pri); }
.final-bar .btn.primary:disabled { background: #1a2038; }

/* crop preview / apply */
.crop-info { display: flex; gap: .4rem; align-items: center; }
.crop-info canvas { max-width: 72px; max-height: 72px; border-radius: 6px; border: 2px solid var(--line); background: #0b0d18; display: block; }
.crop-preview .cropper-modal { opacity: .75; }
.crop-preview .cropper-view-box { outline-color: var(--pri); }

/* upload bar: above the main image, below the top bar */
.upload-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.upload-bar .upload-btn { flex: 0 0 auto; }
.upload-bar .moderation-note { flex: 1 1 260px; }
.upload-bar .error { flex-basis: 100%; margin: 0; }
.thumbs { max-height: 132px; overflow-y: auto; }
/* permission notice (face swap): prominent, above "Change the photo" */
.consent-banner { display: grid; gap: .15rem; background: #3a2140; border: 2px solid var(--acc); border-radius: 10px; padding: .4rem .6rem; }
.consent-banner .check { font-size: 1.15rem; font-weight: 700; color: #fff; align-items: flex-start; }
.consent-banner .check input { width: 22px; height: 22px; accent-color: var(--acc); flex: 0 0 auto; }
.consent-banner.flash { animation: flash 1.2s ease 2; }
@keyframes flash { 50% { box-shadow: 0 0 0 4px var(--acc); } }
.gallery-sub { margin: .5rem 0 0; font-size: .85rem; }
.balance strong.pending { color: #ffd479; }

.brand a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.brand a:hover { color: var(--acc); }

/* credit prices on buttons */
.price .cr { color: var(--ok); font-weight: 700; }

