:root {
  --primary: #6d28d9;
  --primary-dark: #5b21b6;
  --bg: #14101f;
  --card: #1e1830;
  --text: #f1ecff;
  --muted: #a89fc7;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: 110px; /* chừa chỗ cho thanh nav dưới */
}

.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 12px;
}
.logo { width: 48px; height: 48px; border-radius: 12px; }
.app-header h1 { font-size: 22px; }
.tagline { color: var(--muted); font-size: 13px; }

/* ---- Màn hình kiểu app ---- */
.screen { display: none; padding: 16px; }
.screen.active { display: block; animation: fadeUp .25s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---- Thanh nav dưới ---- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  display: flex;
  background: rgba(30, 24, 48, .92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid #2a2145;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
}
.nav-item {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px;
  border-radius: 12px;
  cursor: pointer;
}
.nav-icon { font-size: 22px; line-height: 1; }
.nav-label { font-size: 11px; font-weight: 600; }
.nav-item.active { color: #fff; }
.nav-item.active .nav-icon {
  filter: drop-shadow(0 0 6px rgba(139, 92, 246, .8));
}

/* ---- Màn hình chính ---- */
.hero {
  background: linear-gradient(135deg, #2a1b52 0%, #1e1830 60%, #241a3f 100%);
  border: 1px solid #342a5c;
  border-radius: 22px;
  padding: 28px 22px;
  text-align: center;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(109, 40, 217, .25);
}
.hero-badge {
  display: inline-block;
  background: rgba(139, 92, 246, .15);
  border: 1px solid rgba(139, 92, 246, .4);
  color: #c4b5fd;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 14px;
}
.hero h2 { font-size: 24px; line-height: 1.35; margin-bottom: 10px; }
.grad {
  background: linear-gradient(90deg, #a78bfa, #e879f9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { color: var(--muted); font-size: 14px; line-height: 1.6; margin-bottom: 18px; }
.hero .btn { max-width: 320px; margin: 0 auto; }

.section-title { font-size: 16px; margin: 4px 2px 12px; }

.feature-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid #2a2145;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.feature-card:active { transform: scale(.98); border-color: var(--primary); }
.feature-icon {
  font-size: 32px;
  width: 56px; height: 56px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: #2a2145;
  border-radius: 14px;
}
.feature-body { flex: 1; }
.feature-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.feature-head h4 { font-size: 16px; }
.feature-body p { color: var(--muted); font-size: 13px; line-height: 1.5; }
.feature-arrow { font-size: 28px; color: var(--muted); }
.pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}
.pill.free { background: rgba(47, 125, 79, .25); color: #7ce3a5; border: 1px solid rgba(47, 125, 79, .6); }
.pill.soon { background: rgba(180, 120, 40, .18); color: #f0c987; border: 1px solid rgba(180, 120, 40, .5); }

.perks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 8px;
}
.perk {
  background: var(--card);
  border: 1px solid #2a2145;
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
}
.perk-icon { font-size: 28px; margin-bottom: 8px; }
.perk p { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---- Upload ---- */
.upload-zone {
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: var(--card);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  transition: background .2s;
}
.upload-zone.dragover { background: #2a2145; }
.upload-icon { font-size: 44px; margin-bottom: 8px; }
.upload-title { font-size: 17px; font-weight: 600; }
.upload-sub { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ---- Thanh tiến trình 3 bước ---- */
.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 0 2px;
}
.step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.step .dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #2a2145;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.step.active { color: var(--text); }
.step.active .dot { background: var(--primary); color: #fff; }
.step.done { color: #c4b5fd; }
.step.done .dot { background: #2f7d4f; color: #fff; }
.step-line { flex: 1; height: 2px; background: #2a2145; border-radius: 2px; max-width: 60px; }

.work-area { display: flex; flex-direction: column; gap: 14px; }
.work-area[hidden] { display: none; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.card-head h3 { font-size: 15px; color: var(--muted); }
.img-meta { font-size: 12px; color: var(--muted); }

.preview-block img {
  width: 100%;
  border-radius: 10px;
  display: block;
}

.btn {
  display: inline-block;
  text-align: center;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.btn.big { padding: 16px 20px; font-size: 17px; }
.btn.primary { background: var(--primary); color: #fff; width: 100%; }
.btn.primary:active { background: var(--primary-dark); }
.btn.primary:disabled { opacity: .5; }
.btn.ghost { background: transparent; border: 1px solid var(--primary); color: var(--text); flex: 1; }
.btn.ghost:active { background: #241d3f; }

.progress-box { background: var(--card); border-radius: var(--radius); padding: 16px; }
.progress-box[hidden] { display: none; }
.progress-label { font-size: 14px; margin-bottom: 8px; }
.progress-track { height: 10px; background: #2a2145; border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #8b5cf6, #6d28d9); transition: width .2s; }
.progress-hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

.result-block { display: flex; flex-direction: column; gap: 12px; }
.result-block[hidden] { display: none; }

/* ---- Nút chuyển Trước / Sau ---- */
.seg {
  display: flex;
  background: var(--card);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}
.seg-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  padding: 11px;
  border-radius: 10px;
  cursor: pointer;
}
.seg-btn.active { background: var(--primary); color: #fff; }

/* ---- Khung xem kết quả: lướt trang bình thường, không chặn cảm ứng ---- */
.result-view {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.result-view canvas {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-select: none;
}

.checker {
  background-image:
    linear-gradient(45deg, #3a3350 25%, transparent 25%),
    linear-gradient(-45deg, #3a3350 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #3a3350 75%),
    linear-gradient(-45deg, transparent 75%, #3a3350 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #241e38;
}

.bg-options {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}
.bg-opt {
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 2px solid transparent;
  font-size: 20px;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
}
.bg-opt.active { border-color: var(--primary); }

.actions-row { display: flex; gap: 10px; }

.privacy-note {
  margin-top: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

/* ---- Restore tab ---- */
.coming-soon {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
}
.coming-icon { font-size: 52px; margin-bottom: 12px; }
.coming-soon h2 { margin-bottom: 8px; }
.coming-soon p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.feature-list { list-style: none; margin: 20px 0; text-align: left; display: inline-block; }
.feature-list li { margin: 8px 0; font-size: 14px; }
.price-tag {
  display: inline-block;
  background: #2a2145;
  border: 1px solid var(--primary);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 15px;
}
.price-tag b { color: #c4b5fd; }

.app-footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 24px; }

/* ===== Ảnh thẻ ===== */
.opt-row { display:flex; align-items:center; gap:10px; }
.opt-label { font-size:14px; color:var(--muted); min-width:70px; flex-shrink:0; }
.seg-sm { flex:1; }
.seg-sm .seg-btn { padding:9px 6px; font-size:14px; }
.switch-row {
  display:flex; align-items:center; justify-content:space-between;
  background:var(--card); border-radius:12px; padding:12px 14px;
  font-size:15px; font-weight:600; cursor:pointer;
}
.switch { position:relative; width:52px; height:30px; flex-shrink:0; }
.switch input { opacity:0; width:100%; height:100%; position:absolute; inset:0; margin:0; cursor:pointer; z-index:2; }
.switch .knob { position:absolute; inset:0; background:#2a2145; border-radius:16px; transition:background .2s; }
.switch .knob::after {
  content:''; position:absolute; top:3px; left:3px; width:24px; height:24px;
  border-radius:50%; background:#fff; transition:transform .2s;
}
.switch input:checked + .knob { background:var(--primary); }
.switch input:checked + .knob::after { transform:translateX(22px); }
.pos-row { display:flex; align-items:center; gap:10px; }
.pos-row input[type=range] { flex:1; height:32px; accent-color:var(--primary); }

/* ===== chỉnh áo ảnh thẻ ===== */
.btn.ghost.active { border-color: var(--primary); color: #fff; background: rgba(124,58,237,.22); }
#idResultView.shirt-edit { touch-action: none; cursor: move; outline: 2px dashed var(--primary); outline-offset: -2px; }
.hint { font-size: 13px; color: var(--muted); text-align: center; margin: 0; }
