:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #252836;
  --bg-hover: #2a2d3a;
  --border: #2e3142;
  --text: #e1e4ed;
  --text-dim: #8b8fa3;
  --text-muted: #5f6373;
  --accent: #6c5ce7;
  --accent-hover: #7c6ef7;
  --green: #00b894;
  --blue: #0984e3;
  --yellow: #fdcb6e;
  --red: #e17055;
  --gray: #636e72;
  --score-high: #00b894;
  --score-mid: #fdcb6e;
  --score-low: #e17055;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

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

header {
  padding: 20px 24px 0;
  max-width: 900px;
  margin: 0 auto;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

nav#tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 10px 20px;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }
.hidden { display: none !important; }

/* Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

input[type="url"], select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="url"]:focus, select:focus {
  border-color: var(--accent);
}

select option {
  background: var(--bg-input);
  color: var(--text);
}

button[type="submit"], .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
}

button[type="submit"]:hover, .btn:hover {
  background: var(--accent-hover);
}

button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading */
.loading {
  text-align: center;
  padding: 32px 0;
  color: var(--text-dim);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Error */
.error-box {
  background: rgba(225, 112, 85, 0.1);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--red);
  margin-top: 16px;
  font-size: 0.9rem;
}

/* Result Card */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
  box-shadow: var(--shadow);
}

.result-card h2 {
  font-size: 1.15rem;
  margin-bottom: 12px;
  line-height: 1.4;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

/* Score badge */
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.score-badge .bar {
  width: 40px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.score-badge .bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.score-high { background: rgba(0,184,148,0.15); color: var(--score-high); }
.score-high .bar-fill { background: var(--score-high); }
.score-mid { background: rgba(253,203,110,0.15); color: var(--score-mid); }
.score-mid .bar-fill { background: var(--score-mid); }
.score-low { background: rgba(225,112,85,0.15); color: var(--score-low); }
.score-low .bar-fill { background: var(--score-low); }

/* Action pills */
.action-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.action-implement { background: rgba(0,184,148,0.15); color: var(--green); }
.action-research_more { background: rgba(9,132,227,0.15); color: var(--blue); }
.action-bookmark { background: rgba(253,203,110,0.15); color: var(--yellow); }
.action-skip { background: rgba(99,110,114,0.15); color: var(--gray); }

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  background: var(--bg-input);
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
}

/* Result body (rendered markdown) */
.result-body {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
}

.result-body h1, .result-body h2, .result-body h3 {
  margin: 16px 0 8px;
  color: var(--text);
}

.result-body h1 { font-size: 1.1rem; }
.result-body h2 { font-size: 1rem; }
.result-body h3 { font-size: 0.95rem; }

.result-body p { margin-bottom: 10px; }

.result-body ul, .result-body ol {
  padding-left: 20px;
  margin-bottom: 10px;
}

.result-body li { margin-bottom: 4px; }

.result-body code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
}

.result-body pre {
  background: var(--bg-input);
  padding: 12px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 10px;
}

.result-body pre code {
  background: none;
  padding: 0;
}

.result-body blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.result-body strong { color: var(--text); }

.result-body a {
  color: var(--accent);
  text-decoration: none;
}
.result-body a:hover { text-decoration: underline; }

