:root {
  color-scheme: light;
  --yellow: #ffd92f;
  --yellow-deep: #f4bd19;
  --cream: #fffdf3;
  --ink: #201d1b;
  --purple: #7254e8;
  --purple-deep: #3d2a9c;
  --red: #f45245;
  --blue: #70d8ff;
  --muted: #635f58;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  isolation: isolate;
  color: var(--ink);
  font-family: "Microsoft YaHei", Inter, system-ui, sans-serif;
  background: var(--yellow);
}
body::before,
body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
}
body::before {
  inset: -30vmax;
  background: repeating-conic-gradient(
    from 7deg at 50% 50%,
    rgba(255, 255, 238, .58) 0deg 11deg,
    transparent 11deg 24deg
  );
  opacity: .7;
}
body::after {
  z-index: -1;
  opacity: .42;
  background-image: radial-gradient(rgba(103, 76, 25, .38) 1.35px, transparent 1.8px);
  background-size: 19px 19px;
}
button, input { font: inherit; }

.sticker-rain { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.sticker-drop {
  position: absolute;
  top: -190px;
  left: var(--start-x);
  width: var(--drop-size);
  height: auto;
  opacity: var(--drop-opacity);
  filter: drop-shadow(0 7px 0 rgba(43, 31, 13, .22));
  transform-origin: center;
  will-change: transform;
  animation: sticker-fall var(--fall-duration) linear var(--fall-delay) forwards;
}
@keyframes sticker-fall {
  from { transform: translate3d(0, 0, 0) rotate(var(--spin-start)) scaleX(var(--flip)); }
  to { transform: translate3d(var(--drift-x), calc(100vh + 260px), 0) rotate(var(--spin-end)) scaleX(var(--flip)); }
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 76px;
}
.workspace { display: grid; grid-template-columns: minmax(284px, 348px) 1fr; gap: 26px; align-items: start; }
.panel,
.preview-card {
  border: 4px solid var(--ink);
  border-radius: 30px;
  background: rgba(255, 253, 243, .94);
  box-shadow: 8px 9px 0 var(--ink);
}
.controls-panel { padding: 18px; }

.mask-chip {
  display: flex;
  align-items: center;
  min-height: 76px;
  gap: 12px;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  border-radius: 19px;
  background: var(--blue);
  box-shadow: 3px 3px 0 var(--ink);
}
.mask-chip img { width: 100px; height: 56px; object-fit: contain; }
.mask-chip strong { display: block; color: var(--ink); font-size: 1.05rem; font-weight: 900; letter-spacing: .12em; }

.drop-zone {
  display: flex;
  min-height: 154px;
  margin-top: 18px;
  padding: 22px 14px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  border: 3px dashed var(--ink);
  border-radius: 20px;
  background-color: #fff9d9;
  background-image: radial-gradient(rgba(244, 189, 25, .52) 1.2px, transparent 1.7px);
  background-size: 14px 14px;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .72);
  text-align: center;
  transition: transform .18s ease, background-color .18s ease;
}
.drop-zone:hover,
.drop-zone.is-dragover { transform: translate(-2px, -2px); background-color: #fff3a2; box-shadow: 4px 4px 0 var(--ink); }
.upload-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
}
.drop-zone strong { margin-top: 4px; font-size: 1rem; }
.drop-zone small,
.filename { color: var(--muted); font-size: .78rem; font-weight: 700; }
.filename { min-height: 18px; margin: 10px 4px 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.secondary-button {
  width: 100%;
  min-height: 50px;
  border: 3px solid var(--ink);
  border-radius: 15px;
  background: var(--purple);
  box-shadow: 4px 4px 0 var(--ink);
  color: white;
  cursor: pointer;
  font-weight: 900;
  letter-spacing: .05em;
  transition: transform .16s ease, box-shadow .16s ease;
}
.secondary-button:hover { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); background: var(--purple-deep); }
.status { min-height: 20px; margin: 15px 3px 0; color: var(--muted); font-size: .8rem; font-weight: 700; line-height: 1.45; }
.status.error { color: #b42d27; }
.status.success { color: #26713e; }

.preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px; }
.preview-card { min-width: 0; overflow: hidden; }
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 16px 19px;
  border-bottom: 4px solid var(--ink);
  background: #ff8b50;
  color: var(--ink);
}
.card-heading span { font-size: 1rem; font-weight: 900; }
.card-heading small { font-size: .75rem; font-weight: 800; }
.result-card .card-heading { background: var(--purple); color: white; }
.image-stage {
  position: relative;
  display: grid;
  min-height: 430px;
  place-items: center;
  overflow: hidden;
  background-color: #fff7d9;
  background-image: linear-gradient(45deg, rgba(244, 189, 25, .14) 25%, transparent 25%), linear-gradient(-45deg, rgba(244, 189, 25, .14) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(244, 189, 25, .14) 75%), linear-gradient(-45deg, transparent 75%, rgba(244, 189, 25, .14) 75%);
  background-position: 0 0, 0 15px, 15px -15px, -15px 0;
  background-size: 30px 30px;
}
.image-stage img { display: block; width: 100%; height: 100%; max-height: 650px; object-fit: contain; }
.image-stage img[hidden] { display: none; }
.image-stage p { max-width: 180px; padding: 22px; color: #746e62; font-weight: 800; text-align: center; }
.result-card { border-color: var(--ink); }

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; }
  .controls-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  .mask-chip, .drop-zone, .filename, .secondary-button, .status { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .page-shell { width: min(100% - 24px, 1440px); padding: 18px 0 46px; }
  .workspace, .preview-grid { gap: 16px; }
  .preview-grid { grid-template-columns: 1fr; }
  .controls-panel { display: block; }
  .image-stage { min-height: 300px; }
  .sticker-drop { max-width: 28vw; }
}
@media (prefers-reduced-motion: reduce) { .sticker-rain { display: none; } }
