/* Unlimited SVG: a design-tool pasteboard. The artboard and its selection handles are the one bold element. */
:root {
  --pasteboard: #eef1f5;
  --artboard: #ffffff;
  --ink: #18202e;
  --muted: #5a6577;
  --line: #c9d1dd;
  --path: #2f6bff;
  --path-dark: #1f4fd1;
  --price: #ffc93c;
  --danger: #c2372b;

  --font: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: 1.5rem;
  --step-4: clamp(2.4rem, 4.4vw, 3.5rem);
  --handle: 9px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--pasteboard);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.5;
}
a { color: var(--path-dark); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--path); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  font-size: var(--step-1);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand-mark { width: 28px; height: 28px; color: var(--path); }
.account { display: flex; align-items: center; gap: 18px; font-size: var(--step--1); }
.account-email { color: var(--muted); }
.link-button {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
}
.link-button:hover { text-decoration-color: var(--path); }

/* ---------- layout ---------- */
.pasteboard {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 72px;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  column-gap: 72px;
  row-gap: 72px;
  align-items: start;
}
.history { grid-column: 1 / -1; }

/* ---------- intro ---------- */
.intro { padding-top: 40px; }
h1 {
  font-size: var(--step-4);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: 0 0 20px;
  max-width: 12ch;
}
.lede { font-size: var(--step-1); line-height: 1.45; color: var(--muted); margin: 0 0 32px; max-width: 34ch; }

.mode { border: 0; padding: 0; margin: 0 0 28px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode legend { font-weight: 600; margin-bottom: 10px; padding: 0; }
.mode label { position: relative; display: block; cursor: pointer; }
.mode input { position: absolute; opacity: 0; }
.mode span {
  display: block;
  height: 100%;
  padding: 12px 14px;
  background: var(--artboard);
  border: 1px solid var(--line);
  font-size: var(--step--1);
  color: var(--muted);
  line-height: 1.35;
}
.mode strong { display: block; color: var(--ink); font-size: var(--step-0); margin-bottom: 2px; }
.mode input:checked + span { border-color: var(--path); box-shadow: inset 0 0 0 1px var(--path); }
.mode input:focus-visible + span { outline: 2px solid var(--path); outline-offset: 3px; }

.price-note { margin: 0; max-width: 38ch; color: var(--muted); }
mark { background: var(--price); color: var(--ink); font-weight: 700; padding: 0 4px; }

/* ---------- artboard (the signature element) ---------- */
.workspace { padding: 12px; }
.artboard {
  position: relative;
  aspect-ratio: 1;
  background: var(--artboard);
  outline: 1.5px solid var(--path);
}
.handle {
  position: absolute;
  width: var(--handle);
  height: var(--handle);
  background: var(--artboard);
  border: 1.5px solid var(--path);
  z-index: 2;
  pointer-events: none;
}
.h-nw { top: calc(var(--handle) / -2); left: calc(var(--handle) / -2); }
.h-n  { top: calc(var(--handle) / -2); left: calc(50% - var(--handle) / 2); }
.h-ne { top: calc(var(--handle) / -2); right: calc(var(--handle) / -2); }
.h-w  { top: calc(50% - var(--handle) / 2); left: calc(var(--handle) / -2); }
.h-e  { top: calc(50% - var(--handle) / 2); right: calc(var(--handle) / -2); }
.h-sw { bottom: calc(var(--handle) / -2); left: calc(var(--handle) / -2); }
.h-s  { bottom: calc(var(--handle) / -2); left: calc(50% - var(--handle) / 2); }
.h-se { bottom: calc(var(--handle) / -2); right: calc(var(--handle) / -2); }

/* Marching ants while the model is drawing. */
.ants {
  position: absolute;
  top: -1.5px;
  left: -1.5px;
  width: calc(100% + 3px);
  height: calc(100% + 3px);
  overflow: visible;
  pointer-events: none;
  opacity: 0;
}
.ants rect {
  x: 0.75px;
  y: 0.75px;
  width: calc(100% - 1.5px);
  height: calc(100% - 1.5px);
  fill: none;
  stroke: var(--path);
  stroke-width: 1.5;
  stroke-dasharray: 6 6;
}
.artboard[data-state="working"] { outline-color: transparent; }
.artboard[data-state="working"] .ants { opacity: 1; }
.artboard[data-state="working"] .ants rect { animation: ants 0.9s linear infinite; }
@keyframes ants { to { stroke-dashoffset: -12; } }

.drop {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
}
.drop-title { font-size: var(--step-2); font-weight: 600; letter-spacing: -0.01em; }
.drop-sub { color: var(--muted); max-width: 32ch; font-size: var(--step--1); }
.drop:hover .drop-title, .artboard.dragging .drop-title { color: var(--path); }
.artboard.dragging { background: #f5f8ff; }

.working, .failed {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 32px;
}
.working-title, .failed-title { font-size: var(--step-2); font-weight: 600; margin: 0 0 6px; letter-spacing: -0.01em; }
.working-sub, .failed-sub { margin: 0 0 18px; color: var(--muted); max-width: 36ch; font-variant-numeric: tabular-nums; }

.preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- action bar ---------- */
.actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 22px;
}
.action-status { margin: 0; color: var(--muted); font-size: var(--step--1); }
.action-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.button {
  border: 1px solid transparent;
  padding: 12px 20px;
  font-weight: 600;
  line-height: 1.2;
}
.button:disabled { opacity: 0.55; cursor: progress; }
.button.primary { background: var(--path); color: #fff; }
.button.primary:hover:not(:disabled) { background: var(--path-dark); }
.button.secondary { background: var(--artboard); color: var(--ink); border-color: var(--line); }
.button.secondary:hover:not(:disabled) { border-color: var(--ink); }
.button.buy { background: var(--price); color: var(--ink); border-color: #e3ad1f; }
.button.buy:hover:not(:disabled) { background: #ffbf1a; }

/* ---------- history ---------- */
.history h2 { font-size: var(--step-2); letter-spacing: -0.01em; margin: 0 0 20px; }
.history-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 28px 22px;
}
.history-item button {
  display: block;
  width: 100%;
  padding: 0;
  background: none;
  border: 0;
  text-align: left;
  color: inherit;
}
.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: var(--artboard);
  outline: 1px solid var(--line);
}
.history-item button:hover .thumb, .history-item.active .thumb { outline: 1.5px solid var(--path); }
.thumb-placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: var(--step--1); }
.history-name { display: block; margin-top: 10px; font-size: var(--step--1); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-meta { display: block; font-size: var(--step--1); color: var(--muted); }
.history-meta.owned { color: var(--path-dark); }

/* ---------- footer ---------- */
.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 24px 48px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: var(--step--1);
  border-top: 1px solid var(--line);
}
.footer p { margin: 0; }

/* ---------- dialogs ---------- */
.dialog {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line);
  padding: 28px;
  color: var(--ink);
  background: var(--artboard);
}
.dialog::backdrop { background: rgba(24, 32, 46, 0.45); }
.dialog h2 { margin: 0 0 6px; font-size: var(--step-2); letter-spacing: -0.01em; padding-right: 28px; }
.dialog-sub { margin: 0 0 18px; color: var(--muted); }
.dialog-close-form { position: absolute; top: 12px; right: 12px; margin: 0; }
.close { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); padding: 4px 8px; }
.close:hover { color: var(--ink); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack .button { width: 100%; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: var(--step--1); }
.field input {
  font: inherit;
  font-size: var(--step-0);
  font-weight: 400;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--artboard);
  color: var(--ink);
}
.field input:focus { border-color: var(--path); outline: 1px solid var(--path); outline-offset: 0; }
#code-input { font-size: var(--step-2); letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.form-error { margin: 0; color: var(--danger); font-size: var(--step--1); min-height: 1.2em; }
.form-error:empty { display: none; }
.fineprint { margin: 14px 0 0; font-size: var(--step--1); color: var(--muted); }

