:root {
  --blue: #0064D2;
  --blue-dark: #0053B3;
  --green: #3a7d44;
  --red: #c0392b;
  --yellow: #8a6d00;
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── Login ──────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon { font-size: 48px; display: block; margin-bottom: 8px; }
.logo h1 { font-size: 28px; font-weight: 700; color: var(--blue); }
.logo p { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ─── Header ─────────────────────────────────────────────── */
header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--blue);
}

/* ─── Banners ────────────────────────────────────────────── */
.ebay-banner {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
}

.banner-warn { background: #fffbeb; color: var(--yellow); border-bottom: 1px solid #fde68a; }
.banner-success { background: #f0fdf4; color: var(--green); border-bottom: 1px solid #bbf7d0; }
.banner-error { background: #fef2f2; color: var(--red); border-bottom: 1px solid #fecaca; }

/* ─── Main / Cards ───────────────────────────────────────── */
main {
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ─── Forms ──────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field-group { margin-bottom: 14px; }
.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.char-count {
  font-size: 12px;
  color: var(--muted);
  display: block;
  text-align: right;
  margin-top: 4px;
}

/* ─── Shipping Row ───────────────────────────────────────── */
.ship-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.ship-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Photo Upload ───────────────────────────────────────── */
.photo-drop {
  display: block;
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 24px;
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color 0.15s, background 0.15s;
  min-height: 120px;
}

.photo-drop:active { background: #f9fafb; border-color: var(--blue); }

#photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
}

.upload-icon { font-size: 36px; }
#photo-placeholder span:nth-child(2) { font-weight: 600; font-size: 15px; }
.upload-hint { font-size: 12px; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preview-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6px;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 15px;
  background: var(--blue);
  color: white;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 6px;
  font-family: inherit;
}

.btn-primary:active { background: var(--blue-dark); }
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }

.btn-ghost {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
}

.btn-ghost:active { background: var(--bg); }

.btn-outline {
  display: block;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--blue);
  color: var(--blue);
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  text-align: center;
  text-decoration: none;
  margin-bottom: 10px;
}

.btn-connect {
  white-space: nowrap;
  padding: 6px 12px;
  background: var(--blue);
  color: white;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
}

/* ─── eBay Preview ───────────────────────────────────────── */
.ebay-preview-bar {
  background: #fff;
  border-bottom: 3px solid #0064D2;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.btn-ghost-sm {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
}

.ebay-listing-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #fff;
}

@media (min-width: 640px) {
  .ebay-listing-wrap {
    flex-direction: row;
    align-items: flex-start;
    padding: 20px 16px;
    gap: 24px;
    max-width: 900px;
    margin: 0 auto;
  }
  .gallery-col { width: 50%; }
  .details-col { width: 50%; }
}

/* Gallery */
.gallery-col { padding: 16px 16px 0; }

.main-photo-wrap {
  position: relative;
  background: #f9fafb;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 1;
  margin-bottom: 10px;
  border: 1px solid var(--border);
}

.main-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.main-label {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #0064D2;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  letter-spacing: 0.06em;
}

.gallery-thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.g-thumb {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 2px solid transparent;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.g-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.g-main-tag {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0064D2;
  color: white;
  font-size: 8px;
  font-weight: 700;
  text-align: center;
  padding: 2px;
  letter-spacing: 0.04em;
}

.g-thumb-active {
  border-color: #0064D2;
}

.g-thumb-active .g-main-tag { display: block; }

.gallery-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  margin-bottom: 0;
}

/* Details column */
.details-col {
  padding: 16px;
}

.price-condition-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.price-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.price-wrap:focus-within { border-color: var(--blue); }

.price-sign {
  padding: 0 10px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border-right: 1px solid var(--border);
  line-height: 44px;
}

.price-wrap input {
  border: none;
  flex: 1;
  padding: 12px 10px;
}
.price-wrap input:focus { outline: none; }

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--muted);
}

.dimensions-note {
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.flat-rate-card {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fff;
}

.flat-rate-recommended {
  border-color: #16a34a;
  background: #f0fdf4;
}

.flat-rate-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flat-rate-icon { font-size: 22px; flex-shrink: 0; }

.flat-rate-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  gap: 1px;
}

