:root {
  --bg: #111;
  --card: #1c1c1c;
  --line: #2a2a2a;
  --text: #eee;
  --muted: #888;
  --faint: #555;
  --accent: #ffcb05;
  --accent-ink: #111;
  --new: #ffd866;
  --ok: #4cd37a;
  --err: #ff6b5a;
  --warn: #ffb347;
  --tabs-h: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(17,17,17,.94);
  backdrop-filter: blur(6px);
}
.topbar h1 { margin: 0; font-size: 20px; }
.net { font-size: 11px; color: var(--err); border: 1px solid var(--err); border-radius: 10px; padding: 1px 8px; }

main { max-width: 520px; margin: 0 auto; padding: 0 12px 16px; }

/* ---------- collections ---------- */
.set {
  background: var(--card); border-radius: 12px; padding: 0 12px; margin-bottom: 10px;
}
.set-head {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 12px 0; cursor: pointer;
}
.set-head .t { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; font-size: 15px; }
.set-head .when { color: var(--muted); font-size: 11px; font-weight: 400; white-space: nowrap; }
.set-head .when.new { color: var(--new); font-weight: 700; }
.set-head .d { color: var(--muted); font-size: 12px; margin-top: 2px; display: flex; justify-content: space-between; gap: 8px; }
.set-head .caret { transition: transform .15s; display: inline-block; }
.set.open .set-head .caret { transform: rotate(90deg); }
.set-body { display: none; padding-bottom: 4px; }
.set.open .set-body { display: block; }

.prod { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.prod.dim .img, .prod.dim .name-text, .prod.dim .chips { opacity: .45; }
.img {
  width: 52px; height: 52px; border-radius: 8px; flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #111; text-align: center; line-height: 1.1;
  background: #222;
}
.img img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.img.t-pc_etb { background: linear-gradient(135deg, #e3350d, #ffcb05); }
.img.t-etb { background: linear-gradient(135deg, #3b4cca, #8ec5ff); }
.img.t-upc { background: linear-gradient(135deg, #6b3fa0, #ffd866); }
.img.t-upc_random { background: linear-gradient(135deg, #2b2b6b, #b48cff); color: #fff; }
.img.has-photo { background: #fff; }

.info { flex: 1; min-width: 0; }
.name { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; font-weight: 600; }
.name-text { overflow-wrap: anywhere; }
.price {
  display: inline-block; color: var(--muted); font-size: 12px; margin: 3px 0 7px;
  background: none; border: 0; padding: 0; text-align: left; cursor: pointer;
}
.price .lim { color: var(--text); border-bottom: 1px dashed var(--faint); }
.price .custom { color: var(--accent); }

.limit-edit { display: flex; gap: 6px; align-items: center; margin: 4px 0 8px; flex-wrap: wrap; }
.limit-edit input {
  width: 92px; background: #0b0b0b; color: var(--text); border: 1px solid #444; border-radius: 8px;
  padding: 6px 8px; font-size: 16px; /* 16px stops iOS zoom */
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 12px; padding: 4px 10px; font-size: 11px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); border: 1px solid transparent;
  cursor: pointer; min-height: 26px;
}
.chip.off { background: var(--line); color: var(--muted); }
.chip.na { background: transparent; color: var(--faint); border: 1px dashed #444; text-decoration: line-through; cursor: default; }
.chip .dot, .legend .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; opacity: .8; }

.bought-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.pill { border-radius: 10px; padding: 2px 9px; font-size: 11px; font-weight: 700; background: var(--ok); color: #0b2213; }
.alias-edit input { width: 100%; max-width: 260px; }
.linkbtn.aliases { display: block; text-align: left; margin-top: 4px; color: var(--muted); }
.linkbtn { background: none; border: 0; color: var(--accent); font-size: 12px; padding: 4px 2px; cursor: pointer; text-decoration: underline; }

/* toggle switch */
.tog {
  width: 42px; height: 24px; border-radius: 12px; background: #444; position: relative; flex: none;
  border: 0; padding: 0; cursor: pointer; transition: background .15s;
}
.tog::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #888; transition: left .15s, background .15s;
}
.tog[aria-checked="true"] { background: var(--accent); }
.tog[aria-checked="true"]::after { left: 21px; background: #111; }
.tog:disabled { opacity: .4; cursor: default; }

.legend { color: var(--muted); font-size: 12px; margin: 14px 4px; }
.legend .chip { cursor: default; padding: 2px 8px; min-height: 0; }

/* ---------- alerts screen ---------- */
.card { background: var(--card); border-radius: 12px; padding: 4px 12px 8px; margin-bottom: 10px; }
.lbl { color: var(--muted); font-size: 12px; margin: 10px 0 4px; text-transform: none; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.lbl + .row, .lbl + div > .row:first-child { border-top: 0; }
.row .sub { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; padding: 6px 0; }
.err { color: var(--err); font-size: 12px; }

.btn {
  text-decoration: none; display: inline-block;
  border: 1px solid #444; background: #262626; border-radius: 10px; padding: 9px 14px;
  font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0; }
.text-in {
  flex: 1; min-width: 0; background: #0b0b0b; color: var(--text); border: 1px solid #444; border-radius: 10px;
  padding: 8px 10px; font-size: 16px;
}

.alert { padding: 10px 0; border-top: 1px solid var(--line); }
.lbl + div > .alert:first-child { border-top: 0; }
.alert .a-top { display: flex; justify-content: space-between; gap: 8px; }
.alert .a-title { font-weight: 600; }
.alert .a-age { color: var(--muted); font-size: 11px; white-space: nowrap; }
.alert .a-body { color: #ccc; font-size: 13px; margin: 2px 0; overflow-wrap: anywhere; }
.alert .a-meta { color: var(--muted); font-size: 11px; }
.alert .a-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.tag { display: inline-block; border-radius: 8px; padding: 0 6px; font-size: 10px; font-weight: 700; background: var(--line); color: #ccc; margin-right: 4px; }
.tag.invite { background: var(--accent); color: #111; }
.tag.warn { background: #4a3410; color: var(--warn); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status.ok::before { background: var(--ok); }
.status.error::before, .status.blind::before { background: var(--err); }
.status.not_configured::before { background: var(--faint); }

/* ---------- tabs ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #151515; border-top: 1px solid #333;
}
.tab { flex: 1; background: none; border: 0; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.tab.active { color: var(--accent); }

/* ---------- login / toast ---------- */
.login { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.login-box h2 { margin: 0 0 6px; }
.login-box input { width: 100%; background: #0b0b0b; color: var(--text); border: 1px solid #444; border-radius: 10px; padding: 12px; font-size: 16px; }
.login-box .btn { width: 100%; padding: 12px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom)); z-index: 40;
  background: #2b2b2b; color: var(--text); border: 1px solid #444; border-radius: 10px;
  padding: 9px 14px; font-size: 13px; max-width: calc(100% - 32px); text-align: center;
}
.toast.error { border-color: var(--err); color: #ffd2cc; }

.loading { color: var(--muted); padding: 20px 4px; }
