:root {
  --bg: #f7f4ef;
  --surface: #ffffff;
  --surface-soft: #eef8f6;
  --ink: #171411;
  --muted: #645f58;
  --line: #ded8cf;
  --accent: #e55f32;
  --accent-dark: #bb431d;
  --teal: #0b7375;
  --green: #317345;
  --shadow: 0 18px 42px rgba(23, 20, 17, 0.12);
}

* {
  box-sizing: border-box;
}

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

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
}

.page-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 44px;
}

.topbar,
.brand,
.topbar-actions,
.builder-panel,
.target-control,
.pill-row,
.flyer-details,
.qr-block,
.flyer-footer {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 900;
  text-decoration: none;
}

.brand img,
.flyer-footer img {
  border-radius: 8px;
}

.topbar-actions {
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.button,
.target-button {
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
}

.button--primary {
  background: var(--accent);
  color: #fff;
}

.button--primary:hover,
.button--primary:focus-visible {
  background: var(--accent-dark);
}

.button--ghost,
.target-button {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.builder-panel {
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(23, 20, 17, 0.08);
}

.target-control {
  flex-wrap: wrap;
  gap: 8px;
}

.target-button.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
}

.panel-copy {
  max-width: 620px;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.status-panel {
  display: grid;
  place-items: center;
  gap: 14px;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

.loader {
  width: 42px;
  height: 42px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.flyer-sheet {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 0;
  overflow: hidden;
  width: min(960px, 100%);
  min-height: 620px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flyer-photo {
  position: relative;
  min-height: 620px;
  background: #e3ded5;
}

.flyer-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-badge {
  position: absolute;
  left: 18px;
  top: 18px;
  border-radius: 999px;
  background: rgba(23, 20, 17, 0.86);
  color: #fff;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 900;
}

.flyer-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 38px;
}

.flyer-content h2 {
  font-size: clamp(38px, 6vw, 64px);
  line-height: 0.98;
  letter-spacing: 0;
}

.flyer-description {
  margin-top: 18px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.pill-row {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.pill {
  border: 1px solid #b9d9d6;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--teal);
  padding: 8px 11px;
  font-size: 13px;
  font-weight: 900;
}

.flyer-details {
  gap: 10px;
  margin-top: 24px;
}

.flyer-details div {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf8;
  padding: 13px;
}

.flyer-details span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.flyer-details strong {
  display: block;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.qr-block {
  align-items: center;
  gap: 16px;
  margin-top: 28px;
  padding: 16px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid #b9d9d6;
}

.qr-frame {
  flex: 0 0 auto;
  width: 138px;
  height: 138px;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.qr-frame img {
  width: 100%;
  height: 100%;
}

.qr-label {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.15;
  font-weight: 900;
}

.qr-url {
  margin-top: 8px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.flyer-footer {
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  color: var(--muted);
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 10;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .builder-panel,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .flyer-sheet {
    grid-template-columns: 1fr;
  }

  .flyer-photo {
    min-height: auto;
    aspect-ratio: 4 / 3;
  }

  .flyer-content {
    padding: 24px;
  }
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 20px, 1120px);
    padding-bottom: 24px;
  }

  .brand span {
    display: none;
  }

  .topbar-actions,
  .target-control,
  .flyer-details,
  .qr-block {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button,
  .target-button {
    width: 100%;
  }

  .qr-frame {
    justify-self: center;
  }
}

@media print {
  @page {
    size: letter portrait;
    margin: 0.35in;
  }

  body {
    background: #fff;
  }

  .no-print,
  .toast {
    display: none !important;
  }

  .page-shell {
    width: 100%;
    padding: 0;
  }

  .flyer-sheet {
    width: 100%;
    min-height: 10in;
    box-shadow: none;
    break-inside: avoid;
  }
}