.offers { list-style: none; margin: 0 0 4px; padding: 0; border-top: 1px solid var(--line); }
.offers li { border-bottom: 1px solid var(--line); }
.offer {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 16px;
  padding: 14px 4px;
  background: none;
  border: 0;
  text-align: left;
  color: var(--ink);
}
.offer:hover:not(:disabled), .offer:focus-visible { background: #f5f8ff; }
.offer:disabled { opacity: 0.45; cursor: not-allowed; }
.offer-name { font-weight: 600; }
.offer-detail { grid-column: 1; color: var(--muted); font-size: var(--step--1); }
.offer-price { grid-column: 2; grid-row: 1 / span 2; font-size: var(--step-1); font-weight: 700; font-variant-numeric: tabular-nums; }
.offer.featured .offer-price { background: var(--price); padding: 2px 8px; }

/* ---------- responsive ---------- */
.brand, .link-button, .button { white-space: nowrap; }

@media (max-width: 880px) {
  /* Single column: headline, mode, then the artboard straight away; pricing follows it. */
  .pasteboard { grid-template-columns: minmax(0, 1fr); row-gap: 0; padding-top: 8px; }
  .intro { display: contents; }
  h1 { max-width: 16ch; margin-top: 8px; }
  .lede { margin-bottom: 24px; }
  .mode { margin-bottom: 20px; }
  .workspace { order: 1; margin: 0 -12px; }
  .price-note { order: 2; margin-top: 20px; }
  .history { order: 3; margin-top: 56px; }
}
@media (max-width: 480px) {
  .topbar { padding: 16px; }
  .footer { padding-left: 16px; padding-right: 16px; }
  .pasteboard { padding-left: 16px; padding-right: 16px; }
  .brand { font-size: var(--step-0); }
  .account { gap: 14px; }
  .account-email { display: none !important; }
  .lede { font-size: var(--step-0); }
  .mode span { padding: 10px 12px; }
  .actionbar { flex-direction: column; align-items: stretch; }
  .action-buttons { flex-direction: column-reverse; }
  .action-buttons .button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .artboard[data-state="working"] .ants rect { animation: none; }
}
