:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232633;
  --border: #2d3148;
  --text: #e1e4ed;
  --text-dim: #8b90a5;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.12);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.container { max-width: 900px; margin: 0 auto; padding: 0 1.5rem; }

/* Header */
header {
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-bottom: 2rem;
}
header .inner { display: flex; align-items: center; justify-content: space-between; }
header h1 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.02em; }
header h1 span { color: var(--accent); }
header nav { display: flex; gap: 1.5rem; font-size: 0.875rem; }
header nav a { color: var(--text-dim); }
header nav a:hover { color: var(--text); }
.header-user { display: flex; align-items: center; gap: 0.75rem; }
.header-email { font-size: 0.78rem; color: var(--muted); }
.btn-logout {
  padding: 0.3rem 0.75rem; font-size: 0.75rem; font-weight: 500;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 0.4rem; cursor: pointer; font-family: inherit;
}
.btn-logout:hover { color: var(--text); border-color: var(--border); background: rgba(255,255,255,0.04); }

/* Stats bar */
.stats {
  display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  flex: 1; min-width: 140px;
}
.stat-card .label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; }

/* Post cards */
.post-list { display: flex; flex-direction: column; gap: 1rem; }

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  transition: border-color 0.2s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.post-card:hover { border-color: var(--accent); color: inherit; }

.post-card .top-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.post-card .feature-title { font-weight: 600; font-size: 1rem; }
.post-card .date { font-size: 0.75rem; color: var(--text-dim); }

.post-card .preview {
  font-size: 0.875rem; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 0.75rem;
}

.post-card .tags { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.tag {
  font-size: 0.7rem; padding: 0.2rem 0.6rem;
  border-radius: 999px; font-weight: 500;
}
.tag.published { background: var(--green-bg); color: var(--green); }
.tag.mock { background: var(--yellow-bg); color: var(--yellow); }
.tag.positive { background: var(--green-bg); color: var(--green); }
.tag.negative { background: var(--red-bg); color: var(--red); }
.tag.no-feedback { background: var(--surface2); color: var(--text-dim); }
.tag.ethics { background: rgba(99, 102, 241, 0.12); color: var(--accent); }

/* Post detail */
.back-link { font-size: 0.875rem; color: var(--text-dim); margin-bottom: 1.5rem; display: inline-block; }
.back-link:hover { color: var(--text); }

.detail-header { margin-bottom: 1.5rem; }
.detail-header h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 0.5rem; }
.detail-meta { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.post-text-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.post-image {
  margin-bottom: 1.5rem;
}
.post-image img {
  max-width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
}

/* Feedback section */
.feedback-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
}
.feedback-section h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; }

.feedback-buttons { display: flex; gap: 0.75rem; margin-bottom: 1rem; }

