:root {
  --bg: #fff7f0;
  --card: #ffffff;
  --ink: #2b2521;
  --muted: #8f837a;
  --line: #f0e4d8;
  --accent: #ff7a45;
  --accent-2: #ffb38a;
  --accent-soft: #fff0e6;
  --danger: #e5484d;
  --radius: 18px;
  --checker: repeating-conic-gradient(#f3eee9 0% 25%, #fff 0% 50%) 50% / 14px 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0 auto; max-width: 560px; min-height: 100dvh; color: var(--ink); background: var(--bg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { font-size: 16px; } /* iOS 小于 16px 会放大页面 */
h1 { font-size: 24px; margin: 8px 0 4px; }
h2 { font-size: 18px; margin: 0 0 4px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); margin: 0 0 12px; }
.small { font-size: 12px; }
.grow { flex: 1; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* 顶栏 */
.bar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); background: rgba(255, 247, 240, .92); backdrop-filter: blur(10px);
}
.bar-title { font-weight: 700; font-size: 17px; }
.icon-btn { border: 0; background: none; font-size: 26px; line-height: 1; padding: 0 6px; cursor: pointer; color: var(--ink); }
.points { border: 0; background: #fff; border-radius: 999px; padding: 6px 12px; box-shadow: 0 1px 4px rgba(0,0,0,.06); cursor: pointer; }
.reference-btn { min-height: 40px; border: 0; border-radius: 999px; padding: 6px 10px; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.06); cursor: pointer; white-space: nowrap; }

.screen { padding: 8px 14px 0; }

