/* ============== reset ============== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(52, 211, 153, 0.06), transparent 60%),
    radial-gradient(800px 400px at 100% 0%, rgba(99, 102, 241, 0.04), transparent 50%),
    var(--bg);
  min-height: 100vh;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
  border-radius: 0;
}
button { background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea {
  background: none;
  border: 0;
  outline: none;
}

a { color: inherit; }

::selection { background: var(--accent-dim); color: var(--text); }

/* ============== layout ============== */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============== header ============== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  background: rgba(14, 17, 22, 0.85);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
  gap: var(--space-6);
}

.app-header h1 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.app-header h1::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  margin-right: var(--space-2);
  transform: translateY(1px);
}

.app-header h1 .version {
  color: var(--text-faint);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0;
}

.tabs {
  display: flex;
  gap: var(--space-1);
  margin-left: var(--space-4);
}

.tab {
  color: var(--text-muted);
  padding: 7px var(--space-4);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  transition: background 120ms ease, color 120ms ease;
  letter-spacing: -0.005em;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active {
  color: var(--text);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.status-pill {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  letter-spacing: 0.01em;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}

.status-pill.ok .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.status-pill.err .dot { background: var(--danger); }

/* ============== panels ============== */

.panel {
  display: none;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-12) var(--space-6) var(--space-16);
}
.panel.active { display: block; }

.panel > h2 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-2);
}

.panel > .panel-sub {
  color: var(--text-muted);
  margin: 0 0 var(--space-8);
  font-size: 14px;
}

/* ============== buttons ============== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-weight: 500;
  font-size: 13px;
  padding: 0 var(--space-4);
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 60ms ease, box-shadow 120ms ease;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: var(--ring-accent);
}
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.primary.copied {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.btn.lg { height: 44px; padding: 0 var(--space-5); font-size: 14px; }

.btn.ghost {
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
}
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn.ghost.danger:hover:not(:disabled) { color: var(--danger); }

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-strong), 0 1px 0 var(--bg);
  border-radius: 4px;
  color: var(--text-muted);
  letter-spacing: 0;
}

/* ============== form ============== */

.vsl-form {
  display: grid;
  grid-template-columns: 1fr 220px auto;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.vsl-form input {
  background: transparent;
  height: 44px;
  padding: 0 var(--space-4);
  font-size: 14px;
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: box-shadow 120ms ease;
}
.vsl-form input::placeholder { color: var(--text-faint); }
.vsl-form input:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.vsl-form input:focus { box-shadow: inset 0 0 0 1px var(--accent), var(--ring-focus); }

.vsl-form .btn {
  height: 44px;
  padding: 0 var(--space-6);
  font-size: 14px;
}

/* ============== chip filter ============== */

.chips {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.chip {
  background: transparent;
  color: var(--text-muted);
  padding: 5px var(--space-4);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background 100ms ease, color 100ms ease, box-shadow 100ms ease;
}
.chip:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.chip.active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* ============== job cards ============== */

.empty {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--text-faint);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  font-size: 13px;
}

.job-list { display: grid; gap: var(--space-3); }

.job-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: grid;
  gap: var(--space-3);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-sm);
  transition: box-shadow 160ms ease, transform 160ms ease;
}
.job-card:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-md); }
.job-card.complete { box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.25), var(--shadow-sm); }
.job-card.error    { box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.3), var(--shadow-sm); }
.job-card.running, .job-card.starting {
  box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 3px var(--accent-dim), var(--shadow-sm);
}

.job-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.job-title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}
.job-date {
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
}

.job-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.job-url {
  color: var(--text-muted);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 480px;
  font-family: var(--font-mono);
  font-size: 11px;
}
.job-url:hover { color: var(--accent); }

.pill {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  padding: 2px var(--space-2);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-feature-settings: "tnum";
}
.pill.rag { background: var(--accent-dim); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.3); }
.pill.rag-failed { background: var(--danger-dim); color: var(--danger); box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.3); }
.pill.variations { background: rgba(251, 191, 36, 0.12); color: #fbbf24; box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.3); font-weight: 600; }
.pill.date-range { background: rgba(99, 102, 241, 0.10); color: #a5b4fc; box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25); font-family: var(--font-mono); font-size: 10px; }

.ad-type-pill.variations { background: rgba(251, 191, 36, 0.12); color: #fbbf24; box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.3); }

/* ---------- per-ad metadata pills ---------- */

.ad-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.pill.status { font-weight: 600; }
.pill.status.on  { background: var(--accent-dim); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.3); }
.pill.status.on::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 4px var(--accent); margin-right: 6px; transform: translateY(-1px); }
.pill.status.off { background: var(--surface-2); color: var(--text-faint); }
.pill.status.off::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); margin-right: 6px; transform: translateY(-1px); }

