:root {
  --ink: var(--tools-text);
  --muted: var(--tools-muted);
  --paper: var(--tools-bg);
  --surface: var(--tools-surface);
  --surface-soft: var(--tools-surface-soft);
  --line: var(--tools-line);
  --green: var(--tools-green);
  --green-dark: var(--tools-green-strong);
  --green-soft: var(--tools-green-soft);
  --red: var(--tools-red);
  color: var(--ink);
  background: var(--paper);
  font-family: var(--tools-sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 15%, color-mix(in srgb, var(--green) 8%, transparent), transparent 25rem),
    var(--paper);
}
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; }
.visually-hidden {
  position: fixed;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.site-header {
  width: min(1180px, calc(100% - 40px));
  height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid color-mix(in srgb, var(--green) 18%, transparent);
}
.brand, .footer-home {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: .95rem;
  font-weight: 750;
  letter-spacing: -.02em;
  text-decoration: none;
}
.brand img { width: 42px; height: 42px; }

main {
  width: min(1100px, calc(100% - 40px));
  margin: 0 auto;
}
.hero {
  max-width: 860px;
  margin: 86px auto 50px;
  text-align: center;
}
.eyebrow, .step-label {
  margin: 0 0 12px;
  color: var(--green-dark);
  font: 750 .72rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.hero h1 {
  max-width: 900px;
  margin: 0 auto;
  font-family: var(--tools-serif);
  font-size: clamp(2.7rem, 6vw, 4.9rem);
  font-weight: 500;
  line-height: .98;
  letter-spacing: -.055em;
}
.hero-copy {
  max-width: 680px;
  margin: 26px auto 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.14rem);
  line-height: 1.7;
}
.hero-proof {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px 20px;
  margin: 22px 0 0;
  padding: 0;
  color: var(--green-dark);
  font-size: .77rem;
  font-weight: 750;
  list-style: none;
}
.hero-proof li::before { margin-right: 6px; content: "✓"; }

.workspace, .export-panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--tools-shadow);
}
.workspace { min-height: 430px; overflow: hidden; transition: border-color .2s, transform .2s; }
.workspace.is-dragging { border-color: var(--green); transform: scale(1.004); }
.empty-state {
  min-height: 430px;
  padding: clamp(34px, 7vw, 72px);
  display: grid;
  grid-template-columns: minmax(190px, .75fr) minmax(300px, 1.25fr);
  align-items: center;
  gap: clamp(30px, 6vw, 70px);
}
.empty-state > img {
  width: min(100%, 330px);
  height: auto;
  aspect-ratio: 3 / 2;
  justify-self: center;
  object-fit: contain;
}
.empty-state h2, .editor-heading h2, .export-heading h2 {
  margin: 0;
  font-family: var(--tools-serif);
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 500;
  letter-spacing: -.035em;
}
.empty-state p:not(.step-label), .editor-heading p:not(.step-label) {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}
.empty-state .button { margin-top: 24px; }
.empty-state small {
  margin-top: 10px;
  display: block;
  color: var(--muted);
  font-size: .72rem;
}
.empty-state .privacy-note {
  margin-top: 18px !important;
  color: var(--green-dark) !important;
  font-size: .75rem;
}

.button {
  min-height: 44px;
  padding: 0 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface);
  font-weight: 750;
  transition: transform .18s, background .18s, box-shadow .18s;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary {
  min-height: 50px;
  padding-inline: 22px;
  color: white;
  background: var(--green);
  box-shadow: 0 10px 25px color-mix(in srgb, var(--green) 24%, transparent);
}
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-secondary { color: var(--green-dark); border-color: var(--line); background: var(--surface); }
.button-icon, .button-icon svg { width: 19px; height: 19px; display: block; }

