:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --text: #111827;
  --muted: #6b7280;
  --border: #e6e9ef;
  --shadow: rgba(17, 24, 39, 0.06);
  --accent: #3665f3; /* eBay blue */
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
h1, h2, h3 { letter-spacing: -0.015em; }
button { font-family: inherit; }

/* Single-colour stroke icons — always currentColor, never a colour of their own. */
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon.sm { width: 16px; height: 16px; }
.icon.xs { width: 13px; height: 13px; stroke-width: 2.2; vertical-align: -2px; }

/* Uppercase section rule used to break the long editor form into groups */
.sec { display: flex; align-items: center; gap: 0.6rem; margin: 1.5rem 0 0.7rem;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); }
.sec::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* Login */
.login-view { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: min(360px, 92vw); text-align: center; background: var(--panel);
  border: 1px solid var(--border); border-radius: 20px; padding: 2.2rem 1.5rem 1.6rem;
  box-shadow: 0 12px 32px var(--shadow); }
.login-card h1 { margin: 0 0 0.2rem; font-size: 1.5rem; }
.login-card input { width: 100%; margin: 1rem 0 0.6rem; }
.logo-mark { width: 56px; height: 56px; border-radius: 16px; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.9rem; box-shadow: 0 8px 20px rgba(54, 101, 243, 0.35); }
.logo-mark .icon { width: 30px; height: 30px; stroke-width: 1.8; }

/* Shell — top and bottom bars get a frosted-glass treatment. */
#topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 0.6rem;
  padding: calc(env(safe-area-inset-top) + 0.75rem) 1rem 0.75rem;
  background: rgba(255, 255, 255, 0.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-weight: 700; font-size: 1.05rem; letter-spacing: -0.015em;
  border-bottom: 1px solid var(--border); }
#tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--border); z-index: 10; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 0.55rem 0 0.4rem; background: none; border: none; color: #8a94a3;
  cursor: pointer; transition: color 0.15s; }
.tab .icon { width: 22px; height: 22px; stroke-width: 1.8; }
.tab span { font-size: 0.62rem; font-weight: 600; letter-spacing: 0.02em; }
.tab.active { color: var(--accent); }
.tab.active .icon { stroke-width: 2.2; }

.view { padding: 0.8rem 0.8rem 5.5rem; max-width: 720px; margin: 0 auto; }

/* Inputs & buttons */
input, textarea, select {
  width: 100%; padding: 0.65rem 0.8rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  font-size: 1rem; margin-bottom: 0.7rem; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); background: var(--panel);
  box-shadow: 0 0 0 3px rgba(54, 101, 243, 0.14);
}
label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--muted);
  margin: 0.15rem 0 0.3rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.65rem 1rem; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 0.95rem; font-weight: 500;
  cursor: pointer; text-decoration: none; text-align: center;
  transition: filter 0.15s, background 0.15s, transform 0.06s; }
.btn .icon { width: 18px; height: 18px; }
.btn:not(:disabled):hover { filter: brightness(0.96); }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; font-weight: 600; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; font-weight: 600; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.wide { flex: 1; width: 100%; }
.btn:disabled { opacity: 0.5; }
.row { display: flex; align-items: center; }
.row.gap { gap: 0.6rem; }
.col { flex: 1; }
.actions { margin-top: 0.4rem; }
.file-btn { position: relative; overflow: hidden; }

