/*
 * Mome H5 首页视觉规范实现 v3
 * 设计基准：853×1844 @2x，逻辑画布约 430×930。
 * 仅覆盖首页视觉层；上传、分类、模板、生成、结果等业务逻辑继续使用原节点。
 */

:root {
  --h5-page-max: 430px;
  --h5-page-pad: 16px;
  --h5-header-height: 78px;
  --h5-footer-height: 74px;
  --h5-red: #ab0817;
  --h5-red-dark: #930011;
  --h5-ink: #171111;
  --h5-muted: #71808b;
  --h5-cream: #fdf6ea;
  --h5-line: #f0ddd7;
  --h5-pill: #f1edeb;
  --h5-card: #fcfaf8;
}

html,
body {
  min-height: 100%;
  background: #f4f0ec;
}

body {
  color: var(--h5-ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.phone-page {
  position: relative;
  isolation: isolate;
  width: min(100%, var(--h5-page-max));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, var(--h5-cream) 0 222px, #fff 318px, #fff 100%);
}

/* 设计稿右上角浅色猫形。它是装饰层，必须位于步骤文字下方。 */
.phone-page::before {
  content: "";
  display: block;
  position: absolute;
  z-index: 0;
  top: calc(36px + env(safe-area-inset-top));
  right: 10px;
  width: 112px;
  height: 78px;
  pointer-events: none;
  opacity: .5;
  border: 0;
  border-radius: 0;
  background: #fce8d2;
  box-shadow: none;
  clip-path: none;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 222 155'%3E%3Cpath d='M8 151C3 132 9 113 25 99C35 90 45 85 48 73L53 26C54 15 65 10 74 17L101 36C114 32 129 33 141 37L168 17C177 10 188 15 189 26L194 73C197 85 207 91 217 101C231 116 234 135 226 151Z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 222 155'%3E%3Cpath d='M8 151C3 132 9 113 25 99C35 90 45 85 48 73L53 26C54 15 65 10 74 17L101 36C114 32 129 33 141 37L168 17C177 10 188 15 189 26L194 73C197 85 207 91 217 101C231 116 234 135 226 151Z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.fixed-header {
  position: sticky;
  z-index: 20;
  top: 0;
  height: var(--h5-header-height);
  padding: calc(9px + env(safe-area-inset-top)) 27px 0;
  background: linear-gradient(180deg, rgba(253,246,234,.87), rgba(253,246,234,.78));
  backdrop-filter: blur(4px);
}

.brand-row {
  display: flex;
  align-items: center;
  width: 123px;
  height: 60px;
  gap: 0;
  color: transparent;
  font-size: 0;
  letter-spacing: 0;
  text-shadow: none;
  background: url("brand-logo.png?v=3") left center / 122px auto no-repeat;
}

.brand-row > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.scroll-area {
  position: relative;
  z-index: 1;
  height: calc(100vh - var(--h5-header-height) - var(--h5-footer-height));
  height: calc(100dvh - var(--h5-header-height) - var(--h5-footer-height));
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 var(--h5-page-pad) 28px;
  background: transparent;
  scrollbar-width: none;
  overscroll-behavior: contain;
}

.scroll-area::-webkit-scrollbar { display: none; }

.step-line {
  display: grid;
  grid-template-columns: max-content minmax(18px, 1fr) max-content minmax(18px, 1fr) max-content;
  align-items: center;
  column-gap: 8px;
  margin: 11px 10px 10px;
  color: var(--h5-red);
  font-size: clamp(12px, 3.45vw, 15px);
  font-weight: 650;
  white-space: nowrap;
}

.step-line span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.step-line b {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--h5-red);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: none;
}

.step-line i {
  display: block;
  min-width: 18px;
  height: 1px;
  overflow: hidden;
  color: transparent;
  background: #bd555e;
  opacity: .78;
}

.upload-card { position: relative; }

.upload-shell {
  padding: 13px 12px 14px;
  border: 1px solid #eee3df;
  border-radius: 20px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 8px 21px rgba(86,43,29,.085);
}

.upload-box { position: relative; }

.upload-trigger {
  position: relative;
  width: 100%;
  height: 197px;
  max-height: none;
  aspect-ratio: auto;
  overflow: hidden;
  padding: 10px 15px;
  border: 1px dashed #f0d2c3;
  border-radius: 11px;
  background:
    linear-gradient(0deg, rgba(255,255,255,.27), rgba(255,255,255,.27)),
    linear-gradient(90deg, rgba(251,220,217,.29) 0 25%, rgba(255,255,255,.18) 25% 50%, rgba(219,240,239,.24) 50% 75%, rgba(255,255,255,.18) 75%) 0 0 / 58px 58px,
    linear-gradient(180deg, rgba(255,255,255,.48), rgba(255,255,255,.78));
}

.upload-trigger::before {
  content: "";
  position: absolute;
  right: 7%;
  bottom: -42px;
  left: 7%;
  height: 151px;
  border-radius: 50% 50% 0 0 / 38% 38% 0 0;
  background: rgba(255,255,255,.84);
  box-shadow: 0 -6px 18px rgba(142,61,33,.035);
  pointer-events: none;
}

.upload-placeholder {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.upload-stickers {
  display: block;
  width: 190px;
  height: 75px;
  flex: 0 0 auto;
  margin: -7px 0 -3px;
  background: url("upload-pet-stickers.png?v=3") center / contain no-repeat;
}

.upload-sticker { display: none; }

.upload-title {
  margin-top: 0;
  color: #111;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 750;
  letter-spacing: .1px;
}

.upload-help {
  color: #7f8a91;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 450;
}

.upload-main-btn {
  display: inline-flex;
  width: 176px;
  height: 40px;
  margin-top: 5px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 999px;
  background: var(--h5-red);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(171,8,23,.15);
}

.upload-main-btn::before {
  content: "";
  display: block;
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  background: url("icon-upload.png?v=3") center / contain no-repeat;
  transform: none;
}

.upload-box.has-image .upload-trigger {
  border-style: solid;
  background-color: #f8f4f1;
  background-repeat: no-repeat;
}

.upload-box.has-image .upload-trigger::before,
.upload-box.has-image .upload-placeholder {
  display: none;
}

.nickname-field {
  display: flex;
  position: relative;
  height: 48px;
  margin-top: 10px;
  align-items: center;
  border: 1px solid #f2e5e1;
  border-radius: 10px;
  background: #faf7f7;
}

.nickname-field::before {
  content: "";
  display: block;
  width: 34px;
  height: 35px;
  flex: 0 0 34px;
  margin-left: 8px;
  border-radius: 50%;
  background: url("icon-paw.png?v=3") center / contain no-repeat;
  transform: none;
}

.nickname-field input {
  min-width: 0;
  height: 100%;
  flex: 1 1 auto;
  padding: 0 56px 0 10px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #1b1716;
  font: inherit;
  font-size: 15px;
}

.nickname-field input::placeholder { color: #718391; opacity: 1; }

.nickname-count {
  position: absolute;
  right: 13px;
  color: #667782;
  font-size: 15px;
  font-weight: 500;
}

.style-section {
  margin-top: 10px;
  padding: 0 0 5px;
}

.style-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 4px 8px;
}

.section-title {
  margin: 0;
  color: #111;
  font-size: 21px;
  line-height: 1.35;
  font-weight: 800;
  letter-spacing: .2px;
}

.section-subtitle {
  margin: 0;
  color: #514b48;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 500;
}

.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 8px;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}

.category-tabs::-webkit-scrollbar { display: none; }

.category-tab {
  min-width: 86px;
  max-width: 126px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0 16px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--h5-pill);
  color: #24211f;
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
  scroll-snap-align: start;
  box-shadow: none;
}

.category-tab.active {
  background: var(--h5-red);
  color: #fff;
  box-shadow: 0 6px 13px rgba(171,8,23,.13);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 9px;
  row-gap: 10px;
}

.template-card {
  display: flex;
  position: relative;
  min-width: 0;
  aspect-ratio: 1.17 / 1;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  padding: 5px;
  border: 1px solid #f3ebe7;
  border-radius: 10px;
  background: var(--h5-card);
  color: #282321;
  text-align: left;
  box-shadow: none;
}

.template-card.active {
  border-color: var(--h5-red);
  color: #d00a21;
}

.template-card.active::after {
  content: "✓";
  display: grid;
  position: absolute;
  z-index: 3;
  top: 7px;
  left: 7px;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--h5-red);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  font-weight: 850;
  box-shadow: 0 3px 7px rgba(171,8,23,.13);
}