.editor { padding: clamp(24px, 5vw, 48px); }
.editor-heading, .export-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.editor-heading > div { max-width: 720px; }
.editor-layout {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 235px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}
.toolbar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 18px;
}
.toolbar fieldset { margin: 0; padding: 0; border: 0; }
.toolbar legend, .range-field > span > strong, .field > span {
  margin-bottom: 9px;
  display: block;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 750;
}
.toolbar fieldset { display: grid; gap: 8px; }
.toolbar legend { width: 100%; }
.toolbar fieldset label {
  min-height: 62px;
  padding: 10px 11px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}
.toolbar fieldset label.selected {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px var(--green);
}
.toolbar fieldset input { position: absolute; opacity: 0; pointer-events: none; }
.mode-swatch {
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.mode-black { border-color: #000; background: #000; }
.mode-white { border-color: #aaa; background: #fff; }
.mode-pixelate {
  background:
    linear-gradient(90deg, #315f37 50%, #b2caa9 0) 0 0 / 12px 12px,
    linear-gradient(#d8e3d3 50%, #688965 0) 0 0 / 12px 12px;
  image-rendering: pixelated;
}
.toolbar label > span:last-child { display: grid; gap: 3px; }
.toolbar label strong { font-size: .8rem; }
.toolbar label small { color: var(--muted); font-size: .65rem; line-height: 1.3; }

.range-field {
  padding: 13px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}
.range-field > span { display: flex; justify-content: space-between; gap: 10px; }
.range-field > span > strong { margin: 0; }
.range-field output { color: var(--green-dark); font-size: .72rem; font-weight: 750; }
.range-field input { width: 100%; accent-color: var(--green); }

.history-actions { display: grid; gap: 7px; }
.history-actions button {
  min-height: 44px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  font-size: .72rem;
}
.history-actions button:hover:not(:disabled) { background: var(--green-soft); }
.history-actions button.danger { color: var(--red); }
.history-actions svg { width: 17px; height: 17px; display: block; }

.canvas-column { min-width: 0; }
.touch-mode {
  margin-bottom: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.touch-mode .button { width: 100%; }
.touch-mode p {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.5;
  text-align: center;
}
.canvas-shell {
  position: relative;
  min-height: 330px;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 28px);
  border-radius: 16px;
  background:
    linear-gradient(45deg, color-mix(in srgb, var(--line) 45%, transparent) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(-45deg, color-mix(in srgb, var(--line) 45%, transparent) 25%, transparent 25%) 0 9px / 18px 18px,
    linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--line) 45%, transparent) 75%) 9px -9px / 18px 18px,
    linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--line) 45%, transparent) 75%) -9px 0 / 18px 18px,
    var(--surface-soft);
}
.canvas-shell canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: min(68vh, 720px);
  display: block;
  background: white;
  box-shadow: 0 12px 32px rgb(0 0 0 / 18%);
  cursor: crosshair;
  touch-action: pan-y pinch-zoom;
  user-select: none;
}
.canvas-shell canvas.is-touch-drawing { touch-action: none; }
.canvas-shell canvas:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 70%, white);
  outline-offset: 4px;
}
.canvas-meta {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: .72rem;
}
.canvas-meta strong { color: var(--green-dark); }
.canvas-hint { margin: 7px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.5; }

.drop-overlay {
  position: absolute;
  z-index: 20;
  inset: 10px;
  display: grid;
  place-content: center;
  gap: 12px;
  color: var(--green-dark);
  text-align: center;
  border: 2px dashed var(--green);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}
.drop-icon, .drop-icon svg { width: 42px; height: 42px; display: block; margin: auto; }

