:root {
  --paper: #fbf7ef;
  --paper-2: #f2eadf;
  --ink: #151319;
  --muted: #716b72;
  --coral: #ff6557;
  --coral-dark: #e14d42;
  --violet: #7957df;
  --violet-light: #e8ddff;
  --aqua: #49cbd1;
  --mint: #e6f8f2;
  --line: rgba(21, 19, 25, .13);
  --bottom: max(18px, env(safe-area-inset-bottom));
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-width: 320px; overflow-x: hidden; background: var(--paper); transition: background .25s ease; }
body[data-view="upload"] { background: #f5efff; }
body[data-view="progress"] { background: #ebe3ff; }
body[data-view="review"] { background: var(--mint); }
body[data-view="studio"] { background: #f8f5ee; }
body[data-view="result"] { background: #e5f8f3; }
button, input, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible + span { outline: 3px solid var(--aqua); outline-offset: 3px; }

.app-shell { width: min(100%, 480px); min-height: 100dvh; margin: 0 auto; padding: calc(13px + env(safe-area-inset-top)) 18px var(--bottom); }
.topbar { position: relative; z-index: 5; display: flex; min-height: 42px; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 9px; padding: 0; border: 0; background: none; color: inherit; font-weight: 950; letter-spacing: -.045em; cursor: pointer; }
.brand-mark { position: relative; display: inline-flex; width: 28px; height: 28px; align-items: end; justify-content: center; gap: 2px; padding: 5px 5px 6px; border: 2px solid var(--ink); border-radius: 9px 9px 12px 12px; background: var(--coral); transform: rotate(-5deg); }
.brand-mark i { width: 3px; height: 12px; border-radius: 3px; background: var(--ink); }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { height: 15px; }
.brand-mark b { position: absolute; right: -5px; bottom: 2px; width: 8px; height: 10px; border: 2px solid var(--ink); border-left: 0; border-radius: 0 8px 8px 0; background: var(--coral); }
.trial-chip { display: inline-flex; min-height: 31px; align-items: center; gap: 7px; padding: 0 11px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.62); color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .02em; }
.trial-chip i, .trustline i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--aqua); box-shadow: 0 0 0 3px rgba(73,203,209,.18); }
.view { min-height: calc(100dvh - 66px - var(--bottom)); }
.view[hidden] { display: none !important; }

.welcome { display: flex; flex-direction: column; }
.hero { position: relative; height: clamp(272px, 36dvh, 330px); margin: 2px -8px 7px; overflow: hidden; }
.hero::before { position: absolute; inset: 12px 19px 9px; border-radius: 46% 54% 50% 42%; background: var(--violet-light); content: ""; transform: rotate(-2deg); }
.hero::after { position: absolute; right: 11px; bottom: 17px; width: 38px; height: 38px; border: 2px solid var(--ink); border-radius: 50%; content: "↻"; display: grid; place-items: center; background: var(--aqua); font-weight: 900; transform: rotate(8deg); }
.hero img { position: absolute; z-index: 1; inset: -7% -2% -4%; width: 104%; height: 111%; object-fit: contain; mix-blend-mode: multiply; filter: saturate(1.07) contrast(1.02); }
.hero-number { position: absolute; z-index: 2; top: 24px; left: 25px; color: var(--coral-dark); font-size: 12px; font-weight: 950; letter-spacing: .12em; }
.hero-note { position: absolute; z-index: 2; right: 26px; top: 29px; color: var(--muted); font-size: 9px; font-weight: 850; line-height: 1.2; text-align: right; text-transform: uppercase; letter-spacing: .09em; }
.welcome-copy { text-align: center; }
.eyebrow { margin: 0 0 8px; color: var(--violet); font-size: 10px; font-weight: 950; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 13px; font-size: clamp(37px, 10vw, 49px); line-height: .95; letter-spacing: -.07em; }
h1 em { color: var(--coral-dark); font-style: normal; }
h2 { margin: 0; font-size: 28px; line-height: 1.02; letter-spacing: -.055em; }
.lede { max-width: 350px; margin: 0 auto; color: var(--muted); font-size: 14px; line-height: 1.42; }
.bottom-action { display: grid; gap: 9px; margin-top: auto; padding-top: 18px; }
.button { display: inline-flex; min-height: 56px; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: 18px; cursor: pointer; color: inherit; font-weight: 900; text-align: center; text-decoration: none; transition: transform .14s ease, opacity .14s ease, box-shadow .14s ease; }
.button:active { transform: translateY(2px) scale(.992); }
.button.primary { background: var(--ink); box-shadow: 0 7px 0 var(--coral); color: white; }
.button.primary span { color: var(--coral); font-size: 19px; }
.button.secondary { min-height: 49px; border: 1px solid var(--line); background: rgba(255,255,255,.7); }
.button:disabled { cursor: not-allowed; box-shadow: 0 5px 0 #c6bec0; opacity: .4; }
.trustline { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.35; text-align: center; }

.page-heading { display: flex; min-height: 82px; align-items: center; justify-content: space-between; gap: 13px; padding: 12px 0 11px; }
.page-heading > div { flex: 1; }
.page-heading .eyebrow { margin-bottom: 5px; }
.back-button { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: rgba(255,255,255,.6); cursor: pointer; font-size: 20px; }
.upload { display: flex; flex-direction: column; }
.upload-card { position: relative; display: grid; min-height: min(43dvh, 340px); place-items: center; overflow: hidden; border: 2px dashed rgba(121,87,223,.42); border-radius: 32px 16px 32px 16px; background: rgba(255,255,255,.58); cursor: pointer; }
.upload-card.has-image { border-style: solid; border-color: var(--ink); background: var(--paper); box-shadow: 0 16px 42px rgba(52,32,78,.13); }
.upload-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-empty { display: grid; place-items: center; text-align: center; }
.camera-shape { display: grid; width: 86px; height: 78px; place-items: center; margin-bottom: 17px; border: 3px solid var(--ink); border-radius: 22px 28px 20px 28px; background: var(--coral); box-shadow: 9px 8px 0 var(--violet-light); transform: rotate(-4deg); }
.camera-shape::before { position: absolute; width: 25px; height: 25px; border: 3px solid var(--ink); border-radius: 50%; content: ""; }
.camera-shape b { margin: -62px 0 0 52px; font-size: 28px; transform: rotate(4deg); }
.upload-empty strong { font-size: 18px; }
.upload-empty small { margin-top: 6px; color: var(--muted); font-size: 11px; }
#upload-preview { width: 100%; height: min(43dvh, 340px); object-fit: contain; background: var(--paper); }
.replace-button { position: absolute; z-index: 3; top: 12px; right: 12px; min-height: 36px; padding: 0 13px; border: 0; border-radius: 99px; background: rgba(21,19,25,.84); color: white; font-size: 11px; font-weight: 900; }
.crop-corner { position: absolute; width: 27px; height: 27px; border-color: var(--coral); opacity: .7; }
.corner-a { top: 15px; left: 15px; border-top: 3px solid; border-left: 3px solid; }
.corner-b { right: 15px; bottom: 15px; border-right: 3px solid; border-bottom: 3px solid; }
.quality-note { display: flex; align-items: center; gap: 12px; margin-top: 13px; padding: 12px 14px; border: 1px solid rgba(121,87,223,.2); border-radius: 16px; background: rgba(255,255,255,.55); }
.quality-icon { display: grid; width: 35px; height: 35px; flex: 0 0 auto; place-items: center; border-radius: 11px; background: var(--violet); color: white; }
.quality-note strong { display: block; margin-bottom: 2px; font-size: 12px; }
.quality-note p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.35; }

.progress { display: flex; flex-direction: column; padding-top: 18px; }
.progress-top { display: flex; align-items: center; justify-content: space-between; }
.progress-top .eyebrow { margin: 0; }
.progress-top > span { font-size: 12px; font-weight: 950; }
.progress-stage { position: relative; display: grid; height: min(46dvh, 370px); place-items: center; }
.orbit { position: absolute; border: 1px solid rgba(21,19,25,.15); border-radius: 50%; animation: spin 8s linear infinite; }
.orbit::before { position: absolute; top: 12%; left: 5%; width: 13px; height: 13px; border: 2px solid var(--ink); border-radius: 50%; background: var(--coral); content: ""; }
.orbit-one { width: 280px; height: 210px; transform: rotate(-16deg); }
.orbit-two { width: 210px; height: 280px; border-style: dashed; animation-direction: reverse; }
.progress-core { position: relative; z-index: 2; display: grid; width: 184px; height: 204px; place-items: center; overflow: hidden; border: 2px solid var(--ink); border-radius: 44% 56% 50% 45%; background: var(--paper); box-shadow: 11px 11px 0 var(--aqua); transform: rotate(-2deg); }
.progress-core img { width: 100%; height: 100%; object-fit: contain; }
.progress-core > span { position: absolute; right: 12px; top: 12px; color: var(--violet); }
.spark { position: absolute; color: var(--coral-dark); font-style: normal; font-weight: 950; }
.spark-a { left: 8%; top: 28%; font-size: 25px; }.spark-b { right: 7%; top: 18%; font-size: 22px; }.spark-c { right: 12%; bottom: 20%; color: var(--violet); font-size: 38px; }
.progress-copy { margin-top: auto; text-align: center; }
.progress-copy h1 { font-size: 36px; }
.progress-copy > p:not(.queue-note) { max-width: 330px; margin: 0 auto; color: var(--muted); font-size: 13px; line-height: 1.4; }
.progress-track { height: 7px; margin: 21px 0 11px; overflow: hidden; border-radius: 99px; background: rgba(21,19,25,.1); }
.progress-track span { display: block; width: 12%; height: 100%; border-radius: inherit; background: var(--ink); transition: width .5s ease; }
.queue-note { margin: 0; color: var(--muted); font-size: 10px; }
@keyframes spin { to { transform: rotate(344deg); } }

.review { display: flex; flex-direction: column; }
.final-badge { padding: 8px 10px; border: 1px solid var(--ink); border-radius: 8px; background: var(--aqua); font-size: 10px; font-weight: 950; letter-spacing: .12em; transform: rotate(3deg); }
.character-card { position: relative; display: grid; height: min(54dvh, 440px); place-items: center; overflow: hidden; border: 2px solid var(--ink); border-radius: 34px 16px 34px 16px; background: var(--paper); box-shadow: 10px 10px 0 var(--violet-light); }
.character-card::before { position: absolute; width: 78%; height: 78%; border: 1px dashed rgba(21,19,25,.17); border-radius: 50%; content: ""; }
.character-card img { position: relative; z-index: 1; width: 90%; height: 88%; object-fit: contain; }
.card-label, .card-index { position: absolute; z-index: 2; color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.card-label { top: 14px; left: 17px; }.card-index { right: 16px; bottom: 14px; }
.card-spark { position: absolute; z-index: 2; top: 15px; right: 17px; color: var(--coral); font-size: 19px; }
.review-note { max-width: 340px; margin: 19px auto 0; color: var(--muted); font-size: 11px; line-height: 1.45; text-align: center; }
.split-actions { gap: 12px; }
.text-button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.text-button:disabled { text-decoration: none; opacity: .4; }

.studio { display: flex; flex-direction: column; }
.studio-heading { display: flex; align-items: end; justify-content: space-between; padding: 19px 0 16px; }
.studio-heading .eyebrow { margin-bottom: 6px; }
.mini-character { display: grid; width: 76px; height: 76px; place-items: center; overflow: hidden; border: 2px solid var(--ink); border-radius: 24px 13px 24px 13px; background: var(--mint); box-shadow: 6px 6px 0 var(--coral); transform: rotate(3deg); }
.mini-character img { width: 100%; height: 100%; object-fit: contain; }
.action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.action-card { position: relative; display: flex; min-height: 105px; align-items: end; justify-content: space-between; overflow: hidden; padding: 13px; border: 1.5px solid var(--line); border-radius: 19px; background: rgba(255,255,255,.68); cursor: pointer; text-align: left; transition: transform .14s ease, border-color .14s ease, background .14s ease; }
.action-card::before { position: absolute; top: -22px; right: -14px; width: 79px; height: 79px; border-radius: 50%; background: var(--violet-light); content: ""; }
.action-card:nth-child(2n)::before { background: #ffd9d4; }
.action-card.selected { border-color: var(--ink); background: white; box-shadow: 5px 5px 0 var(--aqua); transform: translate(-2px,-2px); }
.action-card strong { position: relative; z-index: 1; font-size: 14px; }
.action-symbol { position: absolute; z-index: 1; top: 12px; right: 15px; font-size: 25px; font-weight: 950; transform: rotate(-8deg); }
.action-index { color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .12em; }
.pipeline-note { display: flex; align-items: center; gap: 10px; margin-top: 13px; padding: 10px 12px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.pipeline-note > span { padding: 6px 7px; border-radius: 7px; background: var(--ink); color: white; font-size: 8px; font-weight: 950; letter-spacing: .12em; }
.pipeline-note p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.3; }.pipeline-note strong { color: var(--ink); }

.result { display: flex; flex-direction: column; padding-top: 18px; }
.result-head { display: flex; align-items: center; justify-content: space-between; }
.result-head p { margin: 0; color: var(--muted); font-size: 9px; }
.success-pill { padding: 7px 9px; border-radius: 99px; background: var(--aqua); font-size: 8px; font-weight: 950; letter-spacing: .12em; }
.result-stage { position: relative; display: grid; height: min(46dvh, 365px); place-items: center; margin: 12px 0 3px; overflow: hidden; border: 2px solid var(--ink); border-radius: 40px 18px 40px 18px; background-color: white; background-image: linear-gradient(45deg,#eee 25%,transparent 25%),linear-gradient(-45deg,#eee 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#eee 75%),linear-gradient(-45deg,transparent 75%,#eee 75%); background-position: 0 0,0 8px,8px -8px,-8px 0; background-size: 16px 16px; box-shadow: 10px 10px 0 var(--violet-light); }
.result-stage video, .result-stage img { position: relative; z-index: 1; width: 88%; height: 88%; object-fit: contain; }
.result-spark { position: absolute; z-index: 2; color: var(--coral); font-size: 25px; font-weight: 950; }.result-spark.one { top: 14px; left: 16px; }.result-spark.two { right: 16px; bottom: 12px; }
.result-copy { padding-top: 19px; text-align: center; }
.result-copy h1 { margin-bottom: 0; font-size: 36px; }
.result-actions { padding-top: 15px; }
.error { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.error-mark { display: grid; width: 116px; height: 116px; place-items: center; margin-bottom: 27px; border: 3px solid var(--ink); border-radius: 42% 58% 49% 51%; background: var(--coral); box-shadow: 12px 12px 0 var(--violet-light); font-size: 64px; font-weight: 950; transform: rotate(-5deg); }
.error > p:not(.eyebrow) { max-width: 330px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.error .bottom-action { width: 100%; margin-top: 34px; }
.toast { position: fixed; z-index: 20; right: 20px; bottom: calc(20px + var(--bottom)); left: 20px; max-width: 440px; margin: auto; padding: 13px 16px; border-radius: 14px; background: var(--ink); box-shadow: 0 12px 34px rgba(0,0,0,.2); color: white; font-size: 12px; font-weight: 750; text-align: center; }

@media (max-height: 720px) {
  .hero { height: 238px; }
  h1 { font-size: 35px; }
  .upload-card { min-height: 280px; }
  #upload-preview { height: 280px; }
  .quality-note { display: none; }
  .character-card { height: 360px; }
  .action-card { min-height: 91px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
