/* UGCpublisher — dark, calm tones, red accent */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1115;
  --bg-soft: #141821;
  --surface: #181d27;
  --surface-2: #1f2531;
  --border: #262d3a;
  --text: #e8eaef;
  --text-dim: #98a1b3;
  --text-faint: #6b7485;
  --accent: #e5484d;
  --accent-soft: rgba(229, 72, 77, 0.14);
  --ok: #58b26a;
  --ok-soft: rgba(88, 178, 106, 0.14);
  --warn: #d8a015;
  --warn-soft: rgba(216, 160, 21, 0.14);
  --radius: 12px;
}

html { -webkit-text-size-adjust: 100%; height: 100%; }
[hidden] { display: none !important; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  height: 100%;
}
/* app shell: fixed header/tabs, content scrolls internally so the Publish bar
   can pin to the visible bottom even inside iframes (artifact viewer, iOS) */
#app { height: 100dvh; display: flex; flex-direction: column; min-height: 0; }
.topbar, .tabs { flex: none; width: 100%; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-sub { color: var(--text-dim); font-size: 13px; margin-top: -8px; }
.mock-note { color: var(--text-faint); font-size: 12px; text-align: center; }

/* ---------- brand / topbar ---------- */
.brand { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
.brand.big { font-size: 22px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; max-width: 980px; margin: 0 auto;
}
.topbar-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.balance {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 7px 14px; font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums;
  display: flex; flex-direction: column; gap: 2px; align-items: flex-end;
}
.bal-row b { color: var(--text); font-weight: 600; margin-left: 6px; }
.bal-row.topup { color: var(--accent); font-weight: 600; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; padding: 0 20px 14px; max-width: 980px; margin: 0 auto; }
.tab {
  background: none; border: 1px solid transparent; color: var(--text-dim);
  font: inherit; font-weight: 600; padding: 7px 16px; border-radius: 999px; cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--text); border-color: var(--border); }
.badge {
  background: var(--accent); color: #fff; font-size: 11px; border-radius: 999px;
  padding: 1px 7px; margin-left: 4px; vertical-align: 1px;
}

/* ---------- layout / cards ---------- */
.view { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view-inner { max-width: 980px; margin: 0 auto; padding: 2px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card h2 { font-size: 14px; font-weight: 600; color: var(--text-dim); margin-bottom: 12px; letter-spacing: 0.01em; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }

/* ---------- chips (groups) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

/* ---------- dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  padding: 34px 16px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 26px; color: var(--accent); margin-bottom: 6px; }
.dz-hint { color: var(--text-faint); font-size: 13px; margin-top: 4px; }
.file-loaded { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.file-meta { display: flex; align-items: center; gap: 12px; }
.file-icon { font-size: 22px; }
.file-name { font-weight: 600; }
.file-sub { color: var(--text-dim); font-size: 13px; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.field + .field { margin-top: 12px; }
.field > span { font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 8px; }
input[type=text], input[type=password], input[type=number], textarea, select {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font: inherit; padding: 10px 12px; width: 100%;
  -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
.count { position: absolute; right: 2px; top: 0; font-size: 12px; color: var(--text-faint); font-style: normal; }
.count.over { color: var(--accent); font-weight: 700; }
.token-btn {
  background: var(--accent-soft); color: var(--accent); border: none; border-radius: 6px;
  font: inherit; font-size: 12px; font-weight: 600; padding: 2px 8px; cursor: pointer;
}
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text-dim); }
.hint { color: var(--text-faint); font-size: 13px; margin-top: 8px; }
.hint.center { text-align: center; }

/* ---------- segmented (uniques) ---------- */
.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  background: none; border: none; color: var(--text-dim); font: inherit; font-weight: 600;
  padding: 7px 16px; border-radius: 8px; cursor: pointer;
}
.seg button.active { background: var(--accent); color: #fff; }
.uniq-custom { max-width: 110px; margin-left: 10px; }

/* ---------- item grid ---------- */
.val-summary { font-size: 13px; color: var(--text-dim); }
.item-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px; margin-top: 12px;
}
.item-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.item-card.removed { opacity: 0.35; }
.thumb { position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 44px; }
.thumb .glyph { filter: saturate(0.9); }
.thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: transparent; }
.remove-btn {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(15,17,21,0.7); color: var(--text-dim); border: none; cursor: pointer; font-size: 14px; line-height: 1;
}
.remove-btn:hover { color: var(--accent); }
.type-tag {
  position: absolute; left: 8px; bottom: 8px; background: rgba(15,17,21,0.75);
  border-radius: 6px; font-size: 11px; padding: 3px 7px; color: var(--text-dim);
}
.item-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.item-name { position: relative; }
.item-name input { padding: 7px 9px; font-size: 14px; }
.item-name .count { top: -16px; }
.item-row { display: flex; gap: 6px; }
.item-row select { font-size: 13px; padding: 6px 8px; color: var(--text-dim); background-position: right 8px center; }
.val {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px; border-radius: 7px; padding: 5px 9px;
}
.val.pending { background: var(--bg-soft); color: var(--text-dim); }
.val.ok { background: var(--ok-soft); color: var(--ok); }
.val.warn { background: var(--warn-soft); color: var(--warn); }
.val.err { background: var(--accent-soft); color: var(--accent); }
.spinner {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  border: 2px solid var(--border); border-top-color: var(--text-dim);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; border-radius: 10px; padding: 11px 20px; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { transform: scale(0.98); }
.btn.ghost { background: none; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.wide { width: 100%; }

/* ---------- publish button (in topbar) ---------- */
.topbar .btn.primary { padding: 9px 22px; font-size: 15px; box-shadow: 0 2px 12px rgba(229, 72, 77, 0.35); }

/* ---------- status view ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
#batches-list { display: flex; flex-direction: column; gap: 14px; }
.stage-chip {
  background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600;
  border-radius: 999px; padding: 4px 12px; white-space: nowrap;
}
.stage-chip.done { background: var(--ok-soft); color: var(--ok); }
.progress { height: 6px; background: var(--bg-soft); border-radius: 999px; margin: 14px 0 10px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width .5s ease; }
.progress-fill.done { background: var(--ok); }
.ab-counts { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.ab-counts b { color: var(--text); font-variant-numeric: tabular-nums; }
.status-list { display: flex; flex-direction: column; }
.status-row {
  display: flex; align-items: center; gap: 12px; padding: 9px 2px;
  border-top: 1px solid var(--border); font-size: 14px;
}
.status-row .mini-thumb {
  width: 34px; height: 34px; border-radius: 8px; flex: none; position: relative;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.status-row .s-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-row .s-err { color: var(--accent); font-size: 12.5px; }
.pill { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.dim { background: var(--bg-soft); color: var(--text-dim); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }

/* ---------- history ---------- */
.history { display: flex; flex-direction: column; }
.hist-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 2px; border-top: 1px solid var(--border);
}
.hist-row:first-child { border-top: none; }
.hist-name { font-weight: 600; font-size: 14px; }
.hist-sub { color: var(--text-faint); font-size: 12.5px; }

/* ---------- mobile ---------- */
@media (max-width: 480px) {
  .view-inner { padding: 0 12px 20px; }
  .topbar { padding: 12px 14px; }
  .tabs { padding: 0 14px 12px; }
  .item-grid { grid-template-columns: repeat(2, 1fr); }
  .thumb { font-size: 36px; }
  .card { padding: 14px; }
}
