:root {
  color-scheme: light;
  --bg: #f4f1ed;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --accent: #eb5e28;
  --accent-2: #0f172a;
  --outline: #e5e7eb;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
  --radius: 16px;
}

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

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Fraunces", "Georgia", serif;
  background: radial-gradient(circle at top left, #fdf2e4, #f4f1ed 40%, #f0ebe7 100%);
  color: var(--ink);
}

body.is-dark-preview {
  background: radial-gradient(circle at top left, #1e1b22, #121118 45%, #0f0d13 100%);
  color: #f8fafc;
}

.app {
  padding: 32px 6vw 48px;
}

.app__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 32px;
}

.app__controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.app__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  margin-bottom: 8px;
}

.app__logo {
  color: var(--accent);
}

.app__eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--accent-2);
  margin-bottom: 0;
}

p.app__eyebrow {
  margin-bottom: 8px;
}

.app__subhead {
  color: var(--muted);
  max-width: 560px;
}

.app__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.guest-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: var(--radius);
  font-size: 14px;
  color: #92400e;
}

.guest-banner p {
  margin: 0;
}

.guest-banner .btn--ghost {
  color: #b45309;
  font-weight: 700;
  text-decoration: underline;
  padding: 0;
  font-size: inherit;
}

.guest-banner__close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #92400e;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}

.auth {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--outline);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.auth__status {
  font-weight: 600;
  color: var(--accent-2);
}

.user-menu {
  position: relative;
}

.user-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  padding: 8px;
  min-width: 200px;
  display: grid;
  gap: 6px;
  z-index: 20;
}

.user-menu__item {
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  font-family: "Space Grotesk", "Verdana", sans-serif;
  cursor: pointer;
  color: var(--accent-2);
}

.user-menu__item:hover {
  background: rgba(15, 23, 42, 0.08);
}

.btn {
  border-radius: 999px;
  padding: 10px 18px;
  font-family: "Space Grotesk", "Verdana", sans-serif;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

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

.btn--outline {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
}

.btn--ghost {
  background: rgba(15, 23, 42, 0.08);
}

.wizard .btn--ghost {
  background: transparent;
  border: 1px dashed var(--outline);
  color: var(--accent-2);
}

.wizard .btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

body.is-dark-preview .btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.btn.is-success {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
  pointer-events: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.app__main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 28px;
}

.wizard {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  z-index: 50;
}

.modal__panel {
  width: min(440px, 92vw);
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
  display: grid;
  gap: 16px;
}

.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal__tabs {
  display: flex;
  gap: 8px;
  background: #f1f5f9;
  padding: 6px;
  border-radius: 999px;
}

.tab {
  flex: 1;
  border: none;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  background: #fff;
  color: var(--accent-2);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.modal__form {
  display: grid;
  gap: 12px;
}

.modal__body {
  display: grid;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.divider {
  height: 1px;
  background: var(--outline);
  margin: 4px 0;
}

input[disabled] {
  background: rgba(15, 23, 42, 0.04);
  color: var(--muted);
}

body.is-dark-preview .wizard {
  background: rgba(15, 23, 42, 0.7);
}

.wizard__steps {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.step {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--outline);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
}

.step.is-active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.wizard__form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.wizard__form .field + .field {
  margin-top: 6px;
}

.panel {
  display: none;
  gap: 16px;
  flex-direction: column;
}

.panel.is-active {
  display: flex;
}

.group {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fdfbf8;
  display: grid;
  gap: 12px;
}

.group + .group {
  margin-top: 12px;
}

.group summary {
  cursor: pointer;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  list-style: none;
}

.group summary::-webkit-details-marker {
  display: none;
}

.group[open] summary::after {
  content: "–";
  float: right;
  color: var(--muted);
}

.group:not([open]) summary::after {
  content: "+";
  float: right;
  color: var(--muted);
}

.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: 120%;
  background: #0f172a;
  color: #fff;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.tooltip:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.list {
  display: grid;
  gap: 10px;
}

.list__row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: center;
}

.list__row select,
.list__row input {
  width: 100%;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

input,
select {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  font-family: "Space Grotesk", "Verdana", sans-serif;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(235, 94, 40, 0.15);
}

textarea {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  font-family: "Space Grotesk", "Verdana", sans-serif;
  resize: vertical;
}

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

input[type="color"] {
  padding: 0;
  width: 56px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--outline);
  overflow: hidden;
  background: #fff;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 4px;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.field .grid {
  margin-top: 6px;
}

.field textarea {
  min-height: 96px;
}

.panel[data-panel="5"] .field {
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.panel[data-panel="5"] .field:last-child {
  border-bottom: none;
}

.dropzone {
  border: 1px dashed var(--outline);
  padding: 18px;
  border-radius: 14px;
  text-align: center;
  background: #fafafa;
  display: grid;
  gap: 10px;
}

.dropzone__preview {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--outline);
}

.dropzone__preview img {
  max-width: 150px;
  max-height: 80px;
  height: auto;
  width: auto;
  display: block;
}

.dropzone__progress {
  width: 100%;
  height: 8px;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.dropzone__bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.template-card {
  border: 1px solid var(--outline);
  padding: 14px;
  border-radius: 12px;
  background: #fff;
  text-align: left;
  display: grid;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.template-preview {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.template-preview__logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, #d1d5db, #9ca3af);
}

.template-preview__lines {
  display: grid;
  gap: 4px;
}

.template-preview__lines span {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: #cbd5f5;
}

.template-preview__lines span:nth-child(1) {
  width: 80%;
}

.template-preview__lines span:nth-child(2) {
  width: 60%;
}

.template-preview__lines span:nth-child(3) {
  width: 40%;
}

.template-preview__banner {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: #fde68a;
  display: none;
}

.template-preview--banner .template-preview__banner {
  display: block;
}

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

.template-preview--minimalist .template-preview__logo {
  display: none;
}

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

.template-preview--stacked .template-preview__logo {
  width: 36px;
  height: 18px;
}

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

.template-preview--accent .template-preview__logo {
  width: 6px;
  height: 32px;
  border-radius: 999px;
  background: var(--accent);
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.template-card.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(235, 94, 40, 0.2);
  transform: translateY(-2px);
}

.wizard__nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  margin-top: 28px;
  padding-top: 22px;
  border-top: 2px solid var(--outline);
}

.wizard__nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  padding: 12px 22px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wizard__nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

.wizard__nav-btn svg {
  flex-shrink: 0;
}

#prev-step {
  justify-self: start;
}

#prev-step.is-hidden {
  visibility: hidden;
}

