/* ============================================================
   MABEL INBOX — component styles
   "Your email, looked after."
   Built entirely on the design token sheet (colors_and_type.css).
   Class names match the app templates; values reference tokens only.
   Periwinkle is a LIGHT accent: fills carry dark ink
   (--color-accent-ink); thin marks/text on white use the deeper
   --color-accent-strong. Semantics (green/amber/red) stay conventional.
   ============================================================ */

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --sidebar-w: 280px;
  --header-h: 52px;
  --radius: var(--radius-md);
  --shadow: var(--shadow-sm);

  /* Legacy aliases → Mabel tokens (safety net for any stray references) */
  --blue: var(--color-accent-strong);
  --blue-hover: var(--color-accent-hover);
  --red: var(--color-danger);
  --green: var(--color-success);
  --yellow: var(--color-warning);
  --gray-50:  var(--color-bg);
  --gray-100: var(--color-surface-sunken);
  --gray-200: var(--color-border);
  --gray-300: var(--color-border-strong);
  --gray-400: var(--color-text-tertiary);
  --gray-500: var(--color-text-tertiary);
  --gray-600: var(--color-text-secondary);
  --gray-700: var(--color-text-secondary);
  --gray-800: var(--color-text-primary);
  --gray-900: var(--color-text-primary);
}
html, body { height: 100%; font-family: var(--font-sans);
  font-size: var(--text-base); line-height: var(--text-base-lh);
  color: var(--color-text-primary); background: var(--color-bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button { cursor: pointer; font-family: inherit; font-size: var(--text-base);
  border: none; border-radius: var(--radius-md);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), opacity var(--dur) var(--ease); }
input, select, textarea { font-family: inherit; font-size: var(--text-base);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 8px 10px; width: 100%;
  background: var(--color-surface-sunken); color: var(--color-text-primary); }
input::placeholder, textarea::placeholder { color: var(--color-text-tertiary); }
input:focus, select:focus, textarea:focus { outline: none;
  border-color: var(--color-accent-strong);
  box-shadow: 0 0 0 1px var(--color-accent-strong); }
label { display: flex; flex-direction: column; gap: 4px;
  font-size: var(--text-sm); color: var(--color-text-secondary); }
::selection { background: var(--color-accent-subtle); }
.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; }

/* Universal keyboard focus ring (brief: 2px accent-strong, 2px offset) */
:focus-visible { outline: 2px solid var(--color-accent-strong); outline-offset: 2px; }

/* ── Line icons (Lucide) ─────────────────────────────────────────────────── */
/* Inherit currentColor; thin strokes. Built-in bucket chrome uses these;
   user-created bucket labels still use emoji glyphs (rendered as text). */
.licon { display: inline-block; vertical-align: -0.18em; flex: none; }
.bucket-icon .licon { color: var(--color-text-tertiary); }
.bucket-item.active .bucket-icon .licon { color: var(--color-accent-strong); }
.rule-card-icon .licon, .apply-rule-icon .licon, .log-bucket .licon { color: var(--color-text-secondary); }
.match-rule-badge .licon { color: var(--color-accent-strong); }
.match-rule-btn.has-action .licon { color: var(--color-success); }
.stat-chip .licon, .sidebar-lifetime-stats .licon { color: var(--color-text-tertiary); vertical-align: -0.16em; }
.unsub-reminder-banner .licon { color: var(--color-accent-strong); }
.junk-reminder-banner .licon { color: var(--color-warning); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; }
.btn-primary { background: var(--color-accent); color: var(--color-accent-ink);
  font-weight: 500; padding: 8px 18px; }
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:active { transform: translateY(0.5px); }
.btn-secondary { background: var(--color-surface); color: var(--color-text-primary);
  font-weight: 500; padding: 7px 16px; border: 1px solid var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-surface-sunken); }
