:root {
  --ink: #181716;
  --paper: #fffaf0;
  --paper-deep: #f1e4cf;
  --tile: #ffffff;
  --mint: #36b37e;
  --coral: #ff6b4a;
  --blue: #1463ff;
  --yellow: #ffd166;
  --line: rgba(24, 23, 22, 0.14);
  --shadow: 0 24px 70px rgba(34, 25, 16, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12px 12px, rgba(24, 23, 22, 0.08) 2px, transparent 3px) 0 0 / 28px 28px,
    linear-gradient(180deg, #fffdf7 0%, var(--paper) 58%, #f8efe1 100%);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 240, 0.88);
  backdrop-filter: blur(16px);
}

.brand,
.nav,
.hero-actions,
.top-actions,
.button-row,
.switch-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  display: block;
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  object-fit: cover;
  box-shadow: 4px 4px 0 var(--ink);
}

.nav {
  gap: clamp(12px, 3vw, 34px);
  font-size: 14px;
  font-weight: 700;
}

.nav a {
  padding: 8px 0;
}

.pill-btn,
.primary-btn,
.secondary-btn {
  border: 2px solid var(--ink);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.pill-btn,
.primary-btn {
  color: var(--ink);
  background: var(--yellow);
  box-shadow: 5px 5px 0 var(--ink);
}

.secondary-btn {
  background: #fff;
  box-shadow: 4px 4px 0 var(--ink);
}

.pill-btn {
  padding: 10px 16px;
}

.pill-btn.ghost {
  background: #fff;
}

.top-actions {
  gap: 10px;
}

.primary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
}

.compact {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
}

.pill-btn:hover,
.primary-btn:hover,
.secondary-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
}

.hero {
  display: grid;
  grid-template-columns: minmax(280px, 1.08fr) minmax(280px, 0.92fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  min-height: min(760px, calc(88vh - 74px));
  padding: clamp(28px, 6vw, 72px) clamp(18px, 5vw, 72px) 36px;
}

.hero-art {
  min-height: 360px;
  border: 3px solid var(--ink);
  background: #fdf6dc;
  box-shadow: 12px 12px 0 var(--ink);
  overflow: hidden;
}

.hero-art canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hero-copy {
  max-width: 620px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 22px;
  font-size: clamp(42px, 6vw, 76px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
}

h3 {
  margin-bottom: 10px;
  font-size: 22px;
}

.hero-text,
.section-head p,
.dialog-copy,
.fine-print,
.footer {
  color: rgba(24, 23, 22, 0.68);
  line-height: 1.7;
}

.hero-text {
  max-width: 520px;
  font-size: 18px;
}

.hero-actions {
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.section,
.tool-section {
  padding: 76px clamp(18px, 5vw, 72px);
}

.section-band {
  margin: 0 clamp(18px, 5vw, 72px);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 3px solid var(--ink);
  background: #fff;
  box-shadow: 8px 8px 0 var(--ink);
}

.metrics div {
  min-height: 104px;
  padding: 20px;
  border-right: 1px solid var(--line);
}

.metrics div:last-child {
  border-right: 0;
}

.metrics strong {
  display: block;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
}

.metrics span {
  display: block;
  margin-top: 9px;
  color: rgba(24, 23, 22, 0.62);
  font-size: 14px;
  font-weight: 700;
}

.section-head {
  max-width: 720px;
  margin-bottom: 28px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
}

.template-card,
.tool-panel,
.preview-card {
  border: 2px solid var(--ink);
  background: var(--tile);
  box-shadow: 6px 6px 0 var(--ink);
}

.template-card {
  padding: 12px;
}

.template-preview {
  width: 100%;
  aspect-ratio: 1;
  image-rendering: pixelated;
  border: 1px solid var(--line);
  background: var(--paper);
}

.template-card h3 {
  margin: 12px 0 10px;
  font-size: 16px;
}

.template-card button {
  min-height: 36px;
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.tool-panel {
  position: sticky;
  top: 98px;
  display: grid;
  gap: 16px;
  padding: 18px;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 132px;
  padding: 18px;
  border: 2px dashed rgba(24, 23, 22, 0.42);
  background: #fff7de;
  cursor: pointer;
  text-align: center;
  font-weight: 800;
}

.upload-box input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--mint);
  font-size: 28px;
  line-height: 1;
}

.control {
  display: grid;
  grid-template-columns: 1fr auto 82px;
  gap: 8px;
  align-items: center;
  font-weight: 800;
}

.control input[type="range"] {
  grid-column: 1 / -1;
  accent-color: var(--blue);
}

.control .inline-number {
  width: 82px;
  min-height: 34px;
  padding: 0 8px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.select-control {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

.select-control select,
.select-control input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-weight: 800;
}

.switch-row {
  gap: 10px;
  font-weight: 800;
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--mint);
}

.button-row {
  gap: 10px;
}

.fine-print {
  margin: 0;
  font-size: 13px;
}

.preview-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(180px, 0.38fr) minmax(320px, 1fr);
  gap: 16px;
  align-items: start;
}

.preview-card {
  min-width: 0;
  padding: clamp(10px, 2vw, 16px);
  background:
    linear-gradient(45deg, rgba(20, 99, 255, 0.06) 25%, transparent 25%) 0 0 / 22px 22px,
    #fff;
}

.preview-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 32px;
  margin-bottom: 10px;
  font-weight: 900;
}