/* Submissions header */
.submissions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.submissions-header h2 {
  font-size: 1.15rem;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-controls label {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.sort-controls select {
  width: auto;
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* Submission cards */
.submission-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.submission-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.submission-card.expanded {
  border-color: var(--accent);
}

.submission-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.submission-title {
  font-size: 0.95rem;
  font-weight: 500;
  flex: 1;
  line-height: 1.4;
}

.submission-score {
  flex-shrink: 0;
}

.submission-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.submission-detail {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.submission-card.expanded .submission-detail {
  display: block;
}

.submission-url {
  font-size: 0.8rem;
  color: var(--text-muted);
  word-break: break-all;
}

.submission-url a {
  color: var(--accent);
  text-decoration: none;
}
.submission-url a:hover { text-decoration: underline; }

/* Metric badges */
.metric-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.metric-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.metric-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Duplicate badge */
.dup-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  background: rgba(225, 112, 85, 0.15);
  color: var(--red);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

/* Header row */
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* Search */
.search-row {
  display: flex;
  gap: 8px;
}

.search-row input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-row input:focus {
  border-color: var(--accent);
}

.section-title {
  font-size: 1.15rem;
  margin-bottom: 16px;
}

/* Search result cards (reuse submission-card style) */
.search-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.search-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.search-card.expanded {
  border-color: var(--accent);
}

.search-card .submission-detail {
  display: none;
}

.search-card.expanded .submission-detail {
  display: block;
}

/* Dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-value.accent { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.blue { color: var(--blue); }
.stat-value.yellow { color: var(--yellow); }

.stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.dashboard-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.detail-card h3 {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }

.detail-row .label { color: var(--text-dim); }
.detail-row .value { color: var(--text); font-weight: 500; }

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.ok { background: var(--green); }
.status-dot.warn { background: var(--yellow); }
.status-dot.err { background: var(--red); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
}

.modal-body input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.modal-body input[type="password"]:focus {
  border-color: var(--accent);
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.btn-dim {
  background: var(--bg-input);
  color: var(--text-dim);
}

.btn-dim:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* Export bar */
.export-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0;
  padding: 8px 0;
}

.export-btns { display: flex; gap: 6px; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.text-dim { color: var(--text-dim); font-size: 0.85rem; }

/* Topic cards in dashboard */
.subsection-title {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin: 20px 0 10px;
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.topic-card:hover { border-color: var(--accent); background: var(--bg-hover); }
.topic-card .topic-name { font-weight: 500; margin-bottom: 4px; }
.topic-card .topic-stats { font-size: 0.8rem; color: var(--text-dim); }

/* Browse tab */
.browse-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.browse-header h2 { font-size: 1.15rem; }

.btn-block {
  display: block;
  width: 100%;
  margin-top: 12px;
  text-align: center;
}

/* Chat */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
  min-height: 300px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 2px;
}

.chat-bubble.assistant .result-body { font-size: 0.9rem; }
.chat-bubble.typing { color: var(--text-dim); font-style: italic; }

.chat-input-row {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.chat-input-row input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

.chat-input-row input:focus { border-color: var(--accent); }

/* More dropdown */
.tab-dropdown {
  position: relative;
}

.tab-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 50;
  min-width: 160px;
  padding: 4px 0;
  margin-top: 4px;
}

.tab-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.87rem;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s, background 0.15s;
}

.tab-dropdown-item:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.tab-dropdown-item.active {
  color: var(--accent);
}

/* Scan History */
.run-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.run-row:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.run-row.expanded .run-detail {
  display: block;
}

.run-status {
  flex-shrink: 0;
}

.run-info {
  flex: 1;
  min-width: 0;
}

.run-time {
  font-weight: 500;
  font-size: 0.9rem;
}

.run-summary {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.run-stats {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.run-detail {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.run-detail pre {
  background: var(--bg-input);
  padding: 10px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.8rem;
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
}

/* Digest cards */
.digest-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.digest-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.digest-card.expanded {
  border-color: var(--accent);
}

.digest-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.digest-title {
  font-weight: 500;
  font-size: 0.95rem;
}

.digest-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.digest-body {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.digest-card.expanded .digest-body {
  display: block;
}

/* Subscriber row */
.subscriber-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s;
}

.subscriber-row:hover {
  border-color: var(--accent);
}

.subscriber-row.disabled {
  opacity: 0.5;
}

.subscriber-info {
  flex: 1;
  min-width: 0;
}

.subscriber-name {
  font-weight: 500;
  font-size: 0.95rem;
}

.subscriber-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 2px;
  display: flex;
  gap: 10px;
}

.channel-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
}

.channel-telegram { background: rgba(9,132,227,0.15); color: var(--blue); }
.channel-whatsapp { background: rgba(0,184,148,0.15); color: var(--green); }

/* Auto-Implement */
.auto-impl-config .detail-card {
  margin-bottom: 16px;
}

.auto-impl-form .form-row {
  margin-bottom: 12px;
}

.auto-impl-form .form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.toggle-inline {
  display: inline-flex;
  margin-top: 4px;
}

.auto-impl-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.auto-impl-row .run-status {
  flex-shrink: 0;
}

.auto-impl-info {
  flex: 1;
  min-width: 0;
}

.auto-impl-title {
  font-weight: 500;
  font-size: 0.9rem;
}

.auto-impl-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 2px;
  display: flex;
  gap: 10px;
}

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 500;
}

.status-created { background: rgba(9,132,227,0.15); color: var(--blue); }
.status-running { background: rgba(253,203,110,0.15); color: var(--yellow); }
.status-completed { background: rgba(0,184,148,0.15); color: var(--green); }
.status-failed { background: rgba(225,112,85,0.15); color: var(--red); }

/* Sources Tab */
.sources-header, .topics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.sources-header h2, .topics-header h2 {
  font-size: 1.15rem;
}

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar select {
  width: auto;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.source-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.2s, background 0.2s;
}

.source-row:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.source-row.disabled {
  opacity: 0.5;
}

.source-info {
  flex: 1;
  min-width: 0;
}

.source-name {
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.source-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.source-meta a {
  color: var(--accent);
  text-decoration: none;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-meta a:hover { text-decoration: underline; }

.source-stats {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.source-stat {
  text-align: center;
}

.source-stat .stat-num {
  display: block;
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.source-stat .stat-lbl {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.source-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-input);
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* Type badge */
.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.type-rss { background: rgba(253,203,110,0.15); color: var(--yellow); }
.type-youtube_channel { background: rgba(225,112,85,0.15); color: var(--red); }
.type-website { background: rgba(9,132,227,0.15); color: var(--blue); }

/* Icon button variants */
.icon-btn-sm {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}

.icon-btn-sm:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.icon-btn-sm.danger:hover {
  color: var(--red);
  background: rgba(225,112,85,0.1);
}

/* Green button */
.btn-green {
  background: var(--green);
}

.btn-green:hover {
  background: #00d2a0;
}

.btn-green:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Dashboard title row */
.dashboard-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.dashboard-title-row .section-title {
  margin-bottom: 0;
}

/* Form row (side by side) */
.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* Modal wide */
.modal-wide {
  width: 520px;
}

/* Text input (for modals) */
input[type="text"], input[type="number"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--accent);
}

/* Topic admin cards */
.topic-admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: border-color 0.2s;
}

.topic-admin-card:hover {
  border-color: var(--accent);
}

.topic-admin-info {
  flex: 1;
  min-width: 0;
}

.topic-admin-name {
  font-weight: 500;
  font-size: 1rem;
  margin-bottom: 4px;
}

.topic-admin-slug {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: monospace;
}

.topic-admin-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 6px;
}

.topic-admin-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.topic-admin-stats {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
  align-items: center;
}

/* Error dot in source row */
.source-error {
  font-size: 0.75rem;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Scan result toast */
.scan-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 200;
  font-size: 0.9rem;
  animation: slideUp 0.3s ease-out;
  max-width: 360px;
}

.scan-toast.error {
  border-color: var(--red);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 600px) {
  header { padding: 16px 16px 0; }
  main { padding: 16px; }
  .tab { padding: 8px 14px; font-size: 0.85rem; }
  .submission-top { flex-direction: column; }
  .submissions-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .dashboard-details { grid-template-columns: 1fr; }
  .search-row { flex-direction: column; }
  .export-bar { flex-direction: column; gap: 8px; align-items: flex-start; }
  .chat-container { height: calc(100vh - 200px); }
  nav#tabs { overflow-x: auto; flex-wrap: nowrap; }
  .source-row { flex-wrap: wrap; }
  .source-stats { width: 100%; justify-content: flex-start; }
  .form-row { flex-direction: column; }
  .topic-admin-card { flex-direction: column; }
  .topic-admin-stats { width: 100%; justify-content: flex-start; }
}