.btn-danger { background: var(--color-danger); color: #fff; font-weight: 500; padding: 7px 16px; }
.btn-danger:hover { background: var(--color-danger-hover); }
.btn-icon { background: none; padding: 4px 6px; color: var(--color-text-secondary); border-radius: var(--radius-sm); }
.btn-icon:hover { background: var(--color-surface-sunken); color: var(--color-text-primary); }
.btn-large { width: 100%; padding: 12px; font-size: var(--text-lg); font-weight: 500; height: 44px; }
.full-width { width: 100%; margin-top: 6px; }
.btn-small { padding: 5px 12px; font-size: var(--text-sm); margin-top: 2px; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout-shell { display: flex; flex-direction: column; height: 100vh; }
.layout-body { display: flex; flex: 1; overflow: hidden; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}
.header-title { display: flex; align-items: center; gap: 9px;
  font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.014em; }
.header-account { margin-left: auto; color: var(--color-text-secondary); font-size: var(--text-sm); }
.theme-toggle { background: none; border: none; color: var(--color-text-secondary);
  width: 32px; height: 32px; border-radius: var(--radius-sm); font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { background: var(--color-surface-sunken); color: var(--color-text-primary); }

/* ── Brand presence mark (Mabel avatar + friendly coral dot) ─────────────── */
.pmark { position: relative; display: inline-flex; flex: none; }
.pmark img, .pmark svg { display: block; border-radius: 50%; }
.pmark .pdot { position: absolute; right: -1px; bottom: -1px; width: 34%; height: 34%;
  border-radius: 50%; background: #E8956F; box-shadow: 0 0 0 2px var(--pring, var(--color-surface)); }
.pmark.busy .pdot { animation: watch 1.4s var(--ease) infinite; }
@keyframes watch {
  0%   { box-shadow: 0 0 0 2px var(--pring, var(--color-surface)), 0 0 0 1px rgba(232,149,111,0.5); }
  70%  { box-shadow: 0 0 0 2px var(--pring, var(--color-surface)), 0 0 0 7px rgba(232,149,111,0); }
  100% { box-shadow: 0 0 0 2px var(--pring, var(--color-surface)), 0 0 0 0 rgba(232,149,111,0); }
}

/* ── Session stats bar ───────────────────────────────────────────────────── */
.stats-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 16px; height: 40px; background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0; font-size: var(--text-xs); color: var(--color-text-secondary);
}
.stats-progress-track { flex: 1; max-width: 280px; height: 6px;
  background: var(--color-border); border-radius: var(--radius-full); overflow: hidden; }
.stats-progress-fill { height: 100%; background: var(--color-accent-strong);
  border-radius: var(--radius-full); transition: width 0.3s var(--ease); }
.stats-processed { color: var(--color-text-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats-chips { margin-left: auto; display: flex; gap: 6px; }
.stats-none { margin-left: auto; color: var(--color-text-tertiary); }
.stat-chip { display: inline-flex; align-items: center; gap: 5px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-full); padding: 3px 9px; white-space: nowrap; font-weight: 500; }

/* ── Centered screens ───────────────────────────────────────────────────── */
.screen-center { display: flex; align-items: center; justify-content: center; flex: 1; padding: 24px; }

/* ── Sign-in ─────────────────────────────────────────────────────────────── */
.signin-screen { background: var(--color-bg); position: relative; }
.release-stamp { position: absolute; bottom: 5px; left: 0; right: 0; margin: 0;
  text-align: center; font-size: var(--text-xs); color: var(--color-text-tertiary); opacity: .5; user-select: none; }
.signin-card { background: var(--color-surface); border-radius: var(--radius-xl);
  padding: 40px; text-align: center; max-width: 380px; width: 100%; box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; align-items: center; gap: 14px; }
.signin-card .pmark { margin-bottom: 2px; }
.app-logo { font-size: 48px; line-height: 1; }
.signin-card h1 { font: var(--text-2xl-w) var(--text-2xl)/var(--text-2xl-lh) var(--font-sans);
  letter-spacing: -0.02em; }
.signin-card .tagline { color: var(--color-text-secondary); font-size: var(--text-base);
  margin-top: -8px; }
.signin-card .signin-fine { font-size: var(--text-xs); color: var(--color-text-tertiary); margin-top: 2px; }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 44px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong); background: var(--color-surface);
  font-weight: 500; font-size: var(--text-base); color: var(--color-text-primary); }
.gbtn:hover { background: var(--color-surface-sunken); }
.gbtn .g { width: 18px; height: 18px; flex: none; }

/* ── Filter screen ───────────────────────────────────────────────────────── */
.filter-screen { background: var(--color-bg); }
.limit-warning { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--color-warning-subtle);
  border: 1px solid var(--color-warning); color: var(--color-text-secondary);
  font-size: var(--text-sm); line-height: var(--text-sm-lh); }
.limit-warning[hidden] { display: none; }
.filter-card { background: var(--color-surface); border-radius: var(--radius-lg);
  padding: 36px 32px; width: 100%; max-width: 540px; box-shadow: var(--shadow-md); }
.app-explainer { background: var(--color-surface-sunken); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 14px 16px; margin-bottom: 20px;
  display: flex; flex-direction: column; gap: 8px; }
.app-explainer p { font-size: var(--text-sm); color: var(--color-text-secondary); line-height: var(--text-sm-lh); margin: 0; }
.app-explainer strong { color: var(--color-text-primary); font-weight: 600; }
.filter-card h2 { font: var(--text-xl-w) var(--text-xl)/var(--text-xl-lh) var(--font-sans);
  letter-spacing: -0.012em; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.restored-tag { font-size: var(--text-xs); font-weight: 400; background: var(--color-surface-sunken);
  color: var(--color-text-secondary); border-radius: var(--radius-sm); padding: 2px 8px; }
.filter-tabs { display: flex; gap: 6px; margin-bottom: 20px;
  background: var(--color-surface-sunken); padding: 3px; border-radius: var(--radius-full); width: fit-content; }
.filter-tab { background: transparent; color: var(--color-text-secondary); padding: 6px 14px;
  border-radius: var(--radius-full); border: 1px solid transparent; font-weight: 500; font-size: var(--text-sm); }
.filter-tab.active { background: var(--color-accent); color: var(--color-accent-ink); }
.filter-tab:hover:not(.active) { color: var(--color-text-primary); }
.preset-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.preset-btn { background: var(--color-surface); color: var(--color-text-secondary); padding: 6px 14px;
  border-radius: var(--radius-full); border: 1px solid var(--color-border-strong); font-weight: 500; font-size: var(--text-sm); }
.preset-btn.active { background: var(--color-accent); color: var(--color-accent-ink); border-color: var(--color-accent); }
.preset-btn:hover:not(.active) { background: var(--color-surface-sunken); }
#custom-dates { display: flex; gap: 12px; margin-top: 10px; }
#custom-dates label { flex: 1; }
#filter-label, #filter-query { margin-bottom: 4px; }
.saved-rules-banner { background: var(--color-accent-subtle); border-radius: var(--radius-md);
  padding: 12px 16px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; font-size: var(--text-sm); color: var(--color-accent-strong); }
.progress-bar-wrap { background: var(--color-surface-sunken); border-radius: var(--radius-full);
  height: 8px; margin-top: 14px; overflow: hidden; }
.progress-bar { background: var(--color-accent-strong); height: 100%; display: flex; align-items: center;
  justify-content: center; color: transparent; font-size: 0; transition: width 0.3s var(--ease); min-width: 0; border-radius: var(--radius-full); }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto;
}
.sidebar-header { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 8px; font-weight: 600; font-size: var(--text-lg); color: var(--color-text-primary); }
.sidebar-title { font-size: var(--text-lg); letter-spacing: -0.006em; }
/* Segmented pill control — compact, hugs content, left-aligned */
.sidebar-filter { align-self: flex-start; display: inline-flex; gap: 2px; margin: 0 12px 10px; padding: 3px;
  background: var(--color-surface-sunken); border-radius: var(--radius-full); }
.sf-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  font-size: var(--text-sm); font-weight: 500; padding: 4px 12px; line-height: 1.2;
  border-radius: var(--radius-full); border: 0; background: transparent; color: var(--color-text-secondary); }
.sf-btn:hover:not(.active) { color: var(--color-text-primary); }
.sf-btn.active { background: var(--color-surface); color: var(--color-text-primary); box-shadow: var(--shadow-sm); }
.sf-btn .licon { color: var(--color-accent-strong); }
.bucket-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.bucket-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px 7px 9px;
  cursor: pointer; border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  transition: background var(--dur-fast) var(--ease);
}
.bucket-item:hover { background: var(--color-surface-sunken); }
.bucket-item.active { background: var(--color-bucket-active);
  border-left-color: var(--color-accent-strong); }
.bucket-icon { font-size: 15px; flex-shrink: 0; width: 18px; text-align: center; line-height: 1; }
.bucket-name { flex: 1; font-size: var(--text-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bucket-item.active .bucket-name { font-weight: 500; }
/* Round accent rule indicator (bucket has a saved bulk action) */
.rule-set-dot { width: 6px; height: 6px; border-radius: var(--radius-full);
  background: var(--color-accent-strong); flex: none; }
.bucket-count { font-size: var(--text-xs); font-variant-numeric: tabular-nums;
  color: var(--color-text-secondary); background: var(--color-surface-sunken);
  border-radius: var(--radius-full); padding: 1px 8px; flex: none; }
.bucket-count.zero { color: var(--color-text-tertiary); }
.bucket-item.active .bucket-count { background: var(--color-surface); }
/* Hover: reveal reorder + edit, hide count + rule dot */
.bucket-reorder { display: none; align-items: center; gap: 1px; flex: none; }
.bucket-item:hover .bucket-reorder { display: flex; }
.bucket-item:hover .bucket-count,
.bucket-item:hover .rule-set-dot { display: none; }
.bucket-reorder .btn-icon { padding: 2px 3px; line-height: 1; }
.bucket-reorder .btn-icon:disabled { opacity: .25; cursor: default; }
.btn-filter-unsub.active { background: var(--color-accent-subtle); color: var(--color-accent-strong); border-color: var(--accent-line); }
/* Group similar: layers glyph always renders in the accent tone */
#btn-group-toggle .licon { color: var(--color-accent-strong); }
.match-rule-badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs);
  background: var(--color-accent-subtle); color: var(--color-accent-strong); border-radius: var(--radius-full); padding: 2px 8px; flex: none; }