.pill.platforms { background: rgba(99, 102, 241, 0.10); color: #a5b4fc; box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25); font-weight: 600; font-family: var(--font-mono); letter-spacing: 0.04em; }
.pill.cta { background: rgba(245, 158, 11, 0.10); color: #fcd34d; box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.25); font-weight: 600; }
.pill.domain { color: var(--text-muted); font-family: var(--font-mono); font-size: 10px; }

.rank-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface-2);
  padding: 2px var(--space-2);
  border-radius: 4px;
  margin-right: var(--space-2);
  font-weight: 500;
}

.ad-headline {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: inset 0 0 0 1px var(--border);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.5;
}
.ad-headline .ad-section-label { display: block; margin-bottom: 4px; }

/* ---------- detail-view tools (search + view toggle + sort) ---------- */

.detail-tools {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.detail-tools .search-input { flex: 1; }

.view-toggle {
  display: inline-flex;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--border);
  padding: 3px;
}
.toggle-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 5px var(--space-3);
  border-radius: 4px;
  transition: background 100ms ease, color 100ms ease;
}
.toggle-btn:hover { color: var(--text); }
.toggle-btn.active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* ---------- compact ad row ---------- */

.ad-row {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
  transition: background 100ms ease, box-shadow 100ms ease;
}
.ad-row:hover {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.ad-row-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.ad-title.compact { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: 13px; }
.ad-title.compact > span:not(.rank-badge) { letter-spacing: -0.005em; }

.ad-preview {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: var(--space-3);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  overflow: hidden;
}
.ad-preview > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.preview-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  align-self: start;
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 3px;
  text-align: center;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.preview-tag.transcript { color: var(--accent); background: var(--accent-dim); }

.ad-row-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.btn.small {
  font-size: 11px;
  padding: 0 var(--space-3);
  height: 26px;
  font-weight: 500;
}

/* Brief flash so users see a visible response to sort/filter changes even
   when the resulting order is identical (e.g. all data tied). */
@keyframes flash-bg {
  0%   { background-color: rgba(52, 211, 153, 0.10); }
  100% { background-color: transparent; }
}
#scrape-ads-container.flash {
  animation: flash-bg 350ms ease-out;
  border-radius: var(--radius-md);
}

.sort-select {
  height: 40px;
  padding: 0 var(--space-4);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%239aa3b2' fill='none' stroke-width='1.5' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}
.sort-select:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.sort-select:focus { box-shadow: inset 0 0 0 1px var(--accent), var(--ring-focus); outline: none; }
.sort-select option { background: var(--surface); color: var(--text); }
.pill.variations {
  background: rgba(251, 191, 36, 0.10);
  color: #fbbf24;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.3);
  font-weight: 600;
}
.pill.date-range {
  background: rgba(99, 102, 241, 0.10);
  color: #a5b4fc;
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.25);
  font-feature-settings: "tnum";
}
.ad-type-pill.variations {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}

.sort-select {
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface);
  color: var(--text);
  height: 40px;
  padding: 0 var(--space-8) 0 var(--space-4);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    right var(--space-4) center,
    right calc(var(--space-4) - 5px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  transition: box-shadow 120ms ease;
}
.sort-select:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.sort-select:focus { outline: none; box-shadow: inset 0 0 0 1px var(--accent), var(--ring-focus); }

.meta-label {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 500;
}

.job-progress {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text);
  font-size: 13px;
}

.scrape-counter {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.scrape-counter-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.scrape-counter-bar {
  flex: 1;
  height: 6px;
  background: var(--accent-dim);
  border-radius: 3px;
  overflow: hidden;
  max-width: 260px;
}
.scrape-counter-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #6366f1);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.pill.low-impr {
  background: #78350f;
  color: #fed7aa;
  border: 1px solid #b45309;
}

.scrape-warning {
  display: block;
  margin-top: var(--space-2);
  padding: 6px 10px;
  border-radius: 6px;
  background: #78350f;
  color: #fed7aa;
  border: 1px solid #b45309;
  font-size: 12px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.job-error {
  color: var(--danger);
  font-size: 13px;
}
.job-error-detail { font-size: 12px; color: var(--text-muted); }
.job-error-detail pre {
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 11px;
  margin: var(--space-2) 0 0;
}

.job-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.copy-btn { min-width: 160px; }
.char-count { color: var(--text-faint); font-size: 12px; font-feature-settings: "tnum"; }

.transcript summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  padding: var(--space-2) 0;
  user-select: none;
  list-style: none;
}
.transcript summary::-webkit-details-marker { display: none; }
.transcript summary::before {
  content: "▸";
  display: inline-block;
  margin-right: var(--space-2);
  transition: transform 120ms ease;
  font-size: 10px;
  color: var(--text-faint);
}
.transcript[open] summary::before { transform: rotate(90deg); }
.transcript summary:hover { color: var(--text); }
.transcript pre {
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--border);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  max-height: 420px;
  overflow: auto;
  margin: var(--space-2) 0 0;
}

