:root {
  color-scheme: light;
  --ink: #242826;
  --muted: #67716d;
  --paper: #fbf5f3;
  --surface: #fffdfb;
  --line: #e4d9d9;
  --teal: #c94f6a;
  --teal-dark: #81384d;
  --mint: #f8dfe5;
  --coral: #e76f7f;
  --yellow: #f1c84b;
  --brown: #76543a;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow: 0 18px 50px rgb(43 63 57 / 10%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

button, input, select { font: inherit; }
button, a, label, input, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.12; letter-spacing: -0.025em; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--coral) 70%, white);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  transform: translateY(-180%);
  background: var(--ink);
  color: white;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.8rem clamp(1rem, 4vw, 4rem);
  border-bottom: 1px solid rgb(34 45 41 / 10%);
  background: rgb(251 245 243 / 92%);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
}

.brand > span:last-child { display: grid; }
.brand strong { font-size: 1.05rem; letter-spacing: 0.02em; }
.brand small { color: var(--muted); font-size: 0.68rem; }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 0.65rem);
  gap: 0.13rem;
  transform: rotate(-8deg);
}

.brand-mark i {
  width: 0.65rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: inset 0 0 0 0.15rem rgb(255 255 255 / 55%);
}
.brand-mark i:nth-child(2) { background: var(--coral); }
.brand-mark i:nth-child(3) { background: var(--yellow); }
.brand-mark i:nth-child(4) { background: #5ba5cf; }

.site-header nav { display: flex; align-items: center; gap: 0.25rem; }
.site-header nav a {
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  color: #4f5854;
  font-size: 0.9rem;
  text-decoration: none;
}
.site-header nav a:hover { background: rgb(23 111 106 / 9%); color: var(--teal-dark); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(18rem, 0.8fr);
  align-items: center;
  min-height: 42rem;
  max-width: 90rem;
  margin: 0 auto;
  padding: clamp(3rem, 7vw, 7rem) clamp(1.25rem, 6vw, 6rem) 2rem;
  overflow: hidden;
}

.hero-copy { position: relative; z-index: 2; max-width: 43rem; }
.eyebrow {
  margin-bottom: 0.8rem;
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 42rem;
  margin-bottom: 1.3rem;
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", sans-serif;
  font-size: clamp(3rem, 6.4vw, 6.3rem);
  font-weight: 780;
}

.hero-description {
  max-width: 38rem;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.8rem; }
.privacy-note { margin-top: 0.85rem; color: var(--muted); font-size: 0.78rem; }

.hero-character {
  position: relative;
  align-self: end;
  justify-self: center;
  width: min(100%, 39rem);
  height: 38rem;
}

.hero-character::before {
  position: absolute;
  inset: 23% -12% 4% 5%;
  z-index: -1;
  border-radius: 50%;
  background: var(--mint);
  content: "";
}

.hero-character img {
  position: absolute;
  bottom: 0;
  max-height: 36rem;
  object-fit: contain;
  object-position: bottom;
  filter: drop-shadow(0 1.8rem 1.3rem rgb(39 62 52 / 18%));
}

.hero-character .mascot-pink { left: -4%; z-index: 2; width: 61%; }
.hero-character .mascot-blue { right: -3%; width: 57%; }

.speech-bubble {
  position: absolute;
  top: 6%;
  left: -18%;
  z-index: 2;
  max-width: 10.5rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgb(23 111 106 / 18%);
  border-radius: 1rem 1rem 0.2rem 1rem;
  background: white;
  color: var(--teal-dark);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  font-weight: 700;
}

.button {
  display: inline-flex;
  min-height: 2.8rem;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 720;
  text-decoration: none;
  transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: 0.46; }
.button.primary { background: var(--teal); color: white; }
.button.primary:hover:not(:disabled) { background: var(--teal-dark); }
.button.secondary { border-color: #c9d1cd; background: transparent; }
.button.secondary:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.button.quiet { border-color: var(--line); background: #f4f3ee; color: #4f5854; }
.button.light { background: #f4d978; color: #254642; }
.button.outline-light { border-color: rgb(255 255 255 / 35%); background: transparent; color: white; }
.button.full { width: 100%; }

.maker-section, .gallery-section {
  scroll-margin-top: 5rem;
  padding: clamp(3.5rem, 7vw, 7rem) clamp(1rem, 4vw, 4rem);
}

.maker-section {
  border-block: 1px solid rgb(33 52 45 / 9%);
  background: #ebece6;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  max-width: 88rem;
  margin: 0 auto 1.5rem;
  gap: 2rem;
}

.section-heading h2 { margin-bottom: 0; font-size: clamp(2rem, 4vw, 3.7rem); }
.steps { display: flex; margin: 0; padding: 0; gap: 0.4rem; list-style: none; }
.steps li { display: flex; align-items: center; gap: 0.35rem; color: #7b817e; font-size: 0.78rem; }
.steps li:not(:last-child)::after { width: 1.2rem; height: 1px; margin-left: 0.2rem; background: #bec4c0; content: ""; }
.steps span { display: grid; width: 1.55rem; aspect-ratio: 1; place-items: center; border: 1px solid #b8bfbb; border-radius: 50%; }
.steps .active { color: var(--teal-dark); font-weight: 750; }
.steps .active span { border-color: var(--teal); background: var(--teal); color: white; }

.workspace {
  display: grid;
  grid-template-columns: minmax(15.5rem, 0.75fr) minmax(26rem, 1.75fr) minmax(14rem, 0.72fr);
  max-width: 88rem;
  min-height: 42rem;
  margin: 0 auto;
  border: 1px solid #d3d6d0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.control-panel, .palette-panel { padding: 1.25rem; }
.control-panel { border-right: 1px solid var(--line); }
.palette-panel { border-left: 1px solid var(--line); background: #faf9f4; }

.panel-heading { display: flex; align-items: flex-start; gap: 0.7rem; margin-bottom: 1.2rem; }
.panel-heading.compact { margin-bottom: 0.8rem; }
.panel-heading h3, .preview-toolbar h3 { margin: 0 0 0.2rem; font-size: 1rem; }
.panel-heading p:not(.panel-index) { margin: 0; color: var(--muted); font-size: 0.75rem; }
.panel-index { margin: 0; color: var(--coral); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.1em; }

.dropzone {
  display: grid;
  min-height: 7.6rem;
  place-content: center;
  padding: 1rem;
  border: 1px dashed #aeb9b3;
  border-radius: var(--radius-md);
  background: #f7f7f1;
  cursor: pointer;
  text-align: center;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.dropzone:hover, .dropzone.dragging { border-color: var(--teal); background: var(--mint); }
#image-input:focus-visible + .dropzone { outline: 3px solid color-mix(in srgb, var(--coral) 70%, white); outline-offset: 3px; }
.dropzone strong { font-size: 0.86rem; }
.dropzone span { margin-top: 0.2rem; color: var(--muted); font-size: 0.7rem; }

fieldset { margin: 1.2rem 0; padding: 0; border: 0; }
legend, .field-label { display: block; margin-bottom: 0.45rem; font-size: 0.78rem; font-weight: 750; }
select, input[type="text"] {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #cfd4d0;
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
}

.preset-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.35rem; }
.preset-row button, .edit-toolbar button {
  min-height: 2.25rem;
  border: 1px solid #ccd2ce;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 0.76rem;
}
.preset-row button.selected { border-color: var(--teal); background: var(--mint); color: var(--teal-dark); font-weight: 750; }
.field-help { display: block; margin-top: 0.35rem; color: var(--muted); font-size: 0.66rem; }
.range-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.6rem; margin-top: 0.65rem; }
input[type="range"] { width: 100%; accent-color: var(--teal); }
output { min-width: 3.8rem; color: var(--teal-dark); font-size: 0.74rem; font-weight: 700; text-align: right; }

.check-row { display: flex; align-items: flex-start; margin: 1.1rem 0; gap: 0.55rem; cursor: pointer; }
.check-row input { margin-top: 0.2rem; accent-color: var(--teal); }
.check-row span { display: grid; font-size: 0.78rem; }
.check-row small { color: var(--muted); font-size: 0.68rem; }
.form-message { min-height: 1.25rem; margin: 0.55rem 0 0; color: var(--muted); font-size: 0.72rem; }
.form-message.error { color: #a63838; }
.form-message.success { color: var(--teal-dark); }

.canvas-panel { display: grid; grid-template-rows: auto minmax(20rem, 1fr) auto; min-width: 0; background: #f1f0ea; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.preview-toolbar > div:first-child { display: flex; align-items: center; gap: 0.5rem; }
.metrics { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.35rem; }
.metrics span { padding: 0.25rem 0.45rem; border-radius: 5px; background: #e8ebe7; color: #52605a; font-size: 0.66rem; }

.canvas-stage {
  position: relative;
  display: grid;
  min-height: 28rem;
  place-items: center;
  padding: 1.2rem;
  overflow: auto;
  background-image: linear-gradient(45deg, #e6e5df 25%, transparent 25%), linear-gradient(-45deg, #e6e5df 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e6e5df 75%), linear-gradient(-45deg, transparent 75%, #e6e5df 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

#pattern-canvas { display: none; max-width: 100%; height: auto; border: 1px solid #d6d8d4; background: white; box-shadow: 0 12px 25px rgb(52 57 53 / 10%); cursor: crosshair; }
#pattern-canvas.ready { display: block; }
.canvas-empty { display: grid; max-width: 18rem; justify-items: center; text-align: center; }
.canvas-empty strong { margin-top: 0.7rem; }
.canvas-empty p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.78rem; }
.empty-grid { width: 4.3rem; aspect-ratio: 1; border: 1px solid #acb5af; border-radius: 50%; background: radial-gradient(circle, transparent 24%, #73b9ac 26% 46%, transparent 48%) 0 0 / 1.4rem 1.4rem; }

.edit-toolbar { display: flex; align-items: center; gap: 0.45rem; padding: 0.75rem 1rem; border-top: 1px solid var(--line); background: var(--surface); }
.edit-toolbar button { padding-inline: 0.65rem; }
.edit-toolbar button:disabled { opacity: 0.45; }
.compact-check { display: flex; align-items: center; gap: 0.35rem; font-size: 0.72rem; }
.compact-check input { accent-color: var(--teal); }
.edit-hint { margin-left: auto; color: var(--muted); font-size: 0.68rem; }

.palette-summary { margin-bottom: 0.65rem; padding: 0.65rem; border-radius: var(--radius-sm); background: var(--mint); color: var(--teal-dark); font-size: 0.74rem; font-weight: 700; }
.palette-list { display: grid; max-height: 25rem; gap: 0.35rem; overflow-y: auto; }
.palette-item {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.35rem 0.45rem;
  gap: 0.45rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.palette-item:hover, .palette-item.selected { border-color: #b9c9c2; background: white; }
.palette-item.selected { box-shadow: inset 3px 0 var(--teal); }
.color-swatch { width: 1.35rem; aspect-ratio: 1; border: 1px solid rgb(26 34 31 / 18%); border-radius: 50%; box-shadow: inset 0 0 0 0.28rem rgb(255 255 255 / 25%); }
.palette-name { display: grid; font-size: 0.7rem; }
.palette-name strong { font-size: 0.75rem; }
.palette-count { color: var(--muted); font-size: 0.7rem; font-variant-numeric: tabular-nums; }
.palette-disclaimer { margin: 0.75rem 0; color: var(--muted); font-size: 0.64rem; }
.download-stack { display: grid; gap: 0.4rem; }

.frame-section {
  scroll-margin-top: 5rem;
  padding: clamp(4rem, 8vw, 8rem) clamp(1rem, 6vw, 6rem);
  background: var(--teal-dark);
  color: white;
}
.section-heading.light .eyebrow { color: #f4d978; }
.section-heading.light > p { max-width: 24rem; margin: 0; color: rgb(255 255 255 / 70%); }
.frame-layout { display: grid; grid-template-columns: minmax(14rem, 0.48fr) minmax(22rem, 1.25fr); max-width: 78rem; margin: 0 auto; gap: clamp(2rem, 6vw, 6rem); }
.frame-controls { align-self: center; }
.frame-controls select, .frame-controls input { margin-bottom: 1.2rem; }
.frame-controls .button + .button { margin-top: 0.5rem; }
.frame-preview-wrap { position: relative; display: grid; min-height: 34rem; place-items: center; }
#frame-canvas { display: none; width: min(100%, 38rem); height: auto; box-shadow: 0 2rem 4rem rgb(0 0 0 / 28%); }
#frame-canvas.ready { display: block; }
.frame-empty { max-width: 22rem; color: rgb(255 255 255 / 62%); text-align: center; }

.publish-section {
  position: relative;
  display: grid;
  grid-template-columns: 10rem minmax(16rem, 1fr) minmax(19rem, 0.8fr);
  align-items: center;
  max-width: 78rem;
  margin: clamp(3rem, 7vw, 6rem) auto;
  padding: 2rem 2.5rem;
  gap: 2rem;
  border: 1px solid #d8d9d3;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.publish-character { align-self: end; height: 12rem; overflow: hidden; }
.publish-character img { width: 10rem; transform: translateY(0.5rem); }
.publish-copy h2 { margin-bottom: 0.65rem; font-size: 2rem; }
.publish-copy p:last-child { margin: 0; color: var(--muted); }
.publish-consent { margin: 0.8rem 0; }

.gallery-section { max-width: 96rem; margin: 0 auto; }
.gallery-intro { max-width: 88rem; margin: -0.7rem auto 1.8rem; color: var(--muted); }
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 88rem; margin: 0 auto; gap: 1rem; }
.gallery-card { border: 1px solid #d9dbd5; border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.gallery-card > img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #e7e7e0; }
.gallery-card-body { padding: 0.9rem; }
.gallery-card h3 { margin-bottom: 0.25rem; font-size: 1rem; }
.gallery-meta { margin: 0; color: var(--muted); font-size: 0.72rem; }
.gallery-palette { display: flex; margin: 0.75rem 0; gap: 0.18rem; }
.gallery-palette span { width: 0.8rem; aspect-ratio: 1; border: 1px solid rgb(0 0 0 / 12%); border-radius: 50%; }
.gallery-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.gallery-actions a { min-height: 2.3rem; font-size: 0.72rem; }
.gallery-empty { display: flex; align-items: center; justify-content: center; max-width: 88rem; min-height: 18rem; margin: 0 auto; gap: 1rem; border: 1px dashed #bdc3bf; border-radius: var(--radius-lg); }
.gallery-empty img { width: 7rem; max-height: 9rem; object-fit: contain; object-position: top; }
.gallery-empty strong { font-size: 1.1rem; }
.gallery-empty p { margin: 0.2rem 0 0; color: var(--muted); }

footer { display: flex; justify-content: space-between; padding: 2rem clamp(1rem, 4vw, 4rem); border-top: 1px solid #d7d9d4; color: var(--muted); font-size: 0.75rem; }
footer span { color: var(--ink); font-weight: 750; }
footer p { margin: 0; }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  max-width: 22rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.5rem);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.print-area { display: none; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 72rem) {
  .workspace { grid-template-columns: minmax(15rem, 0.72fr) minmax(24rem, 1.45fr); }
  .palette-panel { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; }
  .palette-list { grid-template-columns: repeat(3, 1fr); max-height: none; }
  .download-stack { grid-template-columns: repeat(3, 1fr); }
  .publish-section { margin-inline: 1rem; }
}

@media (max-width: 52rem) {
  .site-header nav a:nth-child(2) { display: none; }
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: 4.5rem; }
  .hero-character { width: min(95%, 32rem); height: 30rem; margin-top: 2rem; }
  .speech-bubble { left: -7%; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .workspace { grid-template-columns: 1fr; }
  .control-panel, .palette-panel { border: 0; }
  .control-panel { border-bottom: 1px solid var(--line); }
  .palette-panel { border-top: 1px solid var(--line); }
  .palette-list { grid-template-columns: repeat(2, 1fr); }
  .frame-layout { grid-template-columns: 1fr; }
  .frame-preview-wrap { min-height: 24rem; }
  .publish-section { grid-template-columns: 6rem 1fr; padding: 1.5rem; }
  .publish-character { grid-row: span 2; height: 11rem; }
  .publish-character img { width: 7rem; }
  .publish-form { grid-column: 2; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 36rem) {
  .site-header { padding-inline: 0.8rem; }
  .site-header nav { gap: 0; }
  .site-header nav a { padding-inline: 0.5rem; font-size: 0.76rem; }
  .hero { padding-inline: 1rem; }
  .hero h1 { font-size: 3.15rem; }
  .hero-character { height: 24rem; }
  .hero-actions .button { width: 100%; }
  .speech-bubble { top: 2%; left: -3%; }
  .maker-section, .gallery-section { padding-inline: 0.7rem; }
  .steps { width: 100%; justify-content: space-between; }
  .steps li { display: grid; justify-items: center; }
  .steps li:not(:last-child)::after { display: none; }
  .workspace { border-radius: var(--radius-md); }
  .preview-toolbar { align-items: flex-start; flex-direction: column; gap: 0.6rem; }
  .canvas-stage { min-height: 22rem; padding: 0.5rem; place-items: start; }
  #pattern-canvas.ready { max-width: none; }
  .edit-toolbar { flex-wrap: wrap; }
  .edit-hint { width: 100%; margin-left: 0; }
  .palette-list, .download-stack { grid-template-columns: 1fr; }
  .frame-section { padding-inline: 1rem; }
  .publish-section { grid-template-columns: 1fr; margin-inline: 0.7rem; text-align: center; }
  .publish-character { display: none; }
  .publish-form { grid-column: auto; text-align: left; }
  .gallery-grid { grid-template-columns: 1fr; }
  footer { flex-direction: column; gap: 0.3rem; }
}

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

@media print {
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  .print-area img { width: 100%; height: auto; }
  @page { margin: 10mm; }
}