.match-rule-btn { border: none; cursor: pointer; font-family: inherit; transition: background var(--dur) var(--ease); }
.match-rule-btn:hover { background: var(--accent-line); }
.match-rule-btn.has-action { background: var(--color-success-subtle); color: var(--color-success); }
.match-rule-btn.has-action:hover { background: #D8EBDF; }
.btn-delete-action { color: var(--color-text-secondary); margin-left: -6px; }
.bucket-item.no-action-rule .bucket-name { color: var(--color-text-secondary); }
.bucket-item.no-action-rule .bucket-count { opacity: .7; }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 6px; }
.sidebar-footer .btn-secondary, .sidebar-footer .btn-apply-rules { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.sidebar-foot-row { display: flex; gap: 6px; }
.sidebar-foot-row .btn-secondary { flex: 1; min-width: 0; }

/* ── Main panel ──────────────────────────────────────────────────────────── */
.main-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--color-bg); }
.main-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--color-border);
  background: var(--color-bg); flex-shrink: 0;
}
.toolbar-spacer { flex: 1; }
/* Search field with leading icon */
.bucket-search-wrap { display: flex; align-items: center; gap: 8px; width: 240px;
  padding: 0 10px; height: 32px; background: var(--color-surface-sunken);
  border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.bucket-search-wrap .licon { color: var(--color-text-tertiary); flex: none; }
.bucket-search-wrap:focus-within { border-color: var(--color-accent-strong);
  background: var(--color-surface); box-shadow: 0 0 0 1px var(--color-accent-strong); }
.bucket-search-input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0;
  font-size: var(--text-sm); color: var(--color-text-primary); height: 100%; }
.bucket-search-input:focus { outline: none; box-shadow: none; }
.select-all-label { display: flex; align-items: center; gap: 8px; flex-direction: row;
  font-size: var(--text-sm); color: var(--color-text-secondary); cursor: pointer;
  white-space: nowrap; flex-shrink: 0; }
.select-all-label input { width: auto; }
/* Cap the smart bulk-action button so a long (nested) label can't blow out the
   toolbar; the inner text ellipsizes instead. Leaf-only labels (see _labelLeaf)
   keep this from triggering in the common case. */
#btn-bulk-action { max-width: 360px; }
.action-btn-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.email-list { flex: 1; overflow-y: auto; }

/* ── Quick groups panel (Unsorted) ─────────────────────────────────────────── */
.quick-groups { flex-shrink: 0; max-height: 46%; overflow-y: auto;
  padding: 12px 16px 14px; border-bottom: 1px solid var(--color-border);
  background: var(--color-surface); }
.qg-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.qg-title { display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: var(--text-sm); font-weight: 600; color: var(--color-text-primary); }
.qg-title .licon { color: var(--color-accent-strong); }
.qg-seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--color-surface-sunken);
  border-radius: var(--radius-full); }
.gb-seg { font-size: var(--text-sm); font-weight: 500; padding: 4px 12px; line-height: 1.2;
  border: 0; border-radius: var(--radius-full); background: transparent;
  color: var(--color-text-secondary); cursor: pointer; }
.gb-seg:hover:not(.active) { color: var(--color-text-primary); }
.gb-seg.active { background: var(--color-surface); color: var(--color-text-primary); box-shadow: var(--shadow-sm); }
.qg-rows { display: flex; flex-direction: column; gap: 6px; }
.qg-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.qg-row:hover { background: var(--color-surface-sunken); }
.qg-row.active { border-color: var(--color-accent-strong); background: var(--color-accent-subtle); }
.qg-icon { flex: none; display: inline-flex; }
.qg-icon .licon { color: var(--color-accent-strong); }
.qg-label { flex: 1; min-width: 0; font-size: var(--text-base); color: var(--color-text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qg-count { flex: none; font-size: var(--text-xs); font-weight: 600;
  padding: 2px 10px; border-radius: var(--radius-full);
  background: var(--color-accent-subtle); color: var(--color-accent-strong); }
.qg-addto-select { flex: none; max-width: 150px; height: 28px; padding: 0 8px;
  font-size: var(--text-sm); color: var(--color-text-secondary);
  background: var(--color-surface-sunken); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); cursor: pointer; }
.qg-addto-select:hover { color: var(--color-text-primary); border-color: var(--color-accent-strong); }
.qg-rule-btn { flex: none; display: inline-flex; align-items: center; gap: 4px; }
.qg-foot { margin: 10px 2px 0; font-size: var(--text-xs); color: var(--color-text-tertiary);
  display: flex; align-items: center; gap: 6px; }
.qg-foot .licon { color: var(--color-accent-strong); flex: none; }
.qg-foot strong { color: var(--color-text-secondary); font-weight: 600; }
.qg-empty { margin: 4px 2px; font-size: var(--text-sm); color: var(--color-text-tertiary); }

/* ── Email rows (single-line: sender · subject + snippet · actions · date) ── */
.email-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--color-border);
  cursor: pointer; transition: background var(--dur-fast) var(--ease);
}
.email-row:hover { background: var(--color-surface); }
.email-row.selected { background: var(--color-selected-row); }
/* Keyboard cursor — the "current" row (distinct from checkbox selection). */
.email-row.focused { background: var(--color-surface);
  box-shadow: inset 3px 0 0 0 var(--color-accent-strong); }
.email-row.focused.selected { background: var(--color-selected-row); }
.email-row.focused .email-actions { display: flex; }
.email-row input[type=checkbox] { width: auto; flex: none; cursor: pointer;
  accent-color: var(--color-accent-strong); }
