:root {
  --bg: #0b0c10;
  --card: #14161d;
  --text: #f0f0f5;
  --muted: #9a9eac;
  --accent: #6ccff6;
  --danger: #ff6b6b;
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ───────────────────── Feed (mobile-first, reels-style) ───────────────── */
.feed-body {
  height: 100vh;
  width: 100%;
  display: flex;
  justify-content: center;
  background: #000;
}

/* Phone-width column always — on a real phone this just fills the screen;
   on desktop it's centered like viewing a phone. No extra "desktop layout"
   is built, by design. */
.phone-frame {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  position: relative;
  background: var(--bg);
  overflow: hidden;
}

.feed {
  height: 100%;
  width: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }

.scroll-card {
  position: relative;
  height: 100%;
  width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scroll-card .card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Flat 30% dim across the whole image so bright/light-colored generated
     images don't wash out the tag/title text — independent of the bottom
     fade gradient below, which only covers the lower portion of the card. */
  filter: brightness(0.7);
}

.scroll-card .card-image-fade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 55%;
  background: linear-gradient(to bottom, rgba(11,12,16,0) 0%, rgba(11,12,16,0.55) 35%, rgba(11,12,16,0.97) 70%, var(--bg) 100%);
}

.scroll-card .card-content {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 18px 74px 28px 22px;
  z-index: 2;
}

.card-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(108, 207, 246, 0.12);
  border: 1px solid rgba(108, 207, 246, 0.35);
  border-radius: 999px;
  padding: 5px 12px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 10px;
}

.card-summary {
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--text);
  margin: 0 0 16px;
}

.card-application-box {
  background: rgba(255,255,255,0.06);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
}

.card-application-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 4px;
}

.card-application-text {
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  margin: 0;
}

.card-source {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.card-source-name { opacity: 0.7; }
.card-source-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  font-size: 12px;
  background: rgba(108, 207, 246, 0.12);
  border: 1px solid rgba(108, 207, 246, 0.4);
  border-radius: 999px;
  padding: 5px 12px;
}
.card-source-link:active { background: rgba(108, 207, 246, 0.22); }

.top-bar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  gap: 8px;
}
.settings-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
}

.card-actions {
  position: absolute;
  right: 14px;
  bottom: 140px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.card-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.card-action-btn .icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0,0,0,0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: transform 0.15s ease;
}
.card-action-btn.active .icon { background: rgba(108, 207, 246, 0.25); }
.card-action-btn:active .icon { transform: scale(0.88); }
.card-action-btn.liked .icon { color: #ff5d7a; }
.card-action-btn.wishlisted .icon { color: var(--accent); }

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 20px;
}

/* ───────────────────── Paywall card (in-feed, free-tier limit hit) ─────── */
.paywall-card {
  height: 100%;
  width: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.paywall-content {
  text-align: center;
  padding: 32px;
  max-width: 320px;
}
.paywall-icon { font-size: 40px; margin-bottom: 14px; }
.paywall-content h2 { font-size: 20px; margin: 0 0 8px; }
.paywall-content p { margin: 0 0 22px; }
.paywall-btn {
  display: inline-block;
  background: var(--accent);
  color: #07131a;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 30px;
  border-radius: 10px;
  text-decoration: none;
}

/* ───────────────────── Flag modal ──────────────────────────────────────── */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-box {
  width: 100%;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 20px 20px 24px;
}
.modal-box h3 { font-size: 15px; margin: 0 0 12px; }
.modal-box textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #1c1f29;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.modal-actions button {
  width: auto;
  margin: 0;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13.5px;
}
.modal-actions #flag-submit {
  border: none;
  background: var(--accent);
  color: #07131a;
  font-weight: 700;
  cursor: pointer;
}
.modal-actions #flag-submit:disabled { opacity: 0.6; cursor: not-allowed; }

/* ───────────────────── Auth ─────────────────────────────────────────── */
.auth-body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 26px;
}
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.wide-card { max-width: 460px; }
.success { color: #6cf6a6; font-size: 13px; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.12);
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0 4px;
}
.plan-card {
  background: #1c1f29;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}
.plan-card.featured { border-color: var(--accent); background: rgba(108, 207, 246, 0.08); }
.plan-name { font-weight: 700; margin-bottom: 6px; font-size: 14px; }
.plan-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--accent);
  color: #07131a;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 4px;
  vertical-align: middle;
}
.plan-price { font-size: 24px; font-weight: 800; margin-bottom: 14px; }
.plan-price span { font-size: 13px; font-weight: 400; color: var(--muted); }
.plan-card button {
  margin-top: 0;
  padding: 10px;
  font-size: 13.5px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.field-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1c1f29;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 12px;
  font-size: 13.5px;
  cursor: pointer;
}
.field-chip input { width: auto; margin: 0; }
.field-chip:has(input:checked) {
  border-color: var(--accent);
  background: rgba(108, 207, 246, 0.1);
}

