:root {
  --ink: #24251f;
  --muted: #77776f;
  --paper: #f7f5ef;
  --card: #fffdf8;
  --line: rgba(36, 37, 31, 0.1);
  --lime: #d9ff57;
  --lime-deep: #b9e931;
  --orange: #ff8359;
  --purple: #8470ff;
  --blue: #6ec8f5;
  --shadow: 0 16px 40px rgba(53, 53, 42, 0.09);
  --radius: 28px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: #dedbd1; color: var(--ink); }

body {
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 70px rgba(0,0,0,.15);
}

#app { min-height: 100dvh; padding-bottom: 102px; }

.page { animation: pageIn .28s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(18px, env(safe-area-inset-top)) 22px 12px;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 20px; letter-spacing: -.5px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--ink); color: var(--lime); border-radius: 13px; transform: rotate(-4deg);
}
.brand-mark svg { width: 21px; }

.credit-pill, .icon-button {
  border: 1px solid var(--line); background: rgba(255,255,255,.72); backdrop-filter: blur(12px);
  min-height: 40px; border-radius: 999px; cursor: pointer;
}
.credit-pill { display: flex; align-items: center; gap: 6px; padding: 0 13px; font-weight: 800; }
.credit-pill svg { width: 17px; color: #d09c00; }
.icon-button { width: 42px; display: grid; place-items: center; }
.icon-button svg { width: 20px; }

.content { padding: 5px 20px 34px; }
.eyebrow { font-size: 12px; font-weight: 850; letter-spacing: 1.4px; color: #77776f; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 9px; font-size: clamp(30px, 9vw, 42px); line-height: 1.07; letter-spacing: -2px; }
h2 { font-size: 22px; letter-spacing: -.7px; }
p { color: var(--muted); line-height: 1.6; }

.hero {
  position: relative; min-height: 410px; margin-top: 5px; overflow: hidden;
  border-radius: 34px; background: linear-gradient(145deg, #c8ebff 0%, #e6f5ec 45%, #fff0c2 100%);
  box-shadow: var(--shadow);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 999px; filter: blur(2px); }
.hero::before { width: 210px; height: 210px; background: rgba(255,255,255,.55); top: -82px; right: -40px; }
.hero::after { width: 120px; height: 120px; background: rgba(217,255,87,.75); bottom: -34px; left: -28px; }
.hero-copy { position: relative; z-index: 3; padding: 26px 24px; max-width: 76%; }
.hero-copy h1 { font-size: 38px; }
.hero-copy p { color: #4e5047; font-size: 14px; max-width: 245px; }
.hero-avatar { position: absolute; width: 285px; right: -53px; bottom: -28px; z-index: 2; filter: drop-shadow(0 20px 13px rgba(40,40,30,.17)); }
.hero-avatar .locked-avatar-image { width: 100%; height: 330px; object-fit: contain; object-position: bottom center; }
.floating-tag {
  position: absolute; z-index: 4; display: flex; align-items: center; gap: 7px;
  border: 1px solid rgba(255,255,255,.9); background: rgba(255,255,255,.73); backdrop-filter: blur(10px);
  border-radius: 999px; padding: 8px 11px; font-size: 12px; font-weight: 750;
}
.tag-one { right: 14px; top: 20px; transform: rotate(3deg); }
.tag-two { left: 17px; bottom: 18px; transform: rotate(-3deg); }
.dot { width: 7px; height: 7px; background: #55bd4b; border-radius: 50%; box-shadow: 0 0 0 4px rgba(85,189,75,.15); }

.primary-button, .secondary-button, .ghost-button {
  border: 0; border-radius: 16px; min-height: 51px; padding: 0 20px; font-weight: 850; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; transition: .18s ease;
}
.primary-button { background: var(--ink); color: white; box-shadow: 0 9px 21px rgba(36,37,31,.18); }
.primary-button.lime { background: var(--lime); color: var(--ink); box-shadow: none; }
.secondary-button { background: white; color: var(--ink); border: 1px solid var(--line); }
.ghost-button { background: transparent; color: var(--ink); padding: 0 12px; }
.primary-button:active, .secondary-button:active, .tool-card:active { transform: scale(.98); }
.primary-button svg, .secondary-button svg { width: 19px; }
.button-row { display: flex; gap: 10px; }
.button-row > * { flex: 1; }
.full { width: 100%; }

.section-head { display: flex; align-items: end; justify-content: space-between; margin: 29px 2px 14px; }
.section-head h2 { margin: 0; }
.section-head button { border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tool-card {
  min-height: 148px; border: 1px solid var(--line); border-radius: 23px; padding: 17px;
  background: var(--card); cursor: pointer; text-align: left; position: relative; overflow: hidden;
}
.tool-card:nth-child(2) { background: #f0ecff; }
.tool-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 14px; background: var(--lime); margin-bottom: 20px; }
.tool-card:nth-child(2) .tool-icon { background: var(--purple); color: white; }
.tool-icon svg { width: 22px; }
.tool-card strong { display: block; font-size: 16px; margin-bottom: 5px; }
.tool-card small { color: var(--muted); line-height: 1.4; }

.project-list { display: grid; gap: 11px; }
.project-card {
  display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 10px;
}
.project-thumb { height: 76px; border-radius: 15px; overflow: hidden; display: grid; place-items: center; background: linear-gradient(135deg,#ffd5c5,#f5f0c8); }
.project-thumb svg { width: 78px; transform: translateY(7px); }
.project-thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-meta strong { display: block; font-size: 14px; margin-bottom: 6px; }
.project-meta small { color: var(--muted); }
.status { padding: 6px 9px; border-radius: 999px; background: #edf8d7; color: #5b7218; font-size: 11px; font-weight: 800; }

.bottom-nav {
  position: fixed; z-index: 30; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 480px); min-height: 82px; padding: 8px 14px max(12px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 1fr 1fr 66px 1fr 1fr; align-items: end;
  background: rgba(255,253,248,.92); backdrop-filter: blur(20px); border-top: 1px solid var(--line);
}
.nav-item { border: 0; background: transparent; color: #9b9a91; display: grid; gap: 4px; justify-items: center; cursor: pointer; }
.nav-item svg { width: 22px; height: 22px; }
.nav-item small { font-size: 10px; font-weight: 700; }
.nav-item.active { color: var(--ink); }
.camera-fab {
  align-self: center; justify-self: center; width: 58px; height: 58px; border: 5px solid var(--paper); border-radius: 20px;
  background: var(--ink); color: var(--lime); display: grid; place-items: center; transform: translateY(-19px) rotate(-3deg);
  box-shadow: 0 9px 22px rgba(36,37,31,.25); cursor: pointer;
}
.camera-fab svg { width: 25px; }

.page-heading { padding: 10px 22px 0; }
.page-heading h1 { font-size: 34px; margin-bottom: 8px; }
.page-heading p { font-size: 14px; }

.creator-card {
  margin: 20px; padding: 20px; border-radius: 28px; color: white;
  background: radial-gradient(circle at 100% 0,#6a5cec,transparent 35%), linear-gradient(135deg,#282932,#41434e);
  overflow: hidden; position: relative;
}
.creator-card h2 { margin-bottom: 8px; }
.creator-card p { color: rgba(255,255,255,.67); font-size: 13px; }
.creator-card .primary-button { background: var(--lime); color: var(--ink); }
.mini-avatar { width: 170px; position: absolute; right: -30px; bottom: -52px; opacity: .86; }
.creator-card .button-row { position: relative; z-index: 2; max-width: 66%; }

.template-scroll { display: flex; gap: 12px; overflow-x: auto; padding: 0 20px 8px; scrollbar-width: none; }
.template-card { flex: 0 0 142px; cursor: pointer; }
.template-cover { height: 184px; border-radius: 22px; overflow: hidden; position: relative; display: grid; place-items: end center; }
.template-cover svg { width: 150px; transform: translateY(21px); }
.template-card strong { display: block; font-size: 13px; margin: 9px 3px 2px; }
.template-card small { color: var(--muted); margin-left: 3px; }
.play-badge { position: absolute; top: 10px; right: 10px; width: 31px; height: 31px; border-radius: 50%; background: rgba(255,255,255,.84); display: grid; place-items: center; }
.play-badge svg { width: 14px; transform: none; }

.space-profile { text-align: center; padding: 6px 20px 18px; }
.avatar-ring { width: 116px; height: 116px; margin: 0 auto 12px; border-radius: 39px; background: var(--lime); overflow: hidden; transform: rotate(-2deg); box-shadow: var(--shadow); }
.avatar-ring svg { width: 118px; transform: translateY(5px) rotate(2deg); }
.locked-avatar-image { width: 100%; height: 100%; display: block; object-fit: cover; object-position: top center; }
.space-profile h2 { margin-bottom: 4px; }
.space-profile p { font-size: 13px; margin-bottom: 15px; }
.stats { display: flex; justify-content: center; gap: 36px; }
.stat strong { display: block; font-size: 18px; }
.stat small { color: var(--muted); font-size: 11px; }
.gallery-tabs { display: flex; gap: 8px; padding: 12px 20px; }
.gallery-tabs button { flex: 1; border: 0; padding: 10px; border-radius: 13px; background: transparent; color: var(--muted); font-weight: 750; cursor: pointer; }
.gallery-tabs button.active { background: white; color: var(--ink); box-shadow: 0 4px 15px rgba(0,0,0,.06); }
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 4px 20px 30px; }
.gallery-item { aspect-ratio: .82; border-radius: 20px; overflow: hidden; display: grid; place-items: end center; position: relative; }
.gallery-item svg { width: 130%; transform: translateY(23%); }
.gallery-item > img { width: 100%; height: 100%; object-fit: cover; }
.gallery-item .duration { position: absolute; right: 9px; bottom: 9px; background: rgba(0,0,0,.58); color: white; border-radius: 7px; padding: 4px 6px; font-size: 10px; }
.empty-card { grid-column: 1 / -1; text-align: center; padding: 52px 24px; border: 1px dashed #cbc8bc; border-radius: 24px; }

.profile-hero { padding: 8px 22px 20px; display: flex; align-items: center; gap: 15px; }
.profile-avatar { width: 69px; height: 69px; border-radius: 23px; overflow: hidden; background: var(--lime); }
.profile-avatar svg { width: 70px; transform: translateY(3px); }
.profile-info h2 { margin: 0 0 5px; }
.profile-info small { color: var(--muted); }
.engine-strip { margin: -4px 20px 18px; padding: 12px 14px; display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); background: rgba(255,255,255,.66); border-radius: 17px; }
.engine-strip strong { display: block; font-size: 12px; margin-bottom: 3px; }
.engine-strip small { display: block; color: var(--muted); font-size: 10px; }
.engine-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #62bd4c; box-shadow: 0 0 0 5px rgba(98,189,76,.13); }
.engine-dot.warning { background: #f0a33c; box-shadow: 0 0 0 5px rgba(240,163,60,.14); }
.balance-card { margin: 5px 20px 22px; padding: 21px; border-radius: 25px; background: var(--ink); color: white; position: relative; overflow: hidden; }
.balance-card::after { content: ""; position: absolute; width: 140px; height: 140px; background: var(--lime); border-radius: 50%; right: -62px; top: -70px; opacity: .82; }
.balance-card small { color: rgba(255,255,255,.6); }
.balance-card strong { display: block; font-size: 32px; margin: 5px 0 16px; }
.balance-card .secondary-button { min-height: 42px; }
.menu-list { margin: 0 20px; background: var(--card); border: 1px solid var(--line); border-radius: 23px; overflow: hidden; }
.menu-item { width: 100%; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 14px; text-align: left; cursor: pointer; }
.menu-item:last-child { border-bottom: 0; }
.menu-icon { width: 38px; height: 38px; border-radius: 12px; background: #f0efe8; display: grid; place-items: center; }
.menu-icon svg, .menu-item > svg { width: 18px; }
.menu-item span { font-weight: 700; font-size: 14px; }

.modal-backdrop { position: fixed; z-index: 80; inset: 0; background: rgba(24,24,20,.53); backdrop-filter: blur(7px); display: grid; align-items: end; justify-items: center; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-sheet { width: min(100%,480px); max-height: 92dvh; overflow: auto; background: var(--paper); border-radius: 31px 31px 0 0; padding: 12px 20px max(28px, env(safe-area-inset-bottom)); animation: sheet .28s ease; }
@keyframes sheet { from { transform: translateY(30px); opacity: .5; } }
.sheet-handle { width: 44px; height: 5px; border-radius: 99px; background: #d0cec5; margin: 0 auto 20px; }
.modal-head { display: flex; align-items: start; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { margin-bottom: 6px; }
.modal-head p { font-size: 13px; margin: 0; }
.close-button { border: 0; border-radius: 50%; width: 37px; height: 37px; background: white; display: grid; place-items: center; cursor: pointer; }
.close-button svg { width: 18px; }

.upload-zone { border: 1.5px dashed #bab8ae; border-radius: 22px; min-height: 170px; display: grid; place-items: center; text-align: center; padding: 25px; background: rgba(255,255,255,.44); cursor: pointer; overflow: hidden; }
.upload-zone.drag { border-color: var(--purple); background: #f0ecff; }
.upload-zone img, .upload-zone video { width: 100%; max-height: 260px; object-fit: cover; border-radius: 15px; }
.upload-icon { width: 54px; height: 54px; border-radius: 18px; background: var(--lime); display: grid; place-items: center; margin: 0 auto 12px; }
.upload-icon svg { width: 26px; }
.upload-zone strong { display: block; margin-bottom: 6px; }
.upload-zone small { color: var(--muted); }

.identity-priority { margin: 0 0 14px; padding: 14px; border-radius: 18px; background: #eef8ca; border: 1px solid rgba(91,114,24,.12); }
.identity-priority strong { display: block; margin-bottom: 9px; font-size: 13px; }
.identity-priority div { display: flex; flex-wrap: wrap; gap: 6px; }
.identity-priority span { padding: 5px 8px; border-radius: 99px; background: rgba(255,255,255,.72); color: #5b7218; font-size: 10px; font-weight: 800; }
.identity-lock-card { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 11px; margin: 0 0 14px; padding: 10px; border: 1px solid rgba(91,114,24,.16); border-radius: 19px; background: #f3f9dc; }
.identity-lock-avatar { width: 58px; height: 64px; border-radius: 14px; background: var(--lime); overflow: hidden; }
.identity-lock-avatar svg { width: 62px; transform: translateY(6px); }
.identity-lock-card strong, .identity-lock-card small { display: block; }
.identity-lock-card strong { margin-bottom: 5px; font-size: 13px; }
.identity-lock-card small { color: #667144; font-size: 10px; line-height: 1.4; }
.identity-lock-card > span { align-self: start; padding: 5px 7px; border-radius: 99px; background: var(--ink); color: var(--lime); font-size: 8px; font-weight: 900; letter-spacing: .7px; }

.field { margin: 15px 0; }
.field label { display: block; font-size: 12px; font-weight: 800; margin-bottom: 8px; color: #66665f; }
.field input, .field select { width: 100%; border: 1px solid var(--line); border-radius: 15px; background: white; padding: 14px 15px; outline: none; }
.style-options { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; }
.style-choice { border: 2px solid transparent; border-radius: 17px; background: white; padding: 7px; text-align: center; cursor: pointer; }
.style-choice.active { border-color: var(--ink); }
.style-swatch { height: 75px; border-radius: 12px; display: grid; place-items: end center; overflow: hidden; }
.style-swatch svg { width: 72px; transform: translateY(13px); }
.style-choice small { display: block; padding: 7px 0 2px; font-weight: 700; }
.cost-line { display: flex; justify-content: space-between; margin: 17px 3px; color: var(--muted); font-size: 13px; }
.cost-line strong { color: var(--ink); }
.cost-line strong { display: inline-flex; align-items: center; gap: 5px; }
.cost-line svg { width: 16px; height: 16px; }

.progress-wrap { text-align: center; padding: 22px 0 8px; }
.progress-avatar { width: 190px; height: 190px; margin: 0 auto 22px; border-radius: 50%; background: linear-gradient(135deg,#d9ff57,#6ec8f5); display: grid; place-items: end center; overflow: hidden; position: relative; }
.progress-avatar::after { content: ""; position: absolute; inset: -4px; border: 5px dashed white; border-radius: 50%; animation: spin 8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-avatar svg { width: 180px; transform: translateY(23px); }
.progress-avatar .locked-avatar-image { object-fit: contain; object-position: bottom center; }
.progress-bar { height: 9px; background: #e5e3da; border-radius: 99px; overflow: hidden; margin: 20px 0 10px; }
.progress-bar span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--ink); transition: width .4s; }
.progress-message { min-height: 22px; color: var(--muted); font-size: 13px; }

.camera-modal { background: #141511; color: white; padding: 0; min-height: 88dvh; overflow: hidden; }
.camera-stage { position: relative; min-height: 68dvh; background: radial-gradient(circle at 50% 30%,#3c4948,#171916 70%); overflow: hidden; }
.camera-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-placeholder { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 40px; }
.camera-placeholder svg { width: 240px; transform: translateY(30px); opacity: .9; }
.camera-top { position: absolute; z-index: 2; top: 16px; left: 16px; right: 16px; display: flex; justify-content: space-between; }
.camera-top button { color: white; background: rgba(0,0,0,.35); }
.camera-tip { position: absolute; z-index: 2; top: 75px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: rgba(0,0,0,.35); padding: 8px 12px; border-radius: 99px; font-size: 12px; }
.camera-controls { min-height: 180px; padding: 18px 24px 25px; text-align: center; }
.mode-switch { display: flex; justify-content: center; gap: 22px; font-size: 12px; color: #80827b; margin-bottom: 18px; }
.mode-switch .active { color: white; font-weight: 800; }
.shutter { width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; border: 5px solid white; background: var(--orange); box-shadow: inset 0 0 0 5px #141511; cursor: pointer; }

.package-list { display: grid; gap: 10px; }
.package { display: grid; grid-template-columns: 1fr auto; align-items: center; border: 2px solid transparent; border-radius: 19px; background: white; padding: 16px; cursor: pointer; }
.package.active { border-color: var(--ink); background: #fbffe9; }
.package strong { display: block; margin-bottom: 4px; }
.package small { color: var(--muted); }
.package-price { font-size: 18px; font-weight: 900; }

.history-list { display: grid; gap: 10px; padding-bottom: 8px; }
.history-card { display: grid; grid-template-columns: 62px 1fr auto; gap: 12px; align-items: center; padding: 10px; background: white; border: 1px solid var(--line); border-radius: 19px; }
.history-avatar { width: 62px; height: 68px; border-radius: 14px; overflow: hidden; display: grid; place-items: end center; }
.history-avatar svg { width: 68px; transform: translateY(12px); }
.history-copy { min-width: 0; }
.history-copy strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px; }
.history-copy small { display: block; color: var(--muted); font-size: 11px; }
.job-status { border-radius: 999px; padding: 6px 8px; font-size: 10px; font-weight: 850; background: #f0efe9; color: var(--muted); }
.job-status.completed { background: #edf8d7; color: #5b7218; }
.job-status.processing, .job-status.queued { background: #eeeaff; color: #6552c6; }
.job-status.failed { background: #ffe7df; color: #a34127; }
.mini-progress { height: 5px; margin-top: 8px; border-radius: 99px; background: #ebe9e2; overflow: hidden; }
.mini-progress span { display: block; height: 100%; background: var(--purple); border-radius: inherit; }
.variant-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 9px; margin: 0 0 22px; }
.source-identity { width: 88px; margin: 0 auto 14px; }
.source-identity img { width: 88px; height: 88px; display: block; border-radius: 24px; object-fit: cover; border: 3px solid white; box-shadow: var(--shadow); }
.source-identity span { display: inline-block; margin-top: 6px; padding: 4px 8px; border-radius: 99px; background: #eceae2; color: var(--muted); font-size: 10px; font-weight: 800; }
.variant-choice { border: 2px solid transparent; border-radius: 16px; background: white; padding: 5px; overflow: hidden; cursor: pointer; }
.variant-choice.active { border-color: var(--ink); }
.variant-choice img { width: 100%; aspect-ratio: .72; object-fit: cover; border-radius: 11px; display: block; }
.variant-choice span { display: block; font-size: 11px; font-weight: 750; padding: 7px 0 3px; }

#toast-root { position: fixed; z-index: 120; left: 50%; bottom: 108px; transform: translateX(-50%); width: min(90%,420px); pointer-events: none; }
.toast { margin-top: 8px; padding: 13px 16px; border-radius: 15px; background: rgba(36,37,31,.93); color: white; font-size: 13px; text-align: center; box-shadow: var(--shadow); animation: toastIn .25s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

.notice { margin: 15px 20px; border-radius: 18px; padding: 14px; background: #fff3d5; color: #6d5928; font-size: 12px; line-height: 1.55; }

@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100dvh - 48px); border-radius: 35px; }
  #app { min-height: calc(100dvh - 48px); }
  .bottom-nav { bottom: 24px; border-radius: 0 0 35px 35px; }
  .modal-backdrop { align-items: center; }
  .modal-sheet { border-radius: 31px; max-height: 88dvh; }
}