.email-from { width: 150px; flex: none; font-weight: 500; font-size: var(--text-base);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-mid { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.email-subject { font-size: var(--text-base); color: var(--color-text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 46%; }
.email-snippet { font-size: var(--text-sm); color: var(--color-text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; max-width: 600px; }
.email-date { font-size: var(--text-xs); color: var(--color-text-tertiary); white-space: nowrap;
  flex: none; width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.email-actions { display: none; align-items: center; gap: 4px; flex: none; }
.email-row:hover .email-actions, .email-row.acted-on .email-actions { display: flex; }
.conflict-badge { display: inline-flex; align-items: center; color: var(--color-warning); flex: none; }
/* ⋯ more-actions menu */
.email-action-menu-wrap { position: relative; }
.email-action-menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 100;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: 5px; min-width: 180px; flex-direction: column; gap: 2px; }
.email-action-menu.open { display: flex; }
.menu-item { display: flex; align-items: center; width: 100%; text-align: left; background: none; border: none;
  padding: 7px 9px; font-size: var(--text-sm); border-radius: var(--radius-sm); cursor: pointer;
  color: var(--color-text-primary); text-decoration: none; }
.menu-item:hover { background: var(--color-surface-sunken); }
.trash-single-btn { color: var(--color-danger); }
.menu-fast-label { display: flex; align-items: center; gap: 6px; padding: 4px 6px; }
.menu-fast-label-icon { font-size: 13px; flex-shrink: 0; }
.menu-fast-label .fast-label-select { flex: 1; font-size: var(--text-xs); padding: 4px 6px; min-width: 0; }
.conflict-badge { font-size: var(--text-xs); cursor: help; }
.acted-on { background: var(--color-acted-row); }
.acted-on .email-from, .acted-on .email-subject, .acted-on .email-snippet { color: var(--color-text-tertiary); }
.action-badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs);
  background: var(--color-success-subtle); color: var(--color-success);
  font-weight: 500; border-radius: var(--radius-full); padding: 2px 8px; white-space: nowrap; flex-shrink: 0; }

/* ── Aggregated grouped scan view (All / Set / Unset) ──────────────────────── */
.agg-toolbar { gap: 10px; }
.agg-scope-title { display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-weight: 600; font-size: var(--text-base); color: var(--color-text-primary); }
.agg-scope-title .licon { color: var(--color-accent-strong); }
.agg-scope-sub { font-size: var(--text-sm); color: var(--color-text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agg-list { padding-bottom: 8px; }
/* Sticky bucket header — pins to the top of the scroll area while its block is in view */
.agg-group-head { position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 9px; padding: 8px 16px;
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
  cursor: pointer; transition: background var(--dur-fast) var(--ease); }
.agg-group-head:hover { background: var(--color-surface-sunken); }
.agg-collapse { flex: none; padding: 2px 3px; line-height: 1; color: var(--color-text-secondary); }
.agg-group-icon { flex: none; display: inline-flex; }
.agg-group-icon .licon { color: var(--color-accent-strong); }
.agg-group-name { font-weight: 600; font-size: var(--text-base); color: var(--color-text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agg-group-count { flex: none; font-size: var(--text-xs); font-weight: 600;
  font-variant-numeric: tabular-nums; padding: 1px 8px; border-radius: var(--radius-full);
  background: var(--color-surface-sunken); color: var(--color-text-secondary); }
.agg-group-head:hover .agg-group-count { background: var(--color-surface); }
.agg-group-open { flex: none; display: none; align-items: center; gap: 4px;
  font-size: var(--text-xs); color: var(--color-accent-strong); }
.agg-group-head:hover .agg-group-open { display: inline-flex; }
.agg-group.collapsed .agg-group-rows { display: none; }
.agg-more { padding: 9px 16px 9px 46px; font-size: var(--text-sm); color: var(--color-accent-strong);
  display: flex; align-items: center; gap: 5px; cursor: pointer;
  border-bottom: 1px solid var(--color-border); }
.agg-more:hover { background: var(--color-surface-sunken); }
.agg-more .licon { flex: none; }

/* ── Rules manager ───────────────────────────────────────────────────────── */
.rules-manager-body { max-height: 65vh; overflow-y: auto; }
/* Combine-buckets suggestion */
.combine-suggest-wrap { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.combine-suggest { display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--color-accent-subtle); border: 1px solid var(--accent-line);
  border-radius: var(--radius-md); }
.combine-suggest-text { flex: 1; font-size: var(--text-sm); color: var(--color-text-secondary); line-height: 1.4; }
.combine-suggest-text strong { color: var(--color-text-primary); }
.combine-suggest-text .licon { color: var(--color-accent-strong); vertical-align: -2px; }
.combine-suggest .btn-small { flex: none; }
.combine-opts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.combine-opt { display: flex; align-items: center; gap: 9px; padding: 9px 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md); cursor: pointer; }
.combine-opt:hover { background: var(--color-surface-sunken); }
.combine-opt input { width: auto; flex: none; accent-color: var(--color-accent-strong); }
.combine-opt-name { font-size: var(--text-base); color: var(--color-text-primary); }
.rules-section-label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-text-tertiary); margin-bottom: 8px; }
.rules-list { display: flex; flex-direction: column; gap: 8px; }
.rule-card { border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.rule-card-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--color-surface-sunken); flex-wrap: wrap; }
.rule-card-icon { font-size: 15px; flex-shrink: 0; }
.rule-card-name { font-weight: 600; font-size: var(--text-base); flex: 1; }
.rule-card-tag { font-size: 10px; padding: 1px 6px; border-radius: var(--radius-sm);
  text-transform: uppercase; letter-spacing: .03em; }
.tag-builtin { background: var(--color-accent-subtle); color: var(--color-accent-strong); }
.tag-custom  { background: var(--color-danger-subtle); color: var(--color-danger); }
.rule-toggle { flex-direction: row; align-items: center; gap: 4px; font-size: var(--text-xs); }
.rule-toggle input { width: auto; accent-color: var(--color-accent-strong); }
.rule-card-body { padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; flex-wrap: wrap; font-size: var(--text-xs); }
.rule-cond-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--color-surface-sunken);
  border-radius: var(--radius-sm); padding: 2px 7px; margin: 2px; }
.excl-chip { background: var(--color-danger-subtle); }
.join-chip { font-weight: 700; font-size: 10px; color: var(--color-accent-strong); text-transform: uppercase; }
.rule-excl-row { margin-top: 2px; }
.rule-chip-row { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-bottom: 2px; }
/* Condition rows — sentence style */
.condition-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.cond-chip-sel {
  width: auto !important; min-width: 0; flex-shrink: 0;
  background: var(--color-surface-sunken); border: 1px solid var(--color-border);
  border-radius: var(--radius-sm); padding: 4px 6px; font-size: var(--text-xs); font-weight: 600;
  color: var(--color-text-primary); cursor: pointer;
}
.cond-op-sel {
  width: auto !important; min-width: 0; flex-shrink: 0;
  border: none; background: transparent; font-size: var(--text-xs);
  color: var(--color-text-secondary); font-style: italic; padding: 4px 2px; cursor: pointer;
}
.cond-val-input {
  flex: 1; border: none; border-bottom: 2px solid var(--color-border);
  border-radius: 0; padding: 4px 4px; font-size: var(--text-sm); font-weight: 500;
  background: transparent;
}
.cond-val-input:focus { border-bottom-color: var(--color-accent-strong); outline: none; box-shadow: none; }
.cond-date-suffix { font-size: var(--text-xs); color: var(--color-text-secondary); flex-shrink: 0; }
/* Date range: two narrow day inputs ("between 7 to 30 days old") */
.cond-range-input {
  flex: 0 1 64px; min-width: 44px; border: none; border-bottom: 2px solid var(--color-border);
  border-radius: 0; padding: 4px 4px; font-size: var(--text-sm); font-weight: 500; background: transparent;
}
.cond-range-input:focus { border-bottom-color: var(--color-accent-strong); outline: none; box-shadow: none; }
/* Calendar date pickers (before / after / between dates) need room for the date. */
.cond-date-input { flex: 0 1 auto; min-width: 130px; color: var(--color-text-primary); }
.suggest-box { background: var(--color-accent-subtle); border-radius: var(--radius-md); padding: 12px 14px; }
.suggest-check-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.suggest-check-row input[type="checkbox"] { margin-top: 14px; width: auto; flex-shrink: 0; accent-color: var(--color-accent-strong); }
/* Dim only when the CHECKBOX is unchecked — scope to .suggest-chk so the inline
   editor's text input (which is never :checked) doesn't permanently dim the box. */
