@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/plus-jakarta-sans.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f6f6f6;
  --panel: #ffffff;
  --line: #e7e7e7;
  --line-2: #d9d9d9;
  --ink: #111111;
  --ink-2: #444444;
  --mute: #8a8a8a;
  --soft: #f2f2f2;
  --good: #1f8a4c;
  --warn: #b7791f;
  --bad: #c53030;
  --r: 10px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 500 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Header */
.top {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }

/* Layout */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  min-height: calc(100vh - 52px);
}
.stage {
  display: flex;
  justify-content: center;
  padding: 32px 24px;
}
.stage-inner {
  width: 100%;
  max-width: 440px;
  position: sticky;
  top: 84px;
  align-self: flex-start;
}
.panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 16px 18px 28px;
  height: calc(100vh - 52px);
  overflow-y: auto;
  position: sticky;
  top: 52px;
}

/* Preview */
.canvas-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.canvas-wrap.checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ececec 25%, transparent 25%),
    linear-gradient(-45deg, #ececec 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ececec 75%),
    linear-gradient(-45deg, transparent 75%, #ececec 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
#preview { display: block; width: 100%; height: auto; }
.canvas-wrap.empty #preview { opacity: 0.12; }
.placeholder {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--ink-2);
}
.canvas-wrap.empty .placeholder { display: flex; }

.badge {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-weight: 600;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.badge[data-state="good"] .dot { background: var(--good); }
.badge[data-state="warn"] .dot { background: var(--warn); }
.badge[data-state="bad"] .dot { background: var(--bad); }
.badge[data-state="checking"] .dot { animation: pulse 0.8s ease-in-out infinite alternate; background: var(--mute); }
@keyframes pulse { to { opacity: 0.25; } }
.tip { margin: 8px 2px 0; color: var(--ink-2); min-height: 0; }
.tip:empty { display: none; }

.export { margin-top: 18px; }
.export-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.export-row .primary { flex: 1; }
.mini { display: flex; align-items: center; gap: 6px; color: var(--mute); font-weight: 600; }
.mini select { width: auto; padding: 8px 8px; }
.meta { margin: 12px 2px 0; color: var(--mute); font-size: 12px; }
.payload {
  margin: 4px 2px 0;
  color: var(--mute);
  font: 500 11.5px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  word-break: break-all;
  max-height: 3.2em;
  overflow: hidden;
}

/* Buttons */
.btn {
  border: 1px solid var(--line-2);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #2a2a2a; }
.btn.ghost { border-color: transparent; color: var(--ink-2); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn {
  border: 1px solid var(--line-2);
  background: var(--panel);
  border-radius: 7px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 13px;
}
.icon-btn:hover { background: var(--soft); }

/* Inputs */
input[type="text"], input[type="email"], input[type="tel"], textarea, select {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 9px 11px;
  background: var(--panel);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, textarea:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06); }
textarea { resize: vertical; }
input.big { padding: 12px 13px; font-size: 14px; }
.stack { display: grid; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }

/* Blocks */
.block { padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.block + .block { padding-top: 14px; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
h2 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--mute); font-weight: 700; }

.sec { border-bottom: 1px solid var(--line); }
.sec > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 0;
  font-weight: 700;
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after { content: "+"; color: var(--mute); font-weight: 500; font-size: 16px; }
.sec[open] > summary::after { content: "−"; }
.sec[open] { padding-bottom: 14px; }
.sec > *:not(summary) + *:not(summary) { margin-top: 10px; }

.label { margin: 0; color: var(--mute); font-weight: 600; font-size: 12px; }
.hint { margin: 0; color: var(--mute); font-size: 12px; }
.foot { color: var(--mute); font-size: 12px; margin: 18px 0 0; }

/* Segmented */
.seg {
  display: flex;
  background: var(--soft);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  border-radius: 6px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.tabs { margin-bottom: 10px; }
.tabs button { padding: 7px 4px; }

/* Field rows */
.field { display: grid; grid-template-columns: 104px 1fr auto; align-items: center; gap: 10px; }
.field > span { color: var(--ink-2); font-weight: 600; }
.field > .seg, .field > .colors { grid-column: 2 / 4; }
.field output { min-width: 40px; text-align: right; color: var(--mute); font-variant-numeric: tabular-nums; font-size: 12px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--line);
  border-radius: 4px;
  outline: none;
  margin: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--ink);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--ink);
  cursor: pointer;
}

.check { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--ink); margin: 0; }

/* Colours */
.colors { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.color {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 3px 4px 3px 3px;
  width: 124px;
}
.color input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  border: 0;
  padding: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  flex: none;
}
.color input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(0, 0, 0, 0.12); border-radius: 6px; }
.color .hex {
  border: 0;
  padding: 4px 2px;
  font: 500 12px ui-monospace, "Cascadia Mono", Consolas, monospace;
  text-transform: uppercase;
  box-shadow: none !important;
}