.btn-feedback {
  flex: 1; padding: 0.75rem; border: 2px solid var(--border);
  border-radius: 0.75rem; background: transparent; color: var(--text);
  font-size: 1rem; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  font-weight: 500;
}
.btn-feedback:hover { border-color: var(--accent); }
.btn-feedback.active-pos { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.btn-feedback.active-neg { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.btn-feedback .icon { font-size: 1.5rem; }

.comment-box {
  width: 100%; padding: 0.75rem; border: 1px solid var(--border);
  border-radius: 0.5rem; background: var(--bg); color: var(--text);
  font-size: 0.875rem; resize: vertical; min-height: 80px;
  font-family: inherit; margin-bottom: 1rem;
}
.comment-box::placeholder { color: var(--text-dim); }
.comment-box:focus { outline: none; border-color: var(--accent); }

.btn-submit {
  padding: 0.75rem 2rem; background: var(--accent); color: white;
  border: none; border-radius: 0.5rem; font-size: 0.875rem;
  font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.btn-submit:hover { background: var(--accent-hover); }
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; }

.saved-banner {
  background: var(--green-bg); color: var(--green); padding: 0.75rem 1rem;
  border-radius: 0.5rem; margin-bottom: 1.5rem; font-size: 0.875rem;
  font-weight: 500;
}

.existing-feedback {
  padding: 1rem; border-radius: 0.5rem; margin-bottom: 1rem;
  font-size: 0.875rem;
}
.existing-feedback.positive { background: var(--green-bg); border: 1px solid rgba(34,197,94,0.3); }
.existing-feedback.negative { background: var(--red-bg); border: 1px solid rgba(239,68,68,0.3); }
.existing-feedback .fb-label { font-weight: 600; margin-bottom: 0.25rem; }

.linkedin-link {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; background: #0a66c2; color: white;
  border-radius: 0.5rem; font-size: 0.8rem; font-weight: 600;
  margin-bottom: 1.5rem;
}
.linkedin-link:hover { background: #004182; color: white; }

/* Quick feedback on index cards */
.post-card-wrapper { position: relative; }

.quick-feedback {
  position: absolute; top: 1rem; right: 1rem;
  display: flex; gap: 0.4rem;
}
.qf-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface2);
  font-size: 1.1rem; cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.qf-btn:hover { transform: scale(1.15); }
.qf-up:hover { background: var(--green-bg); border-color: var(--green); }
.qf-down:hover { background: var(--red-bg); border-color: var(--red); }

/* ── Agent Status Panel ──────────────────────────────────────────────── */
.agent-panel {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 1rem; padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
  gap: 1rem; flex-wrap: wrap;
}

.agent-panel-left { display: flex; align-items: center; gap: 1rem; }
.agent-panel-right { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

/* Animated status dot */
.agent-status-dot {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  transition: background 0.4s;
}
.dot-online {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse-green 2s ease-in-out infinite;
}
.dot-offline {
  background: #4b5563;
}
.dot-running {
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  animation: pulse-yellow 0.8s ease-in-out infinite;
}

@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70%  { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
@keyframes pulse-yellow {
  0%   { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.agent-info {}
.agent-label { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.agent-sub { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.2rem; }

.agent-badge {
  font-size: 0.7rem; font-weight: 700; padding: 0.25rem 0.75rem;
  border-radius: 999px; letter-spacing: 0.08em;
}
.badge-online   { background: var(--green-bg); color: var(--green); }
.badge-offline  { background: var(--surface2); color: var(--text-dim); }
.badge-running  { background: rgba(245,158,11,0.15); color: #f59e0b; }

.btn-toggle {
  padding: 0.55rem 1.25rem; border: none; border-radius: 0.5rem;
  font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-activate {
  background: var(--green); color: #000;
}
.btn-activate:hover { background: #16a34a; }
.btn-deactivate {
  background: var(--surface2); color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-deactivate:hover { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.btn-toggle:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-run-now {
  padding: 0.55rem 1rem; background: var(--accent); color: white;
  border: none; border-radius: 0.5rem; font-size: 0.85rem;
  font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.btn-run-now:hover { background: var(--accent-hover); }
.btn-run-now:disabled { opacity: 0.5; cursor: not-allowed; }

/* Media type checkboxes */
.media-options {
  display: inline-flex; align-items: center; gap: 0.6rem;
  margin-left: 0.5rem; padding: 0.3rem 0.6rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 0.5rem; font-size: 0.8rem;
}
.media-checkbox {
  display: inline-flex; align-items: center; gap: 0.3rem;
  color: var(--text-dim); cursor: pointer; user-select: none;
  transition: color 0.2s;
}
.media-checkbox:hover { color: var(--text); }
.media-checkbox input[type="checkbox"] {
  accent-color: var(--accent); cursor: pointer;
  width: 14px; height: 14px;
}

/* LinkedIn auth button */
.btn-linkedin {
  display: inline-flex; align-items: center;
  padding: 0.55rem 1rem;
  border: none; border-radius: 0.5rem; font-size: 0.85rem;
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.btn-linkedin-connect {
  background: #0a66c2; color: #fff;
}
.btn-linkedin-connect:hover { background: #004182; }
.btn-linkedin-connected {
  background: rgba(10,102,194,0.15); color: #60a5fa;
  border: 1px solid rgba(10,102,194,0.4);
}
.btn-linkedin-connected:hover { background: rgba(10,102,194,0.25); }

/* Pipeline stage bar */
.pipeline-stage-bar {
  border-radius: 0.6rem; padding: 0.65rem 1rem;
  font-size: 0.82rem; font-weight: 500; margin-bottom: 0.75rem;
  background: rgba(99,102,241,0.10); color: #818cf8;
  border: 1px solid rgba(99,102,241,0.25);
  animation: pulse-stage 2s ease-in-out infinite;
}
@keyframes pulse-stage {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── AI Build Panel ─────────────────────────────────────────────────── */
.ai-build-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.ai-build-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem;
  background: rgba(99, 102, 241, 0.08);
  border-bottom: 1px solid var(--border);
}

.ai-build-title {
  font-weight: 700; font-size: 0.85rem; color: var(--accent);
  letter-spacing: 0.02em;
}

.ai-build-timer {
  font-size: 0.75rem; font-weight: 600; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.ai-build-log {
  max-height: 360px;
  overflow-y: auto;
  padding: 0.5rem 0;
  scroll-behavior: smooth;
}

.ai-build-log::-webkit-scrollbar { width: 6px; }
.ai-build-log::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 3px;
}

.ai-log-entry {
  display: flex; align-items: flex-start; gap: 0.5rem;
  padding: 0.35rem 1rem;
  font-size: 0.8rem;
  line-height: 1.5;
  transition: background 0.3s, opacity 0.5s;
  opacity: 1;
}

.ai-log-entry:hover { background: rgba(255,255,255,0.03); }

.ai-log-entry-new {
  opacity: 0;
  animation: log-fade-in 0.4s ease forwards;
}

@keyframes log-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-log-icon {
  flex-shrink: 0; width: 20px; text-align: center;
  font-size: 0.85rem;
}

.ai-log-stage {
  flex-shrink: 0; min-width: 120px;
  font-weight: 600; color: var(--accent);
  font-size: 0.75rem;
}

.ai-log-detail {
  color: var(--text-dim);
  word-break: break-word;
}

/* Loading skeleton inside build log */
.ai-log-loading {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 1rem;
  font-size: 0.82rem; color: var(--text-dim);
  animation: loading-pulse 1.5s ease-in-out infinite;
}

.ai-log-loading-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  animation: loading-bounce 1s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes loading-bounce {
  0%, 100% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 1; }
}

/* Run status bar */
.run-status-bar {
  border-radius: 0.6rem; padding: 0.75rem 1rem;
  font-size: 0.85rem; font-weight: 500; margin-bottom: 1.25rem;
}
.status-running { background: rgba(245,158,11,0.12); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.status-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.status-error   { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }

/* ── Engagement Chart ─────────────────────────────────────────────────── */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.chart-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 0.5rem;
}

.chart-title {
  font-size: 1rem; font-weight: 700; letter-spacing: -0.01em;
}

.chart-controls { display: flex; gap: 0.4rem; }

.chart-btn {
  padding: 0.35rem 0.75rem; border: 1px solid var(--border);
  border-radius: 0.4rem; background: transparent; color: var(--text-dim);
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s;
}
.chart-btn:hover { border-color: var(--accent); color: var(--text); }
.chart-btn-active {
  background: var(--accent); color: white; border-color: var(--accent);
}
.chart-btn-refresh {
  color: var(--accent); border-color: rgba(99,102,241,0.3);
}
.chart-btn-refresh:hover {
  background: rgba(99,102,241,0.1);
}

.chart-container {
  padding: 1rem 1rem 0.5rem;
  height: 240px;
}

.chart-loading {
  text-align: center; padding: 1rem;
  font-size: 0.8rem; color: var(--text-dim);
  animation: loading-pulse 1.5s ease-in-out infinite;
}

/* ── Stats Diagnostic Panel ───────────────────────────────────────────── */
.stats-diagnostic {
  margin: 0 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.82rem;
}
.diag-loading { color: var(--text-dim); }
.diag-issue {
  display: flex; align-items: flex-start; gap: 0.5rem;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border);
}
.diag-issue:last-child { border-bottom: none; }
.diag-icon-warn { color: #f59e0b; font-size: 1rem; flex-shrink: 0; }
.diag-icon-ok { color: var(--green); font-size: 1rem; flex-shrink: 0; }
.diag-icon-err { color: var(--red); font-size: 1rem; flex-shrink: 0; }
.diag-text { color: var(--text); line-height: 1.4; }
.diag-summary {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem; margin-top: 0.75rem;
}
.diag-stat {
  background: var(--surface);
  padding: 0.6rem 0.75rem;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
}
.diag-stat-label { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }
.diag-stat-value { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-top: 0.15rem; }

/* ── Metric Editor ────────────────────────────────────────────────────── */
.metric-editor {
  margin: 0 1rem 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
}
.metric-editor-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.metric-editor-header span { font-weight: 600; color: var(--text); font-size: 0.9rem; }
.metric-editor-close {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 1.1rem; padding: 0.2rem;
}
.metric-editor-close:hover { color: var(--red); }
.metric-editor-fields {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem; margin-bottom: 0.75rem;
}
.me-field label {
  display: block; font-size: 0.72rem; color: var(--text-dim);
  text-transform: uppercase; margin-bottom: 0.25rem;
}
.me-field input {
  width: 100%; padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
}
.me-status {
  margin-left: 0.75rem;
  font-size: 0.82rem;
  color: var(--green);
}

/* ── Filters bar ──────────────────────────────────────────────────────── */
.filters-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; flex-wrap: wrap; gap: 0.75rem;
}

.filters-form {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
}

.filter-label {
  font-size: 0.75rem; color: var(--text-dim); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}

.filter-input {
  padding: 0.4rem 0.6rem; border: 1px solid var(--border);
  border-radius: 0.4rem; background: var(--surface); color: var(--text);
  font-size: 0.8rem; font-family: inherit;
}
.filter-input:focus { outline: none; border-color: var(--accent); }

.filter-btn {
  padding: 0.4rem 0.85rem; background: var(--accent); color: white;
  border: none; border-radius: 0.4rem; font-size: 0.8rem;
  font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.filter-btn:hover { background: var(--accent-hover); }

.filter-clear {
  font-size: 0.8rem; color: var(--text-dim);
}
.filter-clear:hover { color: var(--red); }

.page-info {
  font-size: 0.78rem; color: var(--text-dim);
}

/* ── Pagination ───────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 0.35rem; margin-top: 1.5rem; margin-bottom: 1rem;
}

.page-btn {
  padding: 0.4rem 0.7rem; border: 1px solid var(--border);
  border-radius: 0.4rem; background: var(--surface); color: var(--text-dim);
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  text-decoration: none; transition: all 0.15s;
  display: inline-block;
}
.page-btn:hover { border-color: var(--accent); color: var(--text); }

.page-current {
  background: var(--accent); color: white; border-color: var(--accent);
  cursor: default;
}
.page-current:hover { color: white; }

.page-ellipsis {
  color: var(--text-dim); font-size: 0.8rem; padding: 0 0.25rem;
}

/* ── Auto-publish toggle ────────────────────────────────────────────── */
.auto-publish-toggle {
  display: flex; align-items: center; gap: 0.5rem;
}
.switch-label {
  font-size: 0.75rem; font-weight: 500; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.switch {
  position: relative; display: inline-block; width: 40px; height: 22px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 22px;
  transition: 0.25s;
}
.slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 3px; bottom: 3px; background: white; border-radius: 50%;
  transition: 0.25s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.queue-badge {
  background: #f59e0b; color: #000; font-size: 0.7rem; font-weight: 700;
  padding: 0.2rem 0.5rem; border-radius: 10px; cursor: pointer;
  animation: pulse-badge 2s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Section headers (shared) ────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem;
}
.section-title { font-size: 1.1rem; font-weight: 600; color: var(--text); margin: 0; }

/* ── Approval Queue ──────────────────────────────────────────────────── */
.queue-section {
  margin-top: 1.5rem; padding: 1.2rem 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.75rem;
}
.queue-count {
  font-size: 0.8rem; font-weight: 500; color: var(--accent);
  background: rgba(99,102,241,0.1); padding: 0.2rem 0.6rem;
  border-radius: 0.4rem;
}
.queue-list { display: flex; flex-direction: column; gap: 0.75rem; }
.queue-empty { color: var(--text-dim); font-size: 0.85rem; padding: 1rem 0; text-align: center; }
.queue-loading { color: var(--text-dim); font-size: 0.85rem; text-align: center; }

.queue-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 0.6rem; padding: 1rem;
}
.queue-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.queue-card-header strong { font-size: 0.9rem; color: var(--text); }
.queue-card-meta { font-size: 0.7rem; color: var(--text-dim); }
.queue-textarea {
  width: 100%; padding: 0.5rem; font-size: 0.82rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.4rem; color: var(--text); font-family: inherit;
  resize: vertical; line-height: 1.5; box-sizing: border-box;
}
.queue-textarea:focus { outline: none; border-color: var(--accent); }
.queue-card-vars { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.queue-card-actions {
  display: flex; gap: 0.5rem; margin-top: 0.5rem;
  padding-top: 0.5rem; border-top: 1px solid var(--border);
}
.btn-approve {
  padding: 0.4rem 1rem; font-size: 0.8rem; font-weight: 600;
  background: var(--green); color: white; border: none;
  border-radius: 0.4rem; cursor: pointer;
}
.btn-approve:hover { opacity: 0.9; }
.btn-reject {
  padding: 0.4rem 1rem; font-size: 0.8rem; font-weight: 500;
  background: transparent; color: var(--red); border: 1px solid var(--red);
  border-radius: 0.4rem; cursor: pointer;
}
.btn-reject:hover { background: rgba(239,68,68,0.1); }
.btn-enqueue {
  padding: 0.4rem 1rem; font-size: 0.8rem; font-weight: 600;
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
  border-radius: 0.4rem; cursor: pointer;
}
.btn-enqueue:hover { background: rgba(139,92,246,0.12); }
.queue-approved {
  color: var(--green); font-weight: 500; padding: 0.75rem;
  text-align: center; font-size: 0.9rem;
}
.queue-scheduled-header {
  font-size: 0.78rem; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.85rem 0 0.4rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}
.queue-card-scheduled {
  opacity: 0.85;
  border-style: dashed;
}
.queue-scheduled-badge {
  font-size: 0.72rem; font-weight: 600;
  color: var(--accent); background: rgba(139,92,246,0.1);
  border-radius: 0.3rem; padding: 0.15rem 0.55rem;
  white-space: nowrap;
}
.queue-scheduled-preview {
  font-size: 0.8rem; color: var(--text-dim); line-height: 1.45;
  padding: 0.4rem 0; white-space: pre-wrap;
}
.story-chapter-tag {
  font-size: 0.75rem; color: var(--accent); background: rgba(139,92,246,0.1);
  border-radius: 0.3rem; padding: 0.2rem 0.6rem; margin-top: 0.25rem;
  display: inline-block;
}

/* ── Story Mode Panel ──────────────────────────────────────────────────── */
.story-panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 0.75rem; margin: 1.5rem 0; overflow: hidden;
}
.story-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; cursor: pointer; user-select: none;
}
.story-panel-header:hover { background: rgba(255,255,255,0.03); }
.story-panel-title { display: flex; align-items: center; gap: 0.6rem; }
.story-icon { font-size: 1.1rem; }
.story-badge {
  background: var(--accent); color: white; font-size: 0.65rem;
  font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 999px; letter-spacing: 0.04em;
}
.story-toggle-arrow { color: var(--muted); font-size: 0.85rem; }
.story-panel-body { padding: 0 1.25rem 1.25rem; }
.story-hint { color: var(--muted); font-size: 0.85rem; margin: 0.5rem 0 1rem; }
.story-form { display: flex; flex-direction: column; gap: 0.75rem; }
.story-input {
  background: var(--input); border: 1px solid var(--border); color: var(--text);
  border-radius: 0.5rem; padding: 0.55rem 0.75rem; font-size: 0.9rem;
  outline: none; width: 100%; box-sizing: border-box;
}
.story-textarea {
  background: var(--input); border: 1px solid var(--border); color: var(--text);
  border-radius: 0.5rem; padding: 0.55rem 0.75rem; font-size: 0.85rem;
  outline: none; resize: vertical; width: 100%; box-sizing: border-box; font-family: inherit;
}
.story-input:focus, .story-textarea:focus { border-color: var(--accent); }
.story-form-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.story-label { font-size: 0.85rem; color: var(--muted); }
.story-select {
  background: var(--input); border: 1px solid var(--border); color: var(--text);
  border-radius: 0.4rem; padding: 0.4rem 0.6rem; font-size: 0.85rem; cursor: pointer;
}
.btn-story-start {
  padding: 0.5rem 1.25rem; font-size: 0.85rem; font-weight: 600;
  background: var(--accent); color: white; border: none; border-radius: 0.4rem;
  cursor: pointer; margin-left: auto;
}
.btn-story-start:hover { opacity: 0.9; }
.btn-story-start:disabled { opacity: 0.5; cursor: not-allowed; }
.story-session-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; gap: 0.5rem;
}
.story-progress { color: var(--muted); font-size: 0.85rem; }
.story-session-actions { display: flex; gap: 0.5rem; }
.btn-story-run {
  padding: 0.4rem 1rem; font-size: 0.8rem; font-weight: 600;
  background: var(--accent); color: white; border: none; border-radius: 0.4rem; cursor: pointer;
}
.btn-story-run:hover { opacity: 0.9; }
.btn-story-run:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-story-stop {
  padding: 0.4rem 1rem; font-size: 0.8rem; font-weight: 500;
  background: transparent; color: var(--red); border: 1px solid var(--red);
  border-radius: 0.4rem; cursor: pointer;
}
.btn-story-stop:hover { background: rgba(239,68,68,0.1); }
.btn-story-reset {
  padding: 0.4rem 1rem; font-size: 0.8rem; font-weight: 500;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 0.4rem; cursor: pointer;
}
.btn-story-reset:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.story-arc-list { display: flex; flex-direction: column; gap: 0.4rem; }
.story-chapter-row {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.5rem 0.6rem; border-radius: 0.4rem; background: rgba(255,255,255,0.02);
}
.story-chapter-row:hover { background: rgba(255,255,255,0.04); }
.story-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 0.3rem;
}
.dot-done    { background: var(--green); }
.dot-next    { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.dot-pending { background: var(--border); }
.dot-skip    { background: #f59e0b; }
.dot-running {
  background: var(--accent);
  animation: dot-spin 1s ease-in-out infinite alternate;
}
@keyframes dot-spin {
  from { transform: scale(1);   opacity: 1;   box-shadow: 0 0 4px var(--accent); }
  to   { transform: scale(1.6); opacity: 0.7; box-shadow: 0 0 10px var(--accent); }
}
.story-log-line {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0.6rem 0 0 0;
  padding: 0.4rem 0.7rem;
  background: rgba(139,92,246,0.06);
  border-radius: 6px;
  border-left: 2px solid var(--accent);
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chapter-active {
  background: rgba(139,92,246,0.08);
  border-left: 2px solid var(--accent);
  padding-left: calc(0.6rem - 2px);
}
.story-chapter-info { display: flex; flex-direction: column; gap: 0.1rem; }
.story-chapter-info strong { font-size: 0.85rem; color: var(--text); }
.story-chapter-sub { font-size: 0.75rem; color: var(--muted); }

#story-loading span {
  display: inline-block;
  animation: story-pulse 1.6s ease-in-out infinite;
}
@keyframes story-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── A/B Testing ─────────────────────────────────────────────────────── */
.ab-section {
  margin-top: 1.5rem; padding: 1.2rem 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.75rem;
}
.ab-hint { font-size: 0.75rem; color: var(--text-dim); }
.ab-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}
.ab-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 0.5rem; padding: 0.75rem;
}
.ab-card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.35rem;
}
.ab-var-label { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.ab-var-desc { font-size: 0.72rem; color: var(--text-dim); line-height: 1.4; }
.ab-var-rec { font-size: 0.72rem; color: var(--accent); line-height: 1.4; font-weight: 500; }

.ab-header-right { display: flex; align-items: center; gap: 0.75rem; }
.ab-summary { font-size: 0.75rem; color: var(--text-dim); }

.ab-insights-bar {
  display: none; margin-bottom: 0.75rem; padding: 0.6rem 0.8rem;
  background: rgba(34, 197, 94, 0.08); border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 0.5rem;
}
.ab-insight-item {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; color: var(--text); line-height: 1.6;
}
.ab-insight-icon { color: var(--green); font-size: 0.6rem; }

.ab-card-right { display: flex; align-items: center; gap: 0.5rem; }
.ab-card-locked { border-color: var(--green); background: rgba(34, 197, 94, 0.04); }

.ab-status {
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
}
.ab-concluded { background: var(--green); color: white; }
.ab-leaning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.ab-exploring { background: rgba(99, 102, 241, 0.1); color: var(--accent); }

.ab-locked-value {
  font-size: 0.85rem; font-weight: 600; color: var(--green);
  background: rgba(34, 197, 94, 0.1); padding: 0.2rem 0.5rem;
  border-radius: 0.3rem;
}

.ab-variant-bars { margin-top: 0.4rem; }
.ab-variant-row {
  display: flex; align-items: center; gap: 0.4rem;
  margin-bottom: 0.2rem;
}
.ab-variant-label {
  font-size: 0.68rem; color: var(--text-dim);
  min-width: 80px; text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ab-variant-track {
  flex: 1; height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden;
}
.ab-variant-fill {
  height: 100%; background: var(--accent); border-radius: 3px;
  transition: width 0.5s ease;
}
.ab-variant-winner { background: var(--green); }
.ab-variant-count {
  font-size: 0.65rem; color: var(--text-dim); min-width: 24px;
}

.ab-select { max-width: 160px; font-size: 0.8rem; }
.ab-select { max-width: 160px; font-size: 0.8rem; }

/* ── Post Review Editor ───────────────────────────────────────────────── */
.btn-review {
  padding: 0.35rem 0.7rem; font-size: 0.8rem; font-weight: 500;
  background: var(--surface); color: var(--accent); border: 1px solid var(--accent);
  border-radius: 0.4rem; cursor: pointer; transition: all 0.15s;
}
.btn-review:hover { background: var(--accent); color: white; }
.btn-review:disabled { opacity: 0.5; cursor: not-allowed; }
.queue-review-result {
  margin-top: 0.5rem; padding: 0.7rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 0.5rem;
  font-size: 0.8rem; line-height: 1.5;
}
.review-header { font-size: 0.9rem; margin-bottom: 0.4rem; }
.review-scores {
  display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem;
}
.review-dim {
  font-size: 0.72rem; padding: 0.15rem 0.45rem;
  background: var(--surface); border-radius: 0.3rem; color: var(--text-dim);
}
.review-issues { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.5rem; }
.review-issue {
  font-size: 0.78rem; padding: 0.4rem 0.5rem;
  background: var(--surface); border-radius: 0.35rem;
}
.review-issue em { color: var(--accent); font-style: normal; font-size: 0.75rem; }
.review-summary {
  font-size: 0.78rem; color: var(--text-dim); padding: 0.4rem 0;
  border-top: 1px solid var(--border); margin-top: 0.3rem;
}
.review-actions { margin-top: 0.5rem; }
.btn-apply-review {
  padding: 0.4rem 0.9rem; font-size: 0.8rem; font-weight: 600;
  background: var(--green, #22c55e); color: white; border: none;
  border-radius: 0.4rem; cursor: pointer;
}
.btn-apply-review:hover { opacity: 0.85; }

/* ── RLHF Reward Cycle ───────────────────────────────────────────────── */
.rlhf-section {
  margin-top: 1.5rem; padding: 1.2rem 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.75rem;
}
.rlhf-desc {
  font-size: 0.78rem; color: var(--text-dim); margin-bottom: 0.5rem; line-height: 1.4;
}
.rlhf-result {
  margin-top: 0.5rem; padding: 0.8rem;
  background: var(--bg); border: 1px solid var(--border); border-radius: 0.5rem;
  font-size: 0.82rem;
}
.rlhf-summary { display: flex; flex-direction: column; gap: 0.35rem; }
.rlhf-row { display: flex; justify-content: space-between; align-items: center; }
.rlhf-label { color: var(--text); }
.rlhf-val { font-weight: 600; color: var(--accent); min-width: 2rem; text-align: right; }
.rlhf-feedback {
  margin-top: 0.6rem; padding: 0.6rem; font-size: 0.76rem;
  background: var(--surface); border-radius: 0.4rem;
  color: var(--text-dim); line-height: 1.5; white-space: pre-wrap;
}

/* ── Viral Patterns ──────────────────────────────────────────────────── */
.patterns-section {
  margin-top: 1.5rem; padding: 1.2rem 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.75rem;
}
.btn-add-pattern {
  padding: 0.35rem 0.8rem; font-size: 0.8rem; font-weight: 500;
  background: var(--accent); color: white; border: none;
  border-radius: 0.4rem; cursor: pointer;
}
.btn-add-pattern:hover { opacity: 0.9; }

.add-pattern-form {
  margin-bottom: 1rem; padding: 1rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 0.5rem;
}
.pattern-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 0.8rem;
}
.pf-field label {
  display: block; font-size: 0.72rem; font-weight: 500;
  color: var(--text-dim); margin-bottom: 0.2rem;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.pf-field.full-width { grid-column: 1 / -1; }
.pattern-form-actions {
  display: flex; gap: 0.5rem; margin-top: 0.75rem;
  padding-top: 0.5rem; border-top: 1px solid var(--border);
}

.patterns-list { display: flex; flex-direction: column; gap: 0.5rem; }
.pattern-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 0.5rem; padding: 0.75rem;
}
.pattern-card-header {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.pattern-meta {
  font-size: 0.72rem; font-weight: 600; color: var(--accent);
  background: rgba(99,102,241,0.1); padding: 0.15rem 0.5rem;
  border-radius: 0.3rem;
}
.pattern-engagement {
  font-size: 0.72rem; color: var(--green); font-weight: 500;
}
.btn-delete-pattern {
  margin-left: auto; background: none; border: none;
  color: var(--text-dim); cursor: pointer; font-size: 0.9rem;
}
.btn-delete-pattern:hover { color: var(--red); }
.pattern-what-worked {
  font-size: 0.8rem; color: var(--text); margin-bottom: 0.35rem;
  font-weight: 500;
}
.pattern-example {
  font-size: 0.78rem; color: var(--text-dim); line-height: 1.5;
  font-style: italic; border-left: 2px solid var(--border);
  padding-left: 0.6rem;
}

/* ── Profile Editor ─────────────────────────────────────────────────── */
.profile-section {
  margin-top: 2.5rem; padding: 1.2rem 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.75rem;
}
.profile-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.profile-title { font-size: 1.1rem; font-weight: 600; color: var(--text); margin: 0; }
.profile-controls { display: flex; align-items: center; gap: 0.75rem; }
.profile-name {
  font-size: 0.85rem; color: var(--accent); font-weight: 500;
  background: rgba(99,102,241,0.1); padding: 0.25rem 0.65rem;
  border-radius: 0.4rem;
}
.btn-profile-toggle {
  padding: 0.4rem 0.9rem; font-size: 0.8rem; font-weight: 500;
  border: 1px solid var(--border); border-radius: 0.4rem;
  background: var(--surface); color: var(--text-dim); cursor: pointer;
  transition: all 0.15s;
}
.btn-profile-toggle:hover { border-color: var(--accent); color: var(--text); }

.profile-editor { margin-top: 1rem; }
.profile-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem 1rem;
}
.profile-field.full-width { grid-column: 1 / -1; }
.profile-field label {
  display: block; font-size: 0.75rem; font-weight: 500;
  color: var(--text-dim); margin-bottom: 0.25rem; text-transform: uppercase;
  letter-spacing: 0.03em;
}
.profile-input, .profile-textarea {
  width: 100%; padding: 0.5rem 0.65rem; font-size: 0.85rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 0.4rem; color: var(--text); font-family: inherit;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.profile-input:focus, .profile-textarea:focus {
  outline: none; border-color: var(--accent);
}
.profile-textarea { resize: vertical; }
.profile-json { font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; }

.profile-advanced {
  margin-top: 1rem; padding: 0.75rem; border: 1px solid var(--border);
  border-radius: 0.5rem; background: var(--bg);
}
.profile-advanced summary {
  cursor: pointer; font-size: 0.8rem; color: var(--text-dim); font-weight: 500;
}
.profile-advanced[open] summary { margin-bottom: 0.5rem; }

.profile-actions {
  display: flex; align-items: center; gap: 0.75rem;
  margin-top: 1rem; padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.btn-profile-save {
  padding: 0.5rem 1.2rem; font-size: 0.85rem; font-weight: 600;
  background: var(--accent); color: white; border: none;
  border-radius: 0.4rem; cursor: pointer; transition: opacity 0.15s;
}
.btn-profile-save:hover { opacity: 0.9; }
.btn-profile-cancel {
  padding: 0.5rem 1rem; font-size: 0.85rem; font-weight: 500;
  background: transparent; color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 0.4rem; cursor: pointer;
}
.btn-profile-cancel:hover { color: var(--text); border-color: var(--text-dim); }
.profile-save-status { font-size: 0.8rem; color: var(--text-dim); }
.profile-saved { color: var(--green); }
.profile-error { color: var(--red); }

/* ── Adjacent Niches editor ───────────────────────────────────────────── */
.btn-add-niche {
  margin-top: 0.6rem; padding: 0.35rem 0.85rem;
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  background: transparent; color: var(--accent);
  border: 1px dashed var(--accent); border-radius: 0.4rem;
  transition: background 0.15s;
}
.btn-add-niche:hover { background: rgba(99,102,241,0.08); }

.niche-row {
  border: 1px solid var(--border); border-radius: 0.5rem;
  margin-bottom: 0.5rem; overflow: hidden;
}
.niche-row-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.6rem; background: var(--surface2);
}
.niche-toggle {
  font-size: 0.8rem; color: var(--text-dim); cursor: pointer;
  width: 14px; flex-shrink: 0; user-select: none;
}
.niche-row-header .niche-name {
  flex: 1; font-size: 0.85rem; font-weight: 500;
  background: transparent; border-color: transparent;
  padding: 0.2rem 0.4rem;
}
.niche-row-header .niche-name:focus { background: var(--surface); border-color: var(--accent); }
.btn-remove-niche {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 0.85rem; padding: 0.1rem 0.4rem;
  border-radius: 0.3rem; line-height: 1;
}
.btn-remove-niche:hover { color: var(--red); background: var(--red-bg); }
.niche-row-body {
  display: none; padding: 0.75rem 0.8rem; border-top: 1px solid var(--border);
}
.niche-row-body .profile-input,
.niche-row-body .profile-textarea { margin-bottom: 0.25rem; }

footer {
  border-top: 1px solid var(--border); padding: 1.5rem 0;
  margin-top: 3rem; text-align: center;
  font-size: 0.75rem; color: var(--text-dim);
}

/* ── Search Log section ───────────────────────────────────────────────── */
.search-log-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.75rem; padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}
.search-log-header {
  cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
}
.search-log-header:hover .section-title { color: var(--accent-hover); }
.sl-toggle-icon {
  font-size: 0.85rem; color: var(--text-dim); transition: transform 0.15s;
}
.sl-subtitle {
  font-size: 0.78rem; color: var(--text-dim); margin-left: 0.2rem;
}
#search-log-table-wrap { overflow-x: auto; margin-top: 1rem; }
.sl-table {
  width: 100%; border-collapse: collapse; font-size: 0.825rem;
}
.sl-table thead th {
  text-align: left; padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border); color: var(--text-dim);
  font-weight: 500; white-space: nowrap;
}
.sl-table tbody tr { border-bottom: 1px solid var(--border); }
.sl-table tbody tr:last-child { border-bottom: none; }
.sl-table tbody tr:hover { background: var(--surface2); }
.sl-table td { padding: 0.6rem 0.75rem; vertical-align: top; }
.sl-ts { white-space: nowrap; color: var(--text-dim); font-size: 0.78rem; min-width: 160px; }
.sl-queries { display: flex; flex-wrap: wrap; gap: 0.3rem; line-height: 1.6; }
.sl-chip {
  display: inline-block; padding: 0.15rem 0.5rem;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 0.3rem; font-size: 0.72rem; color: var(--text-dim);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sl-chip-more {
  background: transparent; color: var(--accent); border-color: var(--accent);
  cursor: default;
}
.sl-badge {
  display: inline-block; padding: 0.2rem 0.55rem;
  border-radius: 0.4rem; font-size: 0.75rem; font-weight: 600;
  white-space: nowrap;
}
.sl-badge-core {
  background: rgba(99, 102, 241, 0.15); color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.3);
}
.sl-badge-adj {
  background: rgba(234, 179, 8, 0.12); color: var(--yellow);
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.btn-retry {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 2px 10px; border-radius: 5px; cursor: pointer; font-size: 0.78rem;
  margin-left: 8px; font-family: inherit; transition: border-color 0.15s, color 0.15s;
}
.btn-retry:hover { border-color: var(--accent); color: var(--accent); }

/* ── Auto-Scan button & modal ──────────────────────────────────────── */
.section-header-actions {
  display: flex; align-items: center; gap: 0.5rem;
}

.btn-auto-scrape {
  padding: 0.35rem 0.8rem; font-size: 0.8rem; font-weight: 500;
  background: transparent; color: var(--accent);
  border: 1px solid rgba(99,102,241,0.5); border-radius: 0.4rem; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-auto-scrape:hover  { background: rgba(99,102,241,0.1); border-color: var(--accent); }
.btn-auto-scrape:disabled { opacity: 0.5; cursor: not-allowed; }

.scrape-status-bar {
  margin-bottom: 0.75rem; padding: 0.55rem 0.85rem;
  border-radius: 0.5rem; font-size: 0.82rem; font-weight: 500;
}
.scrape-status-running {
  background: rgba(99,102,241,0.1); color: var(--accent);
  border: 1px solid rgba(99,102,241,0.3);
  animation: scrape-pulse 1.5s ease-in-out infinite;
}
@keyframes scrape-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}
.scrape-status-done { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.scrape-status-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }

/* Modal overlay */
.scrape-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(2px);
}
.scrape-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 0.75rem; width: 420px; max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.scrape-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.95rem; color: var(--text);
}
.scrape-modal-close {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 1.1rem; padding: 0.2rem;
}
.scrape-modal-close:hover { color: var(--red); }
.scrape-modal-body { padding: 1rem 1.25rem; }
.scrape-hint {
  font-size: 0.8rem; color: var(--text-dim); line-height: 1.5;
  margin-bottom: 0.85rem;
}
.scrape-field { margin-bottom: 0.75rem; }
.scrape-field label {
  display: block; font-size: 0.72rem; font-weight: 500;
  color: var(--text-dim); margin-bottom: 0.25rem;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.scrape-modal-footer {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.85rem 1.25rem; border-top: 1px solid var(--border);
}