.suggest-check-row:has(.suggest-chk:not(:checked)) .suggest-box { opacity: .5; }
.impact-good { color: var(--color-success); font-weight: 500; }
.impact-warn { color: var(--color-warning); font-weight: 500; }
.suggest-alt-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.suggest-alt-list .btn-secondary { text-align: left; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.suggest-label { font-weight: 500; font-size: var(--text-sm); margin-bottom: 4px; cursor: pointer; }
.suggest-alt { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--color-text-secondary); }
/* Per-card inline editing of a suggested condition (exclusion / inclusion). */
.suggest-box-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.suggest-summary { display: block; cursor: pointer; }
.suggest-sent-field { color: var(--color-text-primary); }
/* A stemmed-root match value + its "matches variants" explainer (dotted = hover for why). */
.suggest-stem { text-decoration: underline dotted; text-underline-offset: 2px; cursor: help; }
.suggest-stem-note { font-size: var(--text-xs); color: var(--color-text-tertiary); cursor: help; }
.suggest-edit-toggle { flex-shrink: 0; font-size: var(--text-xs); font-weight: 500; color: var(--color-accent-strong);
  background: none; border: 1px solid var(--accent-line); border-radius: var(--radius-sm); padding: 2px 10px; cursor: pointer; line-height: 1.6; }
.suggest-edit-toggle:hover { background: var(--color-surface-raised); }
/* Keyboard-shortcut badges on suggestion modals (Edit buttons + hint line). */
.suggest-shortcut-hint { color: var(--color-text-tertiary); }
kbd { font-family: var(--font-sans); font-size: 0.85em; font-weight: 600; line-height: 1;
  padding: 1px 5px; border: 1px solid var(--accent-line); border-radius: var(--radius-sm);
  background: var(--color-surface-sunken); color: var(--color-text-secondary); }
.suggest-edit-toggle kbd { margin-left: 4px; }
.modal-footer kbd { margin-left: 4px; }

/* Tasteful inline key hints on buttons/menus that have a keyboard shortcut. */
.kbd-hint {
  flex: none; display: inline-block; vertical-align: middle;
  min-width: 15px; text-align: center; padding: 0 4px;
  font-family: var(--font-sans); font-size: 0.72em; font-weight: 600; line-height: 1.5;
  border: 1px solid var(--color-border-strong); border-bottom-width: 2px;
  border-radius: var(--radius-sm); background: var(--color-surface-sunken);
  color: var(--color-text-tertiary);
}
button .kbd-hint, a.menu-item .kbd-hint { margin-left: 6px; }
/* Full-width footer buttons center their contents, so drop the extra margin —
   the flex gap alone keeps the cap snug after the label (no detached float). */
.sidebar-footer .full-width .kbd-hint { margin-left: 0; }
/* On the accent-filled primary button: a soft white cap with ink-colored text —
   present but clearly secondary to the label. */
.btn-primary .kbd-hint { background: rgba(255,255,255,.6);
  border-color: rgba(44,46,80,.18); border-bottom-color: rgba(44,46,80,.28);
  color: var(--color-accent-ink); }
.menu-item .kbd-hint { margin-left: auto; }       /* push to the menu's right edge */
.menu-fast-label .kbd-hint { margin-left: 2px; }
/* Search "/" affordance — fades out once you focus or type. */
.search-kbd { margin-left: 4px; opacity: .75; }
.bucket-search-wrap:focus-within .search-kbd,
.bucket-search-input:not(:placeholder-shown) ~ .search-kbd { display: none; }
.unsub-list { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.unsub-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--color-surface-sunken); border-radius: var(--radius-sm); }
.unsub-from { font-weight: 500; font-size: var(--text-sm); min-width: 120px; flex-shrink: 0; }
.unsub-subject { flex: 1; font-size: var(--text-xs); color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-state { padding: 48px; text-align: center; color: var(--color-text-tertiary); font-size: var(--text-lg); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--color-overlay);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 1000; padding: 48px 20px; overflow-y: auto;
  animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--color-surface-raised);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 600px; max-height: calc(100vh - 96px);
  margin: auto;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop var(--dur) var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--color-border); flex-shrink: 0;
}
.modal-header h3 { font: var(--text-xl-w) var(--text-xl)/var(--text-xl-lh) var(--font-sans); letter-spacing: -0.012em; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; flex: 1; }
.modal-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--color-border); flex-shrink: 0;
}
.modal-footer .btn-danger { margin-right: auto; }

/* ── Confirmation dialog ─────────────────────────────────────────────────── */
.modal.modal-confirm { max-width: 440px; }
.confirm-text { font-size: var(--text-base); line-height: var(--text-base-lh); color: var(--color-text-secondary); }
/* In a confirm dialog the destructive action IS the primary CTA → keep it on the
   right, overriding the default "danger far-left" footer rule. */
.modal-footer.confirm-footer .btn-danger.confirm-primary { margin-right: 0; }

/* ── Rule builder ────────────────────────────────────────────────────────── */
.conditions-list { display: flex; flex-direction: column; gap: 8px; }
.condition-row { display: flex; align-items: center; gap: 8px; }
.condition-row select { flex: 1; }
.condition-row .cond-val { flex: 2; }
.section-label { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-secondary);
  text-transform: uppercase; letter-spacing: .05em; margin-top: 4px; }
.exclude-label { color: var(--color-danger); margin-top: 8px; }