.job-side-actions {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
}
.job-side-actions .btn {
  width: 24px; height: 24px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  background: transparent;
  box-shadow: none;
  color: var(--text-faint);
}
.job-side-actions .btn:hover { background: var(--surface-2); color: var(--danger); box-shadow: none; }

/* ============== exports browser ============== */

.exports-view { display: grid; gap: var(--space-5); }

.exports-tools { display: flex; align-items: center; gap: var(--space-3); }

.search-input {
  flex: 1;
  height: 40px;
  padding: 0 var(--space-4);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: 14px;
  transition: box-shadow 120ms ease;
}
.search-input::placeholder { color: var(--text-faint); }
.search-input:focus { box-shadow: inset 0 0 0 1px var(--accent), var(--ring-focus); }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.export-list { display: grid; gap: var(--space-2); }

.export-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  text-align: left;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 1px var(--border);
  cursor: pointer;
  transition: box-shadow 120ms ease, transform 80ms ease, background 120ms ease;
}
.export-row:hover {
  box-shadow: inset 0 0 0 1px var(--border-strong);
  background: var(--surface-2);
}
.export-row:active { transform: translateY(1px); }

.export-row-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.export-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.export-meta { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.export-date { color: var(--text-faint); font-size: 12px; white-space: nowrap; flex-shrink: 0; }

/* ============== exports detail view ============== */

.back { margin-bottom: var(--space-2); width: max-content; }

.detail-head {
  display: grid;
  gap: var(--space-3);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-2);
}
.detail-head h3 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.015em;
}
.detail-head-row { display: flex; gap: var(--space-3); align-items: center; }
.detail-date { color: var(--text-muted); font-size: 12px; }
.detail-meta { display: flex; gap: var(--space-3); align-items: center; color: var(--text-muted); font-size: 12px; flex-wrap: wrap; }
.detail-url {
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  max-width: 100%;
}
.detail-url:hover { color: var(--accent); }

.kind-pill {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px var(--space-2);
  border-radius: 4px;
  white-space: nowrap;
}
.kind-pill.vsl    { background: var(--accent-dim); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.3); }
.kind-pill.scrape { background: rgba(99, 102, 241, 0.12); color: #818cf8; box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.3); }

.chips-row + .chips-row { margin-top: calc(-1 * var(--space-3)); }

.ad-block-tall { max-height: 600px; }

.detail-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-12);
  color: var(--text-muted);
}

.ad-grid { display: grid; gap: var(--space-3); }

.ad-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: grid;
  gap: var(--space-4);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-sm);
}

.ad-head { display: grid; gap: 4px; }
.ad-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.ad-type-pill {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-muted);
}
.ad-sub {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 12px;
  color: var(--text-muted);
}
.lib-id {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-faint);
}

.ad-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

.ad-sections { display: grid; gap: var(--space-4); }

.ad-section {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: inset 0 0 0 1px var(--border);
}

.ad-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.ad-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.ad-block {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text);
  max-height: 360px;
  overflow: auto;
}

.ad-empty {
  color: var(--text-faint);
  font-style: italic;
  font-size: 13px;
  text-align: center;
  padding: var(--space-4);
}

/* ============== responsive ============== */

@media (max-width: 720px) {
  .vsl-form { grid-template-columns: 1fr; }
  .panel { padding: var(--space-8) var(--space-4) var(--space-12); }
  .panel > h2 { font-size: 22px; }
}

/* ============================ auth ============================ */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
/* author display:flex would otherwise override the UA's [hidden] rule */
.auth-overlay[hidden] { display: none; }
.auth-card {
  width: min(380px, calc(100vw - var(--space-8)));
  padding: var(--space-8);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { margin-bottom: var(--space-6); font-size: 22px; }
.auth-card form { display: grid; gap: var(--space-4); }
.auth-card label { display: grid; gap: var(--space-1); font-size: 13px; color: var(--text-muted); }
.auth-card input {
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.auth-card input:focus { outline: none; border-color: var(--border-focus); box-shadow: var(--ring-focus); }
.auth-hint { font-size: 13px; color: var(--text-muted); }
.auth-error { min-height: 20px; margin-top: var(--space-3); font-size: 13px; color: var(--danger); }

.user-badge {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 13px;
  margin-left: auto; /* keep it clear of the tabs — status pill follows */
  min-width: 0;
}
.user-badge .user-email {
  color: var(--text-muted);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-badge ~ .status-pill { margin-left: var(--space-3); }

/* ============================ team panel ============================ */

.team-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-5); }
.invite-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
}
.invite-url { font-family: var(--font-mono); word-break: break-all; }
.invite-note { color: var(--text-faint); }

.team-list { display: grid; gap: var(--space-2); }
.team-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
}
.team-row .user-email { flex: 1; }
.user-role {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-3);
  color: var(--text-muted);
}
.user-role.admin { background: var(--accent-dim); color: var(--accent); }
.user-date { color: var(--text-faint); font-size: 12px; }
.user-you { color: var(--text-faint); font-size: 12px; }
