* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
}

.layout {
  display: flex;
  min-height: 100vh;
}

.mobile-topbar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-lg) var(--space-md);
}

.sidebar__brand {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: var(--space-lg);
}

.brand-logo {
  display: block;
  width: 180px;
  height: 180px;
  border-radius: 50%;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.sidebar__nav a {
  display: flex;
  align-items: center;
  min-height: 36px;
  color: var(--color-text);
  text-decoration: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
}

.sidebar__nav a:hover {
  background: var(--color-bg);
}

.sidebar__nav a.is-active {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  font-weight: 600;
}

.main-column {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.content {
  flex: 1;
  padding: var(--space-lg);
}

.site-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
}

.btn--primary:hover {
  background: var(--color-primary-dark);
}

.form-group {
  margin-bottom: var(--space-md);
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
}

.alert {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
}

.alert ul {
  margin: 0;
  padding-left: var(--space-md);
}

.alert--error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.alert--success {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.form-group select,
.form-group textarea {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

a.card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.credit-balance-card__label {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.credit-balance-card__value {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.design-grid,
.upload-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-md);
}

.upload-card__thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.upload-card__name {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  word-break: break-word;
}

.render-preview {
  max-width: 100%;
  width: 400px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.design-card__id {
  font-weight: 600;
  margin: 0 0 var(--space-xs);
}

.design-card__date {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin: var(--space-xs) 0 0;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.625rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge--pending {
  background: #fff4d6;
  color: #8a6100;
}

.badge--processing {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge--completed {
  background: #dcf5e3;
  color: #166b3a;
}

.badge--failed,
.badge--rejected {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge--paid,
.badge--approved {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: var(--color-text);
}

@media (max-width: 767px) {
  .layout {
    flex-direction: column;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    position: sticky;
    top: 0;
    z-index: 1001;
    padding: var(--space-xs) var(--space-md);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
  }

  .mobile-topbar__brand {
    display: flex;
    align-items: center;
    font-weight: 700;
  }

  .mobile-topbar__brand .brand-logo {
    width: 116px;
    height: 116px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    max-width: 80vw;
    z-index: 1002;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
  }

  .sidebar--open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
  }

  .sidebar-backdrop--visible {
    opacity: 1;
    pointer-events: auto;
  }

  .content {
    padding: var(--space-md);
  }
}

.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  cursor: pointer;
  color: var(--color-text-muted);
}

.dropzone--active {
  border-color: var(--color-primary);
  background: var(--color-bg);
  color: var(--color-text);
}

.dropzone__input {
  display: none;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-sm);
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  min-height: 96px;
  padding: var(--space-sm);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  text-align: center;
  font-weight: 500;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

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

.tile:active {
  transform: scale(0.98);
}

.tile input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tile__swatch {
  display: block;
  width: 100%;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-border), var(--color-bg));
}

.tile__icon svg {
  width: 32px;
  height: 32px;
  color: var(--color-text-muted);
}

.tile__emoji {
  font-size: 1.75rem;
  line-height: 1;
}

.tile__label {
  font-size: 0.85rem;
}

.tile--selected,
.tile:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-bg);
  color: var(--color-primary);
}

.tile--selected .tile__icon svg,
.tile:has(input:checked) .tile__icon svg {
  color: var(--color-primary);
}

.tile--focused,
.tile:has(input:focus-visible) {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* Style swatches per known seed slug — any unmatched slug keeps the
   default neutral gradient set on .tile__swatch above. */
.tile--style[data-slug="watercolor"] .tile__swatch {
  background: linear-gradient(135deg, #a8d8ea, #eea2c8, #f7d488);
}

.tile--style[data-slug="cartoon"] .tile__swatch {
  background: linear-gradient(135deg, #ff6b6b 50%, #4ecdc4 50%);
}

.tile--style[data-slug="photorealistic"] .tile__swatch {
  background: linear-gradient(135deg, #232526, #8e9eab);
}

.tile--style[data-slug="minimalist"] .tile__swatch {
  background: #f4f4f2;
  box-shadow: inset 0 0 0 1px var(--color-border);
}

.tile--style[data-slug="pop-art"] .tile__swatch {
  background:
    radial-gradient(circle, #1a1a1a 18%, transparent 19%) 0 0 / 14px 14px,
    #ffde59;
}

.tile--style[data-slug="vintage"] .tile__swatch {
  background: linear-gradient(135deg, #d9c69c, #a9744f);
}

.custom-idea-card {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  margin-top: var(--space-md);
  padding: var(--space-md);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  cursor: text;
}

.custom-idea-card:focus-within {
  border-color: var(--color-accent);
  border-style: solid;
}

.custom-idea-card__icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.custom-idea-card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.custom-idea-card__title {
  font-weight: 600;
}

.custom-idea-card textarea {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  resize: vertical;
}

.wizard-header {
  margin-bottom: var(--space-lg);
}

.wizard-header h1 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  margin: 0 0 var(--space-xs);
}

.wizard-header p {
  color: var(--color-text-muted);
  margin: 0;
}

.stepper {
  display: flex;
  flex-direction: column;
}

.step {
  display: flex;
  gap: var(--space-md);
  position: relative;
  padding-bottom: var(--space-xl);
}

.step:last-of-type {
  padding-bottom: var(--space-lg);
}

.step__marker {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.step__number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  font-weight: 700;
  flex-shrink: 0;
}

.step:not(:last-of-type) .step__marker::after {
  content: '';
  flex: 1;
  width: 2px;
  background: var(--color-border);
  margin-top: var(--space-xs);
}

.step__body {
  flex: 1;
  min-width: 0;
}

.step__title {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-display);
  font-size: 1.3rem;
}

.step__hint {
  margin: 0 0 var(--space-sm);
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.wizard-submit {
  margin-top: var(--space-md);
}

.btn--large {
  min-height: 48px;
  padding: var(--space-sm) var(--space-lg);
  font-size: 1.05rem;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
}

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

.admin-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.admin-header__brand {
  font-weight: 700;
}

.admin-header__nav {
  display: flex;
  gap: var(--space-md);
}

.admin-header__nav a {
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  min-height: 36px;
}

.admin-content {
  flex: 1;
  padding: var(--space-lg);
}

.admin-filter-form {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.admin-filter-form .form-group {
  margin-bottom: 0;
}

.admin-actions {
  display: flex;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.admin-pagination {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.admin-pagination a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-text);
}

.admin-pagination a.is-active {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  border-color: var(--color-primary);
}

.badge--label_created {
  background: #dbeafe;
  color: #1d4ed8;
}

.render-credit-note {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.hero {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  padding: var(--space-xl) 0;
  overflow: hidden;
}

.hero__ring {
  position: absolute;
  top: -100px;
  left: -120px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  border: 44px solid var(--color-accent);
  opacity: 0.12;
  pointer-events: none;
}

.hero__content {
  position: relative;
  flex: 1 1 360px;
  min-width: 0;
}

.hero__hand {
  font-family: var(--font-hand);
  font-size: 1.5rem;
  color: var(--color-accent-dark);
  margin: 0 0 var(--space-xs);
  transform: rotate(-2deg);
}

.hero__headline {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.1;
  margin: 0 0 var(--space-md);
}

.hero__subhead {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  max-width: 480px;
  margin: 0 0 var(--space-lg);
}

.hero__visual {
  position: relative;
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.hero__photo {
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.hero__visual-caption {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: 0;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  text-align: center;
  margin: 0 0 var(--space-lg);
}

.how-it-works {
  padding: var(--space-xl) 0;
}

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

.step-card {
  text-align: center;
}

.step-card__image {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-sm);
}

.step-card h3 {
  margin: 0 0 var(--space-xs);
  font-size: 1.05rem;
}

.step-card p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.pricing-note {
  text-align: center;
  padding: var(--space-md) 0;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.cta-band {
  text-align: center;
  padding: var(--space-xl) 0;
}

.cta-band h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  margin: 0 0 var(--space-md);
}

@media (max-width: 767px) {
  .hero {
    flex-direction: column;
    text-align: center;
  }

  .hero__subhead {
    max-width: none;
  }

  .hero__ring {
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
  }
}