.settings-subhead { font-size: 14px; margin: 22px 0 0; color: var(--muted); }
.settings-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
}
.settings-links a { color: var(--accent); font-size: 13px; text-decoration: none; }
.settings-links form { margin: 0; }
.settings-links button { width: auto; margin: 0; }

/* ───────────────────── Forms (shared) ──────────────────────────────── */
form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 14px 0 6px;
}
form input, form select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #1c1f29;
  color: var(--text);
  font-size: 15px;
}
form button {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #07131a;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
form button:disabled { opacity: 0.5; cursor: not-allowed; }
.ghost-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.error { color: var(--danger); font-size: 13px; }

/* ───────────────────── Admin ───────────────────────────────────────── */
.admin-body {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.admin-header h1 { font-size: 20px; margin: 0; }

.admin-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}
.stat {
  background: var(--card);
  border-radius: 12px;
  padding: 12px 16px;
  min-width: 110px;
}
.stat-num { display: block; font-size: 20px; font-weight: 700; }
.stat-label { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.admin-panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.admin-panel h2 { font-size: 16px; margin: 0 0 6px; }

/* ── Analytics ─────────────────────────────────────────────────────────── */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-head h2 { margin: 0; }
.panel-head button { width: auto; margin: 0; }

.analytics-head {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 22px 0 10px;
}
.analytics-head:first-child { margin-top: 8px; }
.analytics-head .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }

.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 78px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.bar-track {
  height: 10px;
  background: #1c1f29;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s ease;
}
.bar-value { text-align: right; font-size: 12px; }

/* ── Collapsible panel (Users) ─────────────────────────────────────────── */
.panel-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.panel-summary::-webkit-details-marker { display: none; }
.panel-summary::before {
  content: "▸";
  color: var(--muted);
  font-size: 13px;
  transition: transform 0.15s ease;
}
details[open] > .panel-summary::before { transform: rotate(90deg); }
.panel-summary h2 { margin: 0; }

.search-input {
  width: 100%;
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #1c1f29;
  color: var(--text);
  font-size: 14px;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
}
#user-load-more { width: 100%; margin-top: 10px; }

.online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6cf6a6;
  margin-right: 5px;
  vertical-align: middle;
}

@media (max-width: 560px) {
  .bar-row { grid-template-columns: 110px 1fr 66px; font-size: 12px; }
}

.job-status { margin-top: 18px; }
.progress-bar {
  height: 8px;
  background: #1c1f29;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.job-log {
  max-height: 140px;
  overflow-y: auto;
  font-size: 11px;
  color: var(--muted);
  white-space: pre-wrap;
  margin-top: 10px;
}

.scroll-list { display: flex; flex-direction: column; gap: 8px; }
.scroll-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1c1f29;
  border-radius: 10px;
  padding: 8px 10px;
}
.scroll-row img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.scroll-row .row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.scroll-row .row-title { flex: 1; font-size: 13px; }
.scroll-row .row-field { font-size: 11px; color: var(--muted); }
.scroll-row .row-reason { font-size: 12px; color: var(--text); font-style: italic; }
.scroll-row .row-resolved { color: var(--accent); font-style: normal; }
.scroll-row .row-source-link { font-size: 11px; color: var(--accent); text-decoration: none; width: fit-content; }
.scroll-row .row-source-link:hover { text-decoration: underline; }
.scroll-row button {
  width: auto;
  margin: 0;
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

/* "Manage scrolls" rows are clickable (opens the full-screen preview) —
   the Delete button inside stops that click from bubbling, see admin.js. */
#scroll-list.scroll-list .scroll-row { cursor: pointer; }
#scroll-list.scroll-list .scroll-row:active { background: #23273380; }

.field-count-bulk {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.field-count-bulk input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #1c1f29;
  color: var(--text);
  font-size: 14px;
}
.field-count-bulk button { width: auto; margin: 0; padding: 10px 16px; font-size: 13px; }

.field-count-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #1c1f29;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.field-count-row input {
  width: 64px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #14161d;
  color: var(--text);
  font-size: 14px;
  text-align: center;
}

/* ───────────────────── Admin scroll preview (full-screen) ──────────────── */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.preview-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-fade {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 55%;
  background: linear-gradient(to bottom, rgba(11,12,16,0) 0%, rgba(11,12,16,0.55) 35%, rgba(11,12,16,0.97) 70%, var(--bg) 100%);
}

/* ───────────────────── Library (liked / saved / flagged) ──────────────── */
.library-body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background: #000;
}
.library-frame {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--bg);
  padding: 18px 16px 40px;
  position: relative;
}
.library-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.library-header h1 { font-size: 17px; margin: 0; }

.library-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.library-tab {
  flex: 1;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: #1c1f29;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.library-tab.active {
  border-color: var(--accent);
  background: rgba(108, 207, 246, 0.1);
  color: var(--text);
}

.library-list { display: flex; flex-direction: column; gap: 8px; }
.library-row img { width: 52px; height: 52px; }
.library-row .row-title { font-size: 14px; font-weight: 600; }