#next-step {
  justify-self: end;
}

#next-step.is-hidden {
  visibility: hidden;
}

.wizard__nav-indicator {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  font-family: "Space Grotesk", "Verdana", sans-serif;
  text-align: center;
}

.preview {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 520px;
}

.preview--sticky {
  position: sticky;
  top: 24px;
  align-self: start;
}

body.is-dark-preview .preview {
  background: #1b1c22;
  color: #f8fafc;
}

.preview__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.preview__canvas {
  margin-top: 18px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
  min-height: 240px;
}

.preview__placeholder {
  color: var(--muted);
}

.preview__actions {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  text-align: center;
}

.preview__action-main {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
}

.preview__action-main svg {
  flex-shrink: 0;
}

.preview__hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.preview__secondary {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 12px;
}

.preview__secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 14px;
}

.preview__secondary-btn svg {
  flex-shrink: 0;
}

body.is-dark-preview .preview__actions {
  border-top-color: rgba(255, 255, 255, 0.1);
}

body.is-dark-preview .preview__hint {
  color: rgba(248, 250, 252, 0.5);
}

.preview__note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}

.toast {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.08);
  font-size: 12px;
  color: var(--accent-2);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.modal__error {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.12);
}

.modal__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal__link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-1);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.modal__link:hover {
  text-decoration: underline;
}

.history {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

body.is-dark-preview .history {
  background: #1b1c22;
  color: #f8fafc;
}

.history__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history__list {
  display: grid;
  gap: 12px;
}

.history__card {
  border: 1px solid var(--outline);
  border-radius: 12px;
  padding: 12px;
  background: #fff7f2;
  display: grid;
  gap: 6px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.history__card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

body.is-dark-preview .history__card {
  background: rgba(255, 255, 255, 0.06);
}

.history__card strong {
  font-size: 13px;
}

.history__card span {
  font-size: 11px;
  color: var(--muted);
}

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

.history__button {
  border: 1px solid var(--outline);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history__button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.badge {
  background: var(--accent-2);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

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

  .app__header {
    flex-direction: column;
    align-items: flex-start;
  }
}
