:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --ink: #1c1f22;
  --muted: #555b60;
  --line: #d9d4cc;
  --accent: #9c3d28;
  --accent-deep: #7d2e1d;
  --focus: #1d4ed8;
  --success-bg: #e8f3ec;
  --success-ink: #1f5d38;
  --error-bg: #fdeceb;
  --error-ink: #8a241b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(28, 31, 34, 0.08);
  --max: 1080px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

::selection { background: #f0d9d2; color: var(--ink); }
input, textarea { caret-color: var(--accent); }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: 20px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 20;
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
}
.skip-link:focus { left: 12px; }

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand img { display: block; width: 32px; height: 32px; }

.site-nav { display: flex; gap: 4px; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.9375rem;
  text-decoration: none;
  border-radius: 8px;
}
.site-nav a:hover { color: var(--accent); background: #f3ebe8; }

a { color: var(--accent-deep); text-underline-offset: 3px; }
a:hover { color: var(--accent-deep); }
.skip-link:hover { color: #ffffff; }

main { padding-block: 48px 72px; }

.intro { max-width: 70ch; margin-bottom: 36px; }
.intro h1,
.section-title {
  margin: 0 0 16px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.intro h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
.section-title { font-size: clamp(1.5rem, 3vw, 2rem); }
.lead { margin: 0; color: var(--muted); font-size: 1.0625rem; }
.byline { margin: 12px 0 0; color: var(--muted); font-size: 0.8125rem; }

.breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 0.875rem;
}
.breadcrumb span[aria-current] { color: var(--ink); font-weight: 600; }

.tool-section {
  margin-bottom: 56px;
}

.dropzone {
  width: 100%;
  min-height: 228px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 20px;
  background: var(--surface);
  color: var(--muted);
  border: 2px dashed #b9b1a6;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
  text-align: center;
  transition: border-color 160ms ease-out, background-color 160ms ease-out, transform 160ms ease-out;
}
.dropzone:hover { border-color: var(--accent); background: #fffaf8; }
.dropzone.is-dragging { border-color: var(--accent); background: #f7eae6; transform: translateY(-2px); }
.upload-icon { width: 42px; height: 42px; color: var(--accent); }
.dropzone-title { color: var(--ink); font-size: 1.0625rem; font-weight: 650; }
.dropzone-hint { font-size: 0.875rem; }

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 24px;
  margin-top: 24px;
  align-items: start;
}
.editor[hidden] { display: none; }

.preview-panel,
.controls,
.faq-list details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.preview-panel { padding: 18px; }
.canvas-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  padding: 12px;
  background: #efede9;
  border-radius: 10px;
  overflow: hidden;
}
#imageCanvas { display: block; max-width: 100%; height: auto; border-radius: 6px; }

.status {
  margin: 14px 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9375rem;
  background: var(--success-bg);
  color: var(--success-ink);
  transition: background-color 160ms ease-out, color 160ms ease-out;
}
.status[data-state="error"] { background: var(--error-bg); color: var(--error-ink); }

.image-meta { margin: 0 0 12px; color: var(--muted); font-size: 0.8125rem; }
.queue {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 148px;
  overflow-y: auto;
}
.queue-item {
  min-height: 36px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-item[aria-current="true"] { border-color: var(--accent); background: #f7eae6; color: var(--accent-deep); }

.controls { padding: 22px; }
.control-group { margin: 0 0 24px; padding: 0; border: 0; }
.control-group h3 {
  margin: 0 0 16px;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}
.field { margin-bottom: 18px; }
.field > label,
.field > legend {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.9375rem;
}
fieldset.field { padding: 0; margin-inline: 0; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 0.8125rem; }

input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #b9b1a6;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
input[type="color"] {
  width: 52px;
  height: 44px;
  padding: 3px;
  border: 1px solid #b9b1a6;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  flex: 0 0 auto;
}
.color-controls { display: flex; gap: 10px; align-items: center; }
.color-controls input[type="text"] { max-width: 160px; }

.select-control {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #b9b1a6;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.logo-preview {
  display: block;
  max-width: 120px;
  max-height: 72px;
  margin-top: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}
.btn-block { width: 100%; }

input[type="range"] {
  width: 100%;
  min-height: 44px;
  accent-color: var(--accent);
  cursor: pointer;
}
output { color: var(--accent-deep); font-variant-numeric: tabular-nums; font-weight: 650; }

.choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
.choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--accent); background: #f7eae6; color: var(--accent-deep); }
.choice input { accent-color: var(--accent); width: 18px; height: 18px; }

.advanced { border-top: 1px solid var(--line); padding-top: 8px; }
.advanced summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-deep);
}
.advanced[open] summary { margin-bottom: 12px; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
.btn {
  min-height: 46px;
  padding: 0 20px;
  border-radius: 9px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 160ms ease-out, border-color 160ms ease-out, transform 160ms ease-out;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-deep); }
.btn-secondary { background: var(--surface); color: var(--accent-deep); border-color: var(--accent); }
.btn-secondary:hover:not(:disabled) { background: #f7eae6; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); padding-inline: 14px; }
.btn-ghost:hover { color: var(--accent-deep); border-color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.prose-section { max-width: 70ch; margin-bottom: 44px; }
.prose-section p { margin: 0 0 14px; color: var(--muted); }
.steps { padding-left: 1.4em; margin: 0 0 18px; }
.steps li { margin-bottom: 10px; }
.steps strong { color: var(--ink); }
.facts { padding-left: 1.2em; margin: 0; color: var(--muted); }
.facts li { margin-bottom: 6px; }

.faq-list { box-shadow: none; }
.faq-list details { margin-bottom: 10px; box-shadow: none; }
.faq-list summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
}
.faq-list details p { margin: 0; padding: 0 16px 16px; color: var(--muted); }

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-block: 24px;
  color: var(--muted);
  font-size: 0.875rem;
}
.site-footer p { margin: 0; }

@media (max-width: 860px) {
  .editor { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .wrap { padding-inline: 16px; }
  .header-inner { flex-wrap: wrap; gap: 8px; padding-block: 12px; }
  .site-nav { width: 100%; overflow-x: auto; }
  .site-nav a { flex: 0 0 auto; padding-inline: 10px; }
  main { padding-block: 32px 56px; }
  .dropzone { min-height: 180px; }
  .preview-panel, .controls { padding: 16px; }
  .color-controls { flex-wrap: wrap; }
  .color-controls input[type="text"] { max-width: none; flex: 1 1 140px; }
  .actions .btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .dropzone, .btn, .status { transition: none; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #c9c2b8; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: var(--bg); }
