/* Subject Ingestion: the guided bulk-add "mini Studio" (#subject-ingest-root).

   Layout-only .sing-* namespace, exactly like scrape-builder.css adds .sbx-*.
   Every reusable atom is borrowed as-is: .card (shared.css), .sbx-ic--thumb
   (scrape-builder.css), the .badge family, .btn / .btn-primary / .icon-btn,
   .filter-chip, the .st-check checkbox, and the dot-loaders. The chat pane mirrors
   the hook-builder thread (.settings-builder-* in app.css); the review pane mirrors
   the Studio cards. Tokens + the 8/16/24/32 spacing scale throughout. */

#subject-ingest-root { height: 100%; }
/* Fill the canvas like Studio (.sbx-main), not the capped .ps-page measure, so
   the two panes get the full workspace width. Overrides .ps-page max-width/margin. */
.sing-page { display: flex; flex-direction: column; height: 100%; max-width: none; margin: 0; padding: 24px 32px 0; }
.sing-page .ps-header { margin-bottom: 16px; }
.sing-subtitle { margin: 6px 0 0; color: var(--text-secondary); font-size: var(--text-sm); max-width: 640px; line-height: 1.6; }

/* Two panes: a fixed chat column + a flexible review column. */
.sing-shell {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 380px 1fr; gap: 24px;
  padding-bottom: 24px;
}

/* ---------- chat pane (mirrors .settings-builder-chat) ---------- */
.sing-chat {
  display: flex; flex-direction: column; min-height: 0;
  border: 1px solid var(--border-default); border-radius: var(--radius);
  background: var(--page-bg); overflow: hidden;
}
.sing-chatbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-bottom: 1px solid var(--border-default);
}
.sing-newchat { height: 32px; padding: 0 10px; font-size: var(--text-xs); }
.sing-newchat svg { width: 14px; height: 14px; }
.sing-thread {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; gap: 14px;
  justify-content: flex-start; overflow-y: auto; padding: 16px;
}
.sing-msg { display: flex; flex-direction: column; gap: 8px; max-width: 90%; }
.sing-msg--user { align-self: flex-end; align-items: flex-end; }
.sing-msg--assistant { align-self: flex-start; align-items: flex-start; }
.sing-bubble {
  padding: 10px 14px; border-radius: 0;
  font-size: var(--text-sm); line-height: 1.5; color: var(--text-primary);
}
.sing-msg--user .sing-bubble { background: var(--accent); color: #fff; }
.sing-msg--assistant .sing-bubble { background: var(--surface-bg); border: 1px solid var(--border-default); }
.sing-bubble-text { white-space: pre-wrap; }
.sing-bubble-err { margin-top: 8px; font-size: var(--text-xs); color: var(--negative); line-height: 1.4; }
/* Activity line: the in-chat record of a UI action (replaces the old toast
   banner). Centered, muted, full-width so it reads as a timeline marker rather
   than a chat bubble. */
.sing-activity {
  align-self: center; display: flex; align-items: center; gap: 6px;
  max-width: 100%; padding: 2px 0;
  font-size: var(--text-xs); color: var(--text-tertiary); line-height: 1.4; text-align: center;
}
.sing-activity svg { width: 13px; height: 13px; flex: none; color: var(--text-tertiary); }
.sing-clarify { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; max-width: 100%; }
.sing-clarify-hint { width: 100%; font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }

.sing-compose { padding: 12px; border-top: 1px solid var(--border-default); }
.sing-inputwrap { position: relative; display: flex; }
.sing-text {
  flex: 1 1 auto; max-height: 200px; overflow-y: auto; resize: none;
  padding: 6px 52px 6px 2px; border: none; border-radius: 0;
  background: transparent; color: var(--text-primary);
  font: inherit; font-size: var(--text-sm); line-height: 1.5; outline: none;
}
.sing-text::placeholder { color: var(--text-tertiary); }
.sing-send {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 0; background: var(--accent); color: #fff; cursor: pointer;
}
.sing-send:hover { filter: brightness(1.1); }
.sing-send:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.sing-send svg { width: 18px; height: 18px; stroke-width: 2.2; }

/* ---------- review pane ---------- */
.sing-review {
  display: flex; flex-direction: column; min-height: 0;
  border: 1px solid var(--border-default); border-radius: var(--radius);
  background: var(--page-bg); overflow: hidden;
}
.sing-review-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px; }

/* clarity bar: stats announce themselves in plain words (reused .badge atoms) */
.sing-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

/* plain-words progress line with a dot-loader matched to the stage */
.sing-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; color: var(--text-secondary); font-size: var(--text-sm); }
.sing-progress .dot-loader { --dot-size: 16px; }
.sing-progress svg { width: 16px; height: 16px; color: var(--positive); }
.sing-running { display: flex; align-items: center; justify-content: center; min-height: 220px; }

/* empty / no-result hero */
.sing-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; gap: 6px; }
.sing-empty-glyph { color: var(--accent); margin-bottom: 8px; }
.sing-empty-glyph svg { width: 30px; height: 30px; stroke-width: 1.5; }
.sing-empty h3 { font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); }
.sing-empty p { color: var(--text-secondary); font-size: 13px; max-width: 400px; margin: 0; line-height: 1.6; }

/* watchlist depth control: a two-state .filter-chip toggle, research-driven and
   pre-selected, with a plain-words "why" line under it (US-013) */