.flat-rate-price {
  font-size: 15px;
  font-weight: 700;
  color: #16a34a;
}

.flat-rate-badge {
  background: #16a34a;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.flat-rate-reason {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  margin-bottom: 0;
  line-height: 1.4;
}

.ebay-fake-btn {
  width: 100%;
  padding: 14px;
  background: #e5f0ff;
  color: #9ca3af;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  text-align: center;
  border: 2px dashed var(--border);
  margin-top: 8px;
  cursor: default;
}

/* Description + Save */
.desc-section {
  background: #fff;
  padding: 0 16px 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.save-section {
  padding: 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* ─── Success ────────────────────────────────────────────── */
.success-card {
  text-align: center;
  padding: 40px 24px;
}

.success-icon { font-size: 56px; display: block; margin-bottom: 16px; }
.success-card h2 { font-size: 22px; margin-bottom: 10px; }
.success-card p { color: var(--muted); margin-bottom: 24px; line-height: 1.5; }

/* ─── Errors ─────────────────────────────────────────────── */
.error-msg {
  color: var(--red);
  font-size: 14px;
  padding: 10px 12px;
  background: #fef2f2;
  border-radius: 8px;
  margin-bottom: 10px;
}

/* ─── Nav tabs + Local/eBay toggle ─────────────────────────────────────────── */
.app-nav {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  max-width: 1100px; margin: 16px auto 0; padding: 0 16px;
}
.nav-tabs { display: flex; gap: 8px; }
.nav-tab {
  background: var(--card-bg); border: 1.5px solid var(--border); color: var(--muted);
  padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.nav-tab.active { border-color: var(--blue); color: var(--blue); background: #eff6ff; }
.count-badge {
  background: var(--blue); color: #fff; border-radius: 999px; font-size: 11px;
  padding: 1px 7px; margin-left: 4px;
}
.draft-mode { display: flex; align-items: center; gap: 8px; }
.mode-label { color: var(--muted); font-size: 13px; }
.mode-switch { display: flex; border: 1.5px solid var(--border); border-radius: 999px; overflow: hidden; }
.mode-opt {
  background: var(--card-bg); border: none; color: var(--muted);
  padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.mode-opt.active { background: var(--blue); color: #fff; }
.mode-opt.disabled { color: #b0b4bd; cursor: not-allowed; }

/* ─── My Drafts ─────────────────────────────────────────────────────────────── */
.drafts-sub { color: var(--muted); font-size: 14px; margin: -6px 0 16px; }
.drafts-empty, .drafts-loading { color: var(--muted); text-align: center; padding: 28px 12px; }
.drafts-list { display: flex; flex-direction: column; gap: 10px; }
.draft-card {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.draft-thumb {
  width: 56px; height: 56px; flex: 0 0 56px; border-radius: 8px; overflow: hidden;
  background: #f1f2f4; display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.draft-thumb img { width: 100%; height: 100%; object-fit: cover; }
.draft-info { flex: 1; min-width: 0; }
.draft-title { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.draft-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.draft-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-mini {
  border: 1.5px solid var(--border); background: var(--card-bg); color: var(--text);
  padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-mini-primary { border-color: var(--blue); color: #fff; background: var(--blue); }
.btn-mini-danger { border-color: #fca5a5; color: var(--red); }

/* ─── Publish confirm modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(17,24,39,.5);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--card-bg); border-radius: var(--radius); padding: 22px;
  max-width: 400px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal p { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.modal-item { font-weight: 600; color: var(--text); background: #f1f2f4; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ─── Add / remove photos in the editor ─────────────────────────────────────── */
.main-photo-wrap { position: relative; }
.no-photo-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; background: #f1f2f4; border-radius: 8px;
}
.add-photos-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  border: 1.5px dashed #c7ccd4; color: var(--blue); background: var(--card-bg);
  padding: 9px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.add-photos-btn:hover { border-color: var(--blue); background: #eff6ff; }
.add-photo-status { font-size: 13px; color: var(--muted); margin-top: 8px; }
.g-thumb { position: relative; }
.g-remove {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  border: none; background: rgba(17,24,39,.72); color: #fff; font-size: 11px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.g-remove:hover { background: var(--red); }