/* ── Two-bucket rule builder ─────────────────────────────────────────────── */
.rule-builder-body { display: flex; flex-direction: column; gap: 8px; }
.bucket-section { border-radius: var(--radius-md); border: 1px solid var(--color-border); overflow: visible; }
.or-bucket   { border-color: var(--accent-line); }
.and-bucket  { border-color: #A8D5B5; }
.excl-bucket { border-color: var(--danger-line); }
.bucket-header { display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--color-surface-sunken); border-bottom: 1px solid var(--color-border); }
.or-bucket   .bucket-header { background: var(--color-accent-subtle); border-bottom-color: var(--accent-line); }
.and-bucket  .bucket-header { background: var(--color-success-subtle); border-bottom-color: #A8D5B5; }
.excl-bucket .bucket-header { background: var(--color-danger-subtle); border-bottom-color: var(--danger-line); }
.bucket-badge { font-size: 10px; font-weight: 700; letter-spacing: .04em; padding: 2px 7px; border-radius: var(--radius-full); }
.or-badge   { background: var(--color-accent); color: var(--color-accent-ink); }
.and-badge  { background: var(--color-success); color: #fff; }
.excl-badge { background: var(--color-danger); color: #fff; }
.bucket-title { font-size: var(--text-sm); flex: 1; }
.optional-tag { font-size: 10px; background: var(--color-surface-sunken); color: var(--color-text-secondary);
  border-radius: var(--radius-sm); padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.bucket-connector { text-align: center; font-size: var(--text-xs); font-weight: 700; color: var(--color-text-tertiary); letter-spacing: .04em; }
/* Progressive rule builder — collapsible advanced sections */
.rule-advanced-section { border: none; }
.rule-advanced-summary { cursor: pointer; list-style: none; padding: 6px 2px; font-size: var(--text-xs);
  color: var(--color-text-tertiary); font-weight: 500; user-select: none; display: flex; align-items: center; gap: 6px; }
.rule-advanced-summary::-webkit-details-marker { display: none; }
.rule-advanced-summary .optional-tag { margin-left: 0; }
.rule-advanced-section[open] > .rule-advanced-summary { color: var(--color-text-primary); }
.rule-advanced-section[open] > .rule-advanced-summary::before { content: '▼ '; }
.rule-advanced-section:not([open]) > .rule-advanced-summary::before { content: '▶ '; }
.bucket-scroll-area { max-height: 260px; overflow-y: auto; }
.conditions-list { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.bucket-empty-hint { color: var(--color-text-tertiary); font-style: italic; margin: 0; }
.bucket-add-btn { margin: 4px 12px 10px; display: block; }
.preview-count { background: var(--color-surface-sunken); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 8px 12px; font-size: var(--text-sm); color: var(--color-text-secondary); margin-top: 4px; }
.preview-count strong { color: var(--color-accent-strong); font-weight: 600; }

/* ── Split bucket panel ──────────────────────────────────────────────────── */
.split-body { display: flex; flex-direction: column; gap: 12px; }
/* Scope-reset the global label{flex-direction:column} + input{width:100%} base
   rules so split checkboxes/rows render as horizontal lines, not centred stacks. */
.split-body label { flex-direction: row; align-items: center; gap: 8px; }
.split-body input[type="checkbox"], .split-body input[type="radio"] { width: auto; flex: none; margin: 0; }
.split-body .split-name { width: auto; }
.split-preview-label { font-size: var(--text-xs); font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  color: var(--color-text-tertiary); }
.split-options { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--color-border);
  padding-top: 12px; margin-top: 2px; }
.split-pill-group { display: inline-flex; gap: 4px; padding: 3px; background: var(--color-surface-sunken);
  border: 1px solid var(--color-border); border-radius: var(--radius-full); width: fit-content; }
.split-pill { border: none; background: transparent; cursor: pointer; font: inherit; font-size: var(--text-sm);
  color: var(--color-text-secondary); padding: 5px 14px; border-radius: var(--radius-full); transition: background var(--dur) var(--ease); }
.split-pill:hover { color: var(--color-text-primary); }
.split-pill.active { background: var(--color-surface); color: var(--color-text-primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.split-start-row { font-size: var(--text-sm); color: var(--color-text-secondary); display: flex;
  align-items: center; gap: 8px; flex-wrap: wrap; }
.split-start-row select { width: auto; min-width: 120px; }
.split-hint { font-size: var(--text-xs); color: var(--color-accent-strong); background: var(--color-accent-subtle);
  border-radius: var(--radius-full); padding: 2px 9px; }
.split-bar { display: flex; gap: 3px; height: 30px; }
.split-seg { display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden;
  border-radius: var(--radius-md); background: var(--color-bucket-active); color: var(--color-accent-strong);
  font-size: var(--text-xs); font-weight: 600; padding: 0 4px; }
.split-seg span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.split-seg-open { background: var(--color-accent-subtle); border: 1px dashed var(--accent-line); }
.split-seg-off { opacity: .4; }
.split-list { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow-y: auto; }
.split-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-surface); }
.split-row-off { opacity: .5; }
.split-row-check { display: flex; align-items: center; }
.split-name { flex: 1 1 auto; min-width: 120px; font-size: var(--text-sm); }
.split-window { flex: 0 0 auto; font-size: var(--text-xs); color: var(--color-text-tertiary); white-space: nowrap; }
.split-count { flex: 0 0 auto; font-size: var(--text-xs); font-weight: 600; color: var(--color-accent-strong);
  background: var(--color-surface-sunken); border-radius: var(--radius-full); padding: 2px 8px; white-space: nowrap; }
.split-check-line { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--color-text-secondary); flex-wrap: wrap; }
.split-keep-original { color: var(--color-text-primary); }
.split-keyword-controls { display: flex; flex-direction: column; gap: 6px; }
.split-kw-label { font-size: var(--text-xs); color: var(--color-text-secondary); }
.split-keywords { width: 100%; resize: vertical; min-height: 84px; font: inherit; font-size: var(--text-sm);
  line-height: 1.5; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text-primary); }

/* ── Nested condition groups ─────────────────────────────────────────────── */
.condition-group {
  flex-direction: column; align-items: stretch;
  background: var(--color-surface-sunken); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 8px 10px; gap: 0;
}
.group-body { display: flex; flex-direction: column; gap: 0; flex: 1; }
.group-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; margin-top: 6px; }
.sub-cond-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.sub-cond-row select { flex: 1; }
.sub-cond-row input  { flex: 2; }
.group-logic-connector { display: flex; align-items: center; padding: 2px 0; }
.group-logic-sel {
  width: auto; font-size: 11px; font-weight: 700; padding: 2px 6px;
  border: 1px solid var(--color-border); border-radius: var(--radius-full);
  background: var(--color-surface); color: var(--color-accent-strong); cursor: pointer; letter-spacing: .03em;
}
.group-body .sub-add { margin-top: 6px; align-self: flex-start; }

/* ── Apply all rules modal ───────────────────────────────────────────────── */
.apply-rules-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.apply-rule-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-md); border: 1px solid var(--color-border); background: var(--color-surface);
}
.apply-rule-left { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.apply-rule-icon { font-size: 18px; flex-shrink: 0; }
.apply-rule-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.apply-rule-name { font-size: var(--text-base); font-weight: 500; }
.apply-rule-action { font-size: var(--text-xs); color: var(--color-text-secondary); }
.apply-rule-count { font-size: var(--text-sm); font-weight: 600; color: var(--color-accent-strong); white-space: nowrap; flex-shrink: 0; }
.apply-rules-total { font-size: var(--text-sm); color: var(--color-text-secondary); text-align: right; }
.apply-rules-note { margin-top: 8px; font-size: var(--text-xs); color: var(--color-text-tertiary); line-height: 1.5; }

/* ── Action steps ────────────────────────────────────────────────────────── */
.action-step-row { display: flex; align-items: center; gap: 8px; }
.step-label-input { flex: 1; }
.action-step-row .step-type { flex: 1; }
.action-step-row .step-label, .action-step-row .step-newlabel { flex: 1.2; }
.save-rule-label { flex-direction: row; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--color-text-primary); }
.save-rule-label input { width: auto; accent-color: var(--color-accent-strong); }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 4px; flex-wrap: wrap; }
.inbox-only-label { flex-direction: row; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--color-text-secondary); }
.inbox-only-label input { width: auto; accent-color: var(--color-accent-strong); }
.limit-label { flex-direction: row; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--color-text-secondary); white-space: nowrap; }
.limit-label select { width: auto; padding: 5px 8px; font-size: var(--text-sm); }
.hint { font-size: var(--text-xs); color: var(--color-text-secondary); }

/* ── Special-bucket reminder banners ─────────────────────────────────────── */
.unsub-reminder-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--color-accent-subtle); border-bottom: 1px solid var(--accent-line);
  padding: 12px 16px; font-size: var(--text-sm); color: var(--color-text-secondary); flex-shrink: 0;
}
.unsub-reminder-banner strong { color: var(--color-text-primary); font-weight: 600; }
.junk-reminder-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--color-warning-subtle); border-bottom: 1px solid var(--color-warning);
  padding: 12px 16px; font-size: var(--text-sm); color: var(--color-text-secondary); flex-shrink: 0;
}
.junk-reminder-banner strong { color: var(--color-warning); font-weight: 600; }