.preview-title b {
  color: rgba(24, 23, 22, 0.58);
  font-size: 12px;
}

.preview-card canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: pixelated;
  background: #fff;
}

.zoom-bar {
  display: grid;
  grid-template-columns: 38px 1fr 38px 66px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.zoom-bar input {
  width: 100%;
  accent-color: var(--blue);
}

.icon-btn,
.tiny-btn {
  min-height: 34px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.tiny-btn {
  width: 100%;
  font-size: 13px;
}

.zoom-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-height: 78vh;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.zoom-stage.dragging {
  cursor: grabbing;
}

.zoom-stage canvas {
  transform-origin: top left;
  will-change: transform;
}

.main-preview canvas {
  max-height: none;
}

.small-preview canvas {
  border: 1px solid var(--line);
  image-rendering: auto;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(24, 23, 22, 0.22);
  background: rgba(255, 250, 240, 0.88);
  color: rgba(24, 23, 22, 0.52);
  font-weight: 800;
  pointer-events: none;
}

.empty-state.hidden {
  display: none;
}

.style-list {
  display: grid;
  gap: 10px;
}

.style-option {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 2px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
}

.style-option.active {
  border-color: var(--ink);
  background: #eafff3;
}

.style-swatch {
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 28px clamp(18px, 5vw, 72px);
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.credit-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 3px solid var(--ink);
  background: #fffaf0;
  box-shadow: 10px 10px 0 var(--ink);
}

.credit-dialog::backdrop {
  background: rgba(24, 23, 22, 0.42);
}

.credit-dialog form {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 26px;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.credit-options,
.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.member-box {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
}

.member-box strong {
  font-size: 18px;
}

.member-box span {
  color: rgba(24, 23, 22, 0.66);
  font-size: 13px;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .tool-panel {
    position: static;
  }

  .template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px 26px;
  }

  .pill-btn {
    width: 100%;
  }

  .top-actions {
    width: 100%;
    flex-direction: column;
  }

  .hero {
    min-height: auto;
    overflow: hidden;
  }

  h1 {
    max-width: 100%;
    font-size: 31px;
    line-height: 1.08;
    overflow-wrap: anywhere;
    word-break: break-all;
  }

  .hero-copy {
    min-width: 0;
  }

  .hero-art {
    min-height: 280px;
  }

  .template-grid,
  .metrics,
  .preview-grid,
  .credit-options,
  .amount-grid {
    grid-template-columns: 1fr;
  }

  .button-row,
  .footer {
    flex-direction: column;
  }

  .zoom-bar {
    grid-template-columns: 34px 1fr 34px;
  }

  .tiny-btn {
    grid-column: 1 / -1;
  }
}
