:root {
  --brand: #438EDB;
  --brand-d: #2f6fb0;
  --bg: #f4f6fb;
  --card: #fff;
  --text: #1f2533;
  --sub: #8a93a6;
  --line: #eceef3;
  --ok: #2bb673;
  --err: #e34d59;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  max-width: 480px; margin: 0 auto; min-height: 100vh;
}
.hidden { display: none !important; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14rpx 18px; height: 56px;
  background: #fff; border-bottom: 1px solid var(--line);
  padding-top: calc(env(safe-area-inset-top) + 8px);
}
.brand { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 22px; }
.title { font-weight: 700; font-size: 17px; }
.topright { display: flex; align-items: center; gap: 12px; }
.balance { font-size: 13px; color: var(--brand); font-weight: 600; }
.avatar-btn {
  border: none; background: var(--brand); color: #fff;
  font-size: 13px; padding: 6px 14px; border-radius: 999px; font-weight: 600;
}

.container { padding: 14px; }
.card {
  background: var(--card); border-radius: 16px; padding: 16px;
  box-shadow: 0 2px 12px rgba(30,50,90,.05); margin-bottom: 14px;
}
.center { text-align: center; }

/* 上传 */
.upload-area {
  border: 2px dashed #c9d6ea; border-radius: 14px; padding: 40px 16px;
  text-align: center; background: #fafcff; transition: .15s;
}
.upload-area:active { background: #eef4ff; }
.up-icon { font-size: 34px; }
.up-text { font-weight: 600; margin-top: 8px; }
.up-sub { font-size: 12px; color: var(--sub); margin-top: 6px; }

/* 预览 */
.preview-wrap { text-align: center; margin-bottom: 14px; }
#previewImg { max-width: 200px; max-height: 260px; border-radius: 10px; border: 1px solid var(--line); }

.field { margin-bottom: 14px; }
.field-label { font-size: 13px; color: var(--sub); margin-bottom: 8px; font-weight: 600; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  font-size: 13px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.size-cell {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px;
  text-align: center; cursor: pointer; background: #fff;
}
.size-cell .nm { font-size: 13px; font-weight: 600; }
.size-cell .px { font-size: 11px; color: var(--sub); margin-top: 2px; }
.size-cell.active { border-color: var(--brand); background: #eef4ff; }

.swatch-row { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; box-shadow: 0 0 0 1px var(--line);
}
.swatch.active { border-color: var(--brand); }

.switch-line { display: flex; align-items: center; gap: 8px; font-size: 14px; }

.primary-btn {
  width: 100%; border: none; background: var(--brand); color: #fff;
  font-size: 16px; font-weight: 700; padding: 13px; border-radius: 12px; margin-top: 6px;
}
.primary-btn:active { background: var(--brand-d); }
.primary-btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.ghost-btn {
  width: 100%; border: 1px solid var(--line); background: #fff; color: var(--sub);
  font-size: 14px; padding: 11px; border-radius: 12px; margin-top: 10px;
}

/* 进度 */
.spinner {
  width: 38px; height: 38px; border: 4px solid #e3ebf7; border-top-color: var(--brand);
  border-radius: 50%; animation: spin 1s linear infinite; margin: 6px auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.prog-text { font-size: 16px; font-weight: 700; }
.prog-bar { height: 8px; background: #eef2f8; border-radius: 999px; margin: 12px 0 8px; overflow: hidden; }
.prog-fill { height: 100%; width: 0; background: var(--brand); transition: width .4s; }
.prog-tip { font-size: 12px; color: var(--sub); }

/* 结果 */
.result-title { font-size: 18px; font-weight: 800; text-align: center; margin-bottom: 12px; }
.result-img-wrap { text-align: center; margin: 10px 0; }
.result-img-wrap img { max-width: 220px; border-radius: 10px; border: 1px solid var(--line); }
.dl-btn {
  display: block; text-align: center; background: var(--brand); color: #fff;
  text-decoration: none; font-weight: 700; padding: 12px; border-radius: 12px; margin: 10px 0;
}
.dl-btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }

/* 我的面板 */
.panel {
  position: fixed; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto;
  background: #fff; border-radius: 18px 18px 0 0; padding: 18px 18px 28px;
  box-shadow: 0 -6px 24px rgba(0,0,0,.12); z-index: 40;
}
.panel-head { display: flex; justify-content: space-between; font-weight: 700; font-size: 16px; margin-bottom: 14px; }
.panel-head .x { border: none; background: none; font-size: 18px; color: var(--sub); }
.profile-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); }
.profile-row b { color: var(--brand); }
.privacy { font-size: 12px; color: var(--sub); text-align: center; margin-top: 14px; }

/* 登录弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(20,28,45,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-card { width: 100%; max-width: 340px; background: #fff; border-radius: 16px; padding: 20px; }
.tabs { display: flex; margin-bottom: 14px; }
.tab { flex: 1; border: none; background: none; font-size: 15px; color: var(--sub); padding: 8px; }
.tab.active { color: var(--brand); font-weight: 700; border-bottom: 2px solid var(--brand); }
.modal-card input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  margin-bottom: 10px; font-size: 15px; outline: none;
}
.modal-card input:focus { border-color: var(--brand); }
.auth-err { color: var(--err); font-size: 13px; min-height: 18px; margin-top: 6px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%);
  background: rgba(20,28,45,.9); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 60; max-width: 80%; text-align: center;
}