/* ── Action history modal ────────────────────────────────────────────────── */
.log-modal-body { display: flex; flex-direction: column; gap: 8px; }
.log-entry { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 10px 12px; background: var(--color-surface); }
.log-entry.log-undone { opacity: .5; }
.log-entry.log-undone .log-action { text-decoration: line-through; }
.log-entry-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.log-action { font-size: var(--text-sm); font-weight: 500; }
.log-count { font-size: var(--text-xs); background: var(--color-surface-sunken); border-radius: var(--radius-full); padding: 1px 8px; color: var(--color-text-secondary); }
.log-bucket { font-size: var(--text-xs); color: var(--color-accent-strong); }
.log-time { font-size: var(--text-xs); color: var(--color-text-tertiary); margin-left: auto; }
.log-preview { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.log-preview-line { font-size: var(--text-xs); color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-more { color: var(--color-text-tertiary); font-style: italic; }
.log-entry-footer { display: flex; justify-content: flex-end; }
.log-undone-label { font-size: var(--text-xs); color: var(--color-text-tertiary); font-style: italic; }

/* ── Toggle switch (rules manager) ───────────────────────────────────────── */
.switch { width: 36px; height: 20px; border-radius: var(--radius-full); background: var(--color-border-strong);
  position: relative; cursor: pointer; transition: background var(--dur) var(--ease); flex: none; }
.switch.on { background: var(--color-accent-strong); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: var(--radius-full); background: #fff; transition: left var(--dur) var(--ease); }
.switch.on::after { left: 18px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 2000; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--color-surface); color: var(--color-text-primary);
  border: 1px solid var(--color-border); border-left: 3px solid var(--color-text-tertiary);
  padding: 11px 14px; border-radius: var(--radius-md); font-size: var(--text-sm);
  max-width: 360px; box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(8px);
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-warn { border-left-color: var(--color-warning); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--color-surface-sunken);
  border-top-color: var(--color-accent-strong);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { font-size: var(--text-sm); color: var(--color-text-secondary); }

/* Unobtrusive "pacing requests…" note shown while the quota pacer is throttling. */
.pace-note { margin: 6px 0 0; font-size: var(--text-xs); color: var(--color-text-tertiary);
  display: flex; align-items: center; justify-content: center; gap: 6px; }
.pace-note::before { content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-accent-strong); animation: pace-pulse 1.1s ease-in-out infinite; }
@keyframes pace-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.pace-note[hidden] { display: none; }

/* ── Scrollbar (webkit) ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }

/* ── Quick-start card ────────────────────────────────────────────────────── */
.quickstart-heading { font: var(--text-xl-w) var(--text-xl)/var(--text-xl-lh) var(--font-sans); letter-spacing: -0.012em; margin-bottom: 8px; }
.quickstart-sub { color: var(--color-text-secondary); font-size: var(--text-base); margin-bottom: 24px; line-height: var(--text-base-lh); }
.btn-link { background: none; border: none; color: var(--color-accent-strong); font-size: var(--text-sm); padding: 0; cursor: pointer; text-decoration: none; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

/* ── Sidebar lifetime stats strip ────────────────────────────────────────── */
.sidebar-lifetime-stats { font-size: var(--text-xs); color: var(--color-text-secondary); padding: 8px 8px 4px; line-height: 1.5; text-align: center; }

/* ── Load banner ─────────────────────────────────────────────────────────── */
.load-banner {
  display: flex; align-items: center; gap: 8px;
  background: var(--color-accent-subtle); font-size: var(--text-sm); padding: 0 16px; height: 36px;
  color: var(--color-accent-strong); flex-shrink: 0;
}
.load-banner-text { flex: 1; color: var(--color-accent-strong); }
.load-banner-text a { color: inherit; text-decoration: underline; cursor: pointer; font-weight: 500; }
.load-banner-text a:hover { opacity: .85; }
.load-banner-dismiss { background: none; border: none; color: var(--color-accent-strong); cursor: pointer;
  font-size: 16px; padding: 0 4px; line-height: 1; margin-left: auto; }
.load-banner-dismiss:hover { opacity: .7; }

/* ── Empty buckets disclosure row ────────────────────────────────────────── */
.empty-buckets-disclosure {
  display: flex; align-items: center; gap: 6px;
  padding: 8px; font-size: var(--text-sm); color: var(--color-text-tertiary);
  cursor: pointer; border-radius: var(--radius-md);
}
.empty-buckets-disclosure:hover { background: var(--color-surface-sunken); color: var(--color-text-secondary); }
.disclosure-arrow { display: inline-flex; flex: none; }
.empty-bucket-item { opacity: .7; }

/* ── First-use tooltip ───────────────────────────────────────────────────── */
.action-tip-popover {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 200;
  background: var(--color-surface-raised); border-radius: var(--radius-md); padding: 12px 14px;
  box-shadow: var(--shadow-md); max-width: 240px;
  font-size: var(--text-xs); color: var(--color-text-primary); line-height: 1.5;
  display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--color-border);
}
.action-tip-arrow {
  position: absolute; top: -6px; left: 20px; width: 12px; height: 12px;
  background: var(--color-surface-raised); transform: rotate(45deg);
  border-top: 1px solid var(--color-border); border-left: 1px solid var(--color-border);
}

/* ── Undo toast ──────────────────────────────────────────────────────────── */
.toast-with-undo { display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
.toast-msg { flex: 1; }
.toast-undo-btn {
  background: var(--color-accent-subtle); color: var(--color-accent-strong); border: 1px solid var(--accent-line);
  border-radius: var(--radius-sm); padding: 4px 10px; font-size: var(--text-xs); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.toast-undo-btn:hover { background: var(--accent-line); }
.toast-close-btn {
  background: none; border: none; color: var(--color-text-tertiary); cursor: pointer;
  font-size: 14px; padding: 0 2px; line-height: 1;
}
.toast-close-btn:hover { color: var(--color-text-primary); }

/* ── Empty-bucket success state ──────────────────────────────────────────── */
.empty-state-success {
  padding: 48px; text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 12px;
}
.empty-done-icon { width: 44px; height: 44px; border-radius: var(--radius-lg);
  background: var(--color-success-subtle); color: var(--color-success);
  display: flex; align-items: center; justify-content: center; font-size: 24px; }
.empty-done-msg { font-size: var(--text-lg); font-weight: 600; color: var(--color-text-primary); }
.empty-all-done { font-size: var(--text-base); color: var(--color-text-secondary); }

/* ── Hide ⊕ nest button by default, show on hover ───────────────────────── */
.condition-row .or-add-sub,
.condition-row .and-add-sub,
.condition-row .excl-add-sub {
  opacity: 0; pointer-events: none; transition: opacity 150ms;
}
.condition-row:hover .or-add-sub,
.condition-row:hover .and-add-sub,
.condition-row:hover .excl-add-sub {
  opacity: 1; pointer-events: auto;
}
@media (max-width: 767px) {
  .condition-row .or-add-sub,
  .condition-row .and-add-sub,
  .condition-row .excl-add-sub { display: none; }
}

/* ── Apply saved rules button (accent-tinted when active) ────────────────── */
.btn-apply-rules {
  background: var(--color-surface); color: var(--color-text-primary); padding: 7px 16px;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  font-weight: 500; font-size: var(--text-sm); cursor: pointer; width: 100%;
  margin-top: 6px; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn-apply-rules:hover:not(:disabled) { background: var(--color-accent-subtle); border-color: var(--accent-line); color: var(--color-accent-strong); }
.btn-apply-rules:not(:disabled) { background: var(--color-accent-subtle); border-color: var(--accent-line); color: var(--color-accent-strong); }
.btn-apply-rules:disabled { opacity: .4; cursor: not-allowed; }

/* ── Keyboard shortcuts: header toggle, quick-pick palette, cheat-sheet ────── */
/* Header toggle dims when shortcuts are off. */
#btn-shortcuts-toggle .licon { color: var(--color-accent-strong); }
#btn-shortcuts-toggle.off { opacity: .55; }
#btn-shortcuts-toggle.off .licon { color: var(--color-text-tertiary); }

/* Quick-pick palette (move `v` / label `l`). */
.quick-pick { display: flex; flex-direction: column; gap: 10px; }
.qp-input {
  width: 100%; height: 38px; padding: 0 12px; font-size: var(--text-base);
  background: var(--color-surface-sunken); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); color: var(--color-text-primary);
}
.qp-input:focus { outline: none; border-color: var(--color-accent-strong);
  box-shadow: 0 0 0 1px var(--color-accent-strong); background: var(--color-surface); }
.qp-list { display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }
.qp-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 10px; border: 1px solid transparent; border-radius: var(--radius-md);
  background: transparent; cursor: pointer; font-size: var(--text-base);
  color: var(--color-text-primary); font-family: inherit;
}
.qp-item:hover { background: var(--color-surface-sunken); }
.qp-item.active { background: var(--color-accent-subtle); border-color: var(--accent-line); color: var(--color-accent-strong); }
.qp-item .qp-icon { flex: none; display: inline-flex; color: var(--color-accent-strong); }
.qp-item .qp-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* "Create bucket …" row — set off from the matched buckets above it. */
.qp-create { margin-top: 4px; border-top: 1px solid var(--color-border); border-radius: 0 0 var(--radius-md) var(--radius-md); }
.qp-create .qp-name { color: var(--color-accent-strong); font-weight: 500; }
.qp-empty { padding: 14px 10px; font-size: var(--text-sm); color: var(--color-text-tertiary); text-align: center; }

/* Cheat-sheet modal. */
.shortcut-help { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; }
.sk-group-title { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--color-text-tertiary); margin-bottom: 8px; }
.sk-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; font-size: var(--text-sm); }
.sk-keys { flex: none; display: inline-flex; align-items: center; gap: 4px; min-width: 86px; }
.sk-or { color: var(--color-text-tertiary); font-size: var(--text-xs); }
.sk-desc { color: var(--color-text-secondary); }
.sk-foot { grid-column: 1 / -1; margin: 4px 0 0; font-size: var(--text-xs);
  color: var(--color-text-tertiary); line-height: 1.5; }
kbd {
  display: inline-block; min-width: 18px; text-align: center;
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 600;
  line-height: 1.4; padding: 1px 6px; color: var(--color-text-primary);
  background: var(--color-surface-sunken); border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px; border-radius: var(--radius-sm);
}
@media (max-width: 600px) { .shortcut-help { grid-template-columns: 1fr; } }

/* ── First-run guided tour (coach-mark overlay) ──────────────────────────────
   Spotlight tour that anchors to the real inbox: sidebar bucket, toolbar
   buttons, and email-row controls. Three fixed layers (scrim / hole / callout)
   live outside #app so re-renders don't wipe them. See js/tour.js. */
.tour-scrim {
  position: fixed; inset: 0; z-index: 80;
  transition: background var(--dur) var(--ease);
}
/* Dimming + ring is ONE box-shadow on the hole. The header "busy" pulse and
   modal anims aside, the hole must SNAP between steps — do NOT add a
   transition on top/left/width/height (it lags the ring a step behind). */
.tour-hole {
  position: fixed; z-index: 81; border-radius: 8px; pointer-events: none;
  box-shadow: 0 0 0 9999px var(--tour-dim), 0 0 0 2px var(--color-accent-strong);
}
.tour-call {
  position: fixed; z-index: 82; width: 320px; box-sizing: border-box;
  background: var(--color-surface-raised); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 16px 16px 13px;
}
.tour-call .tc-step {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--color-accent-strong);
}
.tour-call .tc-h { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; margin-top: 5px; }
.tour-call .tc-b { font-size: var(--text-sm); line-height: 20px; color: var(--color-text-secondary); margin-top: 6px; }
.tour-call .tc-foot { display: flex; align-items: center; gap: 8px; margin-top: 15px; }
.tour-call .tc-foot .sp { flex: 1; }
/* Quiet "skip" row, set off from the primary actions by a hairline divider */
.tour-call .tc-skiprow {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--color-border);
}
.tour-call .tc-skiprow .tc-dot { color: var(--color-text-tertiary); font-size: var(--text-xs); }
/* Skip links — quiet text buttons */
.tour-call .tlink {
  background: none; border: 0; padding: 2px 4px; cursor: pointer; font: inherit;
  font-size: var(--text-xs); font-weight: 400; color: var(--color-text-tertiary);
  display: inline-flex; align-items: center; border-radius: var(--radius-sm);
}
.tour-call .tlink:hover { color: var(--color-text-secondary); }
/* Inline key hints on tour buttons */
.tour-call .tc-k {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; margin-left: 6px;
  border-radius: 4px; font-family: var(--font-mono); font-size: 10px; line-height: 1;
  background: var(--color-surface-sunken); color: var(--color-text-tertiary);
  border: 1px solid var(--color-border);
}
.tour-call .tc-k-pri { background: rgba(255,255,255,0.22); color: #fff; border-color: transparent; }
/* Compact button variants used only inside the callout */
.tour-call .btn-primary.tour-btn-sm,
.tour-call .tour-ghost {
  font-size: var(--text-sm); padding: 6px 14px; border-radius: var(--radius-md);
  cursor: pointer; font-weight: 500;
}
.tour-call .tour-ghost {
  background: none; border: 1px solid transparent; color: var(--color-text-secondary);
}
.tour-call .tour-ghost:hover { background: var(--color-surface-sunken); }
/* Header replay button keeps its own icon+label inline */
#btn-tour { display: inline-flex; align-items: center; gap: 6px; }
/* Email-row action controls are hover-revealed (display:none); steps 3–5 of the
   tour spotlight them, so force the targeted row's actions visible while lit. */
.email-row.tour-reveal .email-actions { display: flex !important; }
/* Fallback example chip — shown in the callout when the real control isn't on
   the page (e.g. no unsubscribe-able emails in the batch) so the user still
   recognizes the button. */
.tour-call .tc-eg {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 12px; padding: 10px 12px;
  background: var(--color-surface-sunken); border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.tour-call .tc-eg-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--color-text-tertiary);
}
.tour-call .tour-eg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text-secondary);
}
.tour-call .tour-eg-select {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; font-size: var(--text-xs); color: var(--color-text-secondary);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface);
}
.tour-call .tc-eg-note {
  flex: 1 1 100%; font-size: var(--text-xs); line-height: 16px;
  color: var(--color-text-tertiary);
}
