:root {
  --bg: #f4f1eb;
  --panel: #fffdf8;
  --ink: #171717;
  --muted: #6a6259;
  --line: #ddd5ca;
  --accent: #ff2b78;
  --teal: #1ec4b6;
  --yellow: #ffd34d;
  --shadow: 0 18px 48px rgba(39, 32, 23, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.control-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 24px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

.brand-row,
.preview-header,
.frame-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.loading {
  border-color: var(--yellow);
  color: #7a5d00;
}

.status-pill.ready {
  border-color: var(--teal);
  color: #08796f;
}

.status-pill.error {
  border-color: var(--accent);
  color: #9d1345;
}

.generator-form {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
button {
  width: 100%;
  min-height: 46px;
  border-radius: 8px;
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
}

.field-hint {
  margin: -4px 0 4px;
  font-size: 12px;
  color: var(--muted);
  min-height: 1em;
}
.field-hint:empty {
  display: none;
}

.photo-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 4px 0 10px;
}
.photo-thumb {
  position: relative;
  width: 96px;
  height: 96px;
}
.photo-thumb img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line, #ddd5ca);
}
.photo-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid var(--card, #fff);
  border-radius: 50%;
  background: var(--ink, #171717);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-add {
  width: 96px;
  height: 96px;
  border: 2px dashed var(--line, #ddd5ca);
  border-radius: 14px;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted, #8a8378);
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.photo-add:hover {
  border-color: var(--teal, #1ec4b6);
  background: rgba(30, 196, 182, 0.05);
}
.photo-add-plus {
  font-size: 26px;
  line-height: 1;
}

.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
}

.swatches legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.swatches label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  cursor: pointer;
}

.swatches input {
  width: 16px;
  min-height: 16px;
}

.swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 50%;
}

.black {
  background: #181818;
}

.white {
  background: #fbfbf8;
}

.cream {
  background: #e8dabe;
}

.pink {
  background: #eb4080;
}

.primary-action {
  border: 0;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.secondary-action {
  border: 1px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.primary-action:disabled,
.secondary-action:disabled {
  cursor: wait;
  opacity: 0.62;
}

.integration-panel {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.printify-mockups {
  display: grid;
  gap: 12px;
  margin-top: 8px;
}

.preview-header.compact h2 {
  font-size: 20px;
}

.mockup-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ebe5dc;
}

.mockup-grid .empty-state {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
}

.mockup-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.mockup-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.mockup-card p {
  margin: 0;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.integration-result {
  min-height: 42px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  word-break: break-word;
}

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

.preview-frame {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr);
  gap: 12px;
  min-width: 0;
}

.frame-title span {
  font-weight: 900;
}

.frame-title small,
.job-id {
  color: var(--muted);
  font-size: 13px;
}

.image-stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 7 / 5;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ebe5dc;
}

.image-stage img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.image-stage.has-image img {
  display: block;
}

.image-stage.has-image .empty-state {
  display: none;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.asset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.asset-row a {
  color: var(--ink);
  font-weight: 800;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 12px;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .mockup-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }
}

/* Wizard */
.stepbar {
  display: flex;
  gap: 6px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.stepbar li {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.stepbar li.active {
  border-color: var(--ink);
  color: var(--ink);
}

.stepbar li.done {
  border-color: var(--teal);
  color: #08796f;
}

.wizard-step {
  margin-top: 20px;
}

.wizard-step[hidden] {
  display: none;
}

.step-title {
  margin: 0 0 14px;
  font-size: 18px;
}

.product-cards {
  display: grid;
  gap: 12px;
}

.product-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  min-height: auto;
  padding: 18px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.product-card.selected {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.product-name {
  font-size: 15px;
  font-weight: 800;
}

.product-sub {
  color: var(--muted);
  font-size: 12px;
}

.product-art {
  display: block;
  margin-bottom: 4px;
}

.product-art.tee {
  width: 64px;
  height: 70px;
  background: #181818;
  border-radius: 12px 12px 8px 8px;
}

.product-art.dog {
  width: 78px;
  height: 54px;
  background: #1ec4b6;
  border-radius: 10px;
}

.product-art.both {
  width: 92px;
  height: 54px;
  background: linear-gradient(90deg, #181818 0 46%, transparent 46% 54%, #1ec4b6 54% 100%);
  border-radius: 10px;
}

.select-group {
  margin-bottom: 18px;
}

.group-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.size-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
}

.size-cell {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}

.size-cell.selected {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.color-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-chip {
  width: auto;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.color-chip.selected {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.wizard-nav {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}

.wizard-nav button {
  width: auto;
  flex: 1;
}

.preview-frame[hidden] {
  display: none;
}

/* Color swatches (Amazon-style, real mockup thumbnails) */
.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.swatch-row[hidden] {
  display: none;
}

.mockup-swatch {
  width: 56px;
  min-height: 0;
  height: 56px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.mockup-swatch img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mockup-swatch.selected {
  border-color: var(--ink);
}

/* ---- Mode tabs (rubric switch) + logo try-on ---- */
.mode-tabs {
  display: flex;
  gap: 8px;
  margin: 4px 0 18px;
}

.mode-tab {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.mode-tab.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.logo-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.logo-swatch {
  width: 112px;
  height: 66px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  /* light half shows dark logos, dark half shows the white variant */
  background: linear-gradient(135deg, #efeae1 0 50%, #1f1f1f 50% 100%);
}

.logo-swatch img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-swatch.selected {
  border-color: var(--teal);
}