/* 按钮 */
.btn { border: 1.5px solid var(--line); background: #fff; border-radius: 14px; padding: 11px 16px; cursor: pointer; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #ff9a5c); border-color: transparent; color: #fff; box-shadow: 0 6px 18px rgba(255, 122, 69, .3); }
.btn.big { padding: 14px 18px; font-size: 16px; }
.btn.full { width: 100%; }
.link { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; }
.price { font-weight: 500; opacity: .85; margin-left: 4px; font-size: .9em; }
.actions { margin: 14px 0; display: grid; gap: 10px; }
.actions.two { grid-template-columns: 1fr 1fr; }
.flow-cta { position: sticky; bottom: 0; z-index: 5; margin-bottom: 0; padding: 10px 0 calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(255,247,240,.75), var(--bg) 18px); }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: 0 2px 10px rgba(120, 80, 40, .05); }
.alert { background: #fdecec; color: var(--danger); border-radius: 12px; padding: 10px 12px; margin: 12px 0; font-size: 14px; }
.field { display: grid; gap: 6px; margin-top: 12px; }
.field > span { font-size: 13px; font-weight: 600; }
.field input, .field textarea, .field select, #cell-text { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fffdfb; outline: none; resize: none; }
.field input:focus, .field textarea:focus, .field select:focus, #cell-text:focus { border-color: var(--accent); }

/* 登录 */
.login { min-height: 90dvh; display: flex; flex-direction: column; justify-content: center; align-items: stretch; text-align: center; gap: 10px; padding: 0 10px; }
.login-art { font-size: 56px; }
.code-input { border: 2px solid var(--line); border-radius: 16px; padding: 16px; text-align: center; font-size: 22px; letter-spacing: 3px; font-family: ui-monospace, Menlo, monospace; background: #fff; outline: none; margin-top: 10px; }
.code-input:focus { border-color: var(--accent); }

/* 我的作品 */
.sec { font-size: 15px; color: var(--muted); margin: 22px 0 8px; }
.projects { display: grid; gap: 10px; }
.project { display: flex; align-items: center; gap: 12px; width: 100%; background: #fff; border: 0; border-radius: 16px; padding: 10px; text-align: left; cursor: pointer; box-shadow: 0 2px 10px rgba(120, 80, 40, .05); }
.project img { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; background: var(--checker); flex: none; }
.project div { flex: 1; min-width: 0; display: grid; }
.project b, .project small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project small { color: var(--muted); }
.chev { color: var(--muted); font-size: 22px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.footer-links { text-align: center; margin-top: 30px; }

/* 步骤条 */
.stepper { list-style: none; display: flex; margin: 4px 0 0; padding: 0; gap: 4px; }
.stepper li { flex: 1; display: grid; justify-items: center; gap: 3px; font-size: 11px; color: var(--muted); position: relative; }
.stepper li i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 1.5px solid var(--line); font-weight: 700; }
.stepper li.done i { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent); }
.stepper li.on { color: var(--ink); font-weight: 600; }
.stepper li.on i { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper li[data-step] { cursor: pointer; min-height: 44px; }

/* 照片 */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: #f6efe8; }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo-view { display: block; width: 100%; height: 100%; border: 0; padding: 0; background: none; cursor: pointer; }
.photo .rm { position: absolute; top: 5px; right: 5px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 16px; cursor: pointer; }
.photo.add { border: 2px dashed var(--accent-2); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--accent); cursor: pointer; background: var(--accent-soft); }
.photo.add span { font-size: 30px; line-height: 1; }

/* 风格 */
.cats { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cat { flex: none; min-height: 40px; border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px; font-size: 13px; cursor: pointer; }
.cat.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.styles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-height: 420px; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.style { border: 2px solid transparent; background: #fbf7f3; border-radius: 14px; padding: 6px; cursor: pointer; display: grid; gap: 4px; }
.style.on { border-color: var(--accent); background: var(--accent-soft); }
.style .img { position: relative; display: block; aspect-ratio: 1; border-radius: 10px; background: #fff; overflow: hidden; }
.style .img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.style .nm { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zoom-btn { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.9); font-style: normal; font-size: 14px; line-height: 32px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }

/* 画风：上传参考图 */
.seg.mode { margin: 4px 0 12px; }
.style-upload { position: relative; display: grid; place-items: center; text-align: center; gap: 4px; min-height: 170px; border: 2px dashed var(--accent-2); border-radius: 14px; background: var(--accent-soft); color: #c4531f; cursor: pointer; overflow: hidden; padding: 14px; }
.style-upload .plus { font-size: 34px; line-height: 1; }
.style-upload small { color: var(--muted); }
.style-upload img { max-width: 100%; max-height: 260px; border-radius: 10px; display: block; }
.style-upload .re { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; }

/* 角色主体 */
.hero { position: relative; width: min(100%, 340px); aspect-ratio: 1; margin: 0 auto; border-radius: 16px; background: var(--checker); overflow: hidden; display: grid; place-items: center; }
.hero.small { width: min(100%, 280px); }
.hero img { width: 100%; height: 100%; object-fit: contain; }
.hero.busy img { opacity: .35; }
.busy-mask { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; padding: 20px; }
.busy-mask small { color: var(--muted); }
.versions { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 2px; justify-content: center; }
.ver { flex: none; width: 54px; height: 54px; padding: 0; border: 2px solid var(--line); border-radius: 12px; background: var(--checker); overflow: hidden; cursor: pointer; }
.ver.on { border-color: var(--accent); }
.ver img { width: 100%; height: 100%; object-fit: contain; }
.ver-num { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.ver-num.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { border: 1.5px solid var(--accent-2); background: var(--accent-soft); color: #c4531f; border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.chip:disabled { opacity: .5; }
.restyle { margin-top: 14px; }
.restyle summary { cursor: pointer; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.restyle .btn { margin-top: 10px; }

/* 表情模板 */
.kits { display: grid; gap: 8px; margin-top: 8px; }
.kit { display: flex; gap: 12px; align-items: center; text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 10px 12px; cursor: pointer; }
.kit.on { border-color: var(--accent); background: var(--accent-soft); }
.kit .em { font-size: 28px; }
.kit span:last-child { display: grid; }
.kit small { color: var(--muted); font-size: 12px; }
.kit .caps { color: #c4531f; }
.custom-hint { margin: 12px 0 6px; }
.custom-captions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.custom-captions label { display: grid; gap: 4px; min-width: 0; font-size: 12px; color: var(--muted); }
.custom-captions input { width: 100%; min-height: 44px; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fffdfb; color: var(--ink); }
.custom-captions input:focus { border-color: var(--accent); outline: none; }
.seg { display: flex; background: #f6efe8; border-radius: 12px; padding: 3px; margin-top: 12px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 8px; font-size: 14px; cursor: pointer; }
.seg button.on { background: #fff; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.set-row { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 0; border-top: 1px solid var(--line); background: none; padding: 12px 2px; cursor: pointer; text-align: left; }

/* 九宫格 */
.grid9 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.cell { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 12px; background: var(--checker); overflow: hidden; cursor: pointer; }
.cell img, .grid9.plain img { width: 100%; height: 100%; object-fit: contain; display: block; }
.grid9.plain img { aspect-ratio: 1; border-radius: 12px; background: var(--checker); -webkit-touch-callout: default; }
.cell-busy { position: absolute; inset: 0; background: rgba(255,255,255,.6); display: grid; place-items: center; }
.badge { position: absolute; top: 5px; left: 5px; background: var(--accent); color: #fff; font-size: 10px; border-radius: 6px; padding: 1px 5px; }
.grid-canvas { width: min(100%, 340px); aspect-ratio: 1; border-radius: 12px; background: var(--checker); margin: 10px auto 0; display: block; }

/* spinner */
.spinner { width: 36px; height: 36px; border: 3.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto; }
.spinner.sm { width: 22px; height: 22px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 底部弹层 */
dialog.sheet { border: 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0; border-radius: 22px 22px 0 0; max-height: 92dvh; background: #fff; overflow-y: auto; overscroll-behavior: contain; }
dialog::backdrop { background: rgba(40, 25, 15, .45); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; padding: 14px 16px 8px; font-size: 16px; background: #fff; }
.sheet-head .icon-btn { min-width: 44px; min-height: 44px; }
.sheet-body { padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.sheet-body p { margin: 0; }
.reference-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.reference-thumb { display: grid; gap: 4px; min-width: 0; border: 0; padding: 0; background: none; color: var(--muted); font-size: 12px; text-align: center; cursor: pointer; }
.reference-thumb img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 12px; background: var(--checker); }
.contact { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; }
.costs { width: 100%; border-collapse: collapse; font-size: 14px; }
.costs td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.costs td:last-child { text-align: right; }
dialog.zoom { border: 0; padding: 10px; border-radius: 18px; width: min(520px, 94vw); background: #fff; }
dialog.zoom img { width: 100%; max-height: 75dvh; object-fit: contain; display: block; background: var(--checker); border-radius: 12px; }
dialog.zoom p { text-align: center; margin: 8px 0 0; font-weight: 600; }

#toast { position: fixed; left: 50%; bottom: calc(30px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(43, 37, 33, .92); color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 100; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }

@media (min-width: 440px) {
  .custom-captions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 380px) {
  .screen { padding-inline: 10px; }
  .bar { padding-inline: 10px; }
  .card { padding: 12px; }
  .actions.two { gap: 8px; }
  .actions.two .btn { padding-inline: 8px; }
  .stepper li { font-size: 10px; }
}

/* 电脑端完整展示分类；触屏手机继续横向滑动。 */
@media (min-width: 861px), (hover: hover) and (pointer: fine) {
  .cats { flex-wrap: wrap; overflow-x: visible; row-gap: 8px; }
}

.assistant-entry { display: block; text-align: center; text-decoration: none; margin-bottom: 10px; }