/* Cards */
.toolbar { margin-bottom: 0.6rem; }
.cards { display: flex; flex-direction: column; gap: 0.6rem; }
/* On a light background, panels need an edge to separate them from the page. */
.card { display: flex; gap: 0.75rem; background: var(--panel); border-radius: 14px;
  padding: 0.7rem; cursor: pointer; border: 1px solid var(--border);
  box-shadow: 0 1px 2px var(--shadow); transition: box-shadow 0.15s, border-color 0.15s;
  /* No iOS text-selection callout — press-and-hold is the delete gesture on drafts. */
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.card:active { background: var(--panel-2); }
@media (hover: hover) {
  .card:hover { box-shadow: 0 4px 14px var(--shadow); border-color: #cbd3df; }
}
.card img, .card .noimg { width: 72px; height: 72px; border-radius: 10px; object-fit: cover;
  background: var(--panel-2); flex-shrink: 0; display: flex; align-items: center;
  justify-content: center; color: #b0b8c4; }
.card .info { flex: 1; min-width: 0; }
.card .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .sub { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.card .sub .icon { vertical-align: -2px; }
.card .price { font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
/* Payment / payout state on sold cards */
.card .pay { font-weight: 600; }
.card .pay.pay-cleared { color: var(--success); }
.card .pay.pay-hold { color: var(--warn); }
.card .pay.pay-bad { color: var(--danger); }
.card .pay.pay-wait { color: var(--muted); }

/* Status pills — neutral chip with a coloured status dot. align-self keeps the pill
   hugging its own text instead of stretching to the full height of the card. */
.badge { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  padding: 4px 10px; border-radius: 999px; font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.05em; line-height: 1.35; text-transform: uppercase; white-space: nowrap;
  background: var(--panel); color: #4b5563; border: 1px solid var(--border); flex-shrink: 0; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #9ca3af; flex-shrink: 0; }
.badge.Draft::before { background: #9ca3af; }
.badge.Publishing::before { background: var(--warn); }
.badge.Listed::before { background: var(--success); }
.badge.Ended::before { background: #6b7280; }
.badge.Sold::before { background: var(--accent); }
.badge.Error::before { background: var(--danger); }
.badge.sandbox { color: #92400e; border-color: #f3dcb1; background: #fdf6e7; }
.badge.sandbox::before { background: var(--warn); }

/* Editor — styled after eBay's listing form: one white card per section,
   bold section titles, pill buttons, and a sticky action bar. */
.editor-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.ecard { background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 1rem; margin-bottom: 0.8rem; box-shadow: 0 1px 2px var(--shadow); }
.etitle { margin: 0 0 0.8rem; font-size: 1.05rem; font-weight: 700; }
.editor .btn { border-radius: 999px; font-weight: 600; }
.editor input, .editor textarea, .editor select {
  background: var(--panel); border-color: #cdd3dd; border-radius: 10px; }
.editor input:focus, .editor textarea:focus, .editor select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(54, 101, 243, 0.22); }
.editor label { color: #41464e; font-weight: 600; }
.editor label.muted, .editor .muted { color: var(--muted); }
.editor-actions { position: sticky; bottom: calc(4.4rem + env(safe-area-inset-bottom)); z-index: 15;
  background: var(--panel); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.5rem; box-shadow: 0 6px 22px rgba(15, 23, 42, 0.18); margin-top: 0.2rem; }
.editor-actions .btn { margin: 0; }
/* Photos card: the main (first) photo spans the full card width; the rest sit
   below as small thumbs. Everything is a tap-target for the full-screen manager. */
.photo-main { position: relative; margin-bottom: 8px; cursor: pointer; }
.photo-main img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 14px; display: block; }
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; cursor: pointer; }
.photo-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
/* Overlay chips shared by the card and the manager. MAIN = the photo eBay shows in search. */
.is-main { position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, 0.62); color: #fff;
  font-size: 0.6rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; letter-spacing: 0.05em; }
.on-ebay { position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, 0.62); color: #fff;
  font-size: 0.6rem; font-weight: 600; padding: 2px 7px; border-radius: 6px; letter-spacing: 0.03em; }

/* Full-screen photo manager */
body.no-scroll { overflow: hidden; }
.pm { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; }
.pm-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
  padding: calc(env(safe-area-inset-top) + 0.6rem) 1rem 0.6rem;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border); font-weight: 700; font-size: 1.05rem; }
.pm-list { flex: 1; overflow-y: auto; padding: 0.8rem; display: flex; flex-direction: column;
  gap: 0.8rem; width: 100%; max-width: 720px; margin: 0 auto; }
.pm-tile { background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 0.6rem; box-shadow: 0 1px 2px var(--shadow); }
.pm-img { position: relative; }
.pm-img img { width: 100%; height: auto; border-radius: 12px; display: block; background: var(--panel-2); }
.pm-ops { display: flex; gap: 0.4rem; margin-top: 0.6rem; }
.pm-ops button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.3rem;
  padding: 0.55rem 0; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); font-size: 0.78rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.pm-ops button:disabled { opacity: 0.35; }
.pm-ops .pm-del { color: var(--danger); border-color: #f1c7c7; }
.pm-foot { display: flex; gap: 0.6rem; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 0.7rem 0.8rem calc(env(safe-area-inset-bottom) + 0.7rem);
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); }
.suggestions { background: var(--panel); border-radius: var(--radius); margin: -0.3rem 0 0.7rem;
  overflow: hidden; border: 1px solid var(--border); box-shadow: 0 2px 6px var(--shadow); }
.suggestions .sug { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); cursor: pointer;
  font-size: 0.88rem; }
.suggestions .sug:last-child { border-bottom: none; }
.suggestions .sug:active { background: var(--panel-2); }
.error { color: var(--danger); min-height: 1.2em; font-size: 0.85rem; }
.error-box { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; border-radius: var(--radius);
  padding: 0.6rem 0.8rem; margin-bottom: 0.7rem; font-size: 0.86rem; white-space: pre-wrap; }

/* eBay messages */
.chat-msg { cursor: default; }
.chat-body { margin-top: 6px; font-size: 0.92rem; white-space: pre-wrap; }
.chat-replies { margin-top: 6px; }
.chat-reply { color: var(--muted); font-size: 0.85rem; padding: 0.35rem 0.5rem; margin-top: 4px;
  background: var(--panel-2); border-radius: 8px; white-space: pre-wrap; }
.chat-input { margin-bottom: 0; }
.chat-media { margin-top: 6px; }
.chat-att { width: 84px; height: 84px; object-fit: cover; border-radius: 8px;
  margin: 0 6px 0 0; border: 1px solid var(--border); }
.chat-attach { flex: 0 0 auto; }
.chat-msg .badge { vertical-align: middle; margin-left: 0.3rem; }

/* Panels / status */
.panel { background: var(--panel); border-radius: 16px; padding: 1rem;
  border: 1px solid var(--border); box-shadow: 0 1px 2px var(--shadow); }
.panel h2 { margin: 0 0 0.7rem; font-size: 1.05rem; }
.status-lines div { padding: 0.3rem 0; font-size: 0.92rem; }
.status-lines b { color: var(--muted); font-weight: 500; margin-right: 0.4rem; }

/* FAB + toast */
.fab { position: fixed; right: 1.1rem; bottom: calc(4.3rem + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: none; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(54, 101, 243, 0.4); cursor: pointer; z-index: 20; }
.fab .icon { width: 26px; height: 26px; stroke-width: 2.2; }
.toast { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(5.5rem + env(safe-area-inset-bottom)); background: rgba(17, 24, 39, 0.92);
  color: #fff; padding: 0.6rem 1.1rem; border-radius: 999px; font-size: 0.9rem; z-index: 50;
  max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(17, 24, 39, 0.25); }

/* Upload destination sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.sheet { background: var(--panel); border-radius: 20px 20px 0 0; padding: 18px;
  width: 100%; max-width: 540px; max-height: 80vh; overflow: auto;
  padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.sheet-backdrop.hidden { display: none; }
