*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #4285f4;
  --primary-dark: #3367d6;
  --success: #34a853;
  --danger: #ea4335;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --font: 'Be Vietnam Pro', system-ui, sans-serif;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

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

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* Header */
.header {
  margin-bottom: 28px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: var(--surface);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.header-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 999px;
  font-family: inherit;
  transition: background 0.2s;
}

.step:hover { background: rgba(66, 133, 244, 0.08); }

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  transition: all 0.2s;
}

.step.active .step-num,
.step.done .step-num {
  background: var(--primary);
  color: #fff;
}

.step.done .step-num {
  background: var(--success);
}

.step-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.step.active .step-label { color: var(--text); font-weight: 600; }

.step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}

/* Main layout */
.main {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel-config {
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.panel h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.panel-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 24px;
}

.step-panel { display: none; flex: 1; }
.step-panel.active { display: block; }

/* Template grid */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.template-card {
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  background: var(--surface);
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1);
}

.template-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.2);
}

.template-thumb {
  height: 120px;
  position: relative;
  overflow: hidden;
}

.template-thumb-inner {
  position: absolute;
  inset: 8px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.5625rem;
  text-align: center;
  padding: 6px;
}

.template-thumb-sticker {
  font-weight: 700;
  font-size: 0.5rem;
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.template-thumb-qr {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.9);
  border-radius: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 4px;
}

.template-thumb-qr span {
  background: currentColor;
  border-radius: 1px;
}

.template-name {
  padding: 8px 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* Thumbnail variants for style templates */
.template-thumb--wave { position: relative; overflow: hidden; }
.template-thumb-wave {
  height: 36px;
  border-radius: 0 0 50% 50% / 0 0 12px 12px;
}
.template-thumb-body {
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.template-thumb-g {
  width: 22px;
  height: 22px;
  background: url('../assets/google-g.svg') center/contain no-repeat;
}
.template-thumb-stars {
  font-size: 0.5rem;
  color: #fbbf24;
  letter-spacing: 1px;
}
.template-thumb-split {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.625rem;
}
.template-thumb--gcolors { display: flex; flex-direction: column; height: 120px; }
.template-thumb-gc-top { height: 40px; }
.template-thumb-gc-mid {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}
.template-thumb-gc-bottom {
  height: 10px;
  background: linear-gradient(90deg, #ea4335 0 33.33%, #34a853 33.33% 66.66%, #fbbc05 66.66% 100%);
  border-radius: 0 0 6px 6px;
}
.template-thumb--dark,
.template-thumb--minimal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
}
.template-thumb-slant {
  font-size: 0.5rem;
  color: #64748b;
  transform: rotate(-8deg);
}

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.required { color: var(--danger); }

.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.15);
}

.form-group input.invalid {
  border-color: var(--danger);
}

.field-hint {
  font-size: 0.75rem;
  margin-top: 4px;
  min-height: 1.2em;
}

.field-hint.error { color: var(--danger); }
.field-hint.ok { color: var(--success); }

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

.color-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-input-wrap input[type="color"] {
  width: 44px;
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  background: none;
}

.color-text {
  flex: 1;
  padding: 8px 10px !important;
  font-family: monospace;
  font-size: 0.8125rem !important;
  text-transform: uppercase;
}

.logo-formats {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.format-tag {
  display: inline-block;
  padding: 2px 8px;
  background: #eef2ff;
  color: var(--primary);
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
}

/* Logo upload */
.logo-upload {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: #fafbfc;
}

.logo-preview {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.625rem;
  text-align: center;
  padding: 4px;
}

.logo-preview-label {
  font-size: 0.5625rem;
  line-height: 1.2;
}

.logo-preview-size {
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.2;
}

.logo-preview img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  padding: 4px;
}

.logo-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Help box */
.help-box {
  margin-top: 16px;
  padding: 14px 16px;
  background: #f0f7ff;
  border-radius: 10px;
  font-size: 0.8125rem;
}

.help-box summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-dark);
}

.help-box ol {
  margin-top: 10px;
  padding-left: 20px;
}

.help-box li { margin-bottom: 4px; }

/* Download */
.download-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.download-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
}

.download-icon { font-size: 1.75rem; }

.download-card h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.download-card p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.download-card--print {
  border-color: #c7d7fe;
  background: #f8faff;
}

.download-card--print h3 {
  color: var(--primary);
}

.print-tips {
  margin-top: 24px;
  padding: 16px;
  background: #fffbeb;
  border-radius: 10px;
  font-size: 0.8125rem;
}

.print-tips h4 {
  font-size: 0.875rem;
  margin-bottom: 8px;
}

.print-tips ul {
  padding-left: 18px;
}

.print-tips li { margin-bottom: 4px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s, transform 0.1s;
}

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

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

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

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

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover { color: var(--text); background: #f1f5f9; }

.btn-sm { padding: 6px 14px; font-size: 0.8125rem; }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* Preview panel */
.panel-preview {
  position: sticky;
  top: 24px;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.preview-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.preview-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  background: #eef2ff;
  color: var(--primary);
  border-radius: 999px;
}

.preview-wrap {
  background: #e8ecf1;
  border-radius: 10px;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#previewCanvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.15);
}

.preview-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.hidden { display: none !important; }

/* Intro / description article */
.intro-card {
  margin-top: 32px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 36px;
  border: 1px solid var(--border);
}

.intro-card h2 {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.intro-card p {
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.intro-card p:last-of-type {
  margin-bottom: 0;
}

.intro-card strong {
  color: var(--text);
  font-weight: 600;
}

.intro-card__footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.875rem !important;
}

/* Responsive */
@media (max-width: 960px) {
  .main {
    grid-template-columns: 1fr;
  }

  .panel-preview {
    position: static;
    order: -1;
  }

  .preview-wrap { padding: 16px; }

  #previewCanvas { max-height: 360px; }
}

@media (max-width: 560px) {
  .step-label { display: none; }
  .step-line { width: 20px; }
  .form-row { grid-template-columns: 1fr; }
  .download-card {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .download-icon { justify-self: center; }

  .intro-card {
    padding: 24px 20px;
  }
}