.template-thumb {
  display: block;
  position: absolute;
  inset: 5px 5px 29px;
  overflow: hidden;
  border-radius: 7px;
  background: #fff4ef;
}

.template-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-name {
  display: block;
  position: relative;
  z-index: 1;
  width: 100%;
  overflow: hidden;
  padding: 0 4px;
  color: inherit;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-pager { margin-top: 12px; }

.fixed-footer {
  position: sticky;
  z-index: 20;
  bottom: 0;
  height: var(--h5-footer-height);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.98) 24%);
}

.fixed-footer::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 8px;
  pointer-events: none;
  background: url("footer-pattern.png?v=3") center bottom / 430px 8px no-repeat;
}

.free-btn {
  display: flex;
  width: 100%;
  height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--h5-red);
  color: #fff;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: .3px;
  box-shadow: 0 7px 16px rgba(171,8,23,.16);
}

.free-btn::before {
  content: "";
  display: block;
  width: 48px;
  height: 29px;
  flex: 0 0 48px;
  margin: 0;
  background: url("icon-preview.png?v=3") center / contain no-repeat;
  transform: none;
}

.free-btn:disabled {
  background: var(--h5-red);
  opacity: .45;
  box-shadow: none;
}

.notice { display: none; }

button:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(171,8,23,.44);
  outline-offset: 2px;
}

@media (max-width: 380px) {
  :root {
    --h5-page-pad: 12px;
    --h5-header-height: 72px;
    --h5-footer-height: 72px;
  }

  .fixed-header { padding-right: 20px; padding-left: 20px; }
  .brand-row { width: 116px; background-size: 116px auto; }

  .step-line {
    column-gap: 4px;
    margin: 9px 5px 9px;
    font-size: 11px;
  }

  .step-line span { gap: 5px; }

  .step-line b {
    width: 21px;
    height: 21px;
    flex-basis: 21px;
    font-size: 11px;
  }

  .upload-trigger { height: 192px; }
  .upload-stickers { width: 181px; height: 71px; }
  .upload-title { font-size: 17px; }
  .upload-main-btn { width: 168px; }

  .category-tab {
    min-width: 78px;
    padding-right: 13px;
    padding-left: 13px;
  }

  .template-grid { gap: 8px; }
  .template-name { font-size: 13px; }

  .fixed-footer { padding-right: 12px; padding-left: 12px; }
  .free-btn { height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