.sing-depth { padding: 0 20px; margin: 16px 0 4px; }
.sing-depth-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sing-depth-label { font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary); margin-right: 4px; }
.sing-depth-chip { gap: 6px; }
.sing-depth-rec {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent); background: var(--accent-subtle); border-radius: 999px; padding: 1px 6px;
}
.sing-depth-chip.active .sing-depth-rec { color: var(--accent); }
.sing-depth-why { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 6px; }

/* topic groups, exactly like Studio groups by container */
.sing-groups { display: flex; flex-direction: column; gap: 24px; }
.sing-group-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
/* per-topic select-all / none, right-aligned in line with the topic title */
.sing-group-actions { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.sing-group-name { font-family: 'Host Grotesk', sans-serif; font-size: var(--text-md); font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); }
.sing-group-n { font-size: var(--text-xs); color: var(--text-tertiary); font-variant-numeric: tabular-nums; }

.sing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }

/* candidate card: reuse .card shell; lay out check + thumb + body + topic */
.sing-card {
  position: relative; min-width: 0; display: grid;
  grid-template-columns: auto 44px minmax(0, 1fr); grid-template-rows: 20px 20px;
  align-items: center; gap: 4px 12px; padding: 12px;
  min-height: 68px;
  transition: opacity var(--transition-fast);
  cursor: pointer;
}
.sing-card.is-skipped { opacity: 0.5; }
.sing-card-check { grid-row: 1 / span 2; }
.sing-card-thumb { grid-row: 1 / span 2; width: 44px; height: 44px; }
.sing-card-thumb svg { width: 18px; height: 18px; color: var(--text-tertiary); }
.sing-card-body { min-width: 0; grid-column: 3; grid-row: 1; }
.sing-card-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 20px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sing-card-brand { font-weight: 600; }
.sing-card-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sing-card-normalizing {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}
.sing-card-normalizing .dot-loader { --dot-size: 12px; }
/* badges sit inline with the topic chip, matched to its height + proportions */
.sing-card-badges { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.sing-card-badges .badge {
  height: 20px;
  padding: 0 8px;
  font-size: 11px;
  line-height: 18px;
  white-space: nowrap;
}
.sing-card-topicwrap { position: relative; grid-column: 3; grid-row: 2; justify-self: start; max-width: 100%; display: flex; align-items: center; gap: 6px; min-width: 0; }
.sing-topic-chip {
  flex: 0 1 auto;
  height: 20px;
  min-width: 0;
  max-width: 100%;
  padding: 0 8px;
  gap: 5px;
  font-size: 11px;
  line-height: 18px;
}
.sing-topic-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sing-topic-chip svg { flex: 0 0 auto; width: 11px; height: 11px; stroke-width: 1.8; }

/* ── Phase-2 streaming placeholders (t=0 "Looking at {brand}…") ── */
.sing-card--skel {
  display: flex; align-items: center; gap: 10px;
  cursor: default; border-color: var(--border-subtle);
}
.sing-card--skel .dot-loader { flex: 0 0 auto; color: var(--text-tertiary); }
.sing-skel-label { font-size: var(--text-base); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sing-skel-label strong { color: var(--text-primary); font-weight: 600; }

/* per-card topic dropdown (modeled on the .sbx-attr-menu pattern) */
.sing-topicmenu {
  position: absolute; left: 0; top: calc(100% + 4px); z-index: 20; width: 240px; padding: 6px;
  background: var(--page-bg); border: 1px solid var(--border-default); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(44, 48, 80, 0.18);
}
.sing-topic-opts { display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow-y: auto; }
.sing-topic-opt {
  text-align: left; padding: 7px 10px; border: none; background: none; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; color: var(--text-primary); cursor: pointer;
}
.sing-topic-opt:hover { background: var(--accent-subtle); }
.sing-topic-opt.is-current { color: var(--accent); font-weight: 600; }
.sing-topic-empty { padding: 8px 10px; font-size: var(--text-xs); color: var(--text-tertiary); }
.sing-topic-add { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border-subtle); }
.sing-topic-input {
  flex: 1; min-width: 0; height: 32px; padding: 0 10px;
  border: 1px solid var(--border-default); border-radius: var(--radius);
  background: var(--page-bg); color: var(--text-primary); font-family: inherit; font-size: 13px; outline: none;
}
.sing-topic-input:focus { border-color: var(--accent-border); box-shadow: var(--shadow-focus); }

/* commit bar pinned to the bottom of the review pane (echoes .sbx-launchbar) */
.sing-commitbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; border-top: 1px solid var(--border-default); background: var(--page-bg);
}
.sing-commit-scope { flex: 1; min-width: 0; }
.sing-commit-count { font-family: 'Host Grotesk', sans-serif; font-size: var(--text-md); font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); }
.sing-commit-count b { color: var(--accent); }
.sing-commit-detail { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 4px; }
.sing-commit-btn { height: 40px; padding: 0 16px; font-size: 13px; }
.sing-commit-btn svg { width: 16px; height: 16px; }
.sing-commit-btn .dot-loader { --dot-size: 14px; }

/* Phase-1 confirm gate: the two brand actions sit side by side at the bottom. */
.sing-confirm-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.sing-find-btn, .sing-brands-only-btn { height: 40px; padding: 0 16px; font-size: 13px; }
.sing-find-btn svg { width: 16px; height: 16px; }
.sing-find-btn .dot-loader { --dot-size: 14px; }

@media (max-width: 980px) {
  .sing-shell { grid-template-columns: 1fr; grid-auto-rows: minmax(320px, auto); }
}