/* Shape pickers */
.shapes { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.shapes[data-icons="outer"], .shapes[data-icons="inner"] { grid-template-columns: repeat(9, 1fr); gap: 5px; }
.shapes[data-icons="outer"] button, .shapes[data-icons="inner"] button { padding: 5px; }
.shapes button {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shapes button:hover { border-color: var(--line-2); background: var(--soft); }
.shapes button.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.shapes svg { width: 100%; height: 100%; display: block; }

/* Designs */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chips button {
  flex: none;
  border: 1px solid var(--line-2);
  background: var(--panel);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.chips button:hover { border-color: var(--ink); color: var(--ink); }
.chips button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.presets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; max-height: 372px; overflow-y: auto; padding: 1px; margin: -1px; }
.presets button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  padding: 6px 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  min-width: 0;
}
.presets button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presets button:hover { border-color: var(--ink); }
.presets canvas { width: 100%; aspect-ratio: 1; display: block; }
.check.keep { margin-top: 12px; font-size: 12.5px; }
.sw-label { margin: 12px 0 8px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.sw {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  padding: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.sw i { display: block; width: 100%; height: 100%; border-radius: 50%; }
.sw:hover { border-color: var(--ink); }
.sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--ink); }
.sw.clear { background-image: linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%), linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%) !important; background-size: 8px 8px; background-position: 0 0, 4px 4px; }
.sw.orig { width: auto; border-radius: 999px; padding: 4px 10px 4px 4px; gap: 6px; }
.sw.orig i { width: 20px; height: 20px; flex: none; }
.sw.orig span { font-size: 11.5px; font-weight: 700; color: var(--ink-2); background: var(--panel); border-radius: 999px; padding: 1px 6px; }

/* Convert */
.cdrop { padding: 12px 14px; }
.cdrop .cicon { width: 26px; height: 26px; flex: none; color: var(--ink); }
.cdrop.busy { pointer-events: none; border-style: solid; }
.cdrop.busy .cicon { animation: pulse 0.7s ease-in-out infinite alternate; }
.convert .hint { margin-top: 8px; }
.convert .hint.err { color: var(--bad); }
.conv {
  margin-top: 10px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px;
  background: var(--soft);
}
.conv-before { margin: 0; flex: none; text-align: center; }
.conv-before img { display: block; width: 72px; height: 72px; border-radius: 8px; background: #fff; border: 1px solid var(--line); object-fit: contain; }
.conv-before figcaption { margin-top: 4px; font-size: 11px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; }
.conv-info { min-width: 0; flex: 1; }
.conv-kind { font-size: 11px; font-weight: 700; color: var(--good); text-transform: uppercase; letter-spacing: 0.05em; }
.conv-text {
  margin: 3px 0 8px;
  font: 500 12px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: var(--ink);
  word-break: break-all;
  max-height: 4.2em;
  overflow: hidden;
}
.conv-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.conv-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.conv-sw { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-2); display: inline-block; }
.drophint {
  position: absolute;
  inset: 10px;
  border: 2px dashed var(--ink);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  font-weight: 700;
  font-size: 15px;
  pointer-events: none;
}
body.dragging .drophint { display: flex; }

/* Logo pickers */
.sub > * + * { margin-top: 10px; }
.stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; }
.stickers button, .mine-item {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stickers button:hover, .mine-item:hover { border-color: var(--line-2); background: var(--soft); }
.stickers button.on, .mine-item.on, .brands button.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.stickers canvas, .stickers svg { width: 100%; height: 100%; display: block; }
.brands { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 5px; }
.brands button {
  height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.brands button:hover { border-color: var(--line-2); }
.brands img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }
.mine-item { position: relative; padding: 0; }
.mine-use { border: 0; background: none; padding: 5px; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.mine-use img { max-width: 100%; max-height: 100%; display: block; }
.mine-x {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--panel);
  font-size: 9px;
  line-height: 1;
  padding: 0;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mine-x:hover { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Dropzones */
.drop {
  position: relative;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: var(--ink-2);
  transition: border-color 0.12s, background 0.12s;
}
.drop:hover, .drop.over { border-color: var(--ink); background: var(--soft); }
.drop-thumb { display: none; width: 44px; height: 44px; object-fit: contain; border-radius: 6px; background: var(--soft); }
.drop.has .drop-thumb { display: block; }
.drop-x { display: none; margin-left: auto; }
.drop.has .drop-x { display: inline-flex; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

[hidden] { display: none !important; }

/* Mobile */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .stage-inner, .panel { min-width: 0; }
  .tabs button { padding: 7px 2px; font-size: 12px; }
  .stage { padding: 16px; }
  .stage-inner { position: static; max-width: 420px; }
  .panel { height: auto; position: static; border-left: 0; border-top: 1px solid var(--line); padding: 16px; }
  .top { padding: 0 16px; }
  .shapes { grid-template-columns: repeat(7, 1fr); }
  .presets { grid-template-columns: repeat(4, 1fr); max-height: 440px; }
  .top-actions .btn { padding: 7px 10px; }
  .field { grid-template-columns: 92px 1fr auto; }
}
