@font-face {
  font-family: "Pixelify Sans";
  src: url("/fonts/pixelify-sans-latin.woff") format("woff");
  font-weight: 400 700;
  font-display: swap;
}
:root {
  --bg: #101633;
  --bg2: #161e45;
  --card: #1b2454;
  --card2: #222c63;
  --line: #34407f;
  --text: #eef1ff;
  --muted: #a8b0d8;
  --sky: #4cc9ff;
  --sun: #ffcf3a;
  --sun-dark: #c99a00;
  --pink: #ff6b9a;
  --pixel: "Pixelify Sans", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); font: 16px/1.55 var(--sans); font-variant-ligatures: no-common-ligatures;
  background:
    linear-gradient(rgba(76,201,255,.05) 1px, transparent 1px) 0 0/32px 32px,
    linear-gradient(90deg, rgba(76,201,255,.05) 1px, transparent 1px) 0 0/32px 32px,
    radial-gradient(1200px 600px at 50% -200px, #24307a 0%, var(--bg) 60%) var(--bg);
  min-height: 100vh;
}
img { max-width: 100%; }
/* Wrapped inline links need one solid box for centre hit testing. */
a { display: inline-block; max-width: 100%; }
h2 { font-size: 30px; }
@media (max-width: 600px) { h2 { font-size: 24px; } }
h1, h2, h3, .step-title, .q-title, .btn-gen, .btn.primary, .pill, .eyebrow, .num, .style-name, .q-big, .full-title, .brand span { font-family: var(--pixel); font-variant-ligatures: none; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1080px; margin: 0 auto; padding: 16px 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 22px; }
.brand b { color: var(--sun); font-weight: 700; }
.brand img { image-rendering: pixelated; }
.brand span { white-space: nowrap; }
.pill { font-size: 13px; color: var(--bg); background: var(--sky); padding: 5px 10px; box-shadow: 3px 3px 0 #1f6f93; white-space: nowrap; }

main { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.tool { display: grid; grid-template-columns: 1fr 520px; gap: 48px; align-items: start; padding: 28px 0 56px; }
.intro { padding-top: 36px; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; color: var(--sky);
  text-transform: uppercase; letter-spacing: .08em; font-size: 14px; }
.dot { width: 10px; height: 10px; background: var(--sun); box-shadow: 2px 2px 0 var(--sun-dark); flex: none; }
h1 { font-size: 52px; line-height: 1.05; margin: 0 0 18px; letter-spacing: .01em; }
.lede { color: var(--muted); font-size: 19px; margin: 0; max-width: 30em; }

.card { background: var(--card); border: 3px solid var(--line); box-shadow: 8px 8px 0 #0a0f26; padding: 22px; }
.step { margin-bottom: 22px; }
.step-title { font-weight: 700; display: flex; align-items: center; gap: 10px; font-size: 17px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .06em; }
.num { display: inline-grid; place-items: center; width: 26px; height: 26px; background: var(--sun); color: var(--bg);
  font-size: 15px; box-shadow: 2px 2px 0 var(--sun-dark); flex: none; }

.drop { display: block; cursor: pointer; border: 3px dashed var(--line); background: var(--bg2); min-height: 190px;
  padding: 18px; text-align: center; transition: border-color .15s, background .15s; outline: none; }
.drop:hover, .drop.drag, .drop:focus-visible { border-color: var(--sky); background: #19245a; }
.drop-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 8px; color: var(--muted); }
.drop-empty strong { color: var(--text); font-family: var(--pixel); font-size: 20px; font-weight: 500; }
.drop-empty small { margin-top: 8px; font-size: 12px; opacity: .8; }
.drop-icon { margin-bottom: 8px; filter: drop-shadow(4px 4px 0 #1f6f93); }
.drop-full { display: flex; align-items: center; gap: 16px; justify-content: center; }
.drop-full img { width: 150px; height: 150px; object-fit: cover; border: 3px solid var(--sun); box-shadow: 4px 4px 0 #0a0f26; background: var(--card2); }
.drop-change { font-family: var(--pixel); color: var(--sky); text-decoration: underline; }
.drop.shake { animation: shake .35s; border-color: var(--pink); }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }
.note { margin: 8px 0 0; font-size: 13px; color: var(--muted); min-height: 1.2em; }

.styles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.style input, .seg input { position: absolute; opacity: 0; pointer-events: none; }
.style-card { display: flex; flex-direction: column; align-items: center; cursor: pointer; background: var(--bg2);
  border: 3px solid var(--line); padding: 10px 4px 6px; transition: transform .1s, border-color .1s; }
.style-art { display: grid; place-items: center; height: 104px; }
.style-art svg { image-rendering: pixelated; filter: drop-shadow(3px 3px 0 rgba(0,0,0,.35)); }
.style-name { font-size: 14px; margin-top: 4px; }
.style input:checked + .style-card { border-color: var(--sun); background: #262f6b; transform: translateY(-2px); box-shadow: 0 4px 0 var(--sun-dark); }
.style input:focus-visible + .style-card, .seg input:focus-visible + span { outline: 2px solid var(--sky); outline-offset: 2px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg span { display: block; cursor: pointer; text-align: center; padding: 12px 8px; background: var(--bg2); border: 3px solid var(--line);
  font-family: var(--pixel); font-size: 18px; line-height: 1.2; }
.seg small { display: block; font-family: var(--sans); font-size: 12px; color: var(--muted); margin-top: 3px; }
.seg input:checked + span { border-color: var(--sky); background: #1b3a6e; }

.btn-gen, .btn.primary { display: block; width: 100%; border: 0; cursor: pointer; padding: 16px 20px; font-size: 22px; color: #1a1300;
  background: var(--sun); box-shadow: 0 6px 0 var(--sun-dark), 6px 12px 0 rgba(0,0,0,.25); letter-spacing: .03em;
  transition: transform .08s, box-shadow .08s; }
.btn-gen:hover, .btn.primary:hover { filter: brightness(1.05); }
.btn-gen:active, .btn.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--sun-dark); }
.error { color: var(--pink); margin: 12px 0 0; font-weight: 600; text-align: center; }
.btn-ghost { margin-top: 18px; background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; text-decoration: underline; padding: 6px 0; }

/* queue */
.session { padding: 28px 0 56px; display: flex; justify-content: center; }
.qcard { width: 100%; max-width: 620px; }
.qhead { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.q-photo { width: 84px; height: 84px; object-fit: cover; border: 3px solid var(--sun); background: var(--card2); flex: none; }
.q-title { font-size: 34px; margin: 0; font-weight: 700; line-height: 1.2; }
.q-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.q-stats > div { background: var(--bg2); border: 3px solid var(--line); padding: 14px; display: flex; flex-direction: column; }
.q-label { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.q-big { font-size: 48px; line-height: 1.1; color: var(--sun); }
.q-sub { font-size: 13px; color: var(--muted); }
.bar { height: 18px; margin: 18px 0 12px; background: var(--bg2); border: 3px solid var(--line); }
.bar span { display: block; height: 100%; width: 0; transition: width .25s linear;
  background: repeating-linear-gradient(90deg, var(--sky) 0 12px, #36a8dd 12px 24px); }
.q-status { font-family: var(--pixel); font-size: 18px; color: var(--sky); margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.full-title { font-size: 30px; line-height: 1.15; color: var(--sun); margin: 6px 0 10px; }
.full-text { color: var(--muted); margin: 0 0 18px; }
.tip { margin: 16px 0 0; padding: 12px 14px; background: #123056; border: 3px solid var(--sky); font-weight: 600; }

/* below the fold */
.how, .faq, .examples, .tips, .editions, .uses { padding: 36px 0; border-top: 3px dashed var(--line); }
.how h2, .faq h2, .examples h2, .tips h2, .editions h2, .uses h2 { margin: 0 0 20px; }
.sec-lede { color: var(--muted); max-width: 46em; margin: -6px 0 20px; }
main a, .foot a { color: var(--sky); }
.ex-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.ex { position: relative; margin: 0; background: var(--card); border: 3px solid var(--line); padding: 10px; }
.ex img { display: block; width: 100%; height: auto; image-rendering: auto; }
.ex-tag { position: absolute; top: 18px; left: 18px; background: var(--sun); color: #1a1300; font: 700 12px/1 var(--sans);
  padding: 5px 7px; letter-spacing: .04em; text-transform: uppercase; box-shadow: 2px 2px 0 var(--sun-dark); }
.ex figcaption { color: var(--muted); font-size: 14px; margin: 8px 2px 2px; }
.tip-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; }
.tip-list li { background: var(--card); border: 3px solid var(--line); padding: 12px 14px; color: var(--muted); }
.tip-list b { color: var(--text); }
.table-wrap { overflow-x: auto; margin-bottom: 14px; }
.ed-table { width: 100%; border-collapse: collapse; background: var(--card); border: 3px solid var(--line); font-size: 15px; }
.ed-table th, .ed-table td { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--line); vertical-align: top; }
.ed-table thead th { font-family: var(--pixel); color: var(--sun); font-size: 17px; }
.ed-table tbody th { color: var(--text); white-space: nowrap; }
.ed-table td { color: var(--muted); }
.use-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.use-grid li { background: var(--card); border: 3px solid var(--line); padding: 16px; }
.use-grid h3 { font-size: 19px; margin: 0 0 6px; }
.use-grid p { margin: 0; color: var(--muted); }
.foot-nav { margin: 8px 0 !important; }
/* article pages (guide, privacy, terms) */
.article { max-width: 760px; margin: 0 auto; padding: 28px 0 40px; }
.article h1 { font-size: 44px; }
.article h2 { margin: 34px 0 12px; }
.article h3 { font-size: 20px; margin: 22px 0 8px; }
.article p, .article li { color: #d6dbf5; }
.article ol, .article ul { padding-left: 1.4em; }
.article li { margin: 6px 0; }
.article .meta { color: var(--muted); font-size: 14px; }
.art-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; margin: 18px 0 6px; align-items: start; }
.art-grid-wide { grid-template-columns: 1fr; }
.art { position: relative; margin: 0; background: var(--card); border: 3px solid var(--line); padding: 8px; }
.art img { display: block; width: 100%; height: auto; }
/* guide diagrams: the label sits above the image, never on top of it (page 3 mobile overlap fix) */
.art .ex-tag { position: static; display: inline-block; margin: 2px 0 8px; }
.art figcaption { color: var(--muted); font-size: 14px; margin: 8px 2px 2px; }
.notfound { text-align: left; min-height: 50vh; }
.nf-code { font-family: var(--pixel); font-size: 96px; line-height: 1; color: var(--sun); margin: 20px 0 0; text-shadow: 6px 6px 0 #0a0f26; }
.article .callout { background: var(--card); border: 3px solid var(--line); padding: 12px 16px; }
.how-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.how-grid li { background: var(--card); border: 3px solid var(--line); padding: 18px; }
.how-grid h3 { font-size: 20px; margin: 12px 0 6px; }
.how-grid p { margin: 0; color: var(--muted); }
.faq details { background: var(--card); border: 3px solid var(--line); margin-bottom: 10px; padding: 0 16px; }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 700; }
.faq details p { margin: 0 0 14px; color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: 14px; padding: 28px 20px 40px; border-top: 3px solid var(--line); margin-top: 20px; }
.foot p { margin: 4px 0; }
.foot b { color: var(--text); font-family: var(--pixel); font-weight: 500; }
.fine { opacity: .7; font-size: 12px; }

@media (max-width: 960px) {
  .tool { grid-template-columns: 1fr; gap: 20px; padding-top: 8px; }
  .intro { padding-top: 0; }
  h1 { font-size: 40px; }
  .use-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .brand { font-size: 17px; gap: 8px; }
  .brand img { width: 26px; height: 26px; }
  .pill { font-size: 11px; padding: 4px 7px; }
  main { padding: 0 14px; }
  .tool { gap: 14px; padding-bottom: 36px; }
  h1 { font-size: 28px; margin-bottom: 8px; }
  .lede { font-size: 15px; line-height: 1.45; }
  .eyebrow { font-size: 12px; margin-bottom: 8px; }
  .card { padding: 16px; box-shadow: 5px 5px 0 #0a0f26; }
  .step { margin-bottom: 14px; }
  .step-title { margin-bottom: 8px; font-size: 15px; }
  .drop { min-height: 0; padding: 10px; }
  .drop-empty { padding-top: 0; }
  .drop-empty strong { font-size: 18px; }
  .drop-empty small { margin-top: 2px; }
  .drop-icon { width: 36px; height: 36px; margin-bottom: 2px; }
  .note { font-size: 12px; margin-top: 6px; }
  .drop-full img { width: 110px; height: 110px; }
  .styles { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .style-card { padding: 6px 2px 4px; }
  .style-art { height: 62px; }
  .style-art svg { width: 29px; height: 58px; }
  .style-name { font-size: 12px; }
  .seg span { font-size: 16px; padding: 10px 6px; }
  .btn-gen { font-size: 19px; padding: 14px; }
  .q-title { font-size: 26px; }
  .q-photo { width: 64px; height: 64px; }
  .q-big { font-size: 36px; }
  .full-title { font-size: 24px; }
  .how-grid, .ex-grid, .tip-list, .use-grid { grid-template-columns: 1fr; }
  .article h1 { font-size: 30px; }
  .art-grid { grid-template-columns: 1fr; }
  .ed-table { font-size: 13px; }
  .ed-table th, .ed-table td { padding: 8px; }
}
@media (max-width: 400px) { .topbar .pill { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
/* Local photo regions and exported skin views. */
#crop-canvas {display:block;max-width:100%;max-height:440px;margin:16px auto;touch-action:none;cursor:crosshair;border:1px solid var(--line);}
.region-numbers {display:flex;gap:8px;flex-wrap:wrap;margin:12px 0;}
.region-numbers label {flex:1;min-width:70px;font-size:12px;}
.region-numbers input {display:block;width:100%;padding:8px;background:#171f35;color:#fff;border:1px solid #51607d;border-radius:4px;}
.skin-views {display:flex;justify-content:center;gap:40px;padding:24px;}
.skin-views figure {margin:0;text-align:center;}
.skin-views canvas {width:112px;height:224px;image-rendering:pixelated;image-rendering:crisp-edges;}
#save-skin {display:block;text-align:center;text-decoration:none;}
body.transaction main > section:not(#tool):not(#session) {display:none;}
body.transaction main > .hero {display:none;}
#skin-output > .full-text {margin-top:20px;}

.credit-packs {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin:28px 0}
.credit-pack {padding:24px;border:1px solid var(--line,#344367);border-radius:18px;background:#18213e}
.credit-pack.recommended {border:2px solid #53caff}
.credit-pack h2 {margin-top:0}
.pack-price {font-size:1.8rem;font-weight:700}
.pack-price small {font-size:.85rem}
.credit-pack button {width:100%}
.credit-pack button:disabled {opacity:.55;cursor:default}
@media(max-width:520px){.credit-packs{grid-template-columns:1fr}}

#upgrade-modal { background: #161c2c; color: #fff; border: 2px solid #53caff; border-radius: 16px; max-width: min(90vw, 440px); padding: 24px; }
#upgrade-modal::backdrop { background: #000b; }
#upgrade-modal .btn-gen, #upgrade-modal .btn-ghost { display: block; margin: 16px 0; }




#history-claim { padding: 12px; color: #b8f5d2; }
#history-list { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 20px; margin: 24px 0; }
#history-list > div { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

.auth-modal { background:#161c2c; color:#fff; border:2px solid #53caff; border-radius:16px; padding:20px; width:min(94vw,460px); max-height:90vh; overflow:auto; }
.auth-modal::backdrop { background:#000b; }
.auth-modal > button { margin-bottom:16px; }
#upgrade-modal .btn-gen { background:#53caff; color:#101827; text-align:center; }
#upgrade-modal .btn-ghost { width:100%; border:2px solid #b9c9e7; color:#fff; }
.auth-modal > .btn-ghost { display:block; padding:10px 16px; border:2px solid #b9c9e7; border-radius:10px; background:#243047; color:#fff; font:inherit; text-decoration:none; cursor:pointer; }
#upgrade-modal .btn-ghost { padding:12px 16px; border-radius:10px; background:#243047; text-decoration:none; }
#sign-in-button { padding:8px 14px; border:2px solid var(--sky); border-radius:10px; background:#243047; color:#fff; text-decoration:none; }

/* Keep the primary result action beside its visual context. */
.topbar > .btn-ghost { margin-top:0; }
#payment-title:empty { display:none; }
.btn-secondary { display:inline-block; padding:10px 18px; border:2px solid var(--sky); border-radius:10px; background:#243047; color:var(--text); font-weight:700; text-decoration:none; }
.btn-secondary:hover { background:#344462; }
#pre-checkout-copy strong { display:block; font-family:var(--pixel); font-size:30px; line-height:1.15; color:var(--sun); margin-bottom:10px; }
@media(max-width:760px) {
  .topbar { flex-wrap:nowrap; gap:6px; padding:12px; }
  .topbar > .pill { display:none; }
  .topbar .brand { font-size:16px; gap:6px; margin-right:auto; }
  .topbar .brand img { width:24px; height:24px; }
  .topbar > a.btn-ghost, #sign-in-button { font-size:12px; white-space:nowrap; }
  #sign-in-button { padding:8px; flex-shrink:0; }


  .skin-views { gap:24px; padding:16px 0; }
  .skin-views canvas { width:96px; height:192px; }
  #pre-checkout-copy strong { font-size:24px; }
}

/* Shared account control: compact at 320px, with identity confined to the browser. */
.topbar { flex-wrap:nowrap; }
.topbar .brand { margin-right:auto; min-width:0; }
.header-pricing { color:var(--muted); text-decoration:none; white-space:nowrap; padding:10px 4px; }
.header-pricing:hover { color:var(--text); }
.profile { display:flex; align-items:center; gap:4px; max-width:240px; position:relative; min-width:0; flex:0 1 auto; }
.profile-button { min-width:0; display:flex; align-items:center; gap:7px; max-width:240px; padding:5px 8px; border:1px solid #3c4d6a; border-radius:24px; background:#19243a; color:var(--text); font:inherit; cursor:pointer; }
.profile-avatar { position:relative; display:grid; place-items:center; flex:0 0 32px; width:32px; height:32px; overflow:hidden; border-radius:50%; background:#344462; color:#fff; font-size:12px; font-weight:700; }
.profile-avatar img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.profile-name { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; }
.profile-buy { flex-shrink:0; padding:2px 5px; border-radius:10px; background:#29453e; color:#b8f5d2; font-size:11px; line-height:16px; white-space:nowrap; text-decoration:none; }
#credit-balance { flex-shrink:0; padding:2px 5px; border-radius:10px; background:#29453e; color:#b8f5d2; font-size:11px; line-height:16px; }
#credit-expiry { display:block; min-width:0; color:var(--muted); font-size:12px; line-height:18px; white-space:normal; overflow-wrap:anywhere; }
.profile-menu #credit-expiry { padding:8px 12px; }
.profile-menu { position:absolute; right:0; top:calc(100% + 8px); width:172px; padding:6px; border:1px solid #465773; border-radius:12px; background:#161f32; box-shadow:0 12px 28px #0008; z-index:50; }
.profile-menu a, .profile-menu button { display:block; width:100%; padding:10px 12px; border:0; border-radius:7px; background:none; color:var(--text); text-align:left; font:inherit; text-decoration:none; cursor:pointer; }
.profile-menu a:hover, .profile-menu button:hover { background:#29394f; }
.profile-buy:focus-visible, .profile-button:focus-visible, .header-pricing:focus-visible, .profile-menu :focus-visible { outline:2px solid var(--sky); outline-offset:3px; }
[hidden] { display:none !important; }
@media(max-width:760px) {
 .topbar { gap:8px; }
 .topbar .brand { font-size:14px; gap:5px; }
 .header-pricing { font-size:12px; }
 .profile { max-width:130px; }
 .profile-button { max-width:130px; gap:4px; padding:4px; }
 .profile-avatar { flex-basis:26px; width:26px; height:26px; }
 .profile-name { font-size:12px; }
}
@media(max-width:359px) {
 .topbar .brand { font-size:12px; }
 .topbar .brand img { width:20px; height:20px; }
 .profile { max-width:100px; }
 .profile-button { max-width:100px; }
}
.plan-dialog { width:min(420px,calc(100vw - 32px)); max-height:85vh; overflow:auto; border:1px solid #64748b; border-radius:16px; background:#161c2c; color:#fff; padding:24px; }
.plan-dialog label { display:block; padding:14px; margin:8px 0; border:1px solid #64748b; border-radius:8px; cursor:pointer; }
.plan-dialog label:has(input:checked) { border-color:#53caff; background:#243047; }
.plan-dialog input { margin-right:12px; }
.plan-dialog button { margin:8px 8px 0 0; }

/* Seasonal generator keeps the shared layout and pixel styling. */
.halloween { --accent: #ffb35c; }
.halloween .intro .eyebrow { color: #ffb35c; }
.halloween .intro { border-top: 3px solid #ffb35c; padding-top: 18px; }
.halloween .card { border-color: #735096; }
.halloween .examples > .ex { max-width: 480px; margin: 20px auto; }

/* Keep each article link in one hit-testable box, including wrapped text. */
.article a { display: inline-block; max-width: 100%; }
.article a.btn-gen { display: block; color: #1a1300; text-align: center; text-decoration: none; }
.spooky-hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center; }
@media (max-width: 600px) { .spooky-hero { grid-template-columns: 1fr; } }
.skin3d-create { margin: 20px 0 32px; }
.skin3d-create .btn.primary { text-align: center; text-decoration: none; }
/* Browser photo to pixel art converter */
.pixel-page { max-width: 920px; }
.pixel-start { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 28px; align-items: start; }
.pixel-example { margin: 0; }
.pixel-example-pair { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: end; }
.pixel-example-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; text-align: center; }
.pixel-example img { display: block; width: 100%; height: auto; aspect-ratio: 1; border: 3px solid var(--line); }
.pixel-example-after img { image-rendering: pixelated; }
.pixel-example figcaption { margin-top: 8px; color: var(--sky); font-size: 14px; text-align: center; }
.pixel-controls, .pixel-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.pixel-controls label { display: grid; gap: 8px; font-weight: 700; }
.pixel-controls select { width: 100%; padding: 12px; color: var(--text); background: var(--bg2); border: 2px solid var(--line); font: inherit; }
.pixel-page .pixel-file-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.pixel-file-input:focus-visible + .pixel-upload { outline: 3px solid var(--sky); outline-offset: 8px; }
.pixel-page .pixel-upload { text-align: center; }
.pixel-page .btn-gen { margin-top: 24px; }
.pixel-comparison figure { margin: 0; min-width: 0; }
.pixel-comparison figcaption { margin-bottom: 10px; color: var(--sky); }
.pixel-comparison img, .pixel-comparison canvas { display: block; width: 100%; height: auto; background: #fff; border: 3px solid var(--line); }
.pixel-comparison canvas { image-rendering: pixelated; }
@media (max-width: 600px) {
  .pixel-start { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .pixel-example { width: 240px; max-width: 100%; justify-self: center; }
  .pixel-example-pair { grid-template-columns: 72px minmax(0, 1fr); }
  .pixel-controls, .pixel-comparison { grid-template-columns: 1fr; }
}

.save-price { margin: 12px 0 0; text-align: center; font-size: 13px; color: var(--muted); }

/* Shared public header. The closed header reserves 72px in normal flow. */
.topbar.site-header {
  height: 72px; min-height: 72px; max-width: none; margin: 0;
  padding: 0 max(20px, calc((100% - 1200px) / 2)); gap: 20px;
  background: #0d1225; border-bottom: 1px solid var(--line);
  position: relative; z-index: 60;
}
.site-header .brand { font-size: 26px; margin-right: auto; flex-shrink: 0; }
.site-header button { cursor: pointer; font: inherit; }
.site-nav { display: flex; align-items: center; gap: 20px; }
.site-nav a, .site-nav #generator-toggle { color: var(--text); text-decoration: none; white-space: nowrap; }
.site-nav #generator-toggle { border: 0; background: none; padding: 12px 0; }
.generator-nav { position: relative; }
.generator-menu { position: absolute; top: 100%; left: 0; width: 210px; padding: 8px; background: #161e35; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 20px #0006; }
.generator-menu a { display: flex; align-items: center; gap: 10px; padding: 10px; }
.generator-menu svg { flex: 0 0 16px; }
.generator-menu a:hover, .site-nav a:hover { background: #24304c; }
.site-header .nav-primary { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 116px; height: 40px; color: #082516; background: #65df91; font-weight: 700; border-radius: 6px; text-decoration: none; white-space: nowrap; }
.site-header :focus-visible { outline: 2px solid var(--sky); outline-offset: 4px; }
.nav-toggle { display: none; border: 0; padding: 6px; background: none; color: var(--text); }
.nav-account { position: relative; }
.nav-account .btn-ghost { margin: 0; padding: 8px 0; white-space: nowrap; }
.site-header .profile { max-width: 110px; }
.site-header .profile-button { max-width: 110px; }
.site-header .profile-buy, .site-header #credit-balance { display: none; }
#drop { scroll-margin-top: 20px; }
@media (min-width: 769px) and (max-width: 1050px) {
  .topbar.site-header { gap: 12px; padding: 0 16px; }
  .site-nav { gap: 12px; font-size: 14px; }
  .site-header .brand { font-size: 22px; }
  .site-header .nav-primary { flex-basis: 102px; }
}
@media (max-width: 768px) {
  .topbar.site-header { display: grid; grid-template-columns: minmax(0, 1fr) 116px 36px; gap: 12px; padding: 0 16px; }
  .site-header .brand { font-size: 24px; }
  .nav-toggle { grid-column: 3; grid-row: 1; display: inline-flex; justify-content: center; align-items: center; }
  .site-header .nav-primary { grid-column: 2; grid-row: 1; width: 116px; }
  .site-nav { grid-column: 1 / -1; grid-row: 2; display: flex; align-items: stretch; flex-direction: column; gap: 4px; padding: 0 0 16px; min-width: 0; }
  .site-nav > a, .site-nav #generator-toggle { padding: 10px; text-align: left; }
  .generator-menu { position: static; width: 100%; box-shadow: none; }
  .site-header.nav-open { height: auto; grid-template-rows: 72px auto; row-gap: 0; }
  .nav-account { padding: 0 10px; }
  .site-header .profile, .site-header .profile-button { max-width: 240px; }
  .site-header .profile-menu { left: 0; right: auto; }
}
@media (min-width: 769px) {
  .site-header .nav-account { width: 110px; flex: 0 0 110px; }
  .site-header .guest-credits { display: none; }
}

/* Homepage photo-to-skin comparisons: square assets reserve their full space. */
.portrait-hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px 32px; }
.portrait-hero .intro { grid-column: 1; padding-top: 0; min-width: 0; }
.portrait-hero h1 { font-size: clamp(30px, 3.8vw, 42px); }
.portrait-hero .lede { font-size: 18px; }
.portrait-hero #gen-form { grid-column: 1; grid-row: 2; min-width: 0; }
.portrait-pair { margin: 0; min-width: 0; border: 2px solid var(--line); background: var(--card); padding: 10px; }
.portrait-feature { grid-column: 2; grid-row: 1 / span 2; align-self: start; margin-top: 12px; }
.portrait-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.portrait-panel { min-width: 0; }
.portrait-panel span { display: block; color: var(--sky); font: 18px/1.4 var(--pixel); margin-bottom: 8px; }
.portrait-panel img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: contain; background: var(--bg2); }
.portrait-panel:last-child img { image-rendering: pixelated; }
.portrait-pair figcaption { color: var(--muted); font-size: 13px; margin-top: 10px; }
.portrait-gallery { padding: 32px 0; border-top: 3px dashed var(--line); }
.portrait-gallery h2 { margin: 0 0 18px; }
.portrait-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) {
  .portrait-hero { grid-template-columns: minmax(0, 1fr); }
  .portrait-hero .intro, .portrait-hero #gen-form, .portrait-feature { grid-column: 1; grid-row: auto; }
  .portrait-feature { margin-top: 0; }
  .portrait-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .portrait-hero { gap: 18px; }
  .portrait-grid { grid-template-columns: minmax(0, 1fr); }
  .portrait-panel span { font-size: 16px; }
}
/* Hero: tilted photo card → large interactive 3D skin + example picker. */
.hero3d { grid-column: 2; grid-row: 1 / span 2; align-self: stretch; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; border: 2px solid var(--line); background: var(--card); padding: 16px; }
.hero3d-show { flex: 1 1 auto; min-height: 460px; display: grid; grid-template-columns: 34% auto minmax(0, 1fr); align-items: center; gap: 8px; }
.hero3d-card { transform: rotate(-6deg); background: #fff; padding: 6px; border-radius: 10px; box-shadow: 0 10px 24px rgba(0,0,0,.45); }
.hero3d-card img { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; border-radius: 6px; }
.hero3d-arrow { color: var(--sky); font-size: 28px; line-height: 1; }
.hero3d-stage { position: relative; align-self: stretch; min-height: 460px; border-radius: 16px; overflow: hidden; background: radial-gradient(ellipse at center, #27305b, #101633); }
.hero3d-poster { position: absolute; inset: 0; margin: auto; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; transition: opacity .2s; }
.hero3d-stage.is-3d .hero3d-poster { opacity: 0; pointer-events: none; }
.hero3d-viewer, .hero3d-viewer .skin3d-stage { position: absolute; inset: 0; }
.hero3d-viewer .skin3d-stage { height: auto; perspective: 900px; overflow: hidden; touch-action: none; cursor: grab; border-radius: 16px; }
.hero3d-viewer .skin3d-stage:active { cursor: grabbing; }
.hero3d-viewer .skin3d-stage:focus-visible { outline: 3px solid #9bb6ff; outline-offset: -3px; }
.hero3d-viewer .skin3d-model { position: absolute; left: 50%; top: 50%; transform-style: preserve-3d; }
.hero3d-viewer .skin3d-cube { position: absolute; transform-style: preserve-3d; }
.hero3d-viewer .skin3d-face { position: absolute; image-rendering: pixelated; backface-visibility: hidden; }
.hero3d-hint { margin: 0; text-align: right; color: var(--muted); font: 13px/1.4 var(--pixel); letter-spacing: .12em; text-transform: uppercase; }
.hero3d-picker { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; }
.hero3d-avatar { padding: 3px; border: 2px solid var(--line); background: var(--bg2); cursor: pointer; aspect-ratio: 1 / 1; min-width: 0; }
.hero3d-avatar[aria-pressed="true"] { border-color: #5ee08a; }
.hero3d-avatar:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.hero3d-head { display: block; position: relative; width: 100%; aspect-ratio: 1 / 1; overflow: hidden; }
/* Atlas is 64 px wide; the 8×8 face sits at (8,8): scale ×8 relative to the box. */
.hero3d-head img { position: absolute; width: 800%; height: 800%; max-width: none; left: -100%; top: -100%; image-rendering: pixelated; }
.hero3d figcaption { color: var(--muted); font-size: 13px; }
@media (max-width: 900px) {
  .hero3d { grid-column: 1; grid-row: auto; padding: 12px; }
  .hero3d-show { min-height: 340px; grid-template-columns: 32% auto minmax(0, 1fr); }
  .hero3d-stage { min-height: 340px; }

  .hero3d-picker { grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
  .hero3d-avatar { padding: 1px; }
  .portrait-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) { .portrait-grid { grid-template-columns: minmax(0, 1fr); } .hero3d-hint { text-align: center; font-size: 11px; } .hero3d-arrow { font-size: 20px; } }
/* Desktop: stage fills the column; the tilted photo card overlaps its left edge (photo → skin). */
@media (min-width: 901px) {
  .hero3d-show { position: relative; display: block; }
  .hero3d-stage { position: absolute; inset: 0; min-height: 0; }
  .hero3d-card { position: absolute; z-index: 2; left: 4%; top: 50%; width: 38%; translate: 0 -50%; }
  .hero3d-poster { left: 28%; width: 72%; }
  .hero3d-arrow { position: absolute; z-index: 2; left: 44%; top: 50%; translate: 0 -50%; }
}
/* Desktop: the column stretches to the form's height; the showcase stays in view while the form scrolls. */
.hero3d-sticky { display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 901px) {
  .hero3d-sticky { position: sticky; top: 76px; }
  .hero3d-show { flex: none; height: clamp(420px, calc(100vh - 290px), 600px); min-height: 0; }
  .hero3d-arrow { left: 42.5%; }
}
/* Mobile shortcut to the upload box; desktop already shows the form in the first screen. */
.hero-upload { display: none; margin-top: 12px; padding: 12px 20px; font: 700 17px/1.2 var(--pixel); color: #082516; background: #65df91; border: 0; border-radius: 6px; box-shadow: 4px 4px 0 #0a0f26; cursor: pointer; }
.hero-upload:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
#drop:focus { outline: 3px solid #65df91; outline-offset: 3px; }
@media (max-width: 900px) { .hero-upload { display: inline-block; } }
.hero3d-arrow svg { display: block; width: 48px; height: 24px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
@media (max-width: 560px) { .hero3d-arrow svg { width: 32px; height: 16px; } }
.hero3d-arrow { pointer-events: none; }

/* Offline homepage outputs, with a wider four-card desktop gallery. */
.home-samples { position: relative; left: 50%; transform: translateX(-50%); width: min(1160px, calc(100vw - 40px)); }
.home-samples-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.home-sample { min-width: 0; padding: 10px; }
.home-sample-style { display: block; margin-bottom: 8px; font-family: var(--pixel); font-size: 20px; }
.home-sample-pair { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; padding-bottom: 68px; }
.home-sample .home-sample-input { aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.home-sample .home-sample-render { aspect-ratio: 4 / 5; object-fit: contain; }
.home-sample-arrow { position: absolute; left: 50%; top: calc((100% - 68px) / 2); transform: translate(-50%, -50%); pointer-events: none; }
.home-sample-arrow svg { display: block; width: 28px; height: 14px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.home-sample-badge { position: absolute; right: 0; bottom: 0; width: 64px; height: 64px; overflow: hidden; background: var(--bg); outline: 2px solid var(--sky); border-radius: 3px; }
/* Render the raw atlas at 4× with nearest-neighbor pixels, then fit the badge. */
.home-sample .home-sample-badge img { width: 256px; height: 256px; max-width: none; image-rendering: pixelated; transform: scale(.25); transform-origin: top left; }
.home-sample-badge:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
.home-sample figcaption { font-size: 13px; }
@media (max-width: 900px) {
  .home-samples-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .home-samples-grid { gap: 10px; }
  .home-sample { padding: 8px; }
  .home-sample-pair { gap: 8px; padding-bottom: 54px; }
  .home-sample-arrow { top: calc((100% - 54px) / 2); }
  .home-sample-arrow svg { width: 22px; height: 11px; }
  .home-sample-badge { width: 48px; height: 48px; }
  .home-sample .home-sample-badge img { transform: scale(.1875); }
}

/* Compact, wrapping controls for the generated atlas. */
.color-editor { min-width:0; margin:16px 0; padding:12px; border:1px solid var(--muted); border-radius:8px; }
.color-editor legend { padding:0 6px; font-weight:700; }
.color-inputs { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin-bottom:12px; }
.color-inputs label { display:flex; flex-direction:column; gap:6px; min-width:0; }
.color-inputs input { width:100%; min-width:0; height:44px; padding:3px; cursor:pointer; }
.color-editor .note { margin:6px 0 12px; }
@media(max-width:480px) { .color-inputs { grid-template-columns:repeat(2,minmax(0,1fr)); } }
.blog-card { overflow: hidden; }
.blog-thumb { width: 96px; height: 120px; float: left; margin: 0 12px 8px 0; }
.blog-figure-img { width: 240px; max-width: 100%; height: auto; aspect-ratio: 4 / 5; }

/* Reserve the result area while preparation copy changes and the skin appears. */
.gen-stage { min-height: 1200px; }
#gen-wait { padding: 24px 0; }
#gen-wait-status { min-height: 1.5em; font-weight: 700; }
#gen-wait-progress { display: block; width: 100%; height: 12px; margin: 20px 0 28px; accent-color: var(--accent, #73efaa); }
#gen-wait-credit { max-width: 100%; white-space: normal; }
/* Credits refreshes can update the header link while preparation is active. */
body:has(#gen-wait:not([hidden])) #buy-credits { display: none; }

@media (max-width: 560px) {
  /* Leave room for the button’s 6px right-hand shadow inside the content area. */
  #gen-wait-credit { width: calc(100% - 6px); }
}
