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

:root {
  --bg:       #f4f5f7;
  --surface:  #ffffff;
  --border:   #e2e5ea;
  --text:     #1a1d23;
  --muted:    #6b7280;
  --accent:   #2563eb;
  --blue-dark:#1e40af;
  --green:    #16a34a;
  --red:      #dc2626;
  --radius:   14px;
  --safe-top: env(safe-area-inset-top,    0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-l:   env(safe-area-inset-left,   0px);
  --safe-r:   env(safe-area-inset-right,  0px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100svh;
  padding-bottom: calc(24px + var(--safe-bot));
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  background: var(--blue-dark);
  color: white;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  padding: calc(12px + var(--safe-top)) 20px 12px;
}
.header-title { display: flex; align-items: center; gap: 12px; }
.header-logo  { width: 40px; height: 40px; flex-shrink: 0; }
h1            { font-size: 18px; font-weight: 700; line-height: 1.2; }
.header-sub   { font-size: 11px; opacity: 0.75; margin-top: 1px; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
main {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* ── Upload area ─────────────────────────────────────────────────────────── */
#file-input { display: none; }

.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 20px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.upload-area:active,
.upload-area.drag-over {
  border-color: var(--accent);
  background: rgba(37,99,235,0.04);
}
.upload-icon        { font-size: 36px; }
.upload-text-primary  { font-size: 15px; font-weight: 500; }
.upload-text-secondary {
  font-size: 12px;
  color: var(--muted);
  display: none;
}
@media (min-width: 640px) {
  .upload-text-secondary { display: block; }
}

/* Upload preview thumbnails */
.upload-preview { display: flex; flex-wrap: wrap; gap: 8px; }
.up-thumb {
  width: 72px; height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}
.up-thumb img { width: 100%; height: 100%; object-fit: cover; }
.up-thumb-badge {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: rgba(22,163,74,0.75);
  color: white;
  pointer-events: none;
}
.up-thumb-badge.error { background: rgba(220,38,38,0.75); }

.up-thumb-del {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.up-thumb-del:hover { background: rgba(220,38,38,0.85); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 18px;
  border: none;
  border-radius: 9px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.12s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active  { opacity: 0.75; transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: white; width: 100%; }
.btn-green   { background: var(--green);  color: white; }
.btn-ghost   {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-danger  { background: #fee2e2; color: var(--red); border: 1px solid #fca5a5; }
.btn-sm      { font-size: 13px; min-height: 36px; padding: 7px 14px; }

/* ── Analyze section ─────────────────────────────────────────────────────── */
.analyze-row { display: flex; flex-direction: column; gap: 10px; }
.progress-label { font-size: 13px; color: var(--muted); }
.progress-bar-bg {
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  width: 0%;
  transition: width 0.3s;
}

/* ── Bulk bar ────────────────────────────────────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.bulk-check-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 500;
  cursor: pointer;
}
.selected-label { font-size: 13px; color: var(--muted); flex: 1; }
.btn-queue { margin-left: auto; }

/* ── Product grid ────────────────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 640px)  { .product-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }

/* ── Product card ────────────────────────────────────────────────────────── */
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s;
}
.product-card.published {
  opacity: 0.55;
}
.product-card-header {
  position: relative;
}
.product-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.product-card-check {
  position: absolute;
  top: 10px; left: 10px;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: rgba(255,255,255,0.9);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: 2px solid var(--border);
}
.product-card-check input { width: 16px; height: 16px; cursor: pointer; }
.published-badge {
  position: absolute;
  top: 10px; right: 10px;
  background: var(--green);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
}

.product-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Inputs — 16px prevents iOS Safari auto-zoom */
input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  appearance: none;
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
textarea { min-height: 80px; resize: vertical; }

.vb-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.vb-label input { cursor: pointer; width: 14px; height: 14px; }
.f-preis:disabled { opacity: 0.4; cursor: not-allowed; }

.char-count {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  margin-top: -6px;
}
.char-count.over { color: var(--red); }

.product-card-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}
.btn-delete { flex: 0 0 40px; padding: 8px; font-size: 16px; min-height: 40px; }
.btn-post   { flex: 1; font-size: 13px; }

/* ── Bookmarklet ─────────────────────────────────────────────────────────── */
.bookmarklet-card { cursor: default; }
.bookmarklet-card summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}
.bookmarklet-card summary::-webkit-details-marker { display: none; }
.badge-once {
  font-size: 10px;
  background: #dbeafe;
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 500;
}
.bookmarklet-body {
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}
.bookmarklet-link {
  display: block;
  padding: 14px;
  text-align: center;
  background: #eff6ff;
  border: 2px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.hint { font-size: 12px; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 32px 16px;
}

/* ── Overlay (publish queue) ─────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.overlay[hidden] { display: none; }

.overlay-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 440px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.overlay-header h2 { font-size: 16px; font-weight: 700; }
.queue-progress { font-size: 13px; color: var(--muted); }

.queue-product {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--bg);
  border-radius: 10px;
  padding: 12px;
}
.queue-thumb { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.queue-title { font-size: 15px; font-weight: 600; }
.queue-price { font-size: 13px; color: var(--muted); margin-top: 4px; }

.queue-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
}
.step-num {
  flex-shrink: 0;
  width: 24px; height: 24px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

.overlay-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.overlay-actions .btn-green { flex: 1; }
.overlay-actions .btn-ghost { min-width: 100px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bot));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: white;
  padding: 11px 22px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  pointer-events: none;
  z-index: 300;
  transition: transform 0.25s ease;
  white-space: nowrap;
  max-width: calc(100vw - 40px);
}
.toast.show { transform: translateX(-50%) translateY(0); }
