:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --accent: #06b6d4;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Lucide default size */
.lucide { width: 16px; height: 16px; stroke-width: 2; vertical-align: -3px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.topbar h1 {
  margin: 0; font-size: 17px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
.topbar h1 .lucide { width: 20px; height: 20px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  color: #fff;
  font-weight: 600;
}
.badge .lucide { width: 13px; height: 13px; }
.badge.ok { background: #16a34a; }
.badge.err { background: #dc2626; }

.app {
  max-width: 560px; margin: 0 auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card h2 {
  margin: 0 0 12px; font-size: 14px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  color: var(--text);
}
.card h2 .lucide { width: 17px; height: 17px; color: var(--primary); }

label {
  display: flex; align-items: center; gap: 5px;
  margin: 10px 0 4px;
  font-size: 11px; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
label .lucide { width: 13px; height: 13px; }

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

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

.photo-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.photo-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 12px;
  border: 0; border-radius: 12px;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform .12s, box-shadow .12s;
}
.photo-btn .lucide { width: 18px; height: 18px; }
.photo-btn:active { transform: scale(.97); }
.photo-btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 10px rgba(79,70,229,.25);
}
.photo-btn.primary:hover { background: var(--primary-dark); }
.photo-btn.secondary {
  background: #eef2ff;
  color: var(--primary);
  border: 1.5px solid #c7d2fe;
}
.photo-btn.secondary:hover { background: #e0e7ff; }

canvas#preview {
  width: 100%;
  border-radius: 12px;
  background: #111;
  display: block;
  margin-bottom: 12px;
}

#btnUpload {
  width: 100%;
  padding: 14px;
  border: 0; border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s;
}
#btnUpload .lucide { width: 18px; height: 18px; }
#btnUpload:hover:not(:disabled) { background: var(--primary-dark); }
#btnUpload:disabled { opacity: .5; cursor: not-allowed; }

.status {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  word-break: break-word;
}
.status.ok { color: #16a34a; font-weight: 600; }
.status.err { color: #dc2626; font-weight: 600; }

/* Preset thumbnails */
.thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.thumb {
  cursor: pointer;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .02em;
}
.thumb canvas {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 2.5px solid transparent;
  display: block;
  transition: border-color .12s, transform .12s;
}
.thumb:hover canvas { transform: scale(1.03); }
.thumb.active canvas {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79,70,229,.3);
}
.thumb.active { color: var(--primary); }

#recentList {
  list-style: none; margin: 0; padding: 0; font-size: 13px;
}
#recentList li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
#recentList li:last-child { border-bottom: 0; }
#recentList a {
  color: var(--primary); text-decoration: none; font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px;
}
#recentList a .lucide { width: 13px; height: 13px; }