.export-panel { margin-top: 24px; padding: clamp(26px, 5vw, 50px); }
.export-heading { align-items: center; }
.local-note {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green-dark);
  font-size: .73rem;
  font-weight: 750;
}
.local-note svg { width: 18px; height: 18px; }
.export-grid {
  margin-top: 30px;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
}
.field { display: grid; gap: 8px; }
.field > span { margin: 0; }
.field input, .field select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.assurance {
  margin-top: 24px;
  padding: 17px;
  display: flex;
  gap: 13px;
  color: var(--green-dark);
  border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line));
  border-radius: 12px;
  background: var(--green-soft);
}
.assurance > span, .assurance svg { width: 24px; height: 24px; flex: 0 0 auto; display: block; }
.assurance strong { font-size: .84rem; }
.assurance p { margin: 5px 0 0; font-size: .75rem; line-height: 1.55; }
.pixel-warning {
  margin: 12px 0 0;
  padding-left: 14px;
  color: var(--muted);
  border-left: 3px solid var(--green);
  font-size: .73rem;
  line-height: 1.55;
}
.message {
  margin-top: 18px;
  padding: 14px 16px;
  display: flex;
  gap: 9px;
  border-radius: 10px;
  font-size: .78rem;
}
.message-error { color: color-mix(in srgb, var(--red) 88%, var(--ink)); border: 1px solid color-mix(in srgb, var(--red) 40%, var(--line)); background: color-mix(in srgb, var(--red) 8%, var(--surface)); }
.message-success { color: var(--green-dark); border: 1px solid color-mix(in srgb, var(--green) 32%, var(--line)); background: var(--green-soft); }
.export-footer {
  margin-top: 27px;
  padding-top: 23px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  border-top: 1px solid var(--line);
}
.export-footer p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.55;
}
.export-button { min-height: 54px; }

.trust-row {
  margin: 68px 0 76px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
}
.trust-row article { display: flex; gap: 16px; }
.trust-number { color: var(--green-dark); font: 700 .67rem/1.5 ui-monospace, monospace; }
.trust-row strong { font-family: var(--tools-serif); font-size: 1.05rem; font-weight: 500; }
.trust-row p { margin: 6px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.55; }

footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 25px 0 35px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: .7rem;
}
.footer-home img { width: 30px; height: 30px; }
.toast {
  position: fixed;
  z-index: 120;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100% - 32px));
  padding: 13px 16px;
  color: white;
  border-radius: 10px;
  background: var(--green-dark);
  box-shadow: var(--tools-shadow);
  font-size: .78rem;
  font-weight: 700;
}
:focus-visible { outline: 3px solid color-mix(in srgb, var(--green) 65%, white); outline-offset: 3px; }

@media (max-width: 820px) {
  .editor-layout { grid-template-columns: 1fr; }
  .toolbar { position: static; }
  .toolbar fieldset { grid-template-columns: repeat(3, 1fr); }
  .toolbar legend { grid-column: 1 / -1; }
  .history-actions { grid-template-columns: repeat(3, 1fr); }
  .history-actions button { justify-content: center; text-align: center; }
  .canvas-shell { min-height: 260px; }
}

@media (max-width: 620px) {
  .site-header, main, footer { width: min(100% - 28px, 1100px); }
  .site-header { height: 68px; }
  .brand span { display: none; }
  .hero { margin: 58px auto 38px; }
  .hero h1 { font-size: clamp(2.45rem, 13vw, 3.7rem); }
  .empty-state { min-height: 0; grid-template-columns: 1fr; padding: 30px 22px; text-align: center; }
  .empty-state > img { width: min(66%, 250px); }
  .empty-state .button { width: 100%; }
  .editor { padding: 22px 16px; }
  .editor-heading, .export-heading { align-items: flex-start; flex-direction: column; }
  .editor-heading .button { width: 100%; }
  .toolbar fieldset { grid-template-columns: 1fr; }
  .toolbar legend { grid-column: auto; }
  .toolbar fieldset label { min-height: 58px; }
  .history-actions { grid-template-columns: 1fr; }
  .history-actions button { justify-content: flex-start; text-align: left; }
  .canvas-shell { min-height: 210px; padding: 10px; }
  .export-panel { padding: 24px 18px; }
  .export-grid { grid-template-columns: 1fr; }
  .local-note { align-self: flex-start; }
  .export-footer { align-items: stretch; flex-direction: column; }
  .export-button { width: 100%; }
  .trust-row { grid-template-columns: 1fr; gap: 22px; margin: 48px 0 56px; }
  footer { align-items: flex-start; flex-direction: column; }
  .footer-home span { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto; transition-duration: .01ms; animation-duration: .01ms; }
}
