:root {
  --paper: #ede6d6;
  --paper-dark: #e2d9c4;
  --card: #f7f3e8;
  --ink: #242320;
  --ink-soft: #55524a;
  --indigo: #2e3a6e;
  --indigo-dark: #202a52;
  --mustard: #d9a441;
  --rust: #b8481f;
  --line: rgba(36, 35, 32, 0.18);
  --shadow: rgba(36, 35, 32, 0.22);
  --radius-card: 6px;
  --focus: 3px solid var(--rust);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(rgba(36,35,32,0.05) 1px, transparent 1px);
  background-size: 4px 4px;
  color: var(--ink);
  font-family: 'Work Sans', sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 28px;
}

a { color: var(--indigo); }

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

button, input {
  font-family: inherit;
}

/* ---------- Header ---------- */
.site-head {
  padding: 48px 0 32px;
  border-bottom: 3px solid var(--ink);
}

.site-head__inner {
  display: flex;
  align-items: flex-start;
  gap: 32px;
}

.stamp {
  flex: 0 0 auto;
  width: 96px;
  height: 96px;
  transform: rotate(-8deg);
}
.stamp svg { width: 100%; height: 100%; }
.stamp circle {
  fill: none;
  stroke: var(--rust);
  stroke-width: 3;
}
.stamp text {
  font-family: 'Anton', sans-serif;
  font-size: 13px;
  fill: var(--rust);
  letter-spacing: 0.5px;
}

.site-title {
  font-family: 'Anton', sans-serif;
  font-weight: 400;
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  line-height: 0.92;
  margin: 0 0 14px;
  color: var(--ink);
}

.site-sub {
  max-width: 46ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 32px;
  padding-top: 40px;
  align-items: start;
}

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

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 26px;
  box-shadow: 0 6px 0 var(--shadow);
}

.mockup-panel { position: sticky; top: 20px; }
@media (max-width: 880px) { .mockup-panel { position: static; } }

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.panel__head h2 {
  font-family: 'Anton', sans-serif;
  font-weight: 400;
  font-size: 1.6rem;
  margin: 0;
}

/* ---------- Buttons ---------- */
.btn {
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 3px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.btn:hover { transform: translateY(-1px); }
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
  .btn:hover { transform: none; }
}

.btn--ghost:hover { background: var(--ink); color: var(--paper); }

.btn--primary {
  width: 100%;
  background: var(--indigo);
  border-color: var(--indigo);
  color: var(--paper);
  padding: 14px 18px;
  font-size: 1.02rem;
}
.btn--primary:hover { background: var(--indigo-dark); border-color: var(--indigo-dark); }

.btn--small {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-width: 1.5px;
}

.btn--danger { border-color: var(--rust); color: var(--rust); }
.btn--danger:hover { background: var(--rust); color: var(--paper); }

/* ---------- Dropzone & gallery ---------- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 4px;
  padding: 22px;
  text-align: center;
  color: var(--ink-soft);
  margin-bottom: 22px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone.is-active {
  border-color: var(--indigo);
  background: rgba(46, 58, 110, 0.06);
}
.dropzone p { margin: 0; font-size: 0.95rem; }

.corkboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 20px 16px;
}

.empty-msg { color: var(--ink-soft); grid-column: 1 / -1; }

.drawing-card {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 8px;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 3px 0 var(--shadow);
}
.drawing-card:nth-child(3n+1) { transform: rotate(-2deg); }
.drawing-card:nth-child(3n+2) { transform: rotate(1.5deg); }
.drawing-card:nth-child(3n+3) { transform: rotate(-1deg); }
.drawing-card:hover { transform: rotate(0deg) translateY(-2px); }
.drawing-card.is-selected {
  outline: 3px solid var(--indigo);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .drawing-card, .drawing-card:hover { transition: none; transform: none !important; }
}

.drawing-card__pin {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--rust);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.drawing-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  display: block;
  background: #fff;
}

.drawing-card__name {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
  text-transform: capitalize;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawing-card__del {
  position: absolute;
  top: 4px;
  right: 4px;
  border: none;
  background: rgba(36,35,32,0.75);
  color: var(--paper);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  line-height: 1;
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0;
}
.drawing-card:hover .drawing-card__del,
.drawing-card__del:focus-visible { opacity: 1; }

/* ---------- Mockup stage ---------- */
.mockup-stage {
  text-align: center;
  margin-bottom: 22px;
}

.shirt-holder {
  max-width: 320px;
  margin: 0 auto;
  user-select: none;
  touch-action: none;
}
.shirt-holder svg { width: 100%; height: auto; display: block; }

.shirt-holder svg image {
  -webkit-user-drag: none;
  user-drag: none;
}

.mockup-hint {
  margin: 10px 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.controls { display: flex; flex-direction: column; gap: 20px; }

.control-block { display: flex; flex-direction: column; gap: 10px; }
.control-row { flex-direction: row; gap: 20px; }
.control-row .slider-field { flex: 1; }

.control-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.type-toggle {
  display: inline-flex;
  border: 2px solid var(--ink);
  border-radius: 3px;
  overflow: hidden;
  width: fit-content;
}

.toggle-btn {
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 9px 22px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
}
.toggle-btn + .toggle-btn { border-left: 2px solid var(--ink); }
.toggle-btn.is-active { background: var(--ink); color: var(--paper); }
.toggle-btn:hover:not(.is-active) { background: rgba(36,35,32,0.08); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }

.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
}
.swatch.is-active {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

.custom-color {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.custom-color input { width: 40px; height: 30px; border: none; background: none; cursor: pointer; }

.slider-field, .text-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.text-field input, .text-field select, .slider-field input[type="range"] {
  font-weight: 400;
}

.text-field input, .text-field select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.95rem;
}

input[type="range"] { accent-color: var(--indigo); }

.save-status {
  min-height: 1.2em;
  font-size: 0.88rem;
  margin: 0;
}
.save-status.ok { color: var(--indigo); }
.save-status.err { color: var(--rust); }

/* ---------- Saved designs ---------- */
.saved-section { padding-top: 44px; padding-bottom: 60px; }

.saved-lookup {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 22px;
  max-width: 420px;
}
.saved-lookup .text-field { flex: 1; }

.saved-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.saved-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px;
  box-shadow: 0 4px 0 var(--shadow);
}
.saved-card svg { width: 100%; height: auto; display: block; margin-bottom: 10px; }

.saved-card__name {
  font-weight: 700;
  margin: 0 0 2px;
}
.saved-card__meta {
  margin: 0 0 10px;
  font-size: 0.8rem;
  color: var(--ink-soft);
}
.saved-card__actions {
  display: flex;
  gap: 8px;
}

.saved-empty {
  color: var(--ink-soft);
  grid-column: 1 / -1;
}

/* ---------- Footer ---------- */
.site-foot {
  border-top: 1px solid var(--line);
  padding: 22px 0 40px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.site-foot__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.signature {
  height: 34px;
  width: auto;
  opacity: 0.85;
}
