:root {
  --ink: #332947;
  --muted: #786d8e;
  --paper: #fbf8ff;
  --card: rgba(255, 255, 255, .92);
  --line: #e7def3;
  --purple: #7856d8;
  --purple-dark: #50349d;
  --lavender: #eee7ff;
  --pink: #ff75a8;
  --pink-soft: #ffe4ef;
  --mint: #83dbc3;
  --yellow: #ffd968;
  --shadow: 0 14px 38px rgba(92, 63, 140, .09);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 7%, rgba(255, 207, 227, .55), transparent 21rem),
    radial-gradient(circle at 92% 12%, rgba(221, 211, 255, .65), transparent 24rem),
    var(--paper);
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}
button, input { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
svg { flex: 0 0 auto; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 76px;
  padding: 0 3.2vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(221, 210, 240, .8);
  background: rgba(255, 253, 255, .82);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(145deg, #8b6bea, #6544c4);
  color: #fff9bc;
  transform: rotate(-4deg);
  box-shadow: 4px 5px 0 #ffc5dd, 0 10px 22px rgba(108, 74, 197, .2);
}
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 21px; letter-spacing: .02em; }
.brand strong em { color: var(--purple); font-style: normal; font-weight: 850; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .05em; }
.header-actions, .export-actions { display: flex; gap: 8px; align-items: center; }
.btn, .header-actions button, .header-actions label, .export-actions button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  border-radius: 13px;
  min-height: 41px;
  padding: 0 15px;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  transition: transform .16s, border-color .16s, background .16s, box-shadow .16s;
}
.btn:hover:not(:disabled), .header-actions button:hover, .header-actions label:hover, .export-actions button:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #c9b8eb;
  box-shadow: 0 8px 18px rgba(98, 67, 150, .09);
}
.btn.dark { background: var(--purple); color: white; border-color: var(--purple); }
.btn.primary {
  background: linear-gradient(135deg, #8a6bec, #d968ba);
  color: white;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(111, 74, 207, .22);
}
.btn.wide { width: 100%; min-height: 50px; font-size: 15px; }
button:disabled { opacity: .42; cursor: not-allowed !important; box-shadow: none !important; }

.hero-line {
  max-width: 1500px;
  margin: 0 auto;
  padding: 44px 3.2vw 32px;
  display: flex;
  justify-content: space-between;
  gap: 60px;
  align-items: flex-end;
}
.eyebrow {
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--purple-dark);
  background: rgba(255,255,255,.72);
  border: 1px solid #e4d7fa;
  font-family: var(--font-geist-mono), monospace;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .11em;
}
.hero-line h1 {
  margin: 14px 0 0;
  max-width: 820px;
  font-size: clamp(34px, 4.3vw, 63px);
  line-height: 1.04;
  letter-spacing: -.055em;
  background: linear-gradient(115deg, #362a4b 12%, #744fd0 62%, #dc5c9e);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}
.hero-note {
  max-width: 370px;
  padding: 15px 17px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--purple-dark);
  background: rgba(255,255,255,.7);
  border: 1px solid rgba(224, 211, 247, .95);
  border-radius: 18px 18px 18px 5px;
  box-shadow: 0 8px 26px rgba(111, 79, 161, .06);
}
.hero-note p { margin: 0; color: var(--muted); line-height: 1.7; font-size: 13px; }

.workspace { width: min(1500px, 94vw); margin: 0 auto; display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 18px; align-items: start; }
.controls { display: grid; gap: 14px; }
.panel, .result-area, .export-bar {
  border: 1px solid rgba(224, 214, 239, .92);
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.step-panel { padding: 22px; }
.section-title { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 19px; }
.section-title > span, .step-chip {
  font-family: var(--font-geist-mono), monospace;
  display: grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  border-radius: 11px;
  background: linear-gradient(145deg, #8a69eb, #6545bd);
  color: #fff8bc;
  font-size: 11px;
  font-weight: 850;
  box-shadow: 3px 3px 0 #ffd0e2;
}
.section-title h2, .result-toolbar h2, .export-bar h2 { font-size: 16px; margin: 0 0 4px; letter-spacing: -.01em; }
.section-title p, .result-toolbar p, .export-bar p { font-size: 11px; color: var(--muted); margin: 0; }
.dropzone {
  min-height: 190px;
  border: 1.5px dashed #cbb8ea;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(247,241,255,.9), rgba(255,240,247,.8));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .18s, background .18s, border-color .18s;
}
.dropzone:hover { transform: translateY(-2px); background: linear-gradient(145deg, #f0e7ff, #ffe7f1); border-color: #9e80d7; }
.upload-icon {
  width: 52px;
  height: 52px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, var(--pink), #a06aea);
  box-shadow: 0 9px 20px rgba(190, 80, 146, .2);
  margin-bottom: 13px;
  transform: rotate(-3deg);
}
.dropzone strong { font-size: 15px; }.dropzone small { color: var(--muted); margin-top: 6px; font-size: 11px; }
.crop-stage { position: relative; overflow: hidden; border-radius: 16px; background: #eee9f5; min-height: 190px; max-height: 310px; touch-action: none; cursor: grab; border: 3px solid #f5efff; }
.crop-stage:active { cursor: grabbing; }.crop-stage canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.crop-stage span { position: absolute; left: 10px; bottom: 9px; padding: 6px 9px; color: white; background: rgba(59,38,82,.76); border-radius: 9px; font-size: 10px; }
.replace-link { display: block; width: max-content; margin: 12px auto 0; color: var(--purple); font-weight: 800; font-size: 12px; cursor: pointer; }
.fit-image-button { display: block; margin: 8px auto 0; border: 1px solid var(--line); border-radius: 9px; padding: 7px 11px; color: var(--purple); background: var(--lavender); font-size: 10px; font-weight: 750; cursor: pointer; }
.range-row { display: grid; grid-template-columns: 52px 1fr 42px; align-items: center; gap: 8px; margin-top: 13px; }
.range-row label, .range-row output { font-size: 11px; color: var(--muted); }.range-row output { text-align: right; font-family: var(--font-geist-mono), monospace; color: var(--purple); }
input[type="range"] { width: 100%; accent-color: var(--purple); }
.dimension-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 12px; }
.switch { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; cursor: pointer; }.switch input { display: none; }.switch span { width: 30px; height: 17px; border-radius: 20px; background: #d4cadf; position: relative; }.switch span:after { content:""; width: 13px; height: 13px; border-radius: 50%; background: white; position: absolute; top: 2px; left: 2px; transition: .16s; }.switch input:checked + span { background: var(--purple); }.switch input:checked + span:after { transform: translateX(13px); }
.dimension-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dimension-grid label { border: 1px solid var(--line); border-radius: 13px; padding: 9px 11px; display: grid; grid-template-columns: 1fr auto; align-items: center; color: var(--muted); font-size: 9px; background: #fdfbff; }
.dimension-grid input { grid-column: 1; border: 0; outline: 0; width: 74px; margin-top: 3px; background: transparent; color: var(--ink); font-size: 17px; font-weight: 800; }.dimension-grid small { grid-column: 2; grid-row: 1 / span 2; font-size: 9px; color: var(--purple); }
.warning { margin-top: 9px; padding: 10px; background: #fff1e4; color: #96532e; border-radius: 11px; font-size: 10px; line-height: 1.5; }
.adjustments { margin: 16px 0; padding-top: 3px; border-top: 1px solid var(--line); }
.check-row { margin-top: 14px; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; font-size: 12px; }.check-row input { accent-color: var(--purple); }.check-row small { grid-column: 2; color: var(--muted); font-size: 9px; margin-top: 3px; }
.palette-panel { overflow: hidden; }.palette-toggle { width: 100%; border: 0; background: transparent; padding: 17px 20px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; text-align: left; }
.palette-title { display: flex !important; grid: none !important; flex-direction: row !important; align-items: center; gap: 11px !important; }.palette-title > i { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 12px; background: var(--pink-soft); color: #c74782; font-style: normal; }.palette-title > span { display: grid; gap: 3px; }
.palette-toggle small { font-size: 10px; font-weight: 400; color: var(--muted); }.palette-toggle > i { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px; background: var(--lavender); color: var(--purple); font-style: normal; }
.palette-editor { padding: 0 15px 16px; }.palette-actions { display: flex; gap: 6px; }.palette-actions button, .palette-actions label { border: 1px solid var(--line); background: white; border-radius: 9px; padding: 7px 9px; font-size: 9px; cursor: pointer; }.palette-note { padding: 9px; border-radius: 9px; background: #fff8dc; color: #79621a; font-size: 9px; line-height: 1.45; }
.palette-list { max-height: 300px; overflow: auto; display: grid; gap: 5px; }.palette-row { display: grid; grid-template-columns: 18px 28px 53px 1fr 24px; gap: 5px; align-items: center; }.palette-row input { min-width: 0; height: 28px; border: 1px solid var(--line); border-radius: 7px; padding: 3px 5px; font-size: 9px; }.palette-row input[type="color"] { padding: 1px; }.palette-row button { border: 0; background: transparent; color: #b54d76; cursor: pointer; }

.result-area { min-height: 740px; overflow: hidden; position: sticky; top: 90px; }
.result-toolbar { min-height: 72px; padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 15px; background: linear-gradient(90deg, rgba(249,245,255,.8), rgba(255,247,251,.72)); }
.result-toolbar > div:first-child, .export-bar > div:first-child { display: flex; align-items: center; gap: 12px; }
.tool-actions { display: flex; align-items: center; gap: 5px; }.tool-actions button, .tool-actions label { min-height: 32px; border: 1px solid var(--line); background: white; border-radius: 9px; padding: 0 9px; gap: 5px; font-size: 10px; display: inline-flex; align-items: center; cursor: pointer; }.tool-actions label input { accent-color: var(--purple); }.tool-actions span { min-width: 38px; text-align: center; font-size: 9px; color: var(--muted); }
.canvas-stage {
  height: 575px;
  background-color: #f0ebf8;
  background-image: linear-gradient(45deg, rgba(255,255,255,.52) 25%, transparent 25%), linear-gradient(-45deg, rgba(255,255,255,.52) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(255,255,255,.52) 75%), linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.52) 75%);
  background-size: 20px 20px;
  background-position: 0 0,0 10px,10px -10px,-10px 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.empty-state { text-align: center; max-width: 350px; padding: 30px; }.empty-state strong { display: block; margin-top: 20px; font-size: 17px; }.empty-state p { color: var(--muted); font-size: 12px; line-height: 1.65; }
.moon-orbit { width: 94px; height: 94px; border-radius: 31px; margin: auto; display: grid; place-items: center; position: relative; color: #fff6aa; background: linear-gradient(145deg, #8e6feb, #6a4ac6); box-shadow: 6px 7px 0 #ffc7dd, 0 15px 32px rgba(93, 65, 157, .2); transform: rotate(-4deg); }.orbit-sparkle { position: absolute; right: -10px; top: -9px; color: var(--pink); filter: drop-shadow(0 2px 0 white); }
.editor-scroll { width: 100%; height: 100%; overflow: auto; padding: 28px; display: block; text-align: center; }.editor-canvas { display: inline-block; background: white; box-shadow: 0 18px 50px rgba(71,46,110,.17); border-radius: 5px; cursor: crosshair; touch-action: none; image-rendering: auto; }
.editor-bottom { border-top: 1px solid var(--line); max-height: 250px; overflow: auto; background: #fffdff; }.color-brush { padding: 12px 16px; display: grid; grid-template-columns: 75px 1fr; gap: 10px; align-items: start; }.color-brush > span, .usage > strong { font-size: 10px; color: var(--muted); font-weight: 750; padding-top: 6px; }.swatch-strip { display: flex; gap: 5px; flex-wrap: wrap; }.swatch-strip button { width: 27px; height: 27px; padding: 0; border-radius: 8px; border: 1px solid rgba(0,0,0,.14); font: 700 9px var(--font-geist-mono), monospace; cursor: pointer; }.swatch-strip button.selected { outline: 2px solid var(--purple); outline-offset: 2px; }
.usage { padding: 0 16px 15px; display: grid; grid-template-columns: 75px 1fr; gap: 10px; }.usage > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 5px; }.usage span { display: grid; grid-template-columns: 12px 1fr auto; gap: 6px; align-items: center; font-size: 9px; color: var(--muted); }.usage i { width: 12px; height: 12px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); }.usage b { color: var(--ink); font-family: var(--font-geist-mono), monospace; }

.export-bar { width: min(1500px, 94vw); margin: 18px auto 0; min-height: 82px; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; gap: 20px; background: linear-gradient(100deg, rgba(255,255,255,.94), rgba(251,244,255,.94)); }
.export-actions button { min-width: 145px; }
footer { width: min(1500px, 94vw); margin: 22px auto 0; padding: 18px 0 34px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 9px; letter-spacing: .06em; } footer span { display: inline-flex; align-items: center; gap: 6px; color: var(--purple); } footer p { margin: 0; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 360px; padding: 13px 17px; border-radius: 13px; color: white; background: var(--purple-dark); box-shadow: 0 12px 35px rgba(72,41,120,.25); font-size: 12px; }.toast.error { background: #a33f67; }

@media (max-width: 1000px) {
  .hero-line { align-items: flex-start; flex-direction: column; gap: 15px; }
  .workspace { grid-template-columns: 1fr; }.result-area { position: static; min-height: 650px; }.canvas-stage { height: 520px; }
  .controls { grid-template-columns: 1fr 1fr; }.palette-panel { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .topbar { height: auto; min-height: 70px; padding: 12px 16px; }.brand small { display: none; }.brand strong { font-size: 18px; }.brand-mark { width: 40px; height: 40px; border-radius: 13px; }
  .header-actions { gap: 4px; }.header-actions button,.header-actions label { min-height: 35px; padding: 0 8px; font-size: 0; }.header-actions svg { width: 16px; height: 16px; }
  .hero-line { padding: 30px 18px 23px; }.hero-line h1 { font-size: 37px; }.hero-note { max-width: 100%; }
  .workspace,.export-bar,footer { width: calc(100% - 24px); }.controls { grid-template-columns: 1fr; }.palette-panel { grid-column: auto; }.result-toolbar { height: auto; padding: 12px; align-items: flex-start; flex-direction: column; }.tool-actions { width: 100%; overflow-x: auto; padding-bottom: 2px; }
  .canvas-stage { height: 430px; }.editor-scroll { padding: 14px; }.export-bar { align-items: flex-start; flex-direction: column; }.export-actions { width: 100%; display: grid; grid-template-columns: 1fr; }.export-actions button { width: 100%; }
  footer { flex-direction: column; }.toast { left: 14px; right: 14px; bottom: 14px; }.color-brush,.usage { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
