/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:        #f6f5f2;
  --surface:   #ffffff;
  --ink:       #1b1a17;
  --ink-soft:  #6a6862;
  --line:      #e7e4dd;
  --accent:    #ff4d5e;   /* warm coral */
  --accent-2:  #12b3a6;   /* teal */
  --accent-ink:#ffffff;
  --amber:     #f5a524;
  --green:     #17c26b;
  --shadow:    0 1px 2px rgba(20,18,14,.05), 0 8px 24px rgba(20,18,14,.06);
  --shadow-lg: 0 12px 40px rgba(20,18,14,.14);
  --r:  14px;
  --r-sm: 10px;
  --maxw: 1120px;
  font-synthesis: none;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#141311; --surface:#1e1c19; --ink:#f4f1ea; --ink-soft:#a5a199;
    --line:#302d28; --accent-ink:#fff;
    --shadow:0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg:0 12px 40px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; letter-spacing: -.02em; }
[hidden] { display: none !important; }

/* ── Buttons / inputs ──────────────────────────────────── */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--ink); transition: .15s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 10px rgba(255,77,94,.3); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { border-color: var(--line); background: var(--surface); }
.btn-ghost:hover { border-color: var(--ink-soft); }
.btn-block { width: 100%; }
.btn-star { background: var(--surface); border-color: var(--line); font-size: 13px; padding: 8px; }
.btn-star:hover { border-color: var(--accent); color: var(--accent); }
.btn-star.is-confirm { background: var(--amber); color: #171512; border-color: var(--amber); }
.btn-star.is-confirm:hover { color: #171512; }
.vcard.is-picked .btn-star { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: .6; cursor: default; }
.linkish { background: none; border: 0; color: var(--ink-soft); font-size: 13px; cursor: pointer; text-decoration: underline; padding: 6px; }

.input, .select {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 13px; font-size: 14px; background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,77,94,.13); }

/* ── Gate ──────────────────────────────────────────────── */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(255,77,94,.12), transparent 60%); }
.gate-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 32px 28px; text-align: center;
}
.gate-logo { font-size: 40px; }
.gate-title { font-size: 30px; margin-top: 6px; }
.gate-sub { color: var(--ink-soft); margin: 6px 0 22px; }
.field { display: block; text-align: left; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; color: var(--ink-soft); font-size: 12px; margin-top: 5px; }
.gate-error { color: var(--accent); font-size: 13px; margin: 12px 0 0; }

/* ── Topbar ────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-mark { font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.pill-live { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.pill-off  { color: var(--ink-soft); background: var(--line); }

/* ── Layout ────────────────────────────────────────────── */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 24px 20px 80px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.section { margin-top: 34px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-head h2 { font-size: 19px; }
.count { font-size: 13px; font-weight: 700; color: var(--ink-soft); background: var(--line); border-radius: 999px; padding: 2px 10px; }
.section-sub { color: var(--ink-soft); font-size: 13px; margin: -6px 0 16px; }
.section-sub b { color: var(--ink); }

/* ── Category review queue ─────────────────────────────── */
.cat-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.btn-cat { background: var(--surface); border-color: var(--line); font-size: 12px; padding: 8px 6px; }
.btn-cat:hover { border-color: var(--accent-2); color: var(--accent-2); }
.btn-cat[data-cat="Renters"]:hover { border-color: var(--accent-2); color: var(--accent-2); }
.btn-cat.pending { opacity: .6; }
#review-section .vcard { border-color: color-mix(in srgb, var(--amber) 40%, var(--line)); }
#review-grid { grid-template-columns: minmax(0, 240px); }   /* one card at a time */

/* ── Ad-status control (library card button) ───────────── */
.btn-adstate { font-size: 12px; padding: 8px 6px; font-weight: 700; border: 1px solid var(--line); background: var(--surface); }
.btn-adstate.is-status { cursor: default; }
.btn-adstate.state-send:hover { border-color: var(--accent); color: var(--accent); }
.btn-adstate.is-confirm { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-adstate.state-confirmed { background: color-mix(in srgb, var(--accent-2) 14%, transparent); color: var(--accent-2); border-color: transparent; }
.btn-adstate.state-confirmed:hover { border-color: var(--accent-2); }
.btn-adstate.state-running { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); border-color: transparent; }
.btn-adstate.state-ranoff  { background: var(--line); color: var(--ink-soft); border-color: transparent; }
.btn-adstate.state-notrun  { background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); border-color: transparent; }
.vcard.is-picked { border-color: color-mix(in srgb, var(--accent-2) 40%, var(--line)); }

/* ── Load more ─────────────────────────────────────────── */
.load-more { display: block; margin: 20px auto 0; min-width: 220px; }

