/* ---------- app dialogs (confirm/alert/prompt replacement) ---------- */
.dialog-card { max-width: 420px; }
.dialog-msg { margin: 4px 0 0; color: var(--text); font-size: 14px; line-height: 1.5;
  white-space: pre-wrap; }   /* honor the \n line breaks the old prompts used */
.dialog-input { width: 100%; margin-top: 14px; padding: 9px 12px; font-family: inherit;
  font-size: 14px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius); }
.dialog-input:focus { outline: none; border-color: var(--coral); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
/* a destructive confirm tints the OK button as a warning */
.dialog-card.danger .btn-accent { background: #ff4d6a; box-shadow: 0 4px 0 rgba(255,77,106,0.25); }
/* alert()-style single-button dialogs hide Cancel */
.dialog-card.alert-only .dialog-actions .btn-ghost { display: none; }

/* ---------- toasts (appToast) ---------- */
.toast-host { position: fixed; top: 16px; right: 16px; z-index: 90;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.app-toast { pointer-events: auto; min-width: 220px; max-width: 340px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--mint);
  border-radius: var(--radius); padding: 12px 16px; color: var(--text); font-size: 13.5px;
  line-height: 1.45; box-shadow: 0 12px 28px rgba(0,0,0,0.4);
  animation: toast-in 0.22s ease; white-space: pre-wrap; }
.app-toast.error { border-left-color: #ff4d6a; }
.app-toast.leaving { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
.log-link:hover { color: var(--text); }
#activityBackBtn { margin-bottom: 10px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px;
}
.stat-grid > div {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; text-align: center;
}
.stat-grid b { display: block; font-size: 18px; color: var(--text); }
.stat-grid span { font-size: 11px; color: var(--muted); }
.activity-err-line {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 6px;
}
.err-badge {
  flex-shrink: 0; font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: #ff7a90; background: var(--bg); padding: 2px 7px; border-radius: 8px; margin-top: 2px;
}
.err-body { min-width: 0; flex: 1; }
/* Rerun button on a source error sits at the right, aligned to the top */
.err-rerun { flex-shrink: 0; margin-top: 1px; }
.err-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.err-msg { font-size: 11.5px; color: var(--muted); word-break: break-word; }
.err-when { font-size: 10.5px; color: var(--muted); opacity: 0.7; margin-top: 2px; }
.failed-tags-grid { display: flex; flex-direction: column; gap: 8px; }
.failed-tag-card {
  display: flex; gap: 10px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px;
}
.failed-tag-card img {
  width: 52px; height: 52px; object-fit: cover; border-radius: 8px;
  cursor: pointer; flex-shrink: 0;
}
.ft-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.ft-name {
  font-size: 12px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.ft-err { font-size: 11px; color: #ff9aa8; word-break: break-word; }
.ft-info .btn-sm { align-self: flex-start; }

/* ---------- reusable SVG chevron ---------- */
.chev {
  width: 1em; height: 1em; flex-shrink: 0;
  vertical-align: -0.12em;               /* optical baseline align next to text */
  transition: transform 0.18s ease;
}
.chev-down  { transform: rotate(90deg); }
.chev-up    { transform: rotate(-90deg); }
.chev-left  { transform: rotate(180deg); }
/* right = base orientation, no rotation */

/* dropdown carets flip to point up when their menu is open */
.chev-toggle.open .chev-down { transform: rotate(-90deg); }

/* nav chevrons (prev/next, scroll-top) sit a touch larger for tap targets */
.photo-nav .chev, .scroll-top .chev { width: 1.4em; height: 1.4em; vertical-align: middle; }

/* ---------- chevron button layout ---------- */
/* text+chevron buttons: keep the glyph vertically centered next to the label */
.filters-btn, #profileFetchBtn, .review-dd-wrap .chev-toggle,
.review-pager .btn-sm, #reviewApproveBtn, #activityBackBtn {
  display: inline-flex; align-items: center; gap: 5px; justify-content: center;
}
/* icon-only nav buttons now hold an SVG, not a big glyph -- reset glyph padding */
.photo-nav { padding: 0 !important; }
.photo-nav .chev { width: 22px; height: 22px; }
.scroll-top { display: inline-flex; align-items: center; justify-content: center; }
.scroll-top .chev { width: 20px; height: 20px; }
.ig-caret .chev { width: 0.85em; height: 0.85em; }

/* ---------- automation status row (status + cancel button) ---------- */
.auto-status-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }

/* ---------- login gate overlay ----------
   Full-screen cover shown when there is no session. Uses the same palette
   variables as the rest of the UI so it re-skins with the active theme. */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-overlay.hidden { display: none; }
.login-card {
  display: flex; flex-direction: column; gap: 14px;
  width: min(360px, 90vw);
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}
.login-brand {
  font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 30px;
  color: var(--coral); text-align: center; line-height: 1;
}
.login-sub {
  color: var(--muted); text-align: center; font-size: 13px; margin-top: -6px;
  margin-bottom: 4px;
}
.login-card input {
  padding: 12px 14px; font-size: 15px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.login-card input:focus { outline: 2px solid var(--coral); outline-offset: 1px; }
.login-card button {
  padding: 12px 14px; font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--coral); color: var(--ink);
  border: none; border-radius: var(--radius);
}
.login-card button:disabled { opacity: 0.6; cursor: default; }
.login-error {
  color: var(--coral); font-size: 13px; text-align: center;
}
.login-error.hidden { display: none; }
/* public_preview (opt-in): "Continue browsing" inside the overlay -- a way out
   for a preview visitor who opened the login form then changed their mind.
   Overrides the coral-fill .login-card button rule so it reads as secondary,
   not a second primary action next to Sign in. */
.login-card button.login-cancel {
  background: none; color: var(--muted); font-weight: 400; font-size: 13px;
  padding: 4px; text-decoration: underline;
}
.auto-status-row .auto-status { flex: 1; min-width: 0; }
#cancelCurrentBtn { flex-shrink: 0; }

/* ---------- source trust indicator ---------- */
.src-trusted { color: #6fe0a0; font-weight: 600; }
.src-trust-on { color: #6fe0a0; border-color: #6fe0a0; }

/* ---------- sources grouped by connected person ---------- */
.source-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.source-group-head { display: flex; align-items: center; gap: 8px; padding: 6px 4px;
  border-bottom: 1px solid var(--border); cursor: pointer; }
.source-group-head .chev { width: 0.9em; height: 0.9em; opacity: 0.7; flex: none; }
.source-group-head:hover .chev { opacity: 1; }
.source-group-head[aria-expanded="false"] .chev-down { transform: rotate(0deg); }  /* point right when collapsed */
.source-group-body { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.source-group-body.collapsed { display: none; }

/* filter box above the sources list -- 29+ groups / 90+ sources gets unwieldy
   to scan by eye, so a quick text filter (label/url/group/person) auto-expands
   any matching group. */
.src-filter-in { display: block; width: 100%; box-sizing: border-box; margin-top: 8px;
  padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-family: inherit; font-size: 13px; }
.src-filter-in:focus { outline: none; border-color: var(--coral); }
.src-filter-in::placeholder { color: var(--muted); }

/* per-row "More" overflow menu: setup-time controls (rename, frequency, group,
   link, limit, hint, remove) that clutter a row when there are dozens of them
   on screen at once. Run now / Trust / Enable stay on the row itself. */
.src-more-wrap { position: relative; }
.src-more-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 70;
  min-width: 160px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px; box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  display: flex; flex-direction: column; gap: 4px; align-items: stretch;
}
.src-more-menu .btn-ghost, .src-more-menu select { width: 100%; text-align: left; }

/* group picker popover: replaces a free-text group prompt with a click list
   of existing groups (avoids re-forking a near-duplicate by typo) plus a
   "New group" entry. Positioned fixed, anchored to the row's Group button. */
.group-picker-menu {
  z-index: 80; min-width: 200px; max-width: 280px; max-height: 320px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px; box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  display: flex; flex-direction: column; gap: 2px;
}
.group-picker-menu .review-dd-item.gp-current { color: var(--coral); font-weight: 600; }
.group-picker-sep { height: 1px; background: var(--border); margin: 4px 2px; flex: none; }
.group-picker-new { display: flex; gap: 6px; padding: 2px; }
.group-picker-input { flex: 1; min-width: 0; padding: 6px 8px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 12px; }
.group-picker-input:focus { outline: none; border-color: var(--coral); }
.sg-icon { flex: none; width: 22px; height: 22px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 13px; line-height: 1; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border); }
.sg-icon.status-active { color: var(--mint); border-color: color-mix(in srgb, var(--mint) 40%, transparent); }
.sg-icon.status-guest  { color: var(--lavender); border-color: color-mix(in srgb, var(--lavender) 35%, transparent); }
.sg-icon.status-former { color: var(--muted); }
.sg-icon-other { color: var(--muted); font-weight: 700; }
.sg-name { font-weight: 600; font-size: 13px; color: var(--text); }
.sg-count { margin-left: auto; font-size: 11px; color: var(--muted);
  background: var(--surface); border-radius: 999px; padding: 1px 8px; }
/* group-header "Rename group" sits after the count pill, flush right */
.sg-rename { flex: none; }
/* per-row connection chip: which person this source feeds. '~' + dimmer = a
   URL-derived guess; solid = a manual link. */
.src-conn { color: var(--mint); font-weight: 600; }
.src-conn.derived { color: var(--muted); font-style: italic; }

/* ---------- automation not-owner warning ---------- */
.auto-not-owner { color: #ffb020; font-size: 12px; }

/* ---------- re-tag test-batch review ---------- */
.retag-review-list { max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.retag-review-row { display: flex; gap: 12px; padding: 8px; background: var(--surface-2); border-radius: 10px; }
.retag-review-row img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.retag-review-body { min-width: 0; flex: 1; }
.retag-cap { font-size: 13px; margin-bottom: 6px; word-break: break-word; }
.retag-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.retag-chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.retag-chip.added { background: color-mix(in srgb, var(--mint) 18%, transparent); color: var(--mint); }
.retag-chip.removed { background: color-mix(in srgb, var(--coral) 16%, transparent); color: var(--coral); text-decoration: line-through; }
.retag-err { color: var(--coral); font-size: 13px; }