/* ── Tabs ──────────────────────────────────────────────── */
.tabs { max-width: var(--maxw); margin: 6px auto -10px; padding: 12px 20px 0; display: flex; gap: 6px; }
.tab { appearance: none; border: 0; background: transparent; color: var(--ink-soft);
  font-size: 14px; font-weight: 700; padding: 8px 15px; border-radius: 999px; cursor: pointer; }
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.synced { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.filters-ads { grid-template-columns: 2fr 1fr; }
.ctable code { font-size: 12px; background: var(--line); padding: 1px 5px; border-radius: 5px; }

/* ── Category editor on library cards ──────────────────── */
.cat-edit { width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--ink); background: var(--surface); cursor: pointer; }
.cat-edit:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 15%, transparent); }

/* ── Priority star on picks ────────────────────────────── */
.p-star { position: absolute; bottom: 8px; left: 8px; width: 28px; height: 28px; border-radius: 999px;
  border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.p-star:hover { background: rgba(0,0,0,.8); }
.p-star.on { background: var(--amber); color: #171512; }
.pcard.is-priority { border-color: var(--amber); box-shadow: 0 0 0 2px color-mix(in srgb, var(--amber) 45%, transparent), var(--shadow); }

/* ── Creators table ────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.ctable { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 480px; }
.ctable th, .ctable td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ctable th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); font-weight: 700; }
.ctable td.num, .ctable th.num { text-align: right; font-variant-numeric: tabular-nums; }
.ctable td.strong { font-weight: 800; }
.ctable tbody tr:last-child td { border-bottom: 0; }
.ctable tbody tr:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }

/* ── Drop a link ───────────────────────────────────────── */
.drop { padding: 22px; }
.drop-head h2 { font-size: 20px; }
.drop-head p { color: var(--ink-soft); margin: 6px 0 16px; max-width: 60ch; }
.drop-inputs { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 10px; }
.drop-preview { margin-top: 14px; display: flex; gap: 12px; align-items: center;
  border: 1px dashed var(--line); border-radius: var(--r-sm); padding: 12px; }
.drop-preview img { width: 64px; height: 84px; object-fit: cover; border-radius: 8px; background: var(--line); }
.drop-preview .dp-text { font-size: 13px; color: var(--ink-soft); }
.drop-preview .dp-text b { color: var(--ink); }
.drop-preview.ok { border-style: solid; border-color: color-mix(in srgb, var(--green) 45%, var(--line)); background: color-mix(in srgb, var(--green) 8%, transparent); }
.dp-ok { color: var(--green); font-weight: 600; font-size: 14px; }

/* ── Rail (up next) ────────────────────────────────────── */
.rail { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 12px; scroll-snap-type: x mandatory; }
.rail::-webkit-scrollbar { height: 8px; }
.rail::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.rail-empty { color: var(--ink-soft); font-size: 14px; padding: 20px; border: 1px dashed var(--line); border-radius: var(--r); width: 100%; text-align: center; }
.pcard {
  scroll-snap-align: start; flex: 0 0 230px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; position: relative;
}
.pcard.is-queued { border-color: var(--amber); }
.pthumb { display: block; aspect-ratio: 3/4; background: linear-gradient(135deg,#2a2723,#171512); position: relative; }
.pthumb img { width: 100%; height: 100%; object-fit: cover; }
.pcard .p-status { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; }
.pcard.is-queued .p-status { background: var(--amber); color: #171512; }
.pbody { padding: 10px 12px 12px; }
.pbody .p-creator { font-weight: 700; font-size: 13px; }
.pbody .p-note { font-size: 12px; color: var(--ink-soft); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-remove { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 999px;
  border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }
.p-remove:hover { background: var(--accent); }

/* ── Filters ───────────────────────────────────────────── */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 10px; margin-bottom: 18px; }

/* ── Grid ──────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.grid-empty { color: var(--ink-soft); text-align: center; padding: 40px; }
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; transition: transform .12s, box-shadow .12s; }
.vcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.vthumb { position: relative; display: block; aspect-ratio: 3/4;
  background: linear-gradient(135deg,#2a2723,#171512); overflow: hidden; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb-ph { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255,255,255,.5); font-size: 26px; }
.vbadge { position: absolute; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; }
.vbadge-cat { top: 8px; left: 8px; background: rgba(0,0,0,.6); color: #fff; }
.vbadge-live { top: 8px; right: 8px; background: var(--green); color: #06301b; }
.vbody { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 9px; }
.vmeta { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.vcreator { font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcode { font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.vstats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; font-size: 12px; color: var(--ink-soft); }
.vstats .stat b { color: var(--ink); font-weight: 700; }

/* ── Toast ─────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 50; max-width: 90vw; }
.toast.err { background: var(--accent); color: #fff; }

/* ── Skeleton ──────────────────────────────────────────── */
.skeleton { position: relative; overflow: hidden; background: var(--line); }
.skeleton::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent);
  transform: translateX(-100%); animation: sk 1.3s infinite; }
@keyframes sk { 100% { transform: translateX(100%); } }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 760px) {
  .drop-inputs { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
}
